tor-browser

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

xhr-messaging.html (1469B)


      1 <!DOCTYPE html>
      2 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
      3 <html>
      4  <head>
      5    <title>XHR messaging - cross-origin XHR request</title>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <!-- Common global functions for referrer-policy tests. -->
      9    <script src="/common/security-features/resources/common.sub.js"></script>
     10  </head>
     11  <body>
     12    <h1>XHR messaging - cross-origin XHR request</h1>
     13    <p>If you can read JSON encoded HTTP request headers of the XHR below,
     14       the messaging works as expected.</p>
     15 
     16    <pre id="received_message">Running...</pre>
     17 
     18    <script>
     19      promise_test(function() {
     20        var urlPath = '/common/security-features/subresource/xhr.py';
     21        var url = location.protocol + "//www1." + location.hostname + ":" + location.port +
     22                  urlPath;
     23        return requestViaXhr(url)
     24          .then(function(message) {
     25              var pre = document.getElementById('received_message')
     26              var headers = message.headers;
     27              pre.innerHTML = "";
     28              pre.innerHTML += url + ":\n\n";
     29              pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n"
     30              assert_own_property(headers, "host")
     31              assert_own_property(headers, "connection")
     32            });
     33      }, "XHR is responding with HTTP headers");
     34    </script>
     35 
     36    <div id="log"></div>
     37  </body>
     38 </html>