2010-06-09 Tony Gentilcore <tonyg@chromium.org>
[WebKit-https.git] / LayoutTests / media / video-timeupdate-during-playback.html
1 <html>
2 <body>
3     
4     <video controls></video>
5
6     <p>
7     Test 'timeupdate' events are posted while playing but not while paused.
8     </p>
9     <script src=media-file.js></script>
10     <script src=video-test.js></script>
11     <script>
12         setSrcByTagName("video", findMediaFile("video", "content/test"));
13     
14         var timeupdateEventCount = 0;
15         var countWhilePlaying = 0;
16
17         function someTimeLater()
18         {
19             if (countWhilePlaying != timeupdateEventCount)
20                 failTest("'timeupdate' events posted after pausing");
21             endTest();
22         }
23
24         function pause()
25         {
26             countWhilePlaying = timeupdateEventCount;
27             setTimeout(someTimeLater, 400) ;
28             consoleWrite("");
29         }
30         
31         function playing()
32         {
33             setTimeout(function () { run("video.pause()"); }, 500) ;
34             consoleWrite("");
35         }
36
37         mediaElement.addEventListener("timeupdate", function () { ++timeupdateEventCount; });
38
39         waitForEvent('error');
40         waitForEvent("loadstart");
41         waitForEvent("waiting");
42         waitForEvent("ratechange");
43         waitForEvent("durationchange");
44         waitForEvent("loadedmetadata");
45         waitForEvent("loadeddata");
46         waitForEvent("canplay");
47         waitForEvent("canplaythrough");
48         waitForEvent("pause", pause);
49         waitForEvent("play");
50         waitForEvent("playing", playing);
51
52         run("video.play()");
53         consoleWrite("");
54     </script>
55
56 </body>
57 </html>