Bug 1230026 - Add test for 'webm' initDataType for ClearKey initData. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Fri, 04 Dec 2015 07:24:32 +1300
changeset 309614 a8b4b4cdab7b9080bee35793078110ae7abfc3d2
parent 309613 fd69513f86b7a61f98e45af9b77431816012bb72
child 309615 9d8af47837101c8f4ce67930e5094a59ed9942a6
child 309677 ca6c81a2c6c2ac3183f31afb437fc88534022f44
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1230026
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1230026 - Add test for 'webm' initDataType for ClearKey initData. r=gerald
dom/media/test/mochitest.ini
dom/media/test/test_eme_initDataTypes.html
dom/media/test/test_eme_key_ids_initdata.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -614,17 +614,17 @@ skip-if = (toolkit == 'android' && proce
 [test_defaultMuted.html]
 [test_delay_load.html]
 skip-if = buildapp == 'b2g' && toolkit != 'gonk' # bug 1082984
 [test_dormant_playback.html]
 skip-if = (os == 'win' && os_version == '5.1') || (os != 'win' && toolkit != 'gonk')
 [test_eme_session_callable_value.html]
 [test_eme_canvas_blocked.html]
 skip-if = toolkit == 'android' # bug 1149374
-[test_eme_key_ids_initdata.html]
+[test_eme_initDataTypes.html]
 skip-if = toolkit == 'android' # bug 1149374
 [test_eme_non_mse_fails.html]
 skip-if = toolkit == 'android' # bug 1149374
 [test_eme_request_notifications.html]
 skip-if = toolkit == 'android' # bug 1149374
 [test_eme_persistent_sessions.html]
 skip-if = toolkit == 'android' # bug 1149374
 [test_eme_playback.html]
rename from dom/media/test/test_eme_key_ids_initdata.html
rename to dom/media/test/test_eme_initDataTypes.html
--- a/dom/media/test/test_eme_key_ids_initdata.html
+++ b/dom/media/test/test_eme_initDataTypes.html
@@ -9,92 +9,125 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var tests = [
   {
     name: "One keyId",
+    initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"]}',
     expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"],"type":"temporary"}',
     sessionType: 'temporary',
     expectPass: true,
   },
   {
     name: "Two keyIds",
+    initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A", "0DdtU9od-Bh5L3xbv0Xf_A"]}',
     expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A","0DdtU9od-Bh5L3xbv0Xf_A"],"type":"temporary"}',
     sessionType: 'temporary',
     expectPass: true,
   },
   {
     name: "Two keyIds, temporary session",
+    initDataType: 'keyids',
     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',
     expectPass: true,
   },
   {
     name: "Invalid keyId",
+    initDataType: 'keyids',
     initData: '{"kids":["0"]}',
     sessionType: 'temporary',
     expectPass: false,
   },
   {
     name: "Empty keyId",
+    initDataType: 'keyids',
     initData: '{"kids":[""]}',
     sessionType: 'temporary',
     expectPass: false,
   },
   {
     name: "SessionType in license doesn't match MediaKeySession's sessionType",
+    initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"]}',
     sessionType: 'persistent',
     expectPass: false,
   },
   {
     name: "One valid and one invalid kid",
+    initDataType: 'keyids',
     initData: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A", "invalid"]}',
     expectedRequest: '{"kids":["LwVHf8JLtPrv2GUXFW2v_A"],"type":"temporary"}',
     sessionType: 'temporary',
     expectPass: true,
   },
   {
     name: "Invalid initData",
+    initDataType: 'keyids',
     initData: 'invalid initData',
     sessionType: 'temporary',
     expectPass: false,
   },
+  {
+    name: "'webm' initDataType",
+    initDataType: 'webm',
+    initData: 'YAYeAX5Hfod+V9ANHtANHg==',
+    expectedRequest: '{"kids":["YAYeAX5Hfod-V9ANHtANHg"],"type":"temporary"}',
+    sessionType: 'temporary',
+    expectPass: true,
+  },
+  {
+    name: "'webm' initDataType with non 16 byte keyid",
+    initDataType: 'webm',
+    initData: 'YAYeAX5Hfod',
+    sessionType: 'temporary',
+    expectPass: false,
+  },
 ];
 
+function PrepareInitData(initDataType, initData)
+{
+  if (initDataType == "keyids") {
+    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: ['keyids']}]).then(
       (access) => access.createMediaKeys()
       ).then(
         (mediaKeys) => {
           var session = mediaKeys.createSession(test.sessionType);
-          var initData = new TextEncoder().encode(test.initData);
           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();
           });
-          return session.generateRequest('keyids', initData);
+          var initData = PrepareInitData(test.initDataType, test.initData);
+          return session.generateRequest(test.initDataType, initData);
         }
       ).catch((x) => {
         ok(!test.expectPass, "'" + test.name + "' expected to fail.");
         resolve();
       });
   });
 }