mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
0d460e3432
This is split from the previous changeset since if we include dom/ the file size is too large for phabricator to handle. This is an autogenerated commit to handle scripts loading mochitest harness files, in the simple case where the script src is on the same line as the tag. This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170 using the `--part 2` argument. Differential Revision: https://phabricator.services.mozilla.com/D27457 --HG-- extra : moz-landing-system : lando
75 lines
2.1 KiB
HTML
75 lines
2.1 KiB
HTML
<!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();
|
|
const src = 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>
|