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
--- 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);