https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 308e630d7aa134239953606b66773fc06626ee9a authored by Domenic Denicola on 26 April 2016, 17:26:56 UTC
Fix #2908: update table cell interface tests
Tip revision: 308e630
timeout-cors-async.htm
<!doctype html>
<html>
  <head>
    <title>XMLHttpRequest: timeout event and cross-origin request</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />
    <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>
    <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
    <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[9]"/>
    <link rel="help" href="https://xhr.spec.whatwg.org/#cross-origin-request-event-rules" data-tested-assertations="following::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
  </head>
  <body>
    <div id="log"></div>
    <script>
      var test = async_test(document.title)
      var client = new XMLHttpRequest()
      var gotTimeout = false
      client.open("GET", "http://www2." + location.hostname + (location.port ? ":" + location.port : "") +(location.pathname.replace(/[^\/]+$/, '')+'resources/corsenabled.py')+"?delay=2&code=200")
      client.timeout = 100
      client.addEventListener('timeout', function (e) {
        test.step(function() {
          assert_equals(e.type, 'timeout')
          assert_equals(client.status, 0)
          gotTimeout = true
        })
      })
      client.addEventListener('load', function (e) {
        test.step(function() {
          assert_unreached('load event should not fire')
        })
      })
      client.addEventListener('loadend', function (e) {
        test.step(function() {
          assert_true(gotTimeout, "timeout event should fire")
          test.done()
        })
      })

      client.send(null)
    </script>
  </body>
</html>
back to top