tor-browser

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

restriction-window-move.https.html (1695B)


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