a3f3b9e26ecb58fa1eea27d85897dd61dab1aeb3
[WebKit-https.git] / LayoutTests / media / video-source-none-supported.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <title>no usable &lt;source&gt; test</title>
5     <script src=video-test.js></script>
6     <script>
7
8         function setup()
9         {
10             findMediaElement();
11             document.addEventListener("error", errorEvent, true);
12         }
13
14         function errorEvent(evt)
15         {
16             consoleWrite("++ ERROR, src = " + relativeURL(event.target.src) + ", type = \"" + event.target.type + "\"");
17             testExpected("event.target.tagName", "SOURCE", "==");
18             
19             // Any more source elements pending?
20             var nextSource = event.target.nextSibling;
21             while (video.hasChildNodes()) {
22                 if (!nextSource || nextSource.tagName == "SOURCE")
23                     break;
24                 nextSource = nextSource.nextSibling;
25             }
26
27             if (!nextSource) {
28                 testExpected("event.target.parentNode.networkState", HTMLMediaElement.NETWORK_NO_SOURCE, "==");
29                 consoleWrite("");
30                 endTest();
31             } else {
32                 // Because the error event is fired asynchronously the network state can be either 
33                 // NETWORK_LOADING or NETWORK_NO_SOURCE, depending on whether or not 
34                 testExpected("event.target.parentNode.networkState", HTMLMediaElement.NETWORK_IDLE, ">");
35             }
36
37             consoleWrite("");
38         }
39     </script>
40
41 </head>
42 <body>
43     <video controls>
44         <source src="test.mp4" type="audio/x-chicken-face">
45         <source src="test.ogv" type="video/x-higglety-pigglety">
46         <source src="doesnotexist.mp4">
47     </video>
48
49     <p>1. Test that no usable &lt;source&gt; element leaves the media element with 
50     networkState == NETWORK_NO_SOURCE</p>
51
52     <script>setup();</script>
53 </body>
54 </html>