tor-browser

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

send-network-error-async-events.sub.htm (2423B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onerror" data-tested-assertations="../.." />
      5    <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[9]/ol/li[2] following::ol[1]/li[9]/ol/li[3]" />
      6    <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following::dt[4] following::dd[4]/p" />
      7    <link rel="help" href="https://xhr.spec.whatwg.org/#network-error" data-tested-assertations=".." />
      8    <link rel="help" href="https://xhr.spec.whatwg.org/#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[6] following::ol[1]/li[7] following::ol[1]/li[7]/ol/li[3] following::ol[1]/li[7]/ol/li[4] following::ol[1]/li[9] following::ol[1]/li[10]" />
      9    <script src="/resources/testharness.js"></script>
     10    <script src="/resources/testharnessreport.js"></script>
     11    <title>XMLHttpRequest: The send() method: Fire a progress event named error when Network error happens (synchronous flag is unset)</title>
     12 </head>
     13 
     14 <body>
     15    <div id="log"></div>
     16 
     17    <script type="text/javascript">
     18        var test = async_test();
     19 
     20        test.step(function(){
     21            var xhr = new XMLHttpRequest();
     22            var expect =  ["loadstart", "upload.loadstart", 4, "upload.error", "upload.loadend", "error", "loadend"];
     23            var actual = [];
     24 
     25            xhr.onreadystatechange = test.step_func(() => {
     26                if (xhr.readyState == 4) {
     27                    actual.push(xhr.readyState);
     28                }
     29            });
     30 
     31            xhr.onloadstart        = test.step_func(e => { actual.push(e.type); })
     32            xhr.onloadend          = test.step_func_done(e => {
     33                actual.push(e.type);
     34                assert_array_equals(actual, expect);
     35            })
     36            xhr.onerror            = test.step_func(e => { actual.push(e.type); })
     37 
     38            xhr.upload.onloadstart = test.step_func(e => { actual.push("upload." + e.type); })
     39            xhr.upload.onloadend   = test.step_func(e => { actual.push("upload." + e.type); })
     40            xhr.upload.onerror     = test.step_func(e => { actual.push("upload." + e.type); })
     41 
     42            xhr.open("POST", "http://nonexistent.{{host}}:{{ports[http][0]}}", true);
     43            xhr.send("Test Message");
     44        });
     45    </script>
     46 </body>
     47 </html>