tor-browser

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

sxg-double-prefetch.tentative.html (1232B)


      1 <!DOCTYPE html>
      2 <title>Prefetching double SignedHTTPExchange files must not crash</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/sxg-util.js"></script>
      7 <body>
      8 <script>
      9 function addPrefetch(url) {
     10  let link = document.createElement('link');
     11  link.rel = 'prefetch';
     12  link.href = url;
     13  document.body.appendChild(link);
     14 }
     15 promise_test(async (t) => {
     16  const sxg1_url =
     17      get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg/sxg-location.sxg?1';
     18  const sxg2_url =
     19      get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg/sxg-location.sxg?2';
     20  addPrefetch(sxg1_url);
     21  addPrefetch(sxg2_url);
     22  await new Promise(resolve => {
     23    setInterval(() => {
     24      const entries = performance.getEntriesByType("resource");
     25      let hit_count = 0;
     26      for (let i = 0; i < entries.length; ++i) {
     27        const entry = entries[i];
     28        if (entry.name == sxg1_url || entry.name == sxg2_url) {
     29          if (++hit_count == 2)
     30            resolve();
     31        }
     32      }
     33    }, 100);
     34  });
     35 }, 'Prefetching double SignedHTTPExchange files must not crash');
     36 </script>
     37 </body>