Bug 1311864 - Reject MediaKeySession::Load() for non temporary session types. r?kikuo draft
authorChris Pearce <cpearce@mozilla.com>
Fri, 21 Oct 2016 11:43:05 +1300
changeset 427829 7ce191dddb2256eecf70fc027d33db9236c7661e
parent 427817 308f4038555493250bf21131b60af20ab0dd6c58
child 534566 361040517f87b8809b99b7c518857bd49cc8fab8
push id33129
push usercpearce@mozilla.com
push dateThu, 20 Oct 2016 22:45:47 +0000
reviewerskikuo
bugs1311864
milestone52.0a1
Bug 1311864 - Reject MediaKeySession::Load() for non temporary session types. r?kikuo We are required to do this by the draft EME spec. MozReview-Commit-ID: FnIEFgVId1z
dom/media/eme/MediaKeySession.cpp
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -377,16 +377,30 @@ MediaKeySession::Load(const nsAString& a
   if (aSessionId.IsEmpty()) {
     promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
                          NS_LITERAL_CSTRING("Trying to load a session with empty session ID"));
     // "The sessionId parameter is empty."
     EME_LOG("MediaKeySession[%p,''] Load() failed, no sessionId", this);
     return promise.forget();
   }
 
+  // 5. If the result of running the Is persistent session type? algorithm
+  // on this object's session type is false, return a promise rejected with
+  // a newly created TypeError.
+  if (mSessionType == MediaKeySessionType::Temporary) {
+    promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
+                         NS_LITERAL_CSTRING("Trying to load() into a non-persistent session"));
+    EME_LOG("MediaKeySession[%p,''] Load() failed, can't load in a non-persistent session", this);
+    return promise.forget();
+  }
+
+  // Note: We don't support persistent sessions in any keysystem, so all calls
+  // to Load() should reject with a TypeError in the preceding check. Omitting
+  // implementing the rest of the specified MediaKeySession::Load() algorithm.
+
   // We now know the sessionId being loaded into this session. Remove the
   // session from its owning MediaKey's set of sessions awaiting a sessionId.
   RefPtr<MediaKeySession> session(mKeys->GetPendingSession(Token()));
   MOZ_ASSERT(session == this, "Session should be awaiting id on its own token");
 
   // Associate with the known sessionId.
   SetSessionId(aSessionId);