tor-browser

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

status-basic.htm (2503B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>XMLHttpRequest: status/statusText - various responses</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7    <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol/li[3]" />
      8    <link rel="help" href="https://xhr.spec.whatwg.org/#the-statustext-attribute" data-tested-assertations="following::ol/li[3]" />
      9    <link rel="help" href="https://xhr.spec.whatwg.org/#the-getresponseheader()-method" data-tested-assertations="following::ol/li[5]" />
     10    <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetext-attribute" data-tested-assertations="following::ol/li[4]" />
     11  </head>
     12  <body>
     13    <div id="log"></div>
     14    <script>
     15    var counter = 0
     16      function statusRequest(method, code, text, content, type) {
     17        counter++
     18        test(function() {
     19          var client = new XMLHttpRequest()
     20          assert_equals(client.status, 0);
     21          client.open(method, "resources/status.py?code=" + code + "&text=" + encodeURIComponent(text) + "&content=" + encodeURIComponent(content) + "&type=" + encodeURIComponent(type), false)
     22          assert_equals(client.status, 0);
     23          client.send(null)
     24          assert_equals(client.status, code)
     25          assert_equals(client.statusText, text)
     26          assert_equals(client.getResponseHeader("X-Request-Method"), method)
     27          if(method != "HEAD") {
     28            if(type == "text/xml") {
     29              assert_equals(client.responseXML.documentElement.localName, "x")
     30            }
     31            assert_equals(client.responseText, content)
     32          }
     33        }, document.title + " " + counter + " (" + method + " " + code + ")")
     34      }
     35      function status(code, text, content, type) {
     36        statusRequest("GET", code, text, content, type)
     37        statusRequest("HEAD", code, text, content, type)
     38        statusRequest("CHICKEN", code, text, content, type)
     39      }
     40      status(204, "UNICORNSWIN", "", "")
     41      status(401, "OH HELLO", "Not today.", "")
     42      status(402, "FIVE BUCKS", "<x>402<\/x>", "text/xml")
     43      status(402, "FREE", "Nice!", "text/doesnotmatter")
     44      status(402, "402 TEH AWESOME", "", "")
     45      status(502, "YO", "", "")
     46      status(502, "lowercase", "SWEET POTATO", "text/plain")
     47      status(503, "HOUSTON WE HAVE A", "503", "text/plain")
     48      status(699, "WAY OUTTA RANGE", "699", "text/plain")
     49    </script>
     50  </body>
     51 </html>