Bug 1313266 - Make gmp-clearkey reject with TypeError instead of InvalidAccessError on invalid input. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Thu, 27 Oct 2016 14:59:02 +1300
changeset 319852 61061d39b87022c493fae5bc6757633a18f716e0
parent 319851 75fe0970cbbc3dee96def8172cc0d1fae508cb32
child 319853 50482ffb2969a1013d3daa2af2924fa3cd86aa75
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1313266
milestone52.0a1
Bug 1313266 - Make gmp-clearkey reject with TypeError instead of InvalidAccessError on invalid input. r=gerald The spec expects this, and now we pass more web platform tests. MozReview-Commit-ID: 9HJFp2ebczk
media/gmp-clearkey/0.1/ClearKeySession.cpp
media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
--- a/media/gmp-clearkey/0.1/ClearKeySession.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySession.cpp
@@ -73,17 +73,17 @@ ClearKeySession::Init(uint32_t aCreateSe
     // "webm" initData format is simply the raw bytes of the keyId.
     vector<uint8_t> keyId;
     keyId.assign(aInitData, aInitData+aInitDataSize);
     mKeyIds.push_back(keyId);
   }
 
   if (!mKeyIds.size()) {
     const char message[] = "Couldn't parse init data";
-    mCallback->RejectPromise(aPromiseId, kGMPInvalidAccessError, message, strlen(message));
+    mCallback->RejectPromise(aPromiseId, kGMPTypeError, message, strlen(message));
     return;
   }
 
   mCallback->SetSessionId(aCreateSessionToken, &mSessionId[0], mSessionId.length());
 
   mCallback->ResolvePromise(aPromiseId);
 }
 
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -215,25 +215,25 @@ ClearKeySessionManager::UpdateSession(ui
     mCallback->RejectPromise(aPromiseId, kGMPNotFoundError, nullptr, 0);
     return;
   }
   ClearKeySession* session = itr->second;
 
   // Verify the size of session response.
   if (aResponseSize >= kMaxSessionResponseLength) {
     CK_LOGW("Session response size is not within a reasonable size.");
-    mCallback->RejectPromise(aPromiseId, kGMPInvalidAccessError, nullptr, 0);
+    mCallback->RejectPromise(aPromiseId, kGMPTypeError, nullptr, 0);
     return;
   }
 
   // Parse the response for any (key ID, key) pairs.
   vector<KeyIdPair> keyPairs;
   if (!ClearKeyUtils::ParseJWK(aResponse, aResponseSize, keyPairs, session->Type())) {
     CK_LOGW("ClearKey CDM failed to parse JSON Web Key.");
-    mCallback->RejectPromise(aPromiseId, kGMPInvalidAccessError, nullptr, 0);
+    mCallback->RejectPromise(aPromiseId, kGMPTypeError, nullptr, 0);
     return;
   }
 
   vector<GMPMediaKeyInfo> key_infos;
   for (size_t i = 0; i < keyPairs.size(); i++) {
     KeyIdPair& keyPair = keyPairs[i];
     mDecryptionManager->InitKey(keyPair.mKeyId, keyPair.mKey);
     mKeyIds.insert(keyPair.mKeyId);