Bug 1065855 - Tests for MediaSource seekable range - r=kinetik
☠☠ backed out by f5c1fce30621 ☠ ☠
authorChris Double <chris.double@double.co.nz>
Tue, 16 Sep 2014 15:16:02 +1200
changeset 205587 d462269d88a946a79249d2210054718bd996be21
parent 205586 97e08c477d63e4fdc7265320e2540c3984dc90bc
child 205588 8cada343f1ab41643d9107644401a5747335e745
push id27498
push userkwierso@gmail.com
push dateWed, 17 Sep 2014 00:06:56 +0000
treeherdermozilla-central@8252eae8278c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1065855
milestone35.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 1065855 - Tests for MediaSource seekable range - r=kinetik
content/media/mediasource/test/mochitest.ini
content/media/mediasource/test/test_MediaSource.html
content/media/mediasource/test/test_SeekableAfterEndOfStream.html
content/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html
content/media/mediasource/test/test_SeekableBeforeEndOfStream.html
content/media/mediasource/test/test_SeekableBeforeEndOfStreamSplit.html
--- a/content/media/mediasource/test/mochitest.ini
+++ b/content/media/mediasource/test/mochitest.ini
@@ -3,11 +3,14 @@ skip-if = e10s || buildapp == 'b2g' # b2
 support-files =
   mediasource.js
   seek.webm seek.webm^headers^
   seek_lowres.webm seek_lowres.webm^headers^
 
 [test_BufferedSeek.html]
 [test_FrameSelection.html]
 [test_MediaSource.html]
+[test_SeekableAfterEndOfStream.html]
+[test_SeekableAfterEndOfStreamSplit.html]
+[test_SeekableBeforeEndOfStream.html]
+[test_SeekableBeforeEndOfStreamSplit.html]
 [test_SplitAppendDelay.html]
 [test_SplitAppend.html]
-
--- a/content/media/mediasource/test/test_MediaSource.html
+++ b/content/media/mediasource/test/test_MediaSource.html
@@ -36,50 +36,69 @@ runWithMSE(function () {
   var o = URL.createObjectURL(ms);
   ok(o, "Create an objectURL from the MediaSource");
 
   var v = document.createElement("video");
   v.preload = "auto";
   v.src = o;
   document.body.appendChild(v);
 
+  var loadedmetadataCount = 0;
+  var updatestartCount = 0;
+  var updateendCount = 0;
+  var updateCount = 0;
+
   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");
     is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer");
 
     fetchWithXHR("seek.webm", function (arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
     });
 
     sb.addEventListener("update", function () {
       is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
+      updateCount++;
       ms.endOfStream();
     });
 
+    sb.addEventListener("updatestart", function () {
+      updatestartCount++;
+    });
+
     sb.addEventListener("updateend", function () {
       is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
+      updateendCount++;
       v.play();
     });
   });
 
   ms.addEventListener("sourceended", function () {
     ok(true, "Receive a sourceended event");
     is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
   });
 
+  v.addEventListener("loadedmetadata", function () {
+    loadedmetadataCount++;
+  });
+
   v.addEventListener("ended", function () {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     is(v.duration, 4.001, "Video has correct duration");
     is(v.currentTime, 4.001, "Video has played to end");
+    is(updateCount, 1, "update event received");
+    is(updateendCount, 1, "updateend event received");
+    is(updatestartCount, 1, "updatestart event received");
+    is(loadedmetadataCount, 1, "loadedmetadata event received");
     v.parentNode.removeChild(v);
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
 </body>
new file mode 100644
--- /dev/null
+++ b/content/media/mediasource/test/test_SeekableAfterEndOfStream.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: seekable attribute after end of stream</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();
+
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm", function (arrayBuffer) {
+      sb.appendBuffer(new Uint8Array(arrayBuffer));
+      sb.addEventListener("updateend", function () {
+        ms.endOfStream()
+      });
+    });
+
+    var target = 2;
+
+    v.addEventListener("loadedmetadata", function () {
+      ok(v.seekable.length, "Resource is seekable");
+      ok(v.seekable.length &&
+          target >= v.seekable.start(0) &&
+          target < v.seekable.end(0), "Target is within seekable range");
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/media/mediasource/test/test_SeekableAfterEndOfStreamSplit.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: seekable attribute after end of stream with split appendBuffer</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();
+
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm", function (arrayBuffer) {
+      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25223));
+      var updateCount = 0;
+      sb.addEventListener("updateend", function () {
+        updateCount++;
+        if (updateCount == 1) {
+          sb.appendBuffer(new Uint8Array(arrayBuffer, 25223));
+        }
+        else {
+          ms.endOfStream();
+        }
+      });
+    });
+
+    var target = 2;
+
+    v.addEventListener("loadedmetadata", function () {
+      ok(v.seekable.length, "Resource is seekable");
+      ok(v.seekable.length &&
+          target >= v.seekable.start(0) &&
+          target < v.seekable.end(0), "Target is within seekable range");
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/media/mediasource/test/test_SeekableBeforeEndOfStream.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: seekable attribute before end of stream</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();
+
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm", function (arrayBuffer) {
+      sb.appendBuffer(new Uint8Array(arrayBuffer));
+    });
+
+    var target = 2;
+
+    v.addEventListener("loadedmetadata", function () {
+      ok(v.seekable.length, "Resource is seekable");
+      ok(v.seekable.length &&
+          target >= v.seekable.start(0) &&
+          target < v.seekable.end(0), "Target is within seekable range");
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/content/media/mediasource/test/test_SeekableBeforeEndOfStreamSplit.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: seekable attribute before end of stream with split appendBuffer</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();
+
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm", function (arrayBuffer) {
+      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25223));
+      sb.addEventListener("updateend", function () {
+        sb.appendBuffer(new Uint8Array(arrayBuffer, 25223));
+      });
+    });
+
+    var target = 2;
+
+    v.addEventListener("loadedmetadata", function () {
+      ok(v.seekable.length, "Resource is seekable");
+      ok(v.seekable.length &&
+          target >= v.seekable.start(0) &&
+          target < v.seekable.end(0), "Target is within seekable range");
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>