Bug 1131392 - Fix EME tests after disable non-MSE EME - r=cpearce a=lmandel
authorEdwin Flores <eflores@mozilla.com>
Tue, 03 Mar 2015 11:02:36 +1300
changeset 250280 1a9d0193519a
parent 250279 dd9bfd410f7e
child 250281 8492532adb28
push id4535
push usercpearce@mozilla.com
push date2015-03-06 20:57 +0000
treeherdermozilla-beta@68707623b5a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1131392
milestone37.0
Bug 1131392 - Fix EME tests after disable non-MSE EME - r=cpearce a=lmandel
dom/media/test/manifest.js
dom/media/test/test_eme_non_fragmented.html
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -684,16 +684,24 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d04" : "7e5744447e5744447e5744447e574444",
     },
     sessionType:"temporary",
     duration:2.00,
     crossOrigin:true,
   },
 ];
 
+var gEMENonFragmentedTests = [
+  {
+    name:"short-cenc.mp4",
+    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
+    duration:0.47,
+  },
+];
+
 function checkMetadata(msg, e, test) {
   if (test.width) {
     is(e.videoWidth, test.width, msg + " video width");
   }
   if (test.height) {
     is(e.videoHeight, test.height, msg + " video height");
   }
   if (test.duration) {
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_eme_non_fragmented.html
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Bug 1131392 - Test that EME does not work for non-MSE media</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <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">
+var manager = new MediaTestManager;
+
+function DoSetMediaKeys(v)
+{
+  var options = [{
+    initDataType: "cenc",
+    videoType: test.type,
+  }];
+
+  return navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
+
+  .then(function(keySystemAccess) {
+    return keySystemAccess.createMediaKeys();
+  })
+
+  .catch(function() {
+    ok(false, token + " was not expecting failure (yet)");
+  })
+
+  .then(function(mediaKeys) {
+    return v.setMediaKeys(mediaKeys);
+  });
+}
+
+function TestSetMediaKeys(test, token)
+{
+  manager.started(token);
+
+  var v = document.createElement("video");
+
+  // XXX the encrypted event should never fire here after bug 1134434
+  v.addEventListener("encrypted", function() {
+    DoSetMediaKeys(v)
+
+    .then(function() {
+      ok(false, token + " expected setMediaKeys to fail.");
+      manager.finished(token);
+    }, function(err) {
+      is(err.name, "NotSupportedError", token + " should return correct error");
+      manager.finished(token);
+    });
+  });
+
+  v.src = test.name;
+}
+
+function TestSetSrc(test, token)
+{
+  manager.started(token);
+
+  var v = document.createElement("video");
+  v.addEventListener("error", function(err) {
+    ok(true, token + " got error setting src on video element, as expected");
+    manager.finished(token);
+  });
+
+  DoSetMediaKeys(v)
+
+  .then(function() {
+    v.src = test.name;
+  })
+
+  .catch(function() {
+    ok(false, token + " got error setting media keys");
+  });
+}
+
+function startTest(test, token)
+{
+  TestSetMediaKeys(test, token + "_setMediaKeys");
+  TestSetSrc(test, token + "_setSrc");
+}
+
+function beginTest() {
+  manager.runTests(gEMENonFragmentedTests, startTest);
+}
+
+var prefs = [
+  [ "media.mediasource.enabled", true ],
+  [ "media.mediasource.youtubeonly", false ],
+  [ "media.mediasource.mp4.enabled", true ],
+];
+
+if (/Linux/.test(navigator.userAgent) ||
+    !document.createElement('video').canPlayType("video/mp4")) {
+  // XXX remove once we have mp4 PlatformDecoderModules on all platforms.
+  prefs.push([ "media.fragmented-mp4.exposed", true ]);
+  prefs.push([ "media.fragmented-mp4.use-blank-decoder", true ]);
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ "set" : prefs }, beginTest);
+</script>
+</pre>
+</body>
+</html>
+