tor-browser

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

referer.https.html (1444B)


      1 <!DOCTYPE html>
      2 <title>Service Worker: check referer of fetch()</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/get-host-info.sub.js"></script>
      6 <script src="resources/test-helpers.sub.js?pipe=sub"></script>
      7 <script>
      8 promise_test(function(t) {
      9    var SCOPE = 'resources/referer-iframe.html';
     10    var SCRIPT = 'resources/fetch-rewrite-worker.js';
     11    var host_info = get_host_info();
     12    return service_worker_unregister_and_register(t, SCRIPT, SCOPE)
     13      .then(function(registration) {
     14          t.add_cleanup(function() {
     15              return service_worker_unregister(t, SCOPE);
     16            });
     17 
     18          return wait_for_state(t, registration.installing, 'activated');
     19        })
     20      .then(function() { return with_iframe(SCOPE); })
     21      .then(function(frame) {
     22          var channel = new MessageChannel();
     23          t.add_cleanup(function() {
     24              frame.remove();
     25            });
     26 
     27          var onMsg = new Promise(function(resolve) {
     28              channel.port1.onmessage = resolve;
     29            });
     30 
     31          frame.contentWindow.postMessage({},
     32                                          host_info['HTTPS_ORIGIN'],
     33                                          [channel.port2]);
     34          return onMsg;
     35        })
     36      .then(function(e) {
     37          assert_equals(e.data.results, 'finish');
     38        });
     39  }, 'Verify the referer');
     40 </script>