tor-browser

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

access-control-preflight-headers-async.htm (1066B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>Test that async CORS requests with custom headers are sent with OPTIONS preflight</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7    <script src="/common/get-host-info.sub.js"></script>
      8    <script src="/common/utils.js"></script>
      9  </head>
     10  <body>
     11    <script type="text/javascript">
     12 async_test((test) => {
     13  let xhr = new XMLHttpRequest;
     14  const uuid = token();
     15 
     16  xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN +
     17      "/xhr/resources/reset-token.py?token=" + uuid, false);
     18  xhr.send();
     19 
     20  xhr = new XMLHttpRequest;
     21  xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN +
     22      "/xhr/resources/no-custom-header-on-preflight.py?token=" + uuid);
     23  xhr.setRequestHeader("x-test", "foobar");
     24 
     25  xhr.onerror = test.unreached_func("Unexpected error");
     26 
     27  xhr.onload = test.step_func_done(() => {
     28    assert_equals(xhr.responseText, "PASS");
     29  });
     30 
     31  xhr.send();
     32 }, "Preflighted async request with custom header");
     33    </script>
     34  </body>
     35 </html>