OLD | NEW |
1 <html lang="en"> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test "error" event are fired on "source" elements and not on "video" whil
e processing invalid "source" elements.</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 <script src=media-file.js></script> | 5 <script src="media-file.js"></script> |
6 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 6 <video> |
7 (Please avoid writing new tests using video-test.js) --> | 7 <source id="missing-src" type="video/blahblah"></source> |
8 <script src=video-test.js></script> | 8 <source id="bogus-type" src="content/test.mp4" type="video/blahblah"></sourc
e> |
| 9 <source id="missing-file" src="content/error2.mpeg" type="video/mpeg"></sour
ce> |
| 10 <source id="format-error" src="content/unsupported_track.mov"></source> |
| 11 <source id="supported-format-mp4" src="content/test.mp4" type="video/mp4; co
decs="avc1.4D400C""></source> |
| 12 <source id="supported-format-ogv" src="content/test.ogv" type="video/ogg"></
source> |
| 13 </video> |
| 14 <script> |
| 15 // 1. Test that errors fired while evaluating/loading "source elements are |
| 16 // fired at the "source" and not at the "video" element. |
| 17 // 2. Verifiy that an "error" event fired while processing/loading a "source" el
ement |
| 18 // does not set the media element's "error" attribute. |
| 19 async_test(function(t) { |
| 20 var video = document.querySelector("video"); |
9 | 21 |
10 <script> | 22 document.addEventListener("error", function(event) { |
| 23 assert_true(event.target instanceof HTMLSourceElement); |
| 24 }, true); |
11 | 25 |
12 var sources = []; | 26 video.onloadstart = t.step_func(function() {}); |
| 27 video.onwaiting = t.step_func(function() {}); |
| 28 video.onratechange = t.step_func(function() {}); |
| 29 video.ondurationchange = t.step_func(function() {}); |
| 30 video.onpause = t.step_func(function() {}); |
| 31 video.onplay = t.step_func(function() {}); |
| 32 video.onplaying = t.step_func(function() {}); |
| 33 video.onerror = t.unreached_func(); |
13 | 34 |
14 function loadeddata() | 35 video.onloadeddata = t.step_func_done(function() { |
15 { | 36 var url = video.currentSrc; |
16 consoleWrite(""); | 37 assert_equals(url.substr(url.lastIndexOf("/media/") + 7), findMediaFile(
"video", "content/test")); |
17 testExpected("relativeURL(video.currentSrc)", findMediaFile("vid
eo", "content/test")); | 38 }); |
18 testExpected("video.error", null); | 39 }); |
19 consoleWrite(""); | 40 </script> |
20 endTest(); | |
21 } | |
22 | |
23 function errorEvent(evt) | |
24 { | |
25 var ndx; | |
26 for (ndx = 0; ndx < sources.length; ndx++) { | |
27 if (sources[ndx] == evt.target) | |
28 break; | |
29 } | |
30 | |
31 if (sources[ndx] == evt.target) | |
32 logResult(true, "EVENT(error) from <source id='<em>" + ev
t.target.id + "</em>' src='<em>" + relativeURL(evt.target.src) + "</em>'>"); | |
33 else | |
34 logResult(false, "EVENT(error) from " + evt.target); | |
35 | |
36 testExpected("video.error", null); | |
37 consoleWrite(""); | |
38 } | |
39 | |
40 function start() | |
41 { | |
42 findMediaElement(); | |
43 | |
44 sources = document.getElementsByTagName('source'); | |
45 | |
46 document.addEventListener("error", errorEvent, true); | |
47 waitForEvent("loadstart"); | |
48 waitForEvent("waiting"); | |
49 waitForEvent("ratechange"); | |
50 waitForEvent("durationchange"); | |
51 waitForEvent("pause"); | |
52 waitForEvent("play"); | |
53 waitForEvent("playing"); | |
54 | |
55 waitForEvent('loadeddata', loadeddata); | |
56 } | |
57 </script> | |
58 </head> | |
59 | |
60 <body> | |
61 | |
62 <video controls> | |
63 <source id=missing-src type="video/blahblah"> | |
64 <source id=bogus-type src=content/test.mp4 type="video/blahblah"> | |
65 <source id=missing-file src=content/error2.mpeg type=video/mpeg> | |
66 <source id=format-error src="content/unsupported_track.mov"> | |
67 <source id=supported-format-mp4 src=content/test.mp4 type="video/mp4
; codecs="avc1.4D400C""> | |
68 <source id=supported-format-ogv src=content/test.ogv type="video/ogg
"> | |
69 </video> | |
70 | |
71 <p>1. Test that errors fired while evaluating/loading <source> ele
ments are fired at the | |
72 <source> and not at the <video> element. | |
73 <br>2. Verifiy that an 'error' event fired while processing/loading a &l
t;source> element | |
74 does not set the media element's 'error' attribute.</p> | |
75 | |
76 <script>start()</script> | |
77 </body> | |
78 </html> | |
OLD | NEW |