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/test/test_bug1512958.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/test/test_bug1512958.html')
-rw-r--r-- | dom/media/test/test_bug1512958.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/dom/media/test/test_bug1512958.html b/dom/media/test/test_bug1512958.html new file mode 100644 index 0000000000..2513515542 --- /dev/null +++ b/dom/media/test/test_bug1512958.html @@ -0,0 +1,74 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test that pausing and resuming a captured media element with audio doesn't stall</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + <script type="text/javascript" src="manifest.js"></script> +</head> +<body> +<audio id="a"></audio> +<pre id="test"> +<script class="testbody" type="text/javascript"> +function dumpEvent({target, type}) { + info(`${target.name} GOT EVENT ${type} currentTime=${target.currentTime} ` + + `paused=${target.paused} ended=${target.ended} ` + + `readyState=${target.readyState}`); +} + +function wait(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +const a = document.getElementById('a'); + +const events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"]; +for (let ev of events) { + a.addEventListener(ev, dumpEvent); +} + +(async () => { + try { + SimpleTest.waitForExplicitFinish(); + SimpleTest.requestFlakyTimeout("Timeouts for shortcutting test-timeout"); + + const test = getPlayableAudio(gTrackTests.filter(t => t.duration > 2)); + if (!test) { + todo(false, "No playable audio"); + return; + } + + // Start playing and capture + a.src = test.name; + a.name = test.name; + const ac = new AudioContext(); + ac.createMediaElementSource(a); + a.play(); + do { + await new Promise(r => a.ontimeupdate = r); + } while(a.currentTime == 0) + + // Pause to trigger recreating tracks in DecodedStream + a.pause(); + await new Promise(r => a.onpause = r); + + // Resuming should now work. Bug 1512958 would cause a stall because the + // original track wasn't ended and we'd block on it. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1512958#c5 + a.play(); + await new Promise(r => a.onplaying = r); + a.currentTime = test.duration - 1; + await Promise.race([ + new Promise(res => a.onended = res), + wait(30000).then(() => Promise.reject(new Error("Timeout"))), + ]); + } catch(e) { + ok(false, e); + } finally { + SimpleTest.finish(); + } +})(); +</script> +</pre> +</body> +</html> |