tor-browser

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

different-initiators-2.https.html (2081B)


      1 <!DOCTYPE html>
      2 <meta name="timeout" content="long">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/dispatcher/dispatcher.js"></script>
      7 <script src="../resources/utils.js"></script>
      8 <script src="resources/utils.sub.js"></script>
      9 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
     10 <script>
     11 setup(() => assertSpeculationRulesIsSupported());
     12 
     13 // Regression test for https://crbug.com/1431804.
     14 promise_test(async t => {
     15  const win = await spawnWindow(t, { protocol: 'https' });
     16  const nextUrl = win.getExecutorURL({ protocol: 'https', page: 2 });
     17 
     18  // Navigate `win` from Document #1 -> #2 (nextUrl) -> #3 (tempUrl) ->
     19  // #4 (nextUrl),
     20  // Start speculation rules prefetch from #1, and
     21  // Try using the prefetched result for the navigation #3 -> #4.
     22  // The Documents #2 and #4 are different, but the same RenderFrameHost is
     23  // used before https://crbug.com/936696 is done.
     24 
     25  await win.forceSinglePrefetch(nextUrl);
     26 
     27  // Register a SW for `nextUrl` -- this is a trick to make the prefetched
     28  // result to put in `PrefetchService::prefetches_ready_to_serve_` in
     29  // Chromium implementation but actually not used by this navigation.
     30  const r = await service_worker_unregister_and_register(
     31      t, 'resources/sw.js', nextUrl);
     32  await wait_for_state(t, r.installing, 'activated');
     33 
     34  // Navigate #1 -> #2.
     35  // This doesn't use the prefetched result due to the ServiceWorker.
     36  await win.navigate(nextUrl);
     37 
     38  // Unregister the SW.
     39  await service_worker_unregister(t, nextUrl);
     40 
     41  // Navigate #2 -> #3 -> #4.
     42  const tempUrl = win.getExecutorURL({ protocol: 'https', page: 3 });
     43  await win.navigate(tempUrl);
     44  await win.navigate(nextUrl);
     45 
     46  const headers = await win.execute_script(() => {
     47    return requestHeaders;
     48  }, []);
     49  assert_not_prefetched(headers,
     50      "Prefetch should not work for different initiators.");
     51 }, "Prefetches from different initiator Documents with same RenderFrameHost");
     52 </script>