Bug 1121692 - Tests. r=mattwoodrow,r=cpearce
authorBobby Holley <bobbyholley@gmail.com>
Fri, 16 Jan 2015 10:58:00 -0800
changeset 224252 3d0dd2ae7e6c2cdb3d43b080b22ac95dd757247f
parent 224251 9bf200fcadbce728912d072eeb646b7c0291fcba
child 224253 c258c2ad63111da7953dae4aac4ec2ffe53de023
push id54170
push userbobbyholley@gmail.com
push dateFri, 16 Jan 2015 18:58:13 +0000
treeherdermozilla-inbound@3d0dd2ae7e6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, cpearce
bugs1121692
milestone38.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 1121692 - Tests. r=mattwoodrow,r=cpearce
dom/media/mediasource/test/mediasource.js
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_SeekTwice_mp4.html
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -74,8 +74,27 @@ function loadSegment(sb, typedArrayOrArr
     once(sb, 'update').then(function() {
       var afterBuffered = timeRangeToString(sb.buffered);
       info(`SourceBuffer buffered ranges grew from ${beforeBuffered} to ${afterBuffered}`);
       resolve();
     });
     sb.appendBuffer(typedArray);
   });
 }
+
+function fetchAndLoad(sb, prefix, chunks, suffix) {
+
+  // Fetch the buffers in parallel.
+  var buffers = {};
+  var fetches = [];
+  for (var chunk of chunks) {
+    fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk)));
+  }
+
+  // Load them in series, as required per spec.
+  return Promise.all(fetches).then(function() {
+    var rv = Promise.resolve();
+    for (var chunk of chunks) {
+      rv = rv.then(loadSegment.bind(null, sb, buffers[chunk]));
+    }
+    return rv;
+  });
+}
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -29,13 +29,15 @@ skip-if = (toolkit == 'android' || build
 [test_HaveMetadataUnbufferedSeek.html]
 [test_LoadedMetadataFired.html]
 [test_MediaSource.html]
 [test_MediaSource_disabled.html]
 [test_SeekableAfterEndOfStream.html]
 [test_SeekableAfterEndOfStreamSplit.html]
 [test_SeekableBeforeEndOfStream.html]
 [test_SeekableBeforeEndOfStreamSplit.html]
+[test_SeekTwice_mp4.html]
+skip-if = os == 'linux' # No fmp4 support on linux
 [test_SetModeThrows.html]
 [test_SplitAppendDelay.html]
 [test_SplitAppend.html]
 [test_WaitingOnMissingData.html]
  skip-if = android_version == '10' # bug 1115148 - frequent failures on Android 2.3
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/test_SeekTwice_mp4.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>MSE: basic functionality</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();
+
+// Avoid making trouble for people who fix rounding bugs.
+function fuzzyEquals(a, b) {
+  return Math.abs(a - b) < 0.01;
+}
+
+function range(start, end) {
+  var rv = [];
+  for (var i = start; i < end; ++i) {
+    rv.push(i);
+  }
+  return rv;
+}
+
+runWithMSE(function(ms, el) {
+  el.controls = true;
+  once(ms, 'sourceopen').then(function() {
+    ok(true, "Receive a sourceopen event");
+    var audiosb = ms.addSourceBuffer("audio/mp4");
+    var videosb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
+    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
+    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(6, 12), '.m4s'))
+    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
+    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
+    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(7, 14), '.m4s'))
+    .then(function() {
+      var p = once(el, 'seeking');
+      el.play();
+      el.currentTime = 4.5; // Seek to a gap in the video
+      return p;
+    }).then(function() {
+      ok(true, "Got seeking event");
+      var p = once(el, 'seeked');
+      el.currentTime = 6; // Seek past the gap.
+      return p;
+    }).then(function() {
+      ok(true, "Got seeked event");
+      ok(el.currentTime >= 6, "Time >= 6");
+      once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+      ms.endOfStream();
+    });
+  });
+});
+
+</script>
+</pre>
+</body>
+</html>