Bug 1093020 - Tests. r=karlt
☠☠ backed out by 43a51201545a ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Wed, 05 Nov 2014 10:09:00 +0100
changeset 214074 21ddb8a58fea635e047c00827675fed3c42b3d31
parent 214073 fe9e11333c7d2489716d6708129b6adbd443cd09
child 214075 8aab8aebc1a5d951e48a84a7c53508a84b9d8c1a
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1093020
milestone36.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 1093020 - Tests. r=karlt
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_BufferingWait.html
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -3,16 +3,17 @@ skip-if = e10s || buildapp == 'b2g' # b2
 support-files =
   mediasource.js
   seek.webm seek.webm^headers^
   seek_lowres.webm seek_lowres.webm^headers^
 
 [test_MediaSource.html]
 [test_MediaSource_disabled.html]
 [test_BufferedSeek.html]
+[test_BufferingWait.html]
 [test_FrameSelection.html]
 [test_HaveMetadataUnbufferedSeek.html]
 [test_SeekableAfterEndOfStream.html]
 [test_SeekableAfterEndOfStreamSplit.html]
 [test_SeekableBeforeEndOfStream.html]
 [test_SeekableBeforeEndOfStreamSplit.html]
 [test_SplitAppendDelay.html]
 [test_SplitAppend.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/test_BufferingWait.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=windows-1252">
+  <title>MSE: Don't get stuck buffering for too long when we have frames to show</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <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() {
+    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);
+      });
+    }
+
+    function waitUntilTime(targetTime) {
+      return new Promise(function(resolve, reject) {
+        v.addEventListener("waiting", function onwaiting() {
+          info("Got a waiting event at " + v.currentTime);
+          if (v.currentTime >= targetTime) {
+            ok(true, "Reached target time of: " + targetTime);
+            v.removeEventListener("waiting", onwaiting);
+            resolve();
+          }
+        });
+      });
+    }
+
+    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(
+      /* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */
+      /* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6]  */
+      loadSegment.bind(null, new Uint8Array(arrayBuffer, 88966))).then(function() {
+        var promise = waitUntilTime(0.7);
+        info("Playing video. It should play for a bit, then fire 'waiting'");
+        v.play();
+        return promise;
+      }).then(function() {
+        window.firstStop = Date.now();
+        loadSegment(new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
+        return waitUntilTime(1.0);
+      }).then(function() {
+        var waitDuration = (Date.now() - window.firstStop) / 1000;
+        ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
+        SimpleTest.finish();
+        /* If we allow the rest of the stream to be played, we get stuck at
+           around 2s. See bug 1093133.
+        once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
+        return loadSegment(new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
+        */
+      });
+    });
+  });
+});
+</script>
+</pre>
+</body>
+</html>