2a996f9d8ef84f1421aef9aeb8899e5fffeba928
[WebKit-https.git] / LayoutTests / media / video-source-error.html
1 <html lang="en">
2     <head>
3         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4         <title>&lt;video&gt; and &lt;source&gt; error test</title>
5         <script src=video-test.js></script>
6
7         <script>
8
9             var sources = [];
10
11             function loadeddata()
12             {
13                 consoleWrite("");
14                 testExpected("relativeURL(video.currentSrc)", "content/test.mp4");
15                 testExpected("video.error", null);
16                 consoleWrite("");
17                 endTest();
18             }
19
20             function errorEvent(evt)
21             {
22                 var ndx;
23                 for (ndx = 0; ndx < sources.length; ndx++) {
24                     if (sources[ndx] == evt.target)
25                         break;
26                 }
27
28                 if (sources[ndx] == evt.target)
29                     logResult(true, "EVENT(error) from &lt;source id='<em>" + evt.target.id + "</em>' src='<em>" + relativeURL(evt.target.src) + "</em>'&gt;");
30                 else
31                     logResult(false, "EVENT(error) from " + evt.target);
32
33                 testExpected("video.error", null);
34                 consoleWrite("");
35             }
36
37             function start()
38             {
39                 findMediaElement();
40
41                 sources = document.getElementsByTagName('source');
42
43                 document.addEventListener("error", errorEvent, true);
44                 waitForEvent("loadstart");
45                 waitForEvent("waiting");
46                 waitForEvent("ratechange");
47                 waitForEvent("durationchange");
48                 waitForEvent("pause");
49                 waitForEvent("play");
50                 waitForEvent("playing");
51
52                 waitForEvent('loadeddata', loadeddata);
53             }
54         </script>
55     </head>
56
57     <body onload="start()">
58
59         <video controls>
60             <source id=missing-src type="video/blahblah">
61             <source id=bogus-type src=content/test.mp4 type="video/blahblah">
62             <source id=unsupported-media-query src=content/test.mp4 media=print>
63             <source id=missing-file src=content/error2.mpeg type=video/mpeg>
64             <source id=format-error src="content/unsupported_track.mov">
65             <source id=supported-format src=content/test.mp4 type="video/mpeg; codecs=&quot;avc1.4D400C&quot;">
66         </video>
67         
68         <p>1. Test that errors fired while evaluating/loading &lt;source&gt; elements are fired at the
69         &lt;source&gt; and not at the &lt;video&gt; element.
70         <br>2. Verifiy that an 'error' event fired while processing/loading a &lt;source&gt; element 
71         does not set the media element's 'error' attribute.</p>
72
73     </body>
74 </html>