tor-browser

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

request-end-to-end.https.html (2113B)


      1 <!DOCTYPE html>
      2 <title>Service Worker: FetchEvent.request passed to onfetch</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/test-helpers.sub.js"></script>
      6 <script>
      7 'use strict';
      8 
      9 promise_test(t => {
     10    var url = 'resources/request-end-to-end-worker.js';
     11    var scope = 'resources/blank.html';
     12    return service_worker_unregister_and_register(t, url, scope)
     13      .then(r => {
     14          add_completion_callback(() => { r.unregister(); });
     15          return wait_for_state(t, r.installing, 'activated');
     16        })
     17      .then(() => { return with_iframe(scope); })
     18      .then(frame => {
     19          add_completion_callback(() => { frame.remove(); });
     20 
     21          var result = JSON.parse(frame.contentDocument.body.textContent);
     22          assert_equals(result.url, frame.src, 'request.url');
     23          assert_equals(result.method, 'GET', 'request.method');
     24          assert_equals(result.referrer, location.href, 'request.referrer');
     25          assert_equals(result.mode, 'navigate', 'request.mode');
     26          assert_equals(result.request_construct_error, '',
     27                        'Constructing a Request with a Request whose mode ' +
     28                        'is navigate and non-empty RequestInit must not throw a ' +
     29                        'TypeError.')
     30          assert_equals(result.credentials, 'include', 'request.credentials');
     31          assert_equals(result.redirect, 'manual', 'request.redirect');
     32          assert_equals(result.append_header_error, 'TypeError',
     33                        'Appending a new header to the request must throw a ' +
     34                        'TypeError.')
     35 
     36          // `assert_equals()` is not used here to create a stable failure
     37          // baseline, because the User-Agent header would be version-dependent
     38          // if set.
     39          assert_true(result.headers['user-agent'] === undefined,
     40                      'Default User-Agent header should not be passed to ' +
     41                      'onfetch event.')
     42        });
     43  }, 'Test FetchEvent.request passed to onfetch');
     44 </script>