[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / video-delay-load-event.html
1 <!doctype html>
2 <html>
3     <head>
4         <title>delay document 'load' event test</title>
5         <style> video { border: 3px solid red; } </style>
6         <script src=video-test.js></script>
7         <script src=media-file.js></script>
8         <script>
9             var video;
10
11             function testMovieWithNoSource(elem)
12             {
13                 video = elem;   // Need it in a global for testExpected() to see it.
14                 consoleWrite("<em>no 'src'.</em>");
15                 testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_EMPTY, "==");
16                 testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_NOTHING, "==");
17             }
18
19             function testMovieWithSource(elem, hasLoaded, msg)
20             {
21                 video = elem;   // Need it in a global for testExpected() to see it.
22                 consoleWrite(msg);
23                 if (hasLoaded) {
24                     // The movie should have loaded at least to HAVE_CURRENT_DATA
25                     testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_NO_SOURCE, "!=");
26                     testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_IDLE, ">=");
27                     testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_CURRENT_DATA, ">=");
28                 } else {
29                     testExpected("video.networkState", HTMLMediaElement.prototype.NETWORK_NO_SOURCE, "==");
30                     testExpected("video.readyState", HTMLMediaElement.prototype.HAVE_NOTHING, "==");
31                 }
32             }
33
34             function loaded()
35             {
36                 consoleWrite("<br><b>document <em>'load'<" + "/em> event handler</b>");
37
38                 testMovieWithNoSource(document.getElementById('video-1'));
39                 testMovieWithSource(document.getElementById('video-2'), true, "<br><em>with 'src' attribute.</em>");
40                 testMovieWithSource(document.getElementById('video-3'), true, "<br><em>with &lt;source&gt; element.</em>");
41
42                 if (window.testRunner)
43                     testRunner.notifyDone();
44             }
45         </script>
46     </head>
47     <body onload="loaded()">
48         <video id="video-1"></video>
49         <video id="video-2"></video>
50         <video id="video-3"><source id="source-1"></video>
51
52         <p>Test the document's load event is delayed until a movie's meta data is available.</p>
53
54         <script>
55             consoleWrite("<br><b>inline script</b>");
56
57             testMovieWithNoSource(document.getElementById('video-1'));
58
59             video = document.getElementById('video-2');
60             video.src = findMediaFile("video", "content/test");
61             testMovieWithSource(video, false, "<br><em>with 'src' attribute.</em>");
62
63             source = document.getElementById('source-1');
64             source.src = findMediaFile("video", "content/test");
65             testMovieWithSource(document.getElementById('video-3'), false, "<br><em>with &lt;source&gt; element.</em>");
66             document.getElementById('video-3').load();
67         </script>
68
69     </body>
70 </html>