tor-browser

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

restriction-window-open.https.html (1365B)


      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    // Run test in a new window for test isolation.
     17    window.open(`${test_file}?uid=${uid}`, '_blank', 'noopener');
     18 
     19    // Wait until the prerendered page sends the result.
     20    const bc = new PrerenderChannel('result', uid);
     21    t.add_cleanup(() => {
     22      new PrerenderChannel('close', uid).postMessage('close');
     23    })
     24    const result = await new Promise(r => bc.addEventListener('message', e => r(e.data)));
     25    assert_equals(result, expectation);
     26  }, description);
     27 }
     28 
     29 // Test that a page opens a window during prerendering.
     30 runTest(
     31    'resources/window-open-during-prerendering.html',
     32    'failed to open',
     33    'window.open() should fail during prerendering');
     34 
     35 // Test that a page opens a window in the prerenderingchange event.
     36 runTest(
     37    'resources/window-open-in-prerenderingchange.html',
     38    'opened',
     39    'window.open() should succeed in the prerenderingchange event');
     40 </script>