Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-load-networkState.html
blobeee64ac8ac51df5091df526748dc826d6dac718e
1 <html>
2 <body>
4 <video controls></video>
6 <p>Test that setting src to an invalid url triggers load(), which sets networkState
7 to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loading
8 events and end up with networkState >= NETWORK_LOADING.
9 </p>
11 <script src=media-file.js></script>
12 <script src=video-test.js></script>
13 <script>
14 function testNetworkState(expected, endit, op)
16 testExpected("video.networkState", expected, op);
17 if (endit)
18 endTest();
21 waitForEvent("loadstart");
22 waitForEvent("loadedmetadata");
23 waitForEvent("loadeddata");
24 waitForEvent("canplay");
25 waitForEventAndFail("play");
26 waitForEventAndFail("playing");
27 waitForEvent("canplaythrough", function () { testNetworkState(HTMLMediaElement.NETWORK_IDLE, true, '>=' ); } );
29 function waitUntilNotLoading()
31 if (video.networkState == HTMLMediaElement.NETWORK_LOADING) {
32 setTimeout(waitUntilNotLoading, 100);
33 return;
36 testNetworkState(HTMLMediaElement.NETWORK_NO_SOURCE);
37 consoleWrite("");
39 // now set a valid url
40 var mediaFile = findMediaFile("video", "content/test");
41 disableFullTestDetailsPrinting();
42 runSilently("video.src = '" + mediaFile + "'");
43 enableFullTestDetailsPrinting();
46 // first set the src to a bogus url, it should attempt a load
47 consoleWrite("");
48 testNetworkState(HTMLMediaElement.NETWORK_EMPTY);
49 run("video.src = 'bogus/movie.mpg'");
51 setTimeout(waitUntilNotLoading, 100);
52 </script>
54 </body>
55 </html>