summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_Threshold_mp4.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/mediasource/test/test_Threshold_mp4.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/mediasource/test/test_Threshold_mp4.html')
-rw-r--r--dom/media/mediasource/test/test_Threshold_mp4.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_Threshold_mp4.html b/dom/media/mediasource/test/test_Threshold_mp4.html
new file mode 100644
index 0000000000..c46883c93d
--- /dev/null
+++ b/dom/media/mediasource/test/test_Threshold_mp4.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>MSE: data gap detection</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) => {
+ const threshold = 0.5; // gap threshold in seconds.
+ const fuzz = 0.000001; // fuzz when comparing double.
+
+ await once(ms, "sourceopen");
+ ok(true, "Receive a sourceopen event");
+ const videosb = ms.addSourceBuffer("video/mp4");
+ const vchunks = [{start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666}];
+
+ await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
+ await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
+ // We will insert a gap of threshold
+ videosb.timestampOffset = threshold;
+ await fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
+ // 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;
+ await once(el, "waiting");
+ // We're waiting for data after the start of the last frame.
+ // 0.033333 is the duration of the last frame.
+ ok((el.currentTime >= vchunks[1].end - 0.033333 + threshold - fuzz &&
+ el.currentTime <= vchunks[1].end + threshold + fuzz),
+ `skipped the gap properly: ${el.currentTime} ${vchunks[1].end + threshold}`);
+ is(el.buffered.length, 2, "buffered range has right length");
+ // Now we test that seeking will succeed despite the gap.
+ el.currentTime = el.buffered.end(0) + (threshold / 2);
+ await once(el, "seeked");
+ // Now we test that we don't pass the gap.
+ // Clean up our sourcebuffer by removing all data.
+ videosb.timestampOffset = 0;
+ videosb.remove(0, Infinity);
+ el.currentTime = 0;
+ el.pause();
+ await once(videosb, "updateend");
+ await fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
+ // We will insert a gap of threshold + 1ms
+ videosb.timestampOffset = threshold + 1 / 1000;
+ await fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
+ info("Invoking play()");
+ p = once(el, "playing");
+ el.play();
+ await p;
+ await once(el, "waiting");
+ // We're waiting for data after the start of the last frame.
+ // 0.033333 is the duration of the last frame.
+ ok((el.currentTime >= vchunks[0].end - 0.033333 - fuzz &&
+ el.currentTime <= vchunks[0].end + fuzz),
+ `stopped at the gap properly: ${el.currentTime} ${vchunks[0].end}`);
+ SimpleTest.finish();
+});
+
+</script>
+</pre>
+</body>
+</html>