tor-browser

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

restriction-message-boxes.https.html (1625B)


      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="../resources/utils.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 <script>
     11 setup(() => assertSpeculationRulesIsSupported());
     12 
     13 function runTest(test_file, expectation, description) {
     14  promise_test(async t => {
     15    const uid = token();
     16    const bc = new PrerenderChannel('prerender-channel', uid);
     17    t.add_cleanup(_ => bc.close());
     18 
     19    const gotMessage = new Promise(resolve => {
     20      bc.addEventListener('message', e => {
     21        resolve(e.data);
     22      }, {
     23        once: true
     24      });
     25    });
     26 
     27    // Open a new window to test the message box.
     28    window.open(`${test_file}&uid=${uid}`, '_blank', 'noopener');
     29 
     30    // Wait for the message from the prerendering page.
     31    assert_equals(await gotMessage, expectation);
     32  }, description);
     33 }
     34 
     35 // Test that a page invokes the alert modal during prerendering.
     36 runTest(
     37    'resources/message-boxes.html?alert',
     38    'no block',
     39    'alert() does not display the modal and returns immediately');
     40 
     41 // Test that a page invokes the confirm modal during prerendering.
     42 runTest(
     43    'resources/message-boxes.html?confirm',
     44    'the return value is no',
     45    'confirm() does not display the modal and returns immediately');
     46 
     47 // Test that a page invokes the prompt modal during prerendering.
     48 runTest(
     49    'resources/message-boxes.html?prompt',
     50    'the return value is null',
     51    'prompt() does not display the modal and returns immediately');
     52 </script>