OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 | 3 |
4 <video controls></video> | 4 <video controls></video> |
5 | 5 |
6 <p>Test that setting src to an invalid url triggers load(), which sets netwo
rkState | 6 <p>Test that setting src to an invalid url triggers load(), which sets netwo
rkState |
7 to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loa
ding | 7 to NETWORK_NO_SOURCE. Setting src to a valid url should then trigger the loa
ding |
8 events and end up with networkState >= NETWORK_LOADING. | 8 events and end up with networkState >= NETWORK_LOADING. |
9 </p> | 9 </p> |
10 | 10 |
11 <script src=media-file.js></script> | 11 <script src=media-file.js></script> |
| 12 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 13 (Please avoid writing new tests using video-test.js) --> |
12 <script src=video-test.js></script> | 14 <script src=video-test.js></script> |
13 <script> | 15 <script> |
14 function testNetworkState(expected, endit, op) | 16 function testNetworkState(expected, endit, op) |
15 { | 17 { |
16 testExpected("video.networkState", expected, op); | 18 testExpected("video.networkState", expected, op); |
17 if (endit) | 19 if (endit) |
18 endTest(); | 20 endTest(); |
19 } | 21 } |
20 | 22 |
21 waitForEvent("loadstart"); | 23 waitForEvent("loadstart"); |
22 waitForEvent("loadedmetadata"); | 24 waitForEvent("loadedmetadata"); |
23 waitForEvent("loadeddata"); | 25 waitForEvent("loadeddata"); |
24 waitForEvent("canplay"); | 26 waitForEvent("canplay"); |
25 waitForEventAndFail("play"); | 27 waitForEventAndFail("play"); |
26 waitForEventAndFail("playing"); | 28 waitForEventAndFail("playing"); |
27 waitForEvent("canplaythrough", function () { testNetworkState(HTMLMediaE
lement.NETWORK_IDLE, true, '>=' ); } ); | 29 waitForEvent("canplaythrough", function () { testNetworkState(HTMLMediaE
lement.NETWORK_IDLE, true, '>=' ); } ); |
28 | 30 |
29 function waitUntilNotLoading() | 31 function waitUntilNotLoading() |
30 { | 32 { |
31 if (video.networkState == HTMLMediaElement.NETWORK_LOADING) { | 33 if (video.networkState == HTMLMediaElement.NETWORK_LOADING) { |
32 setTimeout(waitUntilNotLoading, 100); | 34 setTimeout(waitUntilNotLoading, 100); |
33 return; | 35 return; |
34 } | 36 } |
35 | 37 |
36 testNetworkState(HTMLMediaElement.NETWORK_NO_SOURCE); | 38 testNetworkState(HTMLMediaElement.NETWORK_NO_SOURCE); |
37 consoleWrite(""); | 39 consoleWrite(""); |
38 | 40 |
39 // now set a valid url | 41 // now set a valid url |
40 var mediaFile = findMediaFile("video", "content/test"); | 42 var mediaFile = findMediaFile("video", "content/test"); |
41 disableFullTestDetailsPrinting(); | 43 disableFullTestDetailsPrinting(); |
42 runSilently("video.src = '" + mediaFile + "'"); | 44 runSilently("video.src = '" + mediaFile + "'"); |
43 enableFullTestDetailsPrinting(); | 45 enableFullTestDetailsPrinting(); |
44 } | 46 } |
45 | 47 |
46 // first set the src to a bogus url, it should attempt a load | 48 // first set the src to a bogus url, it should attempt a load |
47 consoleWrite(""); | 49 consoleWrite(""); |
48 testNetworkState(HTMLMediaElement.NETWORK_EMPTY); | 50 testNetworkState(HTMLMediaElement.NETWORK_EMPTY); |
49 run("video.src = 'bogus/movie.mpg'"); | 51 run("video.src = 'bogus/movie.mpg'"); |
50 | 52 |
51 setTimeout(waitUntilNotLoading, 100); | 53 setTimeout(waitUntilNotLoading, 100); |
52 </script> | 54 </script> |
53 | 55 |
54 </body> | 56 </body> |
55 </html> | 57 </html> |
OLD | NEW |