chromium/third_party/blink/web_tests/media/video-error-networkState.html

<!DOCTYPE html>
<title>Test media element networkState value in an error corner case.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING);
    video.onended = t.unreached_func();
    video.onerror = t.step_func(() => {
      assert_equals(video.readyState, HTMLMediaElement.HAVE_ENOUGH_DATA);
      assert_equals(video.networkState, HTMLMediaElement.NETWORK_IDLE);

      var source = document.createElement("source");
      video.removeAttribute("src");
      video.appendChild(source);  // Schedules load timer.
      video.removeChild(source);  // Good luck with that load.
      window.setTimeout(t.step_func_done(() => {
        // If we wait before removing the child, we will get HAVE_ENOUGH_DATA,
        // and NETWORK_NO_SOURCE. It's not really clear if that's correct, nor
        // is it clear whether removing the child immediately should change the
        // result. In any case, the load algorithm handles NETWORK_EMPTY as a
        // special case. For now we'll just test that we don't trigger that.
        assert_true(video.readyState != HTMLMediaElement.HAVE_ENOUGH_DATA ||
                    video.networkState != HTMLMediaElement.NETWORK_EMPTY);
      }), 0);
    });

    video.src = "content/corrupt.ogv";
    video.play();
});
</script>