tor-browser

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

fetch-destination-prefetch.https.html (1598B)


      1 <!DOCTYPE html>
      2 <title>Fetch destination test for prefetching</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="/common/media.js"></script>
      7 <script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
      8 <script>
      9 let frame;
     10 
     11 // Set up the service worker and the frame.
     12 promise_test(t => {
     13    const kScope = 'resources/empty.https.html';
     14    const kScript = 'resources/fetch-destination-worker.js';
     15    return service_worker_unregister_and_register(t, kScript, kScope)
     16      .then(registration => {
     17          add_completion_callback(() => {
     18              registration.unregister();
     19            });
     20 
     21          return wait_for_state(t, registration.installing, 'activated');
     22        })
     23      .then(() => {
     24          return with_iframe(kScope);
     25        })
     26      .then(f => {
     27          frame = f;
     28          add_completion_callback(() => { f.remove(); });
     29        });
     30  }, 'Initialize global state');
     31 
     32 // HTMLLinkElement with rel=prefetch - empty string destination
     33 promise_test(async t => {
     34  await new Promise((resolve, reject) => {
     35      let node = frame.contentWindow.document.createElement("link");
     36      node.rel = "prefetch";
     37      node.onload = resolve;
     38      node.onerror = reject;
     39      node.href = "dummy?dest=";
     40      frame.contentWindow.document.body.appendChild(node);
     41  }).catch(() => {
     42      assert_unreached("Fetch errored.");
     43  });
     44 }, 'HTMLLinkElement with rel=prefetch fetches with an empty string Request.destination');
     45 
     46 </script>