tor-browser

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

helper_zoom_keyboardscroll.html (2789B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width, minimum-scale=1.0">
      6  <title>Tests that keyboard arrow keys scroll after zooming in when there was no scrollable overflow before zooming</title>
      7  <script src="/tests/SimpleTest/EventUtils.js"></script>
      8  <script type="application/javascript" src="apz_test_utils.js"></script>
      9  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
     10  <script src="/tests/SimpleTest/paint_listener.js"></script>
     11 </head>
     12 <body>
     13  <div style="height: 20000px; background-color: green"></div>
     14  <script type="application/javascript">
     15    const utils = SpecialPowers.getDOMWindowUtils(window);
     16 
     17    async function test() {
     18      is(await getResolution(), 1.0, "should not be zoomed (1)");
     19 
     20      is(window.scrollX, 0, "shouldn't have scrolled (2)");
     21      is(window.scrollY, 0, "shouldn't have scrolled (3)");
     22      is(visualViewport.pageTop, 0, "shouldn't have scrolled (4)");
     23      is(visualViewport.pageLeft, 0, "shouldn't have scrolled (5)");
     24 
     25      // Zoom in
     26      SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     27      await promiseApzFlushedRepaints();
     28      await promiseFrame();
     29 
     30      is(await getResolution(), 2.0, "should have zoomed (6)");
     31 
     32      is(window.scrollX, 0, "shouldn't have scrolled (7)");
     33      is(window.scrollY, 0, "shouldn't have scrolled (8)");
     34      is(visualViewport.pageTop, 0, "shouldn't have scrolled (9)");
     35      is(visualViewport.pageLeft, 0, "shouldn't have scrolled (10)");
     36 
     37      window.synthesizeKey("KEY_ArrowRight");
     38 
     39      await promiseApzFlushedRepaints();
     40      await promiseFrame();
     41 
     42      is(await getResolution(), 2.0, "should be zoomed (11)");
     43 
     44      is(window.scrollX, 0, "shouldn't have scrolled (12)");
     45      is(window.scrollY, 0, "shouldn't have scrolled (13)");
     46      is(visualViewport.pageTop, 0, "shouldn't have scrolled (14)");
     47      isnot(visualViewport.pageLeft, 0, "should have scrolled (15)");
     48 
     49      window.synthesizeKey("KEY_ArrowDown");
     50 
     51      await promiseApzFlushedRepaints();
     52      await promiseFrame();
     53 
     54      is(await getResolution(), 2.0, "should be zoomed (16)");
     55 
     56      is(window.scrollX, 0, "shouldn't have scrolled (17)");
     57      is(window.scrollY, 0, "shouldn't have scrolled (18)");
     58      isnot(visualViewport.pageTop, 0, "should have scrolled (19)");
     59      isnot(visualViewport.pageLeft, 0, "should have scrolled (20)");
     60 
     61      // Zoom back out
     62      SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(1.0);
     63      await promiseApzFlushedRepaints();
     64      await promiseFrame();
     65 
     66      is(await getResolution(), 1.0, "should not be zoomed (21)");
     67    }
     68 
     69    waitUntilApzStable()
     70    .then(test)
     71    .then(subtestDone, subtestFailed);
     72  </script>
     73 </body>
     74 </html>