[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / video-fast-seek.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src=media-file.js></script>
5     <script src=video-test.js></script>
6     <script>
7
8         // The test.mp4 file has sync samples at the following presentation time stamps:
9         // 0.0000, 0.7968, 1.5936, 2.3904, 3.1872, 3.9840, 4.7808, 5.5776
10
11         function runTest()
12         {
13             findMediaElement();
14             waitForEvent('canplaythrough', canplaythrough);
15
16             // Other media files may have sync samples at completely different points, so
17             // explicitly use the .mp4 here.
18             video.src = "content/test.mp4";
19         }
20
21         function canplaythrough()
22         {
23             waitForEventOnce('timeupdate', seek1);
24             consoleWrite('Seek past the 4th sync sample:');
25             run('video.currentTime = 2.5');
26         }
27
28         function seek1()
29         {
30             testExpected('video.currentTime.toFixed(1)', 2.5);
31             consoleWrite('Test that fastSeek() past the currentTime will not result in a seek before the currentTime or past the seek time:');
32             waitForEventOnce('timeupdate', seek2);
33             run('video.fastSeek(2.6)');
34         }
35
36         function seek2()
37         {
38             testExpected('video.currentTime', 2.6, '<=');
39             testExpected('video.currentTime', 2.5, '>=');
40             consoleWrite('Seek before the 4th sync sample:');
41             waitForEventOnce('timeupdate', seek3);
42             run('video.currentTime = 2.3');
43         }
44
45         function seek3()
46         {
47             testExpected('video.currentTime.toFixed(1)', 2.3);
48             consoleWrite('Test that fastSeek() before the currentTime will not result in a seek past the seek time:');
49             waitForEventOnce('timeupdate', seek4);
50             run('video.fastSeek(2.2)');
51         }
52
53         function seek4()
54         {
55             testExpected('video.currentTime', 2.2, '<=');
56             endTest();
57         }
58
59     </script>
60 </head>
61 <body onload="runTest()">
62     <video controls></video>
63     <p>Test that fastSeek() commands work correctly.</p>
64 </body>
65 </html>