tor-browser

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

restriction-prompt-by-before-unload.https.html (1187B)


      1 <!DOCTYPE html>
      2 <title>Prerendering cannot invoke the prompt generated by the
      3       beforeunload event</title>
      4 <meta name="timeout" content="long">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/common/utils.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(async t => {
     16  const uid = token();
     17  const bc = new PrerenderChannel('prerender-channel', uid);
     18  t.add_cleanup(_ => bc.close());
     19 
     20  const gotMessage = new Promise(resolve => {
     21    bc.addEventListener('message', e => {
     22      resolve(e.data);
     23    }, {
     24      once: true
     25    });
     26  });
     27  // Start prerendering a page that attempts to invoke
     28  // the prompt generated by the beforeunload event.
     29  // It is activation-gated and expects to fail.
     30  startPrerendering(`resources/prompt-by-before-unload.html?uid=${uid}`);
     31 
     32  const result = await gotMessage;
     33  assert_equals(result,
     34                'unloaded without the prompt by beforeunload.');
     35 }, 'Prerendering cannot invoke the prompt by the beforeunload event.');
     36 </script>