Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Errors

<title>Seamless looping test with resuming video decoding</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>
<script src="background_video.js"></script>
<script type="application/javascript">
* This test aims to check if seamless looping can work well with the mechanism
* of resuming video decoding. When resuming decoding, MDSM will leave the
* looping state and go to video only seek state. We want to ensure that the
* timestamp of new video data that state requests will also be adjusted in
* order to keep video playback ongoing without video being frozen because
* frames get discarded.
add_task(async function testSeamlessLoopingResumeVideoDecoding() {
await SpecialPowers.pushPrefEnv({
set: [
["", true],
["media.suspend-background-video.enabled", true],
["media.suspend-background-video.delay-ms", 0],
info(`create video and play it`);
let video = document.createElement('video');
video.loop = true;
video.src = "gizmo.mp4";
// speed up the test.
video.playbackRate = 2;
info(`test seamless looping once`);
await once(video, "seeked");
ok(true, `loop back happened`);
info(`suspend video decoding`);
await nextVideoSuspends(video);
info(`suspended video decoding`);
info(`resume video decoding (enter video-only seek state)`);
await testVideoOnlySeekCompletedWhenShown(video);
info(`resumed video decoding and finished video-only seeking`);
const lastPaintedFramesAmount = video.mozPaintedFrames;
info(`end test after looping one more time`);
await once(video, "seeked");
const currentPaintedFrameAmount = video.mozPaintedFrames;
ok(lastPaintedFramesAmount < currentPaintedFrameAmount,
`painted frames keeps growing from ${lastPaintedFramesAmount} to ${currentPaintedFrameAmount}`);