OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Test that no usable "source" element leaves the media element with networ
kState == NETWORK_NO_SOURCE.</title> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <title>no usable <source> test</title> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <video> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <source src="test.mp4" type="audio/x-chicken-face"></source> |
7 <script src=video-test.js></script> | 7 <source src="test.ogv" type="video/x-higglety-pigglety"></source> |
8 <script> | 8 <source src="doesnotexist.mp4"></source> |
9 document.addEventListener("error", errorEvent, true); | 9 </video> |
| 10 <script> |
| 11 async_test(function(t) { |
| 12 var errorCount = 0; |
| 13 var video = document.querySelector("video"); |
10 | 14 |
11 function errorEvent(evt) | 15 var sourceList = document.querySelectorAll("source"); |
12 { | 16 for (var source of sourceList) { |
13 findMediaElement(); | 17 source.onerror = t.step_func(function(event) { |
14 consoleWrite("++ ERROR, src = " + relativeURL(event.target.src) + ",
type = \"" + event.target.type + "\""); | 18 errorCount++; |
15 testExpected("event.target.tagName", "SOURCE", "=="); | 19 if (errorCount < 3) { |
16 | 20 // Because the error event is fired asynchronously the network s
tate |
17 // Any more source elements pending? | 21 // can be either NETWORK_LOADING or NETWORK_NO_SOURCE, depending
on |
18 var nextSource = event.target.nextSibling; | 22 // whether or not any pending "source" element is available. |
19 while (video.hasChildNodes()) { | 23 assert_greater_than(video.networkState, HTMLMediaElement.NETWORK
_IDLE); |
20 if (!nextSource || nextSource.tagName == "SOURCE") | 24 } else { |
21 break; | 25 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SO
URCE); |
22 nextSource = nextSource.nextSibling; | 26 t.done(); |
23 } | 27 } |
24 | 28 }); |
25 if (!nextSource) { | 29 } |
26 testExpected("event.target.parentNode.networkState", HTMLMediaEl
ement.NETWORK_NO_SOURCE, "=="); | 30 }); |
27 consoleWrite(""); | 31 </script> |
28 endTest(); | |
29 } else { | |
30 // Because the error event is fired asynchronously the network s
tate can be either | |
31 // NETWORK_LOADING or NETWORK_NO_SOURCE, depending on whether or
not | |
32 testExpected("event.target.parentNode.networkState", HTMLMediaEl
ement.NETWORK_IDLE, ">"); | |
33 } | |
34 | |
35 consoleWrite(""); | |
36 } | |
37 </script> | |
38 | |
39 </head> | |
40 <body> | |
41 <video controls> | |
42 <source src="test.mp4" type="audio/x-chicken-face"> | |
43 <source src="test.ogv" type="video/x-higglety-pigglety"> | |
44 <source src="doesnotexist.mp4"> | |
45 </video> | |
46 | |
47 <p>1. Test that no usable <source> element leaves the media element wi
th | |
48 networkState == NETWORK_NO_SOURCE</p> | |
49 </body> | |
50 </html> | |
OLD | NEW |