tor-browser

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

accept-client-hint-cache.https.html (1378B)


      1 <!DOCTYPE html>
      2 <title>Test Prerender pages maintain their own Client Hint Caches</title>
      3 <meta name="timeout" content="long">
      4 <script src="/common/utils.js"></script>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/client-hints/resources/open-and-add-load-event.js"></script>
      8 <script src="../resources/utils.js"></script>
      9 <script src="resources/utils.js"></script>
     10 
     11 <body>
     12 <script>
     13 setup(() => assertSpeculationRulesIsSupported());
     14 
     15 promise_test(
     16  async t => {
     17    const uid = token();
     18    const initialization_bc = new PrerenderChannel(`test-channel`, uid);
     19    t.add_cleanup(_ => initialization_bc.close());
     20 
     21    const gotMessage = new Promise(resolve => {
     22      initialization_bc.addEventListener('message', e => {
     23        resolve(e.data);
     24      }, {once: true});
     25    });
     26 
     27    // Initialization. For the active pages, it has the client hint cache of
     28    // "sec-ch-ua-bitness".
     29    await open_and_add_load_event('resources/accept-ch.html');
     30    window.open(
     31        `resources/echo-client-hints-received.py?uid=${uid}`, '_blank',
     32        'noopener');
     33 
     34    const result = await gotMessage;
     35    assert_equals(result.result, 'PASSED', result.reason);
     36  },
     37  'Prerender page should maintain their own client hints cache and do not propagate it to' +
     38      'the global cache until activation');
     39 
     40 </script>