Bug 905513 - Use pushPrefEnv instead of setBoolPref, and reenable test on Android. r=doublec
authorMatthew Gregan <kinetik@flim.org>
Fri, 27 Sep 2013 17:22:37 +1200
changeset 148931 935ab0a88dde1354384790b4c709c35bd1f7d0e9
parent 148930 07179c6176b865a3c8a839d848e57f941bc761aa
child 148932 1a134e410e123bd145fe8a6239ca50114282e8fe
push id34385
push usermgregan@mozilla.com
push dateFri, 27 Sep 2013 05:23:17 +0000
treeherdermozilla-inbound@808a8b288ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec
bugs905513
milestone27.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 905513 - Use pushPrefEnv instead of setBoolPref, and reenable test on Android. r=doublec
content/media/mediasource/test/test_MediaSource.html
--- a/content/media/mediasource/test/test_MediaSource.html
+++ b/content/media/mediasource/test/test_MediaSource.html
@@ -8,66 +8,64 @@
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 addLoadEvent(function() {
   ok(!window.MediaSource, "MediaSource should be hidden behind a pref");
-  if (navigator.appVersion.indexOf("Android") != -1) {
-    todo(false, "Fix this test on Android: bug 889712.");
-    SimpleTest.finish();
-    return;
-  }
   var accessThrows = false;
   try {
     new MediaSource();
   } catch (e) {
     accessThrows = true;
   }
   ok(accessThrows, "MediaSource should be hidden behind a pref");
-  SpecialPowers.setBoolPref("media.mediasource.enabled", true);
-  var ms = new MediaSource();
-  ok(ms, "Create a MediaSource object");
-  ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
-  is(ms.readyState, "closed", "New MediaSource must be in closed state");
-  // Force wrapper creation, tests for leaks.
-  ms.foo = null;
-  var o = URL.createObjectURL(ms);
-  ok(o, "Create an objectURL from the MediaSource");
-  var v = document.createElement("video");
-  document.body.appendChild(v);
-  v.src = o;
-  ms.addEventListener("sourceopen", function () {
-    ok(true, "Receive a sourceopen event");
-    is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
-    var sb = ms.addSourceBuffer("video/webm");
-    ok(sb, "Create a SourceBuffer");
-    is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
-    is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
-    fetch("seek.webm", function (blob) {
-      var r = new FileReader();
-      r.addEventListener("load", function (e) {
-        sb.appendBuffer(new Uint8Array(e.target.result));
-        ms.endOfStream();
-        v.play();
+  SpecialPowers.pushPrefEnv({"set": [[ "media.mediasource.enabled", true ]]},
+                            function () {
+    SpecialPowers.setBoolPref("media.mediasource.enabled", true);
+    var ms = new MediaSource();
+    ok(ms, "Create a MediaSource object");
+    ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
+    is(ms.readyState, "closed", "New MediaSource must be in closed state");
+    // Force wrapper creation, tests for leaks.
+    ms.foo = null;
+    var o = URL.createObjectURL(ms);
+    ok(o, "Create an objectURL from the MediaSource");
+    var v = document.createElement("video");
+    v.preload = "auto";
+    document.body.appendChild(v);
+    v.src = o;
+    ms.addEventListener("sourceopen", function () {
+      ok(true, "Receive a sourceopen event");
+      is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
+      var sb = ms.addSourceBuffer("video/webm");
+      ok(sb, "Create a SourceBuffer");
+      is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
+      is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
+      fetch("seek.webm", function (blob) {
+        var r = new FileReader();
+        r.addEventListener("load", function (e) {
+          sb.appendBuffer(new Uint8Array(e.target.result));
+          ms.endOfStream();
+          v.play();
+        });
+        r.readAsArrayBuffer(blob);
       });
-      r.readAsArrayBuffer(blob);
+    });
+    ms.addEventListener("sourceended", function () {
+      ok(true, "Receive a sourceended event");
+      is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
     });
-  });
-  ms.addEventListener("sourceended", function () {
-    ok(true, "Receive a sourceended event");
-    is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
-  });
-  v.addEventListener("playing", function () {
-    is(v.duration, 4, "Video has correct duration");
-    v.parentNode.removeChild(v);
-    SpecialPowers.clearUserPref("media.mediasource.enabled");
-    SimpleTest.finish();
+    v.addEventListener("ended", function () {
+      is(v.duration, 4, "Video has correct duration");
+      v.parentNode.removeChild(v);
+      SimpleTest.finish();
+    });
   });
 });
 
 function fetch(src, cb) {
   var xhr = new XMLHttpRequest();
   xhr.open("GET", src, true);
   xhr.responseType = "blob";
   xhr.addEventListener("load", function (e) {