| <html> |
| <body> |
| |
| <video controls></video> |
| |
| <p>Test that setting src to an invalid url triggers load(), which sets networkState |
| to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loading |
| events and end up with networkState >= NETWORK_LOADING. |
| </p> |
| |
| <script src=media-file.js></script> |
| <script src=video-test.js></script> |
| <script> |
| function testNetworkState(expected, endit, op) |
| { |
| testExpected("video.networkState", expected, op); |
| if (endit) |
| endTest(); |
| } |
| |
| waitForEvent("loadstart"); |
| waitForEvent("loadedmetadata"); |
| waitForEvent("loadeddata"); |
| waitForEvent("canplay"); |
| waitForEventAndFail("play"); |
| waitForEventAndFail("playing"); |
| waitForEvent("canplaythrough", function () { testNetworkState(HTMLMediaElement.NETWORK_IDLE, true, '>=' ); } ); |
| |
| function waitUntilNotLoading() |
| { |
| if (video.networkState == HTMLMediaElement.NETWORK_LOADING) { |
| setTimeout(waitUntilNotLoading, 100); |
| return; |
| } |
| |
| testNetworkState(HTMLMediaElement.NETWORK_NO_SOURCE); |
| consoleWrite(""); |
| |
| // now set a valid url |
| var mediaFile = findMediaFile("video", "content/test"); |
| disableFullTestDetailsPrinting(); |
| runSilently("video.src = '" + mediaFile + "'"); |
| enableFullTestDetailsPrinting(); |
| } |
| |
| // first set the src to a bogus url, it should attempt a load |
| consoleWrite(""); |
| testNetworkState(HTMLMediaElement.NETWORK_EMPTY); |
| run("video.src = 'bogus/movie.mpg'"); |
| |
| setTimeout(waitUntilNotLoading, 100); |
| </script> |
| |
| </body> |
| </html> |