| <!DOCTYPE html> |
| <title>Test that no usable "source" element leaves the media element with networkState == NETWORK_NO_SOURCE.</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <video> |
| <source src="test.mp4" type="audio/x-chicken-face"></source> |
| <source src="test.ogv" type="video/x-higglety-pigglety"></source> |
| <source src="doesnotexist.mp4"></source> |
| </video> |
| <script> |
| async_test(function(t) { |
| var errorCount = 0; |
| var video = document.querySelector("video"); |
| |
| var sourceList = document.querySelectorAll("source"); |
| for (var source of sourceList) { |
| source.onerror = t.step_func(function(event) { |
| errorCount++; |
| if (errorCount < 3) { |
| // Because the error event is fired asynchronously the network state |
| // can be either NETWORK_LOADING or NETWORK_NO_SOURCE, depending on |
| // whether or not any pending "source" element is available. |
| assert_greater_than(video.networkState, HTMLMediaElement.NETWORK_IDLE); |
| } else { |
| assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| t.done(); |
| } |
| }); |
| } |
| }); |
| </script> |