Bug 1121332. Part 5 - update EME mochitests for webidl changes. r=cpearce a=lmandel
authorJW Wang <jwwang@mozilla.com>
Sat, 31 Jan 2015 13:23:19 +1300
changeset 250187 4bcb6239d04b
parent 250186 3d9497f46338
child 250188 075916728a00
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1121332
milestone37.0
Bug 1121332. Part 5 - update EME mochitests for webidl changes. r=cpearce a=lmandel
dom/media/gmp/GMPDecryptorParent.cpp
dom/media/gmp/GMPDecryptorParent.h
dom/media/test/test_eme_persistent_sessions.html
dom/media/test/test_eme_playback.html
--- a/dom/media/gmp/GMPDecryptorParent.cpp
+++ b/dom/media/gmp/GMPDecryptorParent.cpp
@@ -261,17 +261,17 @@ GMPDecryptorParent::RecvSessionError(con
                           GMPExToNsresult(aException),
                           aSystemCode,
                           aMessage);
   return true;
 }
 
 bool
 GMPDecryptorParent::RecvKeyStatusChanged(const nsCString& aSessionId,
-                                         InfallibleTArray<uint8_t>&& aKeyId,
+                                         const nsTArray<uint8_t>& aKeyId,
                                          const GMPMediaKeyStatus& aStatus)
 {
   if (!mIsOpen) {
     NS_WARNING("Trying to use a dead GMP decrypter!");
     return false;
   }
   mCallback->KeyStatusChanged(aSessionId, aKeyId, aStatus);
   return true;
--- a/dom/media/gmp/GMPDecryptorParent.h
+++ b/dom/media/gmp/GMPDecryptorParent.h
@@ -87,17 +87,17 @@ private:
   virtual bool RecvSessionClosed(const nsCString& aSessionId) MOZ_OVERRIDE;
 
   virtual bool RecvSessionError(const nsCString& aSessionId,
                                 const GMPDOMException& aException,
                                 const uint32_t& aSystemCode,
                                 const nsCString& aMessage) MOZ_OVERRIDE;
 
   virtual bool RecvKeyStatusChanged(const nsCString& aSessionId,
-                                    InfallibleTArray<uint8_t>&& aKeyId,
+                                    const nsTArray<uint8_t>& aKeyId,
                                     const GMPMediaKeyStatus& aStatus) MOZ_OVERRIDE;
 
   virtual bool RecvDecrypted(const uint32_t& aId,
                              const GMPErr& aErr,
                              const nsTArray<uint8_t>& aBuffer) MOZ_OVERRIDE;
 
   virtual bool RecvSetCaps(const uint64_t& aCaps) MOZ_OVERRIDE;
 
--- a/dom/media/test/test_eme_persistent_sessions.html
+++ b/dom/media/test/test_eme_persistent_sessions.html
@@ -26,38 +26,41 @@ function UsableKeyIdsMatch(usableKeyIds,
     }
   }
   return true;
 }
 
 function AwaitAllKeysUsable(session, keys, token) {
   return new Promise(function(resolve, reject) {
     function check() {
-      session.getUsableKeyIds().then(function(usableKeyIds) {
-        var u = UsableKeyIdsMatch(usableKeyIds, keys);
-        if (UsableKeyIdsMatch(usableKeyIds, keys)) {
-          session.removeEventListener("keyschange", check);
-          resolve();
-        }
-      }, bail(token + " failed to get usableKeyIds"));
+      var map = session.keyStatuses;
+      var usableKeyIds = [];
+      for (var [key, val] of map.entries()) {
+        is(val, "usable", token + ": key status should be usable");
+        usableKeyIds.push(key);
+      }
+      if (UsableKeyIdsMatch(usableKeyIds, keys)) {
+        Log(token, "resolving AwaitAllKeysUsable promise");
+        session.removeEventListener("keyschange", check);
+        resolve();
+      }
     }
     session.addEventListener("keyschange", check);
     check(); // in case all keys are already usable
   });
 }
 
 function AwaitAllKeysNotUsable(session, token) {
   return new Promise(function(resolve, reject) {
     function check() {
-      session.getUsableKeyIds().then(function(usableKeyIds) {
-        if (usableKeyIds.length == 0) {
-          session.removeEventListener("keyschange", check);
-          resolve();
-        }
-      }, bail(token + " failed to get usableKeyIds"));
+      var map = session.keyStatuses;
+      if (map.size == 0) {
+        session.removeEventListener("keyschange", check);
+        resolve();
+      }
     }
     session.addEventListener("keyschange", check);
     check(); // in case all keys are already removed
   });
 }
 
 function startTest(test, token)
 {
--- a/dom/media/test/test_eme_playback.html
+++ b/dom/media/test/test_eme_playback.html
@@ -17,23 +17,24 @@ function KeysChangeFunc(session, keys, t
   session.keyIdsReceived = [];
   for (var keyid in keys) {
     Log(token, "Set " + keyid + " to false in session.keyIdsReceived");
     session.keyIdsReceived[keyid] = false;
   }
   return function(ev) {
     var session = ev.target;
     session.gotKeysChanged = true;
-    session.getUsableKeyIds().then(function(keyIds) {
-      for (var k = 0; k < keyIds.length; k++) {
-        var kid = Base64ToHex(window.btoa(ArrayBufferToString(keyIds[k])));
-        ok(kid in session.keyIdsReceived, TimeStamp(token) + " session.keyIdsReceived contained " + kid + " as expected.");
-        session.keyIdsReceived[kid] = true;
-      }
-    }, bail("Failed to get keyIds"));
+
+    var map = session.keyStatuses;
+    for (var [key, val] of map.entries()) {
+      is(val, "usable", token + ": key status should be usable");
+      var kid = Base64ToHex(window.btoa(ArrayBufferToString(key)));
+      ok(kid in session.keyIdsReceived, TimeStamp(token) + " session.keyIdsReceived contained " + kid + " as expected.");
+      session.keyIdsReceived[kid] = true;
+    }
   }
 }
 
 function startTest(test, token)
 {
   manager.started(token);
 
   var sessions = [];