test_background_video_suspend_ends.html (1564B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Test Background Suspended Video Fires 'ended' Event</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"> 9 "use strict"; 10 11 PARALLEL_TESTS = 1; 12 13 var manager = new MediaTestManager; 14 15 async function runTest(test, token) { 16 let video = appendVideoToDoc(test.name, token); 17 manager.started(token); 18 19 // This test checks that 'ended' event is received for videos with 20 // suspended video decoding. This is important for looping video logic 21 // handling in HTMLMediaElement. 22 23 let ended = nextVideoEnded(video); 24 let suspends = nextVideoSuspends(video); 25 26 Log(token, "Start playing"); 27 video.play(); 28 29 Log(token, "Set hidden"); 30 video.setVisible(false); 31 32 Log(token, "Waiting for video suspend"); 33 await suspends; 34 35 Log(token, "Waiting for ended"); 36 await ended; 37 38 ok(video.currentTime >= video.duration, 'current time approximates duration.'); 39 40 manager.finished(token); 41 } 42 43 startTest({ 44 desc: "Test Background Suspended Video Fires 'ended' Event", 45 prefs: [ 46 ["media.test.video-suspend", true], 47 ["media.suspend-background-video.enabled", true], 48 // User a short delay to ensure video decode suspend happens before end 49 // of video. 50 ["media.suspend-background-video.delay-ms", 1000] 51 ], 52 tests: gDecodeSuspendTests, 53 runTest 54 }); 55 </script>