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