Bug 1314212: P1. Update and re-enable MSE mochitest. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 01 Nov 2016 18:36:07 +1100
changeset 432501 6dd809215aa54460c1da3ff367b354dee8096758
parent 432454 13993b20e05e1c0b714e19cec1dea208fc64ac8d
child 432502 cc7b2a8e997b77c30aac4afbc520329d6af60704
push id34335
push userbmo:jyavenard@mozilla.com
push dateWed, 02 Nov 2016 07:06:30 +0000
reviewersgerald
bugs1314212
milestone52.0a1
Bug 1314212: P1. Update and re-enable MSE mochitest. r?gerald MozReview-Commit-ID: 9hYddtEWexz
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_WaitingOnMissingData.html
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -124,16 +124,16 @@ skip-if = ((os == "win" && os_version ==
 [test_Threshold_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_TimestampOffset_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_TruncatedDuration.html]
 [test_TruncatedDuration_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_WaitingOnMissingData.html]
-skip-if = true # Disabled due to bug 1124493 and friends. WebM MSE is deprioritized.
+skip-if = (toolkit == 'android' || buildapp == 'mulet') #timeout android/mulet only bug 1101187
 [test_WaitingOnMissingData_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_WaitingOnMissingDataEnded_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_WaitingToEndedTransition_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 
--- a/dom/media/mediasource/test/test_WaitingOnMissingData.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData.html
@@ -6,67 +6,58 @@
   <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();
 
-var receivedSourceOpen = false;
-runWithMSE(function(ms, v) {
-  ms.addEventListener("sourceopen", function() {
+runWithMSE(function(ms, el) {
+  once(ms, 'sourceopen').then(function() {
     ok(true, "Receive a sourceopen event");
-    ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
-    receivedSourceOpen = true;
     var sb = ms.addSourceBuffer("video/webm");
-    ok(sb, "Create a SourceBuffer");
-
-    function once(target, name, cb) {
-      target.addEventListener(name, function() {
-        target.removeEventListener(name, cb);
-        cb();
-      });
-    }
-    function loadSegment(typedArray) {
-      info(`Loading buffer: [${typedArray.byteOffset}, ${typedArray.byteOffset + typedArray.byteLength})`);
-      return new Promise(function(resolve, reject) {
-        once(sb, 'update', resolve);
-        sb.appendBuffer(typedArray);
-      });
-    }
-
     fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-      loadSegment.bind(null, new Uint8Array(arrayBuffer, 0, 318))().then(
-      loadSegment.bind(null, new Uint8Array(arrayBuffer, 318, 25223-318))).then(
-      loadSegment.bind(null, new Uint8Array(arrayBuffer, 25223, 46712-25223))).then(
+      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))()
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223-318)))
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712-25223)))
       /* Note - Missing |46712, 67833 - 46712| segment here */
-      loadSegment.bind(null, new Uint8Array(arrayBuffer, 67833, 88966 - 67833))).then(
-      loadSegment.bind(null, new Uint8Array(arrayBuffer, 88966))).then(function() {
-
-        v.addEventListener("waiting", function onwaiting() {
-          ok(true, "Got a waiting event at " + v.currentTime);
-          if (v.currentTime > 0.7 && v.currentTime < 1.2) {
-            v.removeEventListener("waiting", onwaiting);
-            todo(v.currentTime >= 0.8, "See bug 1091774");
-            gotWaiting = true;
-            ok(true, "Received waiting event at time " + v.currentTime);
-            loadSegment(new Uint8Array(arrayBuffer, 46712, 67833 - 46712)).then(() => ms.endOfStream());
-          }
-        });
-
-        info("Playing video. It should play for a bit, then fire 'waiting'");
-        v.play();
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833)))
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966)))
+      .then(function() {
+        // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
+        // has notified it of available data. Make sure that we get 'playing' before
+        // we starting waiting for 'waiting'.
+        info("Invoking play()");
+        var p = once(el, 'playing');
+        el.play();
+        return p;
+      }).then(function() {
+        ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
+        var p = once(el, 'waiting');
+        el.play();
+        return p;
+      }).then(function() {
+        // currentTime is based on the current video frame, so if the audio ends just before
+        // the next video frame, currentTime can be up to 1 frame's worth earlier than
+        // min(audioEnd, videoEnd).
+        // 0.0465 is the length of the last audio frame.
+        ok(el.currentTime >= (sb.buffered.end(0) - 0.0465),
+           "Got a waiting event at " + el.currentTime);
+        info("Loading more data");
+        var p = once(el, 'ended');
+        loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712)).then(() => ms.endOfStream());
+        return p;
+      }).then(function() {
+        // These fuzz factors are bigger than they should be. We should investigate
+        // and fix them in bug 1137574.
+        isfuzzy(el.duration, 4.001, 0.1, "Video has correct duration: " + el.duration);
+        isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
+        SimpleTest.finish();
       });
     });
   });
-  v.addEventListener("ended", function () {
-    ok(Math.abs(v.duration - 4) < 0.1, "Video has correct duration. This fuzz factor is due to bug 1065207");
-    ok(Math.abs(v.currentTime - 4) < 0.1, "Video has correct currentTime. See bug 1101062");
-    ok(gotWaiting, "Received waiting event and playback continued after data added");
-    SimpleTest.finish();
-  });
 });
 </script>
 </pre>
 </body>
 </html>