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