Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-delay-load-event.html
blobb1d80207bd0a5749c6e21f64157d7c0a3da64b12
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;
11 function testMovieWithNoSource(elem)
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, "==");
19 function testMovieWithSource(elem, hasLoaded, msg)
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, "==");
34 function loaded()
36 consoleWrite("<br><b>document <em>'load'<" + "/em> event handler</b>");
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>");
42 if (window.testRunner)
43 testRunner.notifyDone();
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>
52 <p>Test the document's load event is delayed until a movie's meta data is available.</p>
54 <script>
55 consoleWrite("<br><b>inline script</b>");
57 testMovieWithNoSource(document.getElementById('video-1'));
59 video = document.getElementById('video-2');
60 video.src = findMediaFile("video", "content/test");
61 testMovieWithSource(video, false, "<br><em>with 'src' attribute.</em>");
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>
69 </body>
70 </html>