| <!DOCTYPE html> |
| <title>Test looping edge case to verify http://crbug.com/364442.</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <video></video> |
| <script> |
| // Seek towards end of video (for faster testing). |
| // Play video to end with "loop" set to false. |
| // Once ended, set "loop" to true. Call play. |
| // Verify that "seeked" event fires, seeking back to the beginning. |
| // Pause video and end test. |
| async_test(function(t) { |
| var video = document.querySelector("video"); |
| |
| video.onloadedmetadata = t.step_func(function() { |
| // Video is initially paused and "loop" unset. |
| assert_true(video.paused); |
| assert_false(video.loop); |
| // Seek to just before the end of the video and play. |
| video.currentTime = video.duration - 0.5; |
| video.onended = t.step_func(function() { |
| // Verify played to end and stopped. |
| assert_true(video.ended); |
| assert_true(video.paused); |
| assert_equals(video.currentTime, video.duration); |
| |
| // With playback ended, set "loop" attribute. This will cause ended == false. |
| // looping video cannot be "ended", only paused. |
| assert_false(video.loop); |
| video.loop = true; |
| assert_true(video.loop); |
| assert_false(video.ended); |
| assert_true(video.paused); |
| |
| video.onseeked = t.step_func_done(function() { |
| // Observed seek. Verify current time decreased and still playing. |
| assert_true(video.loop) |
| assert_false(video.paused); |
| assert_false(video.ended); |
| assert_less_than(video.currentTime, video.duration); |
| // Pausing now that test is over to prevent additional unwanted looping. |
| video.pause(); |
| }); |
| |
| // Play video with "loop" set. Expect seek back to start. |
| video.play(); |
| }); |
| |
| video.play(); |
| }); |
| |
| video.src = "content/test.ogv"; |
| }); |
| </script> |