Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<meta charset="utf-8">
<title>Test cloneElementVisually</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src=""></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
<div id="content">
<video id="original"></video>
<video id="streamTarget"></video>
<div id="results">
<canvas id="left"></canvas>
<canvas id="right"></canvas>
<script type="application/javascript">
/* import-globals-from cloneElementVisually_helpers.js */
* Tests that cloning a video prevents the decoder from being suspended
* if the original video stops being visible.
add_task(async () => {
await setup();
let originalVideo = document.getElementById("original");
await setVideoSrc(originalVideo, LONG_VIDEO);
// Ensure that hiding and pausing this video will cause us to
// try suspending it.
await ensureVideoSuspendable(originalVideo);
await withNewClone(originalVideo, async clone => {
// Go back to the beginning of the video to give us enough time to
// fail to suspend the video when it's being cloned before the
// video ends.
originalVideo.currentTime = 0;
await waitForEventOnce(originalVideo, "seeked");
let suspendTimerFired = false;
let listener = () => {
suspendTimerFired = true;
originalVideo.addEventListener("mozstartvideosuspendtimer", listener);
// Have to do this to access normally-preffed off binding methods for some
// reason.
// See bug 1544257.
await waitForEventOnce(originalVideo, "ended");
originalVideo.removeEventListener("mozstartvideosuspendtimer", listener);
"mozstartvideosuspendtimer should not have fired.");
// Have to do this to access normally-preffed off binding methods for some
// reason.
// See bug 1544257.
// With the clone gone, the original video should be able to suspend now.
await ensureVideoSuspendable(originalVideo);
await setVideoSrc(originalVideo, TEST_VIDEO_1);