2009-09-18 Alpha Lam <hclam@chromium.org>
[WebKit-https.git] / LayoutTests / media / video-seeking.html
1 <video controls></video>
2 <p>Test that seeking attribute is true immediately after a seek,
3  goes back to false when seeking completes, and that a 'seeked' event
4  is fired for each seek
5  </p>
6 <script src=media-file.js></script>
7 <script src=video-test.js></script>
8 <script>
9
10     var seekedCount = 0;
11     var counter;
12
13     function seeked()
14     { 
15         ++seekedCount; 
16         consoleWrite("");
17     }
18
19     function someTimeLater()
20     {
21         testExpected("seekedCount", counter);
22         testExpected("video.seeking", false);
23         testExpected("video.currentTime", counter * 0.5);
24         run("video.currentTime = " + (counter + 1) * 0.5);
25         testExpected("video.seeking", true);
26
27         if (counter == 3)
28         {
29             consoleWrite("");
30             endTest();
31         }
32
33         ++counter;
34         consoleWrite("");
35      }
36
37     function loaded() 
38     {
39         run("video.currentTime = 0.5");
40         counter = 1;
41         setTimeout(someTimeLater, 200) 
42         setTimeout(someTimeLater, 400) 
43         setTimeout(someTimeLater, 600) 
44         consoleWrite("");
45     }
46     
47     waitForEvent('waiting' );
48     waitForEvent('seeked', seeked );
49     waitForEvent('load', loaded);
50
51     video.src = findMediaFile("video", "content/test");
52 </script>