tor-browser

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

fetch-messaging.html (1656B)


      1 <!DOCTYPE html>
      2 <!-- TODO(kristijanburnik): Remove subres. duplication. Reuse a template. -->
      3 <html>
      4  <head>
      5    <title>Fetch messaging - same-origin Fetch 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>Fetch messaging - same-origin Fetch request</h1>
     13    <p>If you can read JSON encoded HTTP request headers of the Fetch below,
     14       the messaging works as expected.</p>
     15 
     16    <pre id="received_message">Running...</pre>
     17 
     18    <script>
     19      test(function() {
     20        assert_true(!!window.fetch, "Fetch is not supported by this browser.");
     21      }, "Fetch is supported by the browser.");
     22 
     23      promise_test(function() {
     24          var urlPath = '/common/security-features/subresource/xhr.py';
     25          var url = location.protocol + "//" + location.hostname + ":" +
     26                    location.port + urlPath;
     27          return requestViaFetch(url)
     28            .then(function(message) {
     29                var pre = document.getElementById('received_message')
     30                var headers = message.headers;
     31                pre.innerHTML = "";
     32                pre.innerHTML += url + ":\n\n";
     33                pre.innerHTML += JSON.stringify(headers, null, 2) + "\n\n";
     34                assert_own_property(headers, "host")
     35                assert_own_property(headers, "connection")
     36              });
     37      }, "Fetch is responding with HTTP headers");
     38    </script>
     39 
     40    <div id="log"></div>
     41  </body>
     42 </html>