Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-double-seek-currentTime.html
blob028352db94b4b8fcfd2404135340de0f07daebf3
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
6 <script>
7 var seekCount = 0;
8 var expectedSeek = 0;
9 var video;
11 function seeking(e)
13 consoleWrite("seeking " + e.target.currentTime.toFixed(2));
15 doNextSeek(e.target);
18 function seeked(e)
20 consoleWrite("seeked " + e.target.currentTime.toFixed(2));
22 video = e.target;
23 var now = e.target.currentTime.toFixed(2);
24 var expected = expectedSeek.toFixed(2);
25 if (now != expected) {
26 failTest("Expected " + expectedSeek + " got " + now);
27 return;
29 endTest();
32 function doNextSeek(video)
34 consoleWrite("doNextSeek() " + seekCount);
36 var newSeekPoint = -1;
37 switch (seekCount) {
38 case 0:
39 newSeekPoint = 1;
40 break;
41 case 1:
42 newSeekPoint = 1.5;
43 break;
44 case 2:
45 newSeekPoint = 1.5;
46 break;
49 if (newSeekPoint >= 0) {
50 consoleWrite('doNextSeek() seeking to ' + newSeekPoint.toFixed(2));
51 expectedSeek = newSeekPoint;
52 video.currentTime = newSeekPoint;
54 seekCount++;
57 function loadedmetadata(e)
59 consoleWrite("loadedmetadata()");
60 doNextSeek(e.target);
63 function onWindowLoad(e)
65 video = document.getElementById('video');
67 video.src = findMediaFile("video", "content/test");
68 video.addEventListener('seeking', seeking);
69 video.addEventListener('seeked', seeked);
70 video.addEventListener('loadedmetadata', loadedmetadata);
71 video.load();
74 window.addEventListener('load', onWindowLoad, false);
75 </script>
76 </head>
77 <body>
78 <video controls id="video"></video>
79 <p>Test currentTime values when setting from seeking event.</p>
80 <br/>
81 </body>
82 </html>