blob: 53b380ce15e778a85f38e7f6d8096e1c0d2c2406 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<!DOCTYPE HTML>
<html>
<head>
<title>Resume suspended looping video which doesn't contain audio track</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="manifest.js"></script>
<script src="background_video.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script class="testbody" type="text/javascript">
/**
* This test is used to ensure that the looping video (without audio track) which
* has been suspended can continute to playback correctly after we resume video
* decoding.
*/
async function startTest() {
const video = await createVisibleVideo();
await startVideo(video);
await suspendVideoDecoding(video);
await resumeVideoDecoding(video);
await checkIfVideoIsStillPlaying(video);
endTestAndClearVideo(video);
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({ 'set': [
["media.test.video-suspend", true],
["media.suspend-bkgnd-video.enabled", true],
["media.suspend-bkgnd-video.delay-ms", 0],
]}, () => {
startTest();
});
/**
* The following are test helper functions.
*/
async function createVisibleVideo() {
let video = document.createElement("video");
video.src = "gizmo-noaudio.webm";
video.controls = true;
video.loop = true;
document.body.appendChild(video);
info(`ensure video becomes visible`);
await waitUntilVisible(video);
return video;
}
async function startVideo(video) {
info(`start playing video`);
const played = video && await video.play().then(() => true, () => false);
ok(played, "video has started playing");
}
async function suspendVideoDecoding(video) {
info(`suspend video decoding`);
video.setVisible(false);
await nextVideoSuspends(video);
info(`suspended video decoding`);
}
async function resumeVideoDecoding(video) {
info(`resume video decoding.`);
video.setVisible(true);
await nextVideoResumes(video);
info(`resumed video decoding`);
}
async function checkIfVideoIsStillPlaying(video) {
await once(video, "timeupdate");
ok(!video.paused, "video is still playing after resuming video decoding.")
}
function endTestAndClearVideo(video) {
removeNodeAndSource(video);
SimpleTest.finish();
}
</script>
</body>
</html>
|