chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html

<!doctype html>
<html>
<body>
<pre id='consoleElement'></pre>
<script type="text/javascript">
function log(message) {
  consoleElement.appendChild(document.createTextNode(message + "\n"));
}

if (window.testRunner) {
  testRunner.dumpAsText();
  testRunner.waitUntilDone();
}

(function() {
  var xhr = new XMLHttpRequest;
  var errorCalled = false;

  xhr.onerror = function() {
    errorCalled = true;
    xhr.timeout = 1;

    // To ensure xhr.ontimeout is not called, we asynchronously record whether
    // the test passes.
    setTimeout(function() {
      log("PASS: Timeout override did not reactivate timer after failure");
      if (window.testRunner)
        testRunner.notifyDone();
    }, 50);
  };

  xhr.ontimeout = function() {
    // This test should never time out. There are two failure modes depending on
    // whether xhr.onerror was called or not.
    if (errorCalled)
      log("FAIL: Timeout override reactivated the timer.");
    else
      log("FAIL: Request timed out but should have failed due to origin restrictions.");

    if (window.testRunner)
      testRunner.notifyDone();
  }

  xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-denied.cgi");
  xhr.timeout = 500;
  xhr.send();
})();
</script>
</body>
</html>