Bug 1286723: [MSE] P2. Add live seekable mochitest. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 14 Jul 2016 15:56:05 +1000
changeset 305170 a9bcf6959e2a799b6a25474697185518ea962a0b
parent 305169 fcb130529e8206fb65ed0bff9837762d29cd7a1a
child 305171 501b4b7d83ea286976dd7e7512eb393c1fe8b6bd
push id79518
push usercbook@mozilla.com
push dateSun, 17 Jul 2016 08:09:59 +0000
treeherdermozilla-inbound@711963e8daa3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1286723
milestone50.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 1286723: [MSE] P2. Add live seekable mochitest. r=gerald MozReview-Commit-ID: 4NIGn8HGz93
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_LiveSeekable.html
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -63,16 +63,17 @@ skip-if = ((os == "win" && os_version ==
 [test_DurationUpdated_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_FrameSelection.html]
 [test_FrameSelection_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_HaveMetadataUnbufferedSeek.html]
 [test_HaveMetadataUnbufferedSeek_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
+[test_LiveSeekable.html]
 [test_LoadedDataFired_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_LoadedMetadataFired.html]
 [test_LoadedMetadataFired_mp4.html]
 skip-if = ((os == "win" && os_version == "5.1") || (toolkit == 'android')) # Not supported on xp and android 2.3
 [test_MediaSource.html]
 [test_MediaSource_memory_reporting.html]
 [test_MediaSource_mp4.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/test_LiveSeekable.html
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: live seekable range</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");
+    // Load data with a +2 offset so that we can distinguish buffered range start
+    // and seekable range start.
+    sb.timestampOffset = 2;
+    var promises = [];
+    promises.push(fetchAndLoad(sb, 'seek', [''], '.webm'));
+    promises.push(once(v, "loadedmetadata"));
+    Promise.all(promises)
+    .then(function() {
+      ms.duration = Infinity;
+      sb.abort();
+      is(sb.buffered.length, 1, "continuous buffered range");
+      is(sb.buffered.start(0), 2, "buffered range start at timestamp offset");
+      is(sb.buffered.end(0), 6.001, "buffered range end at original duration + timestamp offset");
+      is(v.seekable.length, 1, "continuous seekable range");
+      is(v.seekable.start(0), 0, "seekable range start at 0");
+      is(v.seekable.end(0), sb.buffered.end(0), "seekable range end at buffered end");
+
+      // LiveSeekableRange.start < buffered.start
+      ms.setLiveSeekableRange(1, 5);
+      is(v.seekable.length, 1, "continuous seekable range");
+      is(v.seekable.start(0), 1, "seekable range start at live range start");
+      is(v.seekable.end(0), sb.buffered.end(0), "seekable range end at buffered end");
+
+      ms.clearLiveSeekableRange();
+      ok(v.seekable.length, 1, "continuous seekable range");
+      is(v.seekable.start(0), 0, "seekable range start at 0");
+      is(v.seekable.end(0), sb.buffered.end(0), "seekable range end at buffered end");
+
+      // LiveSeekableRange.end > buffered.end
+      ms.setLiveSeekableRange(1, 8);
+      is(v.seekable.start(0), 1, "seekable range start at live range start");
+      is(v.seekable.end(0), 8, "seekable range end at live range end");
+
+      // LiveSeekableRange.start > buffered.start
+      // LiveSeekableRange.end < buffered.end
+      ms.setLiveSeekableRange(3, 5);
+      is(v.seekable.start(0), sb.buffered.start(0), "seekable range start at buffered start");
+      is(v.seekable.end(0), sb.buffered.end(0), "seekable range end at live range end");
+
+      // LiveSeekableRange.start > buffered.end
+      ms.setLiveSeekableRange(8, 10);
+      is(v.seekable.start(0), sb.buffered.start(0), "seekable range start at buffered start");
+      is(v.seekable.end(0), 10, "seekable range end at live range end");
+
+      // LiveSeekableRange.end < buffered.start
+      ms.setLiveSeekableRange(0, 2);
+      is(v.seekable.start(0), 0, "seekable range start at live range start");
+      is(v.seekable.end(0), sb.buffered.end(0), "seekable range end at buffered end");
+
+      try {
+        ms.setLiveSeekableRange(2, 0);
+        ok(false, "start > end");
+      } catch (e) { ok(true, "must thow if start > end"); }
+
+      SimpleTest.finish();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>