Bug 1278198 - Fix tests to work with new EME API. r=gerald
☠☠ backed out by 96b0bce9b8f2 ☠ ☠
authorChris Pearce <cpearce@mozilla.com>
Mon, 11 Jul 2016 16:46:21 +1200
changeset 331180 1a73ee138e2322740f4099817434f162ac004313
parent 331179 af577b7547c466bcb2265aec924b191ff838753d
child 331181 c9e56c91112ef3fd3c66f1b1c27c22d288ef8c31
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1278198
milestone50.0a1
Bug 1278198 - Fix tests to work with new EME API. r=gerald MozReview-Commit-ID: WTWyYu2Zgp
dom/media/test/eme.js
dom/media/test/test_eme_detach_media_keys.html
dom/media/test/test_eme_initDataTypes.html
dom/media/test/test_eme_non_mse_fails.html
dom/media/test/test_eme_persistent_sessions.html
dom/media/test/test_eme_requestKeySystemAccess.html
dom/media/test/test_eme_request_notifications.html
dom/media/test/test_eme_session_callable_value.html
dom/media/test/test_eme_setMediaKeys_before_attach_MediaSource.html
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -1,9 +1,15 @@
-const KEYSYSTEM_TYPE = "org.w3.clearkey";
+const CLEARKEY_KEYSYSTEM = "org.w3.clearkey";
+
+const gCencMediaKeySystemConfig = [{
+  initDataTypes: ['cenc'],
+  videoCapabilities: [{ contentType: 'video/mp4' }],
+  audioCapabilities: [{ contentType: 'audio/mp4' }],
+}];
 
 function IsMacOSSnowLeopardOrEarlier() {
   var re = /Mac OS X (\d+)\.(\d+)/;
   var ver = navigator.userAgent.match(re);
   if (!ver || ver.length != 3) {
     return false;
   }
   var major = ver[1] | 0;
@@ -371,17 +377,17 @@ function SetupEME(test, token, params)
       var options = { initDataTypes: [ev.initDataType] };
       if (streamType("video")) {
         options.videoCapabilities = [{contentType: streamType("video")}];
       }
       if (streamType("audio")) {
         options.audioCapabilities = [{contentType: streamType("audio")}];
       }
 
-      var p = navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, [options]);
+      var p = navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, [options]);
       var r = bail(token + " Failed to request key system access.");
       chain(p, r)
       .then(function(keySystemAccess) {
         var p = keySystemAccess.createMediaKeys();
         var r = bail(token +  " Failed to create MediaKeys object");
         return chain(p, r);
       })
 
--- a/dom/media/test/test_eme_detach_media_keys.html
+++ b/dom/media/test/test_eme_detach_media_keys.html
@@ -9,28 +9,28 @@
 </head>
 <body>
 <pre id="test">
 <video id="v" controls></video>
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-const keysystem = 'org.w3.clearkey';
-
 function createAndSet() {
   return new Promise(function(resolve, reject) {
     var m;
-    navigator.requestMediaKeySystemAccess(keysystem, [{initDataTypes: ['cenc']}])
+    navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig)
     .then(function (access) {
       return access.createMediaKeys();
-    }).then(function (mediaKeys) {
+    })
+    .then(function (mediaKeys) {
       m = mediaKeys;
       return document.getElementById("v").setMediaKeys(mediaKeys);
-    }).then(function() {
+    })
+    .then(function() {
       resolve(m);
     });
   }
 )}
 
 var m1,m2;
 
 // Test that if we create and set two MediaKeys on one video element,
--- a/dom/media/test/test_eme_initDataTypes.html
+++ b/dom/media/test/test_eme_initDataTypes.html
@@ -34,19 +34,19 @@ var tests = [
     initData: '{"type":"temporary", "kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
     expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"temporary"}',
     sessionType: 'temporary',
     expectPass: true,
   },
   {
     name: "Two keyIds, persistent session, type before kids",
     initDataType: 'keyids',
-    initData: '{"type":"persistent", "kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
-    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"persistent"}',
-    sessionType: 'persistent',
+    initData: '{"type":"persistent-license", "kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
+    expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"persistent-license"}',
+    sessionType: 'persistent-license',
     expectPass: true,
   },
   {
     name: "Invalid keyId",
     initDataType: 'keyids',
     initData: '{"kids":["0"]}',
     sessionType: 'temporary',
     expectPass: false,
@@ -57,17 +57,17 @@ var tests = [
     initData: '{"kids":[""]}',
     sessionType: 'temporary',
     expectPass: false,
   },
   {
     name: "SessionType in license doesn't match MediaKeySession's sessionType",
     initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"]}',
-    sessionType: 'persistent',
+    sessionType: 'persistent-license',
     expectPass: false,
   },
   {
     name: "One valid and one invalid kid",
     initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A", "invalid"]}',
     expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"],"type":"temporary"}',
     sessionType: 'temporary',
@@ -103,20 +103,23 @@ function PrepareInitData(initDataType, i
     return new TextEncoder().encode(initData);
   } else if (initDataType == "webm") {
     return StringToArrayBuffer(atob(initData));
   }
 }
 
 function Test(test) {
   return new Promise(function(resolve, reject) {
-    navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{initDataTypes: [test.initDataType]}]).then(
-      (access) => access.createMediaKeys()
-      ).then(
-        (mediaKeys) => {
+    var configs = [{
+      initDataTypes: [test.initDataType],
+      videoCapabilities: [{contentType: 'video/mp4' }],
+    }];
+    navigator.requestMediaKeySystemAccess('org.w3.clearkey', configs)
+      .then((access) => access.createMediaKeys())
+      .then((mediaKeys) => {
           var session = mediaKeys.createSession(test.sessionType);
           session.addEventListener("message", function(event) {
             is(event.messageType, "license-request", "'" + test.name + "' MediaKeyMessage type should be license-request.");
             var text = new TextDecoder().decode(event.message);
             is(text, test.expectedRequest, "'" + test.name + "' got expected response.");
             is(text == test.expectedRequest, test.expectPass,
                "'" + test.name + "' expected to " + (test.expectPass ? "pass" : "fail"));
             resolve();
--- a/dom/media/test/test_eme_non_mse_fails.html
+++ b/dom/media/test/test_eme_non_mse_fails.html
@@ -15,17 +15,17 @@ var manager = new MediaTestManager;
 function DoSetMediaKeys(v, test)
 {
   var options = [{
     initDataTypes: ["cenc"],
     audioCapabilities: [{contentType: test.audioType}],
     videoCapabilities: [{contentType: test.videoType}],
   }];
 
-  return navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
+  return navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, options)
 
   .then(function(keySystemAccess) {
     return keySystemAccess.createMediaKeys();
   })
 
   .catch(function() {
     ok(false, token + " was not expecting failure (yet)");
   })
--- a/dom/media/test/test_eme_persistent_sessions.html
+++ b/dom/media/test/test_eme_persistent_sessions.html
@@ -81,27 +81,27 @@ function startTest(test, token)
         .then(function() {
           sessionId = session.sessionId;
           Log(token, "Closing session with id=" + sessionId);
           return session.close();
         })
 
         // Once the session is closed, reload the MediaKeys and reload the session
         .then(function() {
-          return navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, [{initDataTypes:["cenc"]}]);
+          return navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig);
         })
 
         .then(function(requestedKeySystemAccess) {
           keySystemAccess = requestedKeySystemAccess;
           return keySystemAccess.createMediaKeys();
         })
 
         .then(function(mediaKeys) {
           Log(token, "re-created MediaKeys object ok");
-          recreatedSession = mediaKeys.createSession("persistent");
+          recreatedSession = mediaKeys.createSession("persistent-license");
           Log(token, "Created recreatedSession, loading sessionId=" + sessionId);
           return recreatedSession.load(sessionId);
         })
 
         .then(function(suceeded) {
           if (suceeded) {
             return Promise.resolve();
           } else {
@@ -122,32 +122,32 @@ function startTest(test, token)
           Log(token, "removed session, all keys unusable.");
           // Attempt to recreate the session, the attempt should fail.
           return keySystemAccess.createMediaKeys();
         })
 
         .then(function(mediaKeys) {
           Log(token, "re-re-created MediaKeys object ok");
           // Trying to load the removed persistent session should fail.
-          return mediaKeys.createSession("persistent").load(sessionId);
+          return mediaKeys.createSession("persistent-license").load(sessionId);
         })
 
         .then(function(suceeded) {
           is(suceeded, false, token + " we expect the third session creation to fail, as the session should have been removed.");
           manager.finished(token);
         })
 
         .catch(function(reason) {
           // Catch rejections if any.
           ok(false, token + " rejected, reason=" + reason);
           manager.finished(token);
         });
 
       },
-      sessionType: "persistent",
+      sessionType: "persistent-license",
     }
   );
 
   LoadTestWithManagedLoadToken(test, v, manager, token,
                                { onlyLoadFirstFragments:2, noEndOfStream:false });
 }
 
 function beginTest() {
--- a/dom/media/test/test_eme_requestKeySystemAccess.html
+++ b/dom/media/test/test_eme_requestKeySystemAccess.html
@@ -6,17 +6,16 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
   <script type="text/javascript" src="manifest.js"></script>
   <script type="text/javascript" src="eme.js"></script>
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
-const CLEARKEY_ID = 'org.w3.clearkey';
 const SUPPORTED_LABEL = "pass label";
 
 function ValidateConfig(name, expected, observed) {
   info("ValidateConfig " + name);
   info("expected cfg=" + JSON.stringify(expected));
   info("observed cfg=" + JSON.stringify(observed));
 
   is(observed.label, expected.label, name + " label should match");
@@ -31,31 +30,38 @@ function ValidateConfig(name, expected, 
   }
   if (typeof expected.videoCapabilities !== 'undefined') {
     info("expected.videoCapabilities=" + expected.videoCapabilities);
     dump("expected.videoCapabilities=" + expected.videoCapabilities + "\n");
     ok(expected.videoCapabilities.length == 1, "Test function can only handle one capability.");
     ok(observed.videoCapabilities.length == 1, "Test function can only handle one capability.");
     is(observed.videoCapabilities[0].contentType, expected.videoCapabilities[0].contentType, name + " videoCapabilities should match.");
   }
+  if (expected.sessionTypes) {
+    is(expected.sessionTypes.length, observed.sessionTypes.length, "Should have expected number of sessionTypes");
+    for (var i = 0; i < expected.sessionTypes.length; i++) {
+      is(expected[i], observed[i], "Session type " + i + " should match");
+    }
+  }
 }
 
 function Test(test) {
   var name = "'" + test.name + "'";
   return new Promise(function(resolve, reject) {
     var p;
     if (test.options) {
-      p = navigator.requestMediaKeySystemAccess(test.keySystem, test.options);
+      var keySystem = (test.keySystem !== undefined) ? test.keySystem : CLEARKEY_KEYSYSTEM;
+      p = navigator.requestMediaKeySystemAccess(keySystem, test.options);
     } else {
-      p = navigator.requestMediaKeySystemAccess(test.keySystem);
+      p = navigator.requestMediaKeySystemAccess(keySystem);
     }
     p.then(
       function(keySystemAccess) {
         ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
-        is(keySystemAccess.keySystem, CLEARKEY_ID, "CDM keySystem should be in MediaKeySystemAccess.keySystem");
+        is(keySystemAccess.keySystem, CLEARKEY_KEYSYSTEM, "CDM keySystem should be in MediaKeySystemAccess.keySystem");
         ValidateConfig(name, test.expectedConfig, keySystemAccess.getConfiguration());
         resolve();
       },
       function(ex) {
         if (test.shouldPass) {
           info(name + " failed: " + ex);
         }
         ok(!test.shouldPass, name + " failed and was expected to " + (test.shouldPass ? "pass" : "fail"));
@@ -73,38 +79,37 @@ var tests = [
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'Empty options specified',
-    keySystem: CLEARKEY_ID,
     options: [ ],
     shouldPass: false,
   },
   {
     name: 'Undefined options',
-    keySystem: CLEARKEY_ID,
     shouldPass: false,
   },
   {
     name: 'Basic MP4 cenc',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
+        audioCapabilities: [{contentType: 'audio/mp4'}],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
+      audioCapabilities: [{contentType: 'audio/mp4'}],
       videoCapabilities: [{contentType: 'video/mp4'}],
     },
     shouldPass: true,
   },
   {
     name: 'Invalid keysystem failure',
     keySystem: 'bogusKeySystem',
     options: [
@@ -112,134 +117,113 @@ var tests = [
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'Invalid initDataType',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['bogus'],
+        audioCapabilities: [{contentType: 'audio/mp4'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'Valid initDataType after invalid',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['bogus', 'invalid', 'cenc'],
+        audioCapabilities: [{contentType: 'audio/mp4'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
+      audioCapabilities: [{contentType: 'audio/mp4'}],
     },
     shouldPass: true,
   },
   {
-    name: 'Empty initDataTypes',
-    keySystem: CLEARKEY_ID,
-    options: [
-      {
-        initDataTypes: [],
-      }
-    ],
-    shouldPass: false,
-  },
-  {
     name: 'Invalid videoType',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/bogus'}],
       }
     ],
     shouldPass: false,
   },
   {
-    name: 'distinctiveIdentifier, persistentState, and robustness ignored',
-    keySystem: CLEARKEY_ID,
+    name: 'Invalid distinctiveIdentifier fails',
+    options: [
+      {
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        distinctiveIdentifier: 'bogus',
+        persistentState: 'bogus',
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'distinctiveIdentifier is prohibited for ClearKey',
+    options: [
+      {
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        distinctiveIdentifier: 'required',
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'Invalid persistentState fails',
+    options: [
+      {
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        persistentState: 'bogus',
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'Invalid robustness unsupported',
+    options: [
+      {
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4', robustness: 'very much so'}],
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'Unexpected config entry should be ignored',
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
-        videoCapabilities: [{contentType: 'video/mp4', robustness: 'somewhat'}],
-        distinctiveIdentifier: 'bogus',
-        persistentState: 'bogus',
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        unexpectedEntry: 'this should be ignored',
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4'}],
     },
     shouldPass: true,
   },
   {
-    name: 'Only unrecognised dict entries specified with unrecognised video type',
-    keySystem: CLEARKEY_ID,
-    options: [
-      {
-        videoCapabilities: [{robustness: 'very much so'}],
-        distinctiveIdentifier: 'required',
-        persistentState: 'required',
-      }
-    ],
-    shouldPass: false,
-  },
-  {
-    name: 'Only unrecognised dict entries specified should be ignored',
-    keySystem: CLEARKEY_ID,
-    options: [
-      {
-        label: SUPPORTED_LABEL,
-        distinctiveIdentifier: 'required',
-        persistentState: 'required',
-      }
-    ],
-    expectedConfig: {
-      label: SUPPORTED_LABEL,
-    },
-    shouldPass: true,
-  },
-  {
-    name: 'Empty config dict',
-    keySystem: CLEARKEY_ID,
-    options: [{ label: SUPPORTED_LABEL }],
-    expectedConfig: {
-      label: SUPPORTED_LABEL
-    },
-    shouldPass: true,
-  },
-  {
-    name: 'Unexpected config entry should be ignored',
-    keySystem: CLEARKEY_ID,
-    options: [
-      {
-        label: SUPPORTED_LABEL,
-        initDataTypes: ['cenc'],
-        unexpectedEntry: 'this should be ignored',
-      }
-    ],
-    expectedConfig: {
-      label: SUPPORTED_LABEL,
-      initDataTypes: ['cenc'],
-    },
-    shouldPass: true,
-  },
-  {
     name: 'Invalid option followed by valid',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: "this config should not be supported",
         initDataTypes: ['bogus'],
       },
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
@@ -249,135 +233,177 @@ var tests = [
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4'}],
     },
     shouldPass: true,
   },
   {
+    name: 'Persistent sessions; persistence required',
+    options: [
+      {
+        label: SUPPORTED_LABEL,
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        sessionTypes: ['temporary','persistent-license'],
+        persistentState: 'required',
+      }
+    ],
+    expectedConfig: {
+      label: SUPPORTED_LABEL,
+      initDataTypes: ['cenc'],
+      videoCapabilities: [{contentType: 'video/mp4'}],
+      sessionTypes: ['temporary','persistent-license'],
+      persistentState: 'required',
+    },
+    shouldPass: true,
+  },
+  {
+    name: 'Persistent sessions not allowed when persistentState prohibited',
+    options: [
+      {
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        sessionTypes: ['temporary','persistent-license'],
+        persistentState: 'not-allowed',
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'Persistent sessions; should bump optional persistState to required',
+    options: [
+      {
+        label: SUPPORTED_LABEL,
+        initDataTypes: ['cenc'],
+        videoCapabilities: [{contentType: 'video/mp4'}],
+        sessionTypes: ['temporary','persistent-license'],
+        persistentState: 'optional',
+      }
+    ],
+    expectedConfig: {
+      label: SUPPORTED_LABEL,
+      initDataTypes: ['cenc'],
+      videoCapabilities: [{contentType: 'video/mp4'}],
+      sessionTypes: ['temporary','persistent-license'],
+      persistentState: 'required',
+    },
+    shouldPass: true,
+  },
+  {
     name: 'MP4 audio container',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         audioCapabilities: [{contentType: 'audio/mp4'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       audioCapabilities: [{contentType: 'audio/mp4'}],
     },
     shouldPass: true,
   },
   {
     name: 'MP4 audio container with AAC-LC',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
     },
     shouldPass: true,
   },
   {
     name: 'MP4 audio container with invalid codecs',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         audioCapabilities: [{contentType: 'audio/mp4; codecs="bogus"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 audio container with mp3 is unsupported',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         audioCapabilities: [{contentType: 'audio/mp4; codecs="mp3"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 video container type with an mp3 codec is unsupported',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4; codecs="mp3"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 audio container type with a video codec is unsupported',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         audioCapabilities: [{contentType: 'audio/mp4; codecs="avc1.42E01E"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 video container with constrained baseline h.264',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
     },
     shouldPass: true,
   },
   {
     name: 'MP4 video container with invalid codecs',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4; codecs="bogus"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 video container with both audio and video codec type in videoType',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 audio and video type both specified',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
         audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
       }
     ],
@@ -386,51 +412,48 @@ var tests = [
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
       audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
     },
     shouldPass: true,
   },
   {
     name: 'Basic WebM video',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['webm'],
         videoCapabilities: [{contentType: 'video/webm'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['webm'],
       videoCapabilities: [{contentType: 'video/webm'}],
     },
     shouldPass: true,
   },
   {
     name: 'Basic WebM audio',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['webm'],
         audioCapabilities: [{contentType: 'audio/webm'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['webm'],
       audioCapabilities: [{contentType: 'audio/webm'}],
     },
     shouldPass: true,
   },
   {
     name: 'Webm with Vorbis audio and VP8 video.',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['webm'],
         videoCapabilities: [{contentType: 'video/webm;codecs="vp8"'}],
         audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
       }
     ],
@@ -439,17 +462,16 @@ var tests = [
       initDataTypes: ['webm'],
       videoCapabilities: [{contentType: 'video/webm;codecs="vp8"'}],
       audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
     },
     shouldPass: true,
   },
   {
     name: 'Webm with Vorbis audio and VP9 video.',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['webm'],
         videoCapabilities: [{contentType: 'video/webm;codecs="vp9"'}],
         audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
       }
     ],
@@ -458,73 +480,72 @@ var tests = [
       initDataTypes: ['webm'],
       videoCapabilities: [{contentType: 'video/webm;codecs="vp9"'}],
       audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
     },
     shouldPass: true,
   },
   {
     name: 'Webm with bogus video.',
-    keySystem: CLEARKEY_ID,
     options: [
       {
         initDataTypes: ['webm'],
         videoCapabilities: [{contentType: 'video/webm;codecs="bogus"'}],
       }
     ],
     shouldPass: false,
   },
   {
     name: "CDM version less than",
-    keySystem: CLEARKEY_ID + ".0",
+    keySystem: CLEARKEY_KEYSYSTEM + ".0",
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4'}],
     },
     shouldPass: true
   },
   {
     name: "CDM version equal to",
-    keySystem: CLEARKEY_ID + ".1",
+    keySystem: CLEARKEY_KEYSYSTEM + ".1",
     options: [
       {
         label: SUPPORTED_LABEL,
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     expectedConfig: {
       label: SUPPORTED_LABEL,
       initDataTypes: ['cenc'],
       videoCapabilities: [{contentType: 'video/mp4'}],
     },
     shouldPass: true
   },
   {
     name: "CDM version greater than",
-    keySystem: CLEARKEY_ID + ".2",
+    keySystem: CLEARKEY_KEYSYSTEM + ".2",
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     shouldPass: false
   },
   {
     name: "Non-whole number CDM version",
-    keySystem: CLEARKEY_ID + ".0.1",
+    keySystem: CLEARKEY_KEYSYSTEM + ".0.1",
     options: [
       {
         initDataTypes: ['cenc'],
         videoCapabilities: [{contentType: 'video/mp4'}],
       }
     ],
     shouldPass: false
   },
--- a/dom/media/test/test_eme_request_notifications.html
+++ b/dom/media/test/test_eme_request_notifications.html
@@ -31,17 +31,17 @@ function SetPrefs(prefs) {
 }
 
 function Test(test) {
   var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
   observedStatus = "nothing";
   var name = "'" + test.keySystem + "'";
   return p.then(function() {
     return new Promise(function(resolve, reject) {
-      navigator.requestMediaKeySystemAccess(test.keySystem, [{initDataTypes:["cenc"]}])
+      navigator.requestMediaKeySystemAccess(test.keySystem, gCencMediaKeySystemConfig)
       .then(
         function(keySystemAccess) {
           return keySystemAccess.createMediaKeys();
         })
       .then(
         function(mediaKeys) {
           ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
           is(observedStatus, test.expectedStatus, name + " observer service result");
@@ -54,39 +54,37 @@ function Test(test) {
           is(observedStatus, test.expectedStatus, name + " observer service result");
           resolve();
         }
       );
     });
   });
 }
 
-const CLEARKEY_ID = 'org.w3.clearkey';
-
 var tests = [
   {
-    keySystem: CLEARKEY_ID,
+    keySystem: CLEARKEY_KEYSYSTEM,
     shouldPass: false,
     expectedStatus: 'api-disabled',
     prefs: [["media.eme.enabled", false], ["media.eme.clearkey.enabled", true]]
   },
   {
-    keySystem: CLEARKEY_ID,
+    keySystem: CLEARKEY_KEYSYSTEM,
     shouldPass: false,
     expectedStatus: 'cdm-disabled',
     prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]]
   },
   {
-    keySystem: CLEARKEY_ID + '.10000' , // A stupendously high min CDM version, presumably not installed.
+    keySystem: CLEARKEY_KEYSYSTEM + '.10000' , // A stupendously high min CDM version, presumably not installed.
     shouldPass: false,
     expectedStatus: 'cdm-insufficient-version',
     prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
   },
   {
-    keySystem: CLEARKEY_ID,
+    keySystem: CLEARKEY_KEYSYSTEM,
     shouldPass: true,
     expectedStatus: 'cdm-created',
     prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
   },
 ];
 
 SetupEMEPref(function() {
   tests.reduce(function(p,c,i,array) {
--- a/dom/media/test/test_eme_session_callable_value.html
+++ b/dom/media/test/test_eme_session_callable_value.html
@@ -7,17 +7,17 @@
   <script type="text/javascript" src="manifest.js"></script>
   <script type="text/javascript" src="eme.js"></script>
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function Test() {
-  navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{ initDataTypes: ['cenc'] }])
+  navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig)
   .then(access => access.createMediaKeys())
   .then(mediaKeys => {
     var initData = (new TextEncoder()).encode( 'this is an invalid license, and that is ok');
     var s = mediaKeys.createSession("temporary");
     s.generateRequest("cenc", initData); // ignore result.
     // "update()" call should fail, because MediaKeySession is "not callable"
     // yet, since CDM won't have had a chance to set the sessionId on MediaKeySession.
     return s.update(initData);
--- a/dom/media/test/test_eme_setMediaKeys_before_attach_MediaSource.html
+++ b/dom/media/test/test_eme_setMediaKeys_before_attach_MediaSource.html
@@ -9,17 +9,17 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function beginTest() {
   var video = document.createElement("video");
 
-  navigator.requestMediaKeySystemAccess("org.w3.clearkey", [{initDataTypes: ["cenc"]}])
+  navigator.requestMediaKeySystemAccess(CLEARKEY_KEYSYSTEM, gCencMediaKeySystemConfig)
     .then(function(keySystemAccess) {
       return keySystemAccess.createMediaKeys();
     })
     .then(mediaKeys => {
       return video.setMediaKeys(mediaKeys);
     })
     .then(() => {
       var ms = new MediaSource();