diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/mediasource/test/test_MediaSource_mp4.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/mediasource/test/test_MediaSource_mp4.html')
-rw-r--r-- | dom/media/mediasource/test/test_MediaSource_mp4.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/dom/media/mediasource/test/test_MediaSource_mp4.html b/dom/media/mediasource/test/test_MediaSource_mp4.html new file mode 100644 index 0000000000..2ab79f37f3 --- /dev/null +++ b/dom/media/mediasource/test/test_MediaSource_mp4.html @@ -0,0 +1,90 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>MSE: basic functionality</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, v) => { + SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail"); + SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail"); + + ok(ms instanceof EventTarget, "MediaSource must be an EventTarget"); + is(ms.readyState, "closed", "New MediaSource must be in closed state"); + + // Wrapper creation, tests for leaks. + SpecialPowers.wrap(ms); + + // Set an expando to force wrapper creation, tests for leaks. + ms.foo = null; + + ok(URL.createObjectURL(ms), "Create an objectURL from the MediaSource"); + + let loadedmetadataCount = 0; + let updatestartCount = 0; + let updateendCount = 0; + let updateCount = 0; + + await once(ms, "sourceopen"); + ok(true, "Receive a sourceopen event"); + is(ms.readyState, "open", "MediaSource must be in open state after sourceopen"); + const sb = ms.addSourceBuffer("video/mp4"); + ok(sb, "Create a SourceBuffer"); + is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length"); + is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer"); + is(ms.activeSourceBuffers.length, 0, "MediaSource.activeSourceBuffers is expected length"); + + sb.appendBuffer(new Uint8Array(await fetchWithXHR("bipbop/bipbop2s.mp4"))); + is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer"); + + sb.addEventListener("update", () => { + is(sb.updating, false, "SourceBuffer.updating is expected value in update event"); + updateCount++; + /* Ensure that we endOfStream on the first update event only as endOfStream can + raise more if the duration of the last buffered range and the intial duration + differ. See bug 1065207 */ + if (updateCount == 1) { + ms.endOfStream(); + } + }); + + sb.addEventListener("updatestart", () => updatestartCount++); + + sb.addEventListener("updateend", () => { + is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer"); + is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event"); + updateendCount++; + v.play(); + }); + + ms.addEventListener("sourceended", () => { + ok(true, "Receive a sourceended event"); + is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended"); + }); + + v.addEventListener("loadedmetadata", () => loadedmetadataCount++); + + await once(v, "ended"); + // The bipbop video doesn't start at 0. The old MSE code adjust the + // timestamps and ignore the audio track. The new one doesn't. + isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration"); + isfuzzy(v.currentTime, 1.696, 0.166, "Video has correct duration"); + // XXX: 2 update events can be received dueto duration differences, see bug 1065207. + ok(updateCount == 1 || updateCount == 2, "update event received"); + ok(updateendCount == 1 || updateendCount == 2, "updateend event received"); + ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received"); + is(loadedmetadataCount, 1, "loadedmetadata event received"); + SimpleTest.finish(); +}); + +</script> +</pre> +</body> +</html> |