OLD | NEW |
1 <html lang="en"> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test that "error" event is fired from "source" element when it can not be
used.</title> |
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | 3 <script src="../resources/testharness.js"></script> |
4 <title><video> and <source> error test</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <video> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <source id="missing-src" type="video/blahblah"></source> |
7 <script src=video-test.js></script> | 7 <source id="bogus-type" src="content/test.ogv" type="video/blahblah"></sourc
e> |
| 8 <source id="empty-src" src="" type="video/ogg"></source> |
| 9 <source id="no-extension-no-type" src="nonexistent"></source> |
| 10 </video> |
| 11 <script> |
| 12 async_test(function(t) { |
| 13 var errorCount = 0; |
| 14 document.addEventListener("error", function(event) { |
| 15 assert_true(event.target instanceof HTMLSourceElement); |
| 16 assert_equals(document.querySelector("video").error, null); |
| 17 assert_less_than(errorCount, 4); |
8 | 18 |
9 <script> | 19 if (++errorCount == 4) |
10 | 20 setTimeout(t.step_func_done(), 200); |
11 var sources = []; | 21 }, true); |
12 var errorCount = 0; | 22 }); |
13 var expectedErrorCount = 4; | 23 </script> |
14 | |
15 function errorEvent(evt) | |
16 { | |
17 consoleWrite(""); | |
18 | |
19 var ndx; | |
20 for (ndx = 0; ndx < sources.length; ndx++) { | |
21 if (sources[ndx] == evt.target) | |
22 break; | |
23 } | |
24 | |
25 var src = sources[ndx].getAttribute('src') == null ? "null" : "'
" + relativeURL(evt.target.src) + "'"; | |
26 if (sources[ndx] == evt.target) | |
27 logResult(true, "EVENT(error) from <source id='<em>" + ev
t.target.id + "</em>' src=<em>" + src + "</em>>"); | |
28 else | |
29 logResult(false, "EVENT(error) from " + evt.target); | |
30 | |
31 testExpected("video.error", null); | |
32 | |
33 if (++errorCount == expectedErrorCount) { | |
34 consoleWrite(""); | |
35 setTimeout(endTest, 200); | |
36 } | |
37 } | |
38 | |
39 function start() | |
40 { | |
41 document.addEventListener("error", errorEvent, true); | |
42 | |
43 sources = document.getElementsByTagName('source'); | |
44 | |
45 findMediaElement(); | |
46 } | |
47 </script> | |
48 </head> | |
49 | |
50 <body> | |
51 | |
52 <video onloadstart="start()" controls> | |
53 <source id=missing-src type="video/blahblah"> | |
54 <source id=bogus-type src=content/test.ogv type="video/blahblah"> | |
55 <source id=empty-src src="" type="video/ogg"> | |
56 <source id=no-extension-no-type src=nonexistent> | |
57 </video> | |
58 | |
59 <p>Test that 'error' events are fired from <source> element when i
t can not be used.</p> | |
60 | |
61 </body> | |
62 </html> | |
OLD | NEW |