tor-browser

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

nested-blob-url-workers.https.html (1608B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Service Worker: nested blob URL worker clients</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 <body>
      8 <script>
      9 
     10 const SCRIPT = 'resources/simple-intercept-worker.js';
     11 const SCOPE = 'resources/';
     12 const RESOURCE = 'resources/simple.txt';
     13 
     14 promise_test((t) => {
     15  return runTest(t, 'resources/nested-blob-url-workers.html');
     16 }, 'Nested blob URL workers should be intercepted by a service worker.');
     17 
     18 promise_test((t) => {
     19  return runTest(t, 'resources/nested-worker-created-from-blob-url-worker.html');
     20 }, 'Nested worker created from a blob URL worker should be intercepted by a service worker.');
     21 
     22 promise_test((t) => {
     23  return runTest(t, 'resources/nested-blob-url-worker-created-from-worker.html');
     24 }, 'Nested blob URL worker created from a worker should be intercepted by a service worker.');
     25 
     26 async function runTest(t, iframe_url) {
     27  const reg = await service_worker_unregister_and_register(t, SCRIPT, SCOPE);
     28  t.add_cleanup(_ => reg.unregister());
     29  await wait_for_state(t, reg.installing, 'activated');
     30 
     31  const frame = await with_iframe(iframe_url);
     32  t.add_cleanup(_ => frame.remove());
     33  assert_not_equals(frame.contentWindow.navigator.serviceWorker.controller,
     34                    null, 'frame should be controlled');
     35 
     36  const response_text = await frame.contentWindow.fetch_in_worker(RESOURCE);
     37  assert_equals(response_text, 'intercepted by service worker',
     38                'fetch() should be intercepted.');
     39 }
     40 
     41 </script>
     42 </body>