test_seamless_looping_resume_video_decoding.html (2156B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Seamless looping test with resuming video decoding</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 <script type="text/javascript" src="manifest.js"></script> 8 <script src="background_video.js"></script> 9 </head> 10 <script type="application/javascript"> 11 12 /** 13 * This test aims to check if seamless looping can work well with the mechanism 14 * of resuming video decoding. When resuming decoding, MDSM will leave the 15 * looping state and go to video only seek state. We want to ensure that the 16 * timestamp of new video data that state requests will also be adjusted in 17 * order to keep video playback ongoing without video being frozen because 18 * frames get discarded. 19 */ 20 add_task(async function testSeamlessLoopingResumeVideoDecoding() { 21 await SpecialPowers.pushPrefEnv({ 22 set: [ 23 ["media.test.video-suspend", true], 24 ["media.suspend-background-video.enabled", true], 25 ["media.suspend-background-video.delay-ms", 0], 26 ], 27 }); 28 29 info(`create video and play it`); 30 let video = document.createElement('video'); 31 video.loop = true; 32 video.src = "gizmo.mp4"; 33 document.body.appendChild(video); 34 // speed up the test. 35 video.playbackRate = 2; 36 await video.play(); 37 38 info(`test seamless looping once`); 39 await once(video, "seeked"); 40 ok(true, `loop back happened`); 41 42 info(`suspend video decoding`); 43 video.setVisible(false); 44 await nextVideoSuspends(video); 45 info(`suspended video decoding`); 46 47 info(`resume video decoding (enter video-only seek state)`); 48 video.setVisible(true); 49 await testVideoOnlySeekCompletedWhenShown(video); 50 info(`resumed video decoding and finished video-only seeking`); 51 52 const lastPaintedFramesAmount = video.mozPaintedFrames; 53 info(`end test after looping one more time`); 54 await once(video, "seeked"); 55 56 const currentPaintedFrameAmount = video.mozPaintedFrames; 57 ok(lastPaintedFramesAmount < currentPaintedFrameAmount, 58 `painted frames keeps growing from ${lastPaintedFramesAmount} to ${currentPaintedFrameAmount}`); 59 }); 60 61 </script> 62 <body> 63 </body> 64 </html>