| OLD | NEW |
| 1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
| 2 <html> | 2 <title>Test seeking by very small increments.</title> |
| 3 <head> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src=media-file.js></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <script src="media-file.js"></script> |
| 6 (Please avoid writing new tests using video-test.js) --> | 6 <video></video> |
| 7 <script src=video-test.js></script> | 7 <script> |
| 8 async_test(function(t) { |
| 9 var seekedEventCount = 0; |
| 10 var increment = 0; |
| 11 var video = document.querySelector("video"); |
| 8 | 12 |
| 9 <script> | 13 video.currentTime = seekIncrement(); |
| 10 var seekedEventCount = 0; | |
| 11 var increment = 0; | |
| 12 | 14 |
| 13 function seekIncrement() | 15 video.onseeked = t.step_func(function() { |
| 14 { | 16 if (++seekedEventCount == 8) { |
| 15 // We want to verify that seeking by an increment smaller than t
he test movie's time scale | 17 t.done(); |
| 16 // (the smallest unit of time in that file) succeeds. test.mp4 h
as a time scale of 2500, | 18 return; |
| 17 // 0.0004 seconds, so start with that and decrease by half each
time. | 19 } |
| 18 if (!increment) | 20 video.currentTime += seekIncrement(); |
| 19 increment = 0.0004; | 21 }); |
| 20 else | |
| 21 increment /= 2; | |
| 22 return increment; | |
| 23 } | |
| 24 | 22 |
| 25 function seeked() | 23 function seekIncrement() { |
| 26 { | 24 // We want to verify that seeking by an increment smaller than the test
movie's |
| 27 if (++seekedEventCount == 8) { | 25 // time scale(the smallest unit of time in that file) succeeds. test.mp4
has a time // scale of 2500, 0.0004 seconds, so start with that and decrease by
half each time. |
| 28 consoleWrite(""); | 26 if (!increment) |
| 29 endTest(); | 27 increment = 0.0004; |
| 30 return; | 28 else |
| 31 } | 29 increment /= 2; |
| 32 attemptSeek(); | 30 return increment; |
| 33 } | 31 } |
| 34 | 32 |
| 35 function attemptSeek() | 33 video.onseeking = t.step_func(function() {}); |
| 36 { | 34 video.onplay = t.step_func(function() {}); |
| 37 var increment = seekIncrement(); | 35 video.onpause = t.step_func(function() {}); |
| 38 consoleWrite("<br>** Seeking by " + increment); | |
| 39 video.currentTime += increment; | |
| 40 } | |
| 41 | 36 |
| 42 function start() | 37 video.src = findMediaFile("video", "content/test"); |
| 43 { | 38 }); |
| 44 findMediaElement(); | 39 </script> |
| 45 video.src = findMediaFile("video", "content/test"); | |
| 46 | |
| 47 waitForEventOnce('canplaythrough', attemptSeek); | |
| 48 waitForEvent('seeked', seeked); | |
| 49 waitForEvent('seeking'); | |
| 50 waitForEvent('play'); | |
| 51 waitForEvent('pause'); | |
| 52 } | |
| 53 </script> | |
| 54 </head> | |
| 55 <body> | |
| 56 <video controls></video> | |
| 57 <p>Test seeking by very small increments.</p> | |
| 58 <script>start()</script> | |
| 59 </body> | |
| 60 </html> | |
| OLD | NEW |