Bug 1318982 - Enable dormant for most media mochitests. r?jya draft
authorJW Wang <jwwang@mozilla.com>
Wed, 02 Nov 2016 16:56:38 +0800
changeset 442233 6a98ee34439ffff259836ff787130fee2ef946ec
parent 442232 69f40ba5e012ac1a408c520eca5dc58ea5e6ed4b
child 442296 380d6e47fb5daaaa6ea2b32f900ed08319292627
push id36632
push userjwwang@mozilla.com
push dateTue, 22 Nov 2016 02:43:16 +0000
reviewersjya
bugs1318982
milestone53.0a1
Bug 1318982 - Enable dormant for most media mochitests. r?jya MozReview-Commit-ID: 7AXEhCmFUeR
dom/media/mediasource/test/mediasource.js
dom/media/mediasource/test/test_Eviction_mp4.html
dom/media/mediasource/test/test_PlayEvents.html
dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
testing/profiles/prefs_general.js
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -1,10 +1,19 @@
 // Helpers for Media Source Extensions tests
 
+var gMSETestPrefs = [
+  [ "media.mediasource.enabled", true ]
+];
+
+// Called before runWithMSE() to set the prefs before running MSE tests.
+function addMSEPrefs(...prefs) {
+  gMSETestPrefs = gMSETestPrefs.concat(prefs);
+}
+
 function runWithMSE(testFunction) {
   function bootstrapTest() {
     var ms = new MediaSource();
 
     var el = document.createElement("video");
     el.src = URL.createObjectURL(ms);
     el.preload = "auto";
 
@@ -12,20 +21,17 @@ function runWithMSE(testFunction) {
     SimpleTest.registerCleanupFunction(function () {
       el.parentNode.removeChild(el);
     });
 
     testFunction(ms, el);
   }
 
   addLoadEvent(function () {
-    SpecialPowers.pushPrefEnv({"set": [
-      [ "media.mediasource.enabled", true ],
-    ]},
-                              bootstrapTest);
+    SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest);
   });
 }
 
 function fetchWithXHR(uri, onLoadFunction) {
   var p = new Promise(function(resolve, reject) {
     var xhr = new XMLHttpRequest();
     xhr.open("GET", uri, true);
     xhr.responseType = "arraybuffer";
--- a/dom/media/mediasource/test/test_Eviction_mp4.html
+++ b/dom/media/mediasource/test/test_Eviction_mp4.html
@@ -26,56 +26,56 @@ function fillUpSourceBuffer(sourceBuffer
     onCaughtExceptionCallback(ex);
     return;
   }
   once(sourceBuffer, 'updateend', () => {
     fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback);
   });
 }
 
+addMSEPrefs(
+  ["media.mediasource.eviction_threshold.audio", 524288],
+  ["media.dormant-on-pause-timeout-ms", -1] // FIXME: bug 1319292
+);
+
 runWithMSE(function(ms, el) {
   el.controls = true;
   once(ms, 'sourceopen').then(function() {
     ok(true, "Receive a sourceopen event");
-    SpecialPowers.pushPrefEnv({
-      "set": [
-        ["media.mediasource.eviction_threshold.audio", 524288],
-      ]
-    }, function() {
-      let audiosb = ms.addSourceBuffer("audio/mp4");
-      audiosb.mode = "sequence";
-      fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
-      .then(function() {
-        fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) {
-           fillUpSourceBuffer(audiosb,
-             function() { // doAppendDataFunc
-               audiosb.appendBuffer(audioBuffer);
-             },
-             function(ex) { // onCaughtExceptionCallback
-               is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown");
-               is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
-               let seekTime = audiosb.buffered.end(0) / 2;
-               el.currentTime = seekTime;
-               once(el, 'seeked', () => {
-                 is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
-                 try {
-                   audiosb.appendBuffer(audioBuffer);
-                 } catch(ex) {
-                   ok(false, "Shouldn't throw another time when data can be evicted");
-                   el.mozDumpDebugInfo();
-                   SimpleTest.finish();
-                   return;
-                 }
-                 once(audiosb, 'update', () => {
-                   ok(true, "appendBuffer succeeded");
-                   SimpleTest.finish();
-                 });
+    let audiosb = ms.addSourceBuffer("audio/mp4");
+    audiosb.mode = "sequence";
+    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
+    .then(function() {
+      fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) {
+         fillUpSourceBuffer(audiosb,
+           function() { // doAppendDataFunc
+             audiosb.appendBuffer(audioBuffer);
+           },
+           function(ex) { // onCaughtExceptionCallback
+             is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown");
+             is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
+             let seekTime = audiosb.buffered.end(0) / 2;
+             el.currentTime = seekTime;
+             once(el, 'seeked', () => {
+               dump("dump: seeked to " + seekTime);
+               is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
+               try {
+                 audiosb.appendBuffer(audioBuffer);
+               } catch(ex) {
+                 ok(false, "Shouldn't throw another time when data can be evicted");
+                 el.mozDumpDebugInfo();
+                 SimpleTest.finish();
+                 return;
+               }
+               once(audiosb, 'update', () => {
+                 ok(true, "appendBuffer succeeded");
+                 SimpleTest.finish();
                });
-            });
-        });
+             });
+          });
       });
     });
   });
 });
 
 </script>
 </pre>
 </body>
--- a/dom/media/mediasource/test/test_PlayEvents.html
+++ b/dom/media/mediasource/test/test_PlayEvents.html
@@ -16,16 +16,19 @@ SimpleTest.waitForExplicitFinish();
 // 1. Load 1.6s of data and ensure that canplay event is fired.
 // 2. Load data to have a complete buffered range from 0 to duration and ensure that canplaythrough is fired.
 // 3. Seek to an area with no buffered data, and ensure that readyState goes back to HAVE_METADATA
 // 4. Load 1.6s of data at the seek position and ensure that canplay is fired and that readyState is now HAVE_FUTURE_DATA
 // 5. Start playing video and check that once it reaches a position with no data, readyState goes back to HAVE_CURRENT_DATA and waiting event is fired.
 // 6. Add 1.6s of data once video element fired waiting, that canplay is fired once readyState is HAVE_FUTURE_DATA.
 // 7. Finally load data to the end and ensure that canplaythrough is fired and that readyState is now HAVE_ENOUGH_DATA
 
+// FIXME: bug 1319293
+addMSEPrefs(["media.dormant-on-pause-timeout-ms", -1]);
+
 runWithMSE(function(ms, el) {
   el.controls = true;
   once(ms, 'sourceopen').then(function() {
     // Log events for debugging.
     var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
                   "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
                   "waiting", "pause", "durationchange", "seeking", "seeked"];
     function logEvent(e) {
--- a/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
+++ b/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
@@ -6,16 +6,19 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
+// FIXME: bug 1319295
+addMSEPrefs(["media.dormant-on-pause-timeout-ms", -1]);
+
 var receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
     var sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -39,17 +39,17 @@ user_pref("dom.min_background_timeout_va
 user_pref("test.mousescroll", true);
 user_pref("security.default_personal_cert", "Select Automatically"); // Need to client auth test be w/o any dialogs
 user_pref("network.http.prompt-temp-redirect", false);
 user_pref("media.preload.default", 2); // default = metadata
 user_pref("media.preload.auto", 3); // auto = enough
 user_pref("media.cache_size", 1000);
 user_pref("media.volume_scale", "0.01");
 user_pref("media.test.dumpDebugInfo", true);
-user_pref("media.dormant-on-pause-timeout-ms", -1); // Disable dormant for it breaks some tests.
+user_pref("media.dormant-on-pause-timeout-ms", 0); // Enter dormant immediately without waiting for timeout.
 user_pref("security.warn_viewing_mixed", false);
 user_pref("app.update.enabled", false);
 user_pref("app.update.staging.enabled", false);
 user_pref("app.update.url.android", "");
 // Make sure GMPInstallManager won't hit the network.
 user_pref("media.gmp-manager.url.override", "http://%(server)s/dummy-gmp-manager.xml");
 user_pref("media.gmp-manager.updateEnabled", false);
 user_pref("dom.w3c_touch_events.enabled", 1);