tor-browser

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

restriction-window-resize.https.html (1710B)


      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 // ResizeTo and ResizeBy operations should be ignored.
     14 // See https://github.com/jeremyroman/alternate-loading-modes/issues/73.
     15 ['resizeTo', 'resizeBy'].forEach(resizeFunc => {
     16  promise_test(
     17      async t => {
     18        const uid = token();
     19        const bc = new PrerenderChannel('test-channel', uid);
     20        t.add_cleanup(_ => bc.close());
     21 
     22        const gotMessage = new Promise(resolve => {
     23          bc.addEventListener('message', e => {
     24            resolve(e.data);
     25          }, {once: true});
     26        });
     27 
     28        const url = `resources/window-resize.html?resize=${resizeFunc}&uid=${uid}`;
     29 
     30        // We have to open a new window to run the test, since a window that was
     31        // not created by window.open() cannot be resized.
     32        window.open(
     33            url, '_blank',
     34            `width=${window.screen.availWidth / 2},height=${
     35                window.screen.availHeight / 2},noopener`);
     36 
     37        const result = await gotMessage;
     38        assert_equals(result.status, 'PASS');
     39        assert_equals(
     40            result.prevRect.width, result.newRect.width,
     41            'width for prerendering');
     42        assert_equals(
     43            result.prevRect.height, result.newRect.height,
     44            'height for prerendering');
     45      },
     46      `a prerendering page cannot resize its window by executing ${
     47          resizeFunc}.`);
     48 });
     49 </script>