Bug 1401147 - part2 : add test. draft
authorAlastor Wu <alwu@mozilla.com>
Fri, 22 Sep 2017 12:01:14 +0800
changeset 668860 0c948a3346a2cbc1fa5c0f855ac2620f3f665ddf
parent 668859 f529c6617b73710eb2d22364481d1e73054b82fb
child 668965 073b2176f5bc2eb46c6783bdcc4acacca1b4ac64
push id81143
push useralwu@mozilla.com
push dateFri, 22 Sep 2017 04:02:12 +0000
bugs1401147
milestone57.0a1
Bug 1401147 - part2 : add test. MozReview-Commit-ID: 2onCtimjuz4
dom/media/mediasource/test/mochitest.ini
dom/media/mediasource/test/test_SeekWithoutValidSourceBuffer.html
--- a/dom/media/mediasource/test/mochitest.ini
+++ b/dom/media/mediasource/test/mochitest.ini
@@ -128,16 +128,18 @@ skip-if = toolkit == 'android' # Not sup
 [test_SeekedEvent_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
 [test_SeekToEnd_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
 [test_SeekToLastFrame_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
 [test_SeekTwice_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
+[test_SeekWithoutValidSourceBuffer.html]
+skip-if = toolkit == 'android' # Not supported on android
 [test_Sequence_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
 [test_SetModeThrows.html]
 [test_SplitAppendDelay.html]
 skip-if = android_version == '22' # bug 1293896 bug 1342683
 [test_SplitAppendDelay_mp4.html]
 skip-if = toolkit == 'android' # Not supported on android
 [test_SplitAppend.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/test_SeekWithoutValidSourceBuffer.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=windows-1252">
+  <title>MSE: seeking video without any valid source buffer</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">
+
+var videoURL = "seek.webm";
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("ensure seeking won't be completed.");
+
+function seek(el, time) {
+  el.currentTime = time;
+  return new Promise(async function(resolve) {
+    await once(el, "seeking");
+    ok(true, "start seeking");
+
+    let timer = setTimeout(function() {
+      ok(true, "seeking would never be completed because of lacking enough data.");
+      resolve();
+    }, 1000);
+
+    el.addEventListener("seeked", function() {
+      ok(false, "seeking should not be completed!");
+      clearTimeout(timer);
+      SimpleTest.finish();
+    }, {once: true});
+  });
+}
+
+runWithMSE(async function(ms, el) {
+  info("- wait for sourceopen -");
+  await once(ms, 'sourceopen');
+
+  info("- wait for fetching data -");
+  var arrayBuffer = await fetchWithXHR(videoURL);
+
+  info("- create source buffer and append data -");
+  var sourceBuffer = ms.addSourceBuffer("video/webm");
+  sourceBuffer.appendBuffer(arrayBuffer);
+  await once(sourceBuffer, "updateend");
+
+  info("- remove source buffer from media source -");
+  ms.removeSourceBuffer(sourceBuffer);
+  await once(ms.sourceBuffers, "removesourcebuffer");
+  is(el.buffered.length, 0,
+    "buffered range should be 0 when we don't have any source buffer");
+
+  info("- seek video to 0.0 -");
+  await seek(el, 0,0);
+  SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>