tor-browser

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

simple-requests-ch.tentative.htm (1899B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>CORS - simple requests</title>
      4 <meta name=author title="Odin Hørthe Omdal" href="mailto:odiho@opera.com">
      5 
      6 <script src=/resources/testharness.js></script>
      7 <script src=/resources/testharnessreport.js></script>
      8 <script src=support.js?pipe=sub></script>
      9 <script src=/common/utils.js></script>
     10 
     11 <h1>Simple requests</h1>
     12 <p>Simple requests shouldn't trigger preflight</p>
     13 
     14 <div id=log></div>
     15 <script>
     16 
     17 var test_c = 0;
     18 
     19 function check_simple(method, headers)
     20 {
     21    test(function() {
     22        var client = new XMLHttpRequest()
     23        var uuid_token = token();
     24        client.open(method, CROSSDOMAIN + 'resources/preflight.py?token='
     25                            + uuid_token, false)
     26        for (head in headers)
     27            client.setRequestHeader(head, headers[head])
     28        client.send("data")
     29        assert_equals(client.getResponseHeader('content-type'), "text/plain")
     30        if (method == 'HEAD')
     31            assert_equals(client.response, '', 'response')
     32        else
     33            assert_equals(client.response, 'NO', 'response')
     34 
     35        client.open('GET', 'resources/preflight.py?check&token='
     36                          + uuid_token, false)
     37        client.send("data")
     38        assert_equals(client.response, "0", "Found preflight log")
     39    },
     40    'No preflight ' + method + ' and ' + JSON.stringify(headers))
     41 }
     42 
     43 function check_simple_headers(headers) {
     44    check_simple('GET', headers)
     45    check_simple('HEAD', headers)
     46    check_simple('POST', headers)
     47 }
     48 
     49 check_simple_headers({
     50                        'save-data': 'on',
     51                        'device-memory': '2.0',
     52                        'dpr': '3.0',
     53                        'width': '1200',
     54                        'viewport-width': '1300',
     55                        'rtt': '1',
     56                        'downlink': '1.0',
     57                        'ect': '2g'
     58                     })
     59 
     60 </script>