Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

  • This test has a WPT meta file that expects 1 subtest issues.
  • This WPT test may be referenced by the following Test IDs:
    • /html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-invoke-insert-source-networkState.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>NOT invoking resource selection by inserting &lt;source> when networkState is not NETWORK_EMPTY</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var loadstartCount = 0;
var s1ErrorCount = 0;
var s2ErrorCount = 0;
var v;
var t = async_test(function(t) {
v = document.createElement('video');
v.onloadstart = function() { loadstartCount++; };
var s1 = document.createElement('source');
s1.src = 'resources/delayed-broken-video.py';
s1.onerror = function() { s1ErrorCount++; };
v.appendChild(s1); // invokes resource selection
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in first script');
});
</script>
<script>
t.step(function() {
assert_equals(v.networkState, v.NETWORK_LOADING, 'networkState in second script');
assert_equals(s1ErrorCount, 0, 's1ErrorCount in second script');
var s2 = document.createElement('source');
s2.onerror = t.step_func(function() {
s2ErrorCount++;
assert_equals(s1ErrorCount, 1, 's1ErrorCount in s2.onerror');
});
v.appendChild(s2);
onload = t.step_func(function() {
assert_equals(s2ErrorCount, 1, 's2ErrorCount in window.onload');
assert_equals(loadstartCount, 1, 'loadstartCount in window.onload'); // reliable if https://www.w3.org/Bugs/Public/show_bug.cgi?id=24353 is fixed
assert_equals(v.networkState, v.NETWORK_NO_SOURCE, 'networkState in window.onload'); // See Waiting step
t.done();
});
});
</script>