OLD | NEW |
---|---|
1 <!DOCTYPE HTML> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test "abort" event.</title> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <title>'abort' event test</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <script src=../../media-resources/media-file.js></script> | 5 <script src="../../media-resources/media-file.js"></script> |
6 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 6 <video></video> |
7 (Please avoid writing new tests using video-test.js) --> | 7 <script> |
8 <script src=../../media-resources/video-test.js></script> | 8 async_test(function(t) { |
fs
2016/07/22 14:59:46
This looks like a test that might even be simpler
Srirama
2016/07/22 17:37:30
Done.
| |
9 <script> | 9 var didLoad = false; |
10 var didLoad = false; | 10 var video = document.querySelector("video"); |
11 | 11 |
12 function loadstart() | 12 video.onerror = t.unreached_func(); |
13 { | 13 // Test before movie is open. |
14 consoleWrite("<br><b><em>'loadstart'</em> event</b>"); | 14 assert_equals(video.error, null); |
15 testExpected("video.error", null); | 15 var movie = findMediaFile("video", "../resources/test"); |
16 video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?name=" + m ovie + "&throttle=256"; | |
16 | 17 |
17 if (didLoad) | 18 video.onloadstart = t.step_func(function() { |
18 return; | 19 assert_equals(video.error, null); |
19 didLoad = true; | |
20 | 20 |
21 // Force the element to reload, while the current movie is still loading, | 21 if (didLoad) |
22 // this should generate an 'abort' event | 22 return; |
23 run("video.load()"); | 23 didLoad = true; |
24 } | |
25 | 24 |
26 function abort() | 25 // Force the element to reload, while the current movie is still loading , |
27 { | 26 // this should generate an "abort" event. |
28 consoleWrite("<br><b><em>'abort'</em> event</b>"); | 27 video.load(); |
29 testExpected("video.error", null); | 28 }); |
30 | 29 |
31 // Progress events have a 'lengthComputable' field, check to mak e sure this event | 30 video.onabort = t.step_func(function() { |
32 // doesn't have one. | 31 assert_equals(video.error, null); |
33 testExpected("event.lengthComputable", undefined); | 32 }); |
34 } | |
35 | 33 |
36 function canplaythrough() | 34 video.oncanplaythrough = t.step_func_done(function() { |
37 { | 35 assert_equals(video.error, null); |
38 consoleWrite("<br><b><em>'canplaythrough'</em> event</b>"); | 36 }); |
39 testExpected("video.error", null); | 37 }); |
40 | 38 </script> |
41 consoleWrite(""); | |
42 endTest(); | |
43 } | |
44 | |
45 function start() | |
46 { | |
47 findMediaElement(); | |
48 | |
49 waitForEvent("error"); | |
50 | |
51 consoleWrite("<br><b>Test before movie is open</b>"); | |
52 testExpected("video.error", null); | |
53 | |
54 var movie = findMediaFile("video", "../resources/test"); | |
55 video.src = "http://127.0.0.1:8000/media/video-throttled-load.cg i?name=" + movie + "&throttle=256"; | |
56 } | |
57 </script> | |
58 </head> | |
59 | |
60 <body onload="start()"> | |
61 <video controls | |
62 onloadstart="loadstart()" | |
63 onabort="abort()" | |
64 oncanplaythrough="canplaythrough()" | |
65 ></video> | |
66 </body> | |
67 </html> | |
OLD | NEW |