OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <body> | 2 <title>Test that seeking video with "loop" past it's end rewinds to the beginnin
g and continues playback.</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="media-file.js"></script> |
| 6 <video loop></video> |
| 7 <script> |
| 8 async_test(function(t) { |
| 9 var timeupdateEventCount = 0; |
| 10 var video = document.querySelector("video"); |
3 | 11 |
4 <video loop controls></video> | 12 video.oncanplaythrough = t.step_func(function () { |
5 <p>Test that seeking video with 'loop' past it's end rewinds to the beginning an
d continues playback.</p> | 13 video.oncanplaythrough = null; |
6 <script src=media-file.js></script> | 14 assert_true(video.paused); |
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 15 video.play(); |
8 (Please avoid writing new tests using video-test.js) --> | 16 assert_false(video.paused); |
9 <script src=video-test.js></script> | |
10 <script> | |
11 var timeupdateEventCount = 0; | |
12 | |
13 waitForEventOnce('canplaythrough', function () { | |
14 testExpected("video.paused", true); | |
15 run("video.play()"); | |
16 testExpected("video.paused", false); | |
17 }); | 17 }); |
18 | 18 |
19 function timeupdate() | 19 video.ontimeupdate = t.step_func(function() { |
20 { | |
21 ++timeupdateEventCount; | 20 ++timeupdateEventCount; |
22 | 21 |
23 // wait 2 timeupdate events so we are sure the media engine is | 22 // wait 2 timeupdate events so we are sure the media engine is |
24 // playing the media. | 23 // playing the media. |
25 if (timeupdateEventCount == 2) { | 24 if (timeupdateEventCount == 2) { |
26 consoleWrite(""); | 25 assert_false(video.paused); |
27 testExpected("video.paused", false); | |
28 // make sure time is advancing and seek past end | 26 // make sure time is advancing and seek past end |
29 testExpected("mediaElement.currentTime", 0, '>'); | 27 assert_greater_than(video.currentTime, 0); |
30 run("video.currentTime = 500"); | 28 video.currentTime = 500; |
31 } else if (timeupdateEventCount == 10) { | 29 } else if (timeupdateEventCount == 10) { |
32 // Wait some more timeupdate events so we can check the | 30 // Wait some more timeupdate events so we can check the |
33 // media engine performed the seek. | 31 // media engine performed the seek. |
34 consoleWrite(""); | 32 assert_false(video.paused); |
35 testExpected("video.paused", false); | 33 assert_greater_than(video.currentTime, 0); |
36 testExpected("mediaElement.currentTime", 0, '>'); | 34 t.done(); |
37 consoleWrite(""); | |
38 // reset the counter to prevent infinite loop if the | |
39 // test is re-executed manually. | |
40 timeupdateEventCount = 0; | |
41 endTest(); | |
42 } | 35 } |
43 } | 36 }); |
44 | 37 |
45 mediaElement.addEventListener("timeupdate", timeupdate); | 38 video.src = findMediaFile("video", "content/test"); |
46 var mediaFile = findMediaFile("video", "content/test"); | 39 }); |
47 disableFullTestDetailsPrinting(); | 40 </script> |
48 runSilently("video.src = '" + mediaFile + "'"); | |
49 enableFullTestDetailsPrinting(); | |
50 </script> | |
51 </body> | |
52 </html> | |
OLD | NEW |