From 22b1ca7b537eba6eb2d7f26a02a59bb9883b2352 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Fri, 21 Oct 2016 11:43:05 +1300 Subject: [PATCH] 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 --HG-- extra : rebase_source : 23042d3acda6cfcb379db457224d648dc955f688 --- dom/media/eme/MediaKeySession.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dom/media/eme/MediaKeySession.cpp b/dom/media/eme/MediaKeySession.cpp index bdc880dc5cb8..c81f416ed6d7 100644 --- a/dom/media/eme/MediaKeySession.cpp +++ b/dom/media/eme/MediaKeySession.cpp @@ -382,6 +382,20 @@ MediaKeySession::Load(const nsAString& aSessionId, ErrorResult& aRv) 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 session(mKeys->GetPendingSession(Token()));