OLD | NEW |
---|---|
1 <html> | 1 <!DOCTYPE html> |
2 <body> | 2 <title>Test "timeupdate" events are posted while playing but not while paused.</ title> |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="media-file.js"></script> | |
6 <video></video> | |
7 <script> | |
8 async_test(function(t) { | |
9 var video = document.querySelector("video"); | |
10 video.src = findMediaFile("video", "content/test"); | |
11 var timeupdateEventCount = 0; | |
3 | 12 |
4 <video controls></video> | 13 video.ontimeupdate = t.step_func(function() { ++timeupdateEventCount; }); |
14 video.onplaying = t.step_func(function() { | |
15 setTimeout(function() { | |
16 // Expect one "timeupdate" event just before "pause" event. | |
17 video.pause(); | |
18 assert_greater_than(timeupdateEventCount, 0); | |
19 timeupdateEventCount = 0; | |
20 }, 500) ; | |
foolip
2016/07/07 12:33:09
This seems like the test is still slower than nece
Srirama
2016/07/07 13:17:48
Done.
| |
21 }); | |
5 | 22 |
6 <p> | 23 video.onpause = t.step_func(function() { |
7 Test 'timeupdate' events are posted while playing but not while paused. | 24 assert_equals(timeupdateEventCount, 1); |
8 </p> | 25 video.ontimeupdate = t.unreached_func(); |
9 <script src=media-file.js></script> | 26 setTimeout(t.step_func_done(), 400); |
10 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 27 }); |
11 (Please avoid writing new tests using video-test.js) --> | |
12 <script src=video-test.js></script> | |
13 <script> | |
14 setSrcByTagName("video", findMediaFile("video", "content/test")); | |
15 | 28 |
16 var timeupdateEventCount = 0; | 29 video.play(); |
17 var countWhilePlaying = 0; | 30 }); |
18 | 31 </script> |
19 function someTimeLater() | |
20 { | |
21 if (countWhilePlaying != timeupdateEventCount) | |
22 failTest("'timeupdate' events posted after pausing"); | |
23 endTest(); | |
24 } | |
25 | |
26 function pause() | |
27 { | |
28 countWhilePlaying = timeupdateEventCount; | |
29 setTimeout(someTimeLater, 400) ; | |
30 consoleWrite(""); | |
31 } | |
32 | |
33 function playing() | |
34 { | |
35 setTimeout(function () { run("video.pause()"); }, 500) ; | |
36 consoleWrite(""); | |
37 } | |
38 | |
39 mediaElement.addEventListener("timeupdate", function () { ++timeupdateEv entCount; }); | |
40 | |
41 waitForEvent('error'); | |
42 waitForEvent("loadstart"); | |
43 waitForEvent("waiting"); | |
44 waitForEvent("ratechange"); | |
45 waitForEvent("durationchange"); | |
46 waitForEvent("loadedmetadata"); | |
47 waitForEvent("loadeddata"); | |
48 waitForEvent("canplay"); | |
49 waitForEvent("pause", pause); | |
50 waitForEvent("play"); | |
51 waitForEvent("playing", playing); | |
52 | |
53 run("video.play()"); | |
54 consoleWrite(""); | |
55 </script> | |
56 | |
57 </body> | |
58 </html> | |
OLD | NEW |