summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_WaitingOnMissingData.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/mediasource/test/test_WaitingOnMissingData.html')
-rw-r--r--dom/media/mediasource/test/test_WaitingOnMissingData.html60
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_WaitingOnMissingData.html b/dom/media/mediasource/test/test_WaitingOnMissingData.html
new file mode 100644
index 0000000000..b1ad41bb37
--- /dev/null
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=windows-1252">
+ <title>MSE: |waiting| event when source data is missing</title>
+ <script 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(async (ms, el) => {
+ await once(ms, "sourceopen");
+ ok(true, "Receive a sourceopen event");
+ const sb = ms.addSourceBuffer("video/webm");
+ sb.addEventListener("error", e => {
+ ok(false, "Got Error: " + e);
+ SimpleTest.finish();
+ });
+ const arrayBuffer = await fetchWithXHR("seek.webm");
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 0, 318));
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 318, 25223 - 318));
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 25223, 46712 - 25223));
+ /* Note - Missing |46712, 67833 - 46712| segment here */
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 88966));
+ // HTMLMediaElement fires "waiting" if somebody invokes |play()| before the MDSM
+ // has notified it of available data. Make sure that we get "playing" before
+ // we starting waiting for "waiting".
+ info("Invoking play()");
+ let p = once(el, "playing");
+ el.play();
+ await p;
+ ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
+ p = once(el, "waiting");
+ el.play();
+ await p;
+ // currentTime is based on the current video frame, so if the audio ends just before
+ // the next video frame, currentTime can be up to 1 frame's worth earlier than
+ // min(audioEnd, videoEnd).
+ // 0.0465 is the length of the last audio frame.
+ ok(el.currentTime >= (sb.buffered.end(0) - 0.0465),
+ `Got a waiting event at ${el.currentTime}`);
+ info("Loading more data");
+ p = once(el, "ended");
+ await loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
+ ms.endOfStream();
+ await p;
+ // These fuzz factors are bigger than they should be. We should investigate
+ // and fix them in bug 1137574.
+ isfuzzy(el.duration, 4.001, 0.1, "Video has correct duration: " + el.duration);
+ isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
+ SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>