tor-browser

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

helper_checkerboard_no_multiplier.html (2326B)


      1 <!DOCTYPE html>
      2 <html lang="en"><head>
      3 <meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8">
      4 <title>Testcase for checkerboarding with displayport multipliers dropped to zero</title>
      5 <script type="application/javascript" src="apz_test_utils.js"></script>
      6 <script src="/tests/SimpleTest/paint_listener.js"></script>
      7 <meta name="viewport" content="width=device-width"/>
      8 <style>
      9 body, html {
     10    margin: 0;
     11 }
     12 </style>
     13 <body>
     14 <div style="height: 5000px; background-color: green"></div>
     15 </body>
     16 <script type="application/javascript">
     17 async function test() {
     18  var utils = SpecialPowers.getDOMWindowUtils(window);
     19  var scrollerId = utils.getViewId(document.scrollingElement);
     20 
     21  // Zoom in a bunch
     22  const scale = 3.0;
     23  utils.setResolutionAndScaleTo(scale);
     24 
     25  // And now we scroll the visual viewport to cover the range it has inside
     26  // the layout viewport, plus a bit more so that we also cover the boundary
     27  // case where the layout viewport has to move.
     28  // At each scroll position, we make sure there's no checkerboarding.
     29  // We advance the scroll position on each axis by 43 CSS pixels at a time,
     30  // because 43 is a non-power-of-two/prime number and should give us reasonable
     31  // coverage of different displayport tile alignment values. Making the
     32  // increment too small increases runtime and too large might miss some
     33  // alignment values so this seems like a good number.
     34 
     35  async function scrollAndCheck(x, y) {
     36    dump(`Scrolling visual viewport to ${x}, ${y}\n`);
     37    utils.scrollToVisual(x, y, utils.UPDATE_TYPE_MAIN_THREAD, utils.SCROLL_MODE_INSTANT);
     38    await promiseApzFlushedRepaints();
     39    assertNotCheckerboarded(utils, scrollerId, `At ${x}, ${y}`);
     40  }
     41 
     42  let vv_scrollable_x = window.innerWidth - (window.innerWidth / scale);
     43  for (var x = 0; x < vv_scrollable_x + 100; x += 43) {
     44    await scrollAndCheck(x, 0);
     45  }
     46  ok(window.scrollX == 0, "Layout viewport couldn't move on the x-axis, page not scrollable that way");
     47  let vv_scrollable_y = window.innerHeight - (window.innerHeight / scale);
     48  for (var y = 0; y < vv_scrollable_y + 100; y += 43) {
     49    await scrollAndCheck(0, y);
     50  }
     51  ok(window.scrollY > 0, `Layout viewport moved down to ${window.scrollY} on the y-axis`);
     52 }
     53 
     54 waitUntilApzStable()
     55 .then(test)
     56 .then(subtestDone, subtestFailed)
     57 </script>