3 <title>Test Background Video Suspend Cancels (Visibility)
</title>
4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <script src=
"manifest.js"></script>
6 <script src=
"background_video.js"></script>
7 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css"/>
8 <script type=
"text/javascript">
11 var manager
= new MediaTestManager
;
14 * Check that making the element visible before suspend timer delay causes the
15 * the suspend timer to be canceled.
16 * @param {HTMLMediaElement} video Video element under test.
17 * @returns {Promise} Promise that is resolved when video decode resumes.
19 function testSuspendTimerCanceledWhenShown(video
) {
21 video
.removeEventListener("mozcancelvideosuspendtimer", canceled
);
22 ok(false, `${video.token} ended before suspend cancels`);
27 video
.removeEventListener("ended", ended
);
28 ok(true, `${video.token} suspend cancels`);
29 this.canceled_resolve();
32 let p
= Promise
.race([
33 new Promise((resolve
) => {
34 video
.ended_resolve
= resolve
;
35 video
.addEventListener('ended', ended
, { 'once': true });
37 new Promise((resolve
) => {
38 video
.canceled_resolve
= resolve
;
39 video
.addEventListener('mozcancelvideosuspendtimer', canceled
, { 'once': true });
43 Log(video
.token
, "Set visible");
44 video
.setVisible(true);
50 desc
: 'Test Background Video Suspend Cancels (Visibility)',
52 [ "media.test.video-suspend", true ],
53 [ "media.suspend-background-video.enabled", true ],
54 [ "media.suspend-background-video.delay-ms", 10000 ]
56 tests
: gDecodeSuspendTests
,
57 runTest
: (test
, token
) => {
58 let v
= appendVideoToDoc(test
.name
, token
);
59 manager
.started(token
);
62 .then(() => testSuspendTimerStartedWhenHidden(v
))
63 .then(() => testSuspendTimerCanceledWhenShown(v
))
65 ok(true, `${v.token} finished`);
66 manager
.finished(token
);