tor-browser

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

helper_doubletap_zoom_htmlelement.html (2573B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=2100"/>
      6  <title>Check that double tapping on a scrollbar does not scroll to top</title>
      7  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      8  <script type="application/javascript" src="apz_test_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <script type="application/javascript">
     11 
     12 async function test() {
     13  let useTouchpad = (location.search == "?touchpad");
     14 
     15  var resolution = await getResolution();
     16  var start_resolution = resolution;
     17  ok(resolution > 0,
     18     "The initial_resolution is " + resolution + ", which is some sane value");
     19 
     20  // Check that double-tapping once zooms in
     21  await doubleTapOn(document.getElementById("target"), 10, 10, useTouchpad);
     22  var prev_resolution = resolution;
     23  resolution = await getResolution();
     24  ok(resolution > prev_resolution, "The first double-tap has increased the resolution to " + resolution);
     25 
     26  // instant scroll to the middle of the page
     27  window.scrollTo({
     28    top: 4 * window.innerHeight,
     29    left: 0,
     30    behavior: 'auto'
     31  });
     32 
     33  await promiseApzFlushedRepaints();
     34 
     35  let prevScrollX = window.scrollX;
     36  let prevScrollY = window.scrollY;
     37 
     38  ok(3.9 * window.innerHeight < window.scrollY && window.scrollY < 4.1 * window.innerHeight,
     39    "scrollY looks good");
     40 
     41  // Check that double-tapping on the bottom scrollbar does not scroll us to the top
     42  // Need to divide by resolution because the coords are assumed to be inside the resolution
     43  await doubleTapOn(window, (window.innerWidth/2)/resolution, (window.innerHeight - 5)/resolution, useTouchpad);
     44  prev_resolution = resolution;
     45  resolution = await getResolution();
     46  ok(resolution < prev_resolution, "The second double-tap has decreased the resolution to " + resolution);
     47  ok(resolution == start_resolution, "The second double-tap has decreased the resolution to the start to " + resolution);
     48 
     49  info("prevscroll " + prevScrollX + " " + prevScrollY + "\n");
     50  info("window.scroll " + window.scrollX + " " + window.scrollY + "\n");
     51 
     52  ok(0.88*prevScrollY < window.scrollY && window.scrollY < prevScrollY*1.12, "scroll y didn't change by much");
     53 }
     54 
     55 waitUntilApzStable()
     56 .then(test)
     57 .then(subtestDone, subtestFailed);
     58 
     59  </script>
     60  <style type="text/css">
     61    .spacer {
     62      background-color: #eee;
     63      width: 10px;
     64      height: 800vh;
     65    }
     66 </style>
     67 </head>
     68 <body>
     69 
     70 <div id="target" style="width: 100px; height: 100px; background: red;">
     71 </div>
     72 <div class="spacer">
     73 </div>
     74 
     75 </body>
     76 </html>