tor-browser

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

fetch-event-throws-after-respond-with.https.html (1392B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title></title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script src="resources/test-helpers.sub.js"></script>
      7 <script>
      8 
      9 promise_test(function(t) {
     10    var scope = 'resources/fetch-event-throws-after-respond-with-iframe.html';
     11    var workerscript = 'resources/respond-then-throw-worker.js';
     12    var iframe;
     13    return service_worker_unregister_and_register(t, workerscript, scope)
     14      .then(function(reg) {
     15          t.add_cleanup(function() {
     16              return service_worker_unregister(t, scope);
     17            });
     18 
     19          return wait_for_state(t, reg.installing, 'activated')
     20            .then(() => reg.active);
     21        })
     22      .then(function(worker) {
     23          var channel = new MessageChannel();
     24          channel.port1.onmessage = function(e) {
     25              assert_equals(e.data, 'SYNC', ' Should receive sync message.');
     26              channel.port1.postMessage('ACK');
     27            }
     28          worker.postMessage({port: channel.port2}, [channel.port2]);
     29          // The iframe will only be loaded after the sync is completed.
     30          return with_iframe(scope);
     31        })
     32      .then(function(frame) {
     33        assert_true(frame.contentDocument.body.innerHTML.includes("intercepted"));
     34      })
     35  }, 'Fetch event handler throws after a successful respondWith()');
     36 
     37 </script>