loop-from-ended.tentative.html (2516B)
1 <!DOCTYPE html> 2 <title>play() with loop set to true after playback ended</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/media.js"></script> 6 <video></video> 7 <script> 8 // Seek towards end of video (for faster testing). 9 // Play video to end with "loop" set to false. 10 // Once ended, set "loop" to true. Call play. 11 // Verify that "seeked" event fires, seeking back to the beginning. 12 // Pause video and end test. 13 // Chromium bug: https://crbug.com/364442 14 // Spec issue: https://github.com/whatwg/html/issues/4487 15 async_test(function(t) { 16 var video = document.querySelector("video"); 17 18 video.onloadedmetadata = t.step_func(function() { 19 // Video is initially paused and "loop" unset. 20 assert_true(video.paused, "paused initially "); 21 assert_false(video.loop, "loop initially"); 22 // Seek to just before the end of the video and play. 23 video.currentTime = video.duration - 0.5; 24 video.onended = t.step_func(function() { 25 // Verify played to end and stopped. 26 assert_true(video.ended, "ended at ended event"); 27 assert_true(video.paused, "paused at ended event"); 28 assert_equals(video.currentTime, video.duration, "currentTime at ended event"); 29 30 // With playback ended, set "loop" attribute. This will cause ended == false. 31 // looping video cannot be "ended", only paused. 32 assert_false(video.loop, "loop at ended event"); 33 video.loop = true; 34 assert_true(video.loop, "loop after seek"); 35 assert_false(video.ended, "ended after seek"); 36 assert_true(video.paused, "paused after seek"); 37 38 video.onseeked = t.step_func_done(function() { 39 // Observed seek. Verify current time decreased and still playing. 40 assert_true(video.loop, "loop at seeked event") 41 assert_false(video.paused, "paused at seeked event"); 42 assert_false(video.ended, "ended at seeked event"); 43 assert_less_than(video.currentTime, video.duration, "currentTime at seeked event"); 44 // Pausing now that test is over to prevent additional unwanted looping. 45 video.pause(); 46 }); 47 48 // Play video with "loop" set. Expect seek back to start. 49 video.play(); 50 }); 51 52 video.play(); 53 }); 54 55 video.src = getVideoURI("/media/movie_5"); 56 }); 57 </script>