Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>This tests that media element controls are reset to their default state w hen the src is changed to an invalid url.</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 <script src="media-controls.js"></script> |
| 7 <script src=video-test.js></script> | 7 <video></video> |
| 8 <script src=media-controls.js></script> | 8 <script> |
| 9 <script> | 9 async_test(function(t) { |
| 10 var video; | 10 var video = document.querySelector("video"); |
| 11 video.src = findMediaFile("video", "content/test"); | |
| 11 | 12 |
| 12 function init() | 13 video.oncanplaythrough = t.step_func(function() { |
| 13 { | 14 video.oncanplaythrough = null; |
| 14 video = document.getElementsByTagName("video")[0]; | 15 assert_equals(getTimeLineValue(), video.currentTime); |
|
Srirama
2016/06/01 20:21:22
Should we compare with 0 instead of video.currentT
foolip
2016/06/02 09:37:03
If there are other tests that verify how and when
Srirama
2016/06/02 13:29:37
Done.
| |
| 15 video.src = findMediaFile("video", "content/test"); | 16 // Seeking to time value 1.0 |
| 17 video.currentTime = 1.0; | |
| 18 }); | |
| 16 | 19 |
| 17 waitForEventOnce("canplaythrough", start); | 20 video.onseeked = t.step_func(function() { |
| 18 waitForEvent("seeked", seeked); | 21 assert_equals(getTimeLineValue(), video.currentTime); |
| 19 waitForEvent("error", error); | 22 // Change video source to an invalid one |
| 20 } | 23 video.src = "/invalid.mov"; |
| 21 | 24 |
| 22 function getTimeLineValue() | 25 }); |
| 23 { | |
| 24 return mediaControlsButton(video, "timeline").value; | |
| 25 } | |
| 26 | 26 |
| 27 function error() | 27 video.onerror = t.step_func_done(function() { |
| 28 { | 28 assert_equals(getTimeLineValue(), video.currentTime); |
| 29 try { | 29 }); |
| 30 testExpected("getTimeLineValue()", video.currentTime); | |
| 31 endTest(); | |
| 32 } catch (exception) { | |
| 33 failTest(exception.description); | |
| 34 } | |
| 35 } | |
| 36 | 30 |
| 37 function seeked() | 31 function getTimeLineValue() { |
|
foolip
2016/06/02 09:37:04
This capitalization is too weird, and it's MediaCo
Srirama
2016/06/02 13:29:37
Done.
| |
| 38 { | 32 var timeStr = mediaControlsButton(video, "timeline").value; |
| 39 try { | 33 return parseInt(timeStr); |
|
foolip
2016/06/02 09:37:03
parseInt('1.5') return 1, so it's not obvious if t
Srirama
2016/06/02 13:29:37
Done.
| |
| 40 testExpected("getTimeLineValue()", video.currentTime); | 34 } |
| 41 } catch (exception) { | 35 }); |
| 42 failTest(exception.description); | 36 </script> |
| 43 } | |
| 44 | |
| 45 // Change video source to an invalid one | |
| 46 video.src = "/invalid.mov"; | |
| 47 } | |
| 48 | |
| 49 function start() | |
| 50 { | |
| 51 if (!window.testRunner) | |
| 52 return; | |
| 53 | |
| 54 try { | |
| 55 testExpected("getTimeLineValue()", video.currentTime); | |
| 56 } catch (exception) { | |
| 57 failTest(exception.description); | |
| 58 } | |
| 59 | |
| 60 // Seeking to time value 1.0 | |
| 61 video.currentTime = 1.0; | |
| 62 } | |
| 63 </script> | |
| 64 </head> | |
| 65 <body onload="init()"> | |
| 66 <p>This tests that media element controls are reset to their default sta te when the src is changed to an invalid url.</p> | |
| 67 <p>This test only runs in DRT!</p> | |
| 68 <video controls></video> | |
| 69 <div id="console"></div> | |
| 70 </body> | |
| 71 </html> | |
| OLD | NEW |