tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

xmlhttprequest-timeout-reused.html (1840B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <meta charset="utf-8" />
      5    <title>XHR2 Timeout Property Tests</title>
      6    <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" />
      7    <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" />
      8    <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-ontimeout" data-tested-assertations="../.."/>
      9    <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".."/>
     10    <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[9]"/>
     11    <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" />
     12    <meta name=timeout content=long>
     13    <script src="/resources/testharness.js"></script>
     14    <script src="/resources/testharnessreport.js"></script>
     15 </head>
     16 <body>
     17    <div id="log"></div>
     18    <script type="text/javascript">
     19 
     20 var test = async_test();
     21 
     22 function startRequest() {
     23    xhr.open("GET", "./resources/content.py?content=Hi", true);
     24    xhr.timeout = 2000;
     25    test.step_timeout(function () {
     26      xhr.send();
     27    }, 1000);
     28 }
     29 
     30 test.step(function()
     31 {
     32    var count = 0;
     33    xhr = new XMLHttpRequest();
     34    xhr.onload = function () {
     35        assert_equals(xhr.response, "Hi");
     36        if (++count == 2) {
     37            test.done();
     38        }
     39    }
     40    xhr.ontimeout = function () {
     41      assert_unreached("HTTP error should not timeout");
     42    }
     43    startRequest();
     44    test.step_timeout(startRequest, 3500);
     45 });
     46 
     47    </script>
     48 </body>
     49 </html>