tor-browser

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

helper_horizontal_checkerboard.html (2180B)


      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 during horizontal scrolling</title>
      5 <script type="application/javascript" src="apz_test_utils.js"></script>
      6 <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      7 <script src="/tests/SimpleTest/paint_listener.js"></script>
      8 <style>
      9 
     10 .scrollbox {
     11  margin: 50px;
     12  border: 2px solid black;
     13  background: red;
     14  width: 1120px;
     15  height: 200px;
     16  overflow: auto;
     17 }
     18 
     19 .scrolled {
     20  width: 20000px;
     21  height: 200px;
     22  background: lime;
     23 }
     24 
     25 </style>
     26 
     27 </head><body>
     28  <div class="scrollbox"><div class="scrolled"></div></div>
     29 </body>
     30 
     31 <script type="application/javascript">
     32 async function test() {
     33  var scroller = document.querySelector(".scrollbox");
     34  var utils = SpecialPowers.getDOMWindowUtils(window);
     35  var scrollerId = utils.getViewId(scroller);
     36 
     37  // This test contains a wide horizontal scroll box and scrolls it horizontally
     38  // from right to left. The size of the box is chosen so that the displayport
     39  // snapping logic in nsLayoutUtils.cpp would tries an horizontal alignment larger
     40  // than the margins. In such a situation we want to make sure the displayport
     41  // alignment is adjusted so we don't snap too far which would cause content to
     42  // be missed on the right side.
     43 
     44  // The scroll values here just need to be "thorough" enough to exercise the
     45  // code at different alignments, so using a non-power-of-two or prime number
     46  // for the increment seems like a good idea. The smaller the increment, the
     47  // longer the test takes to run (because more iterations) so we don't want it
     48  // too small either.
     49  // The scroll box is rather wide so we only scroll a portion of it so that the
     50  // test doesn't run for too long.
     51  var maxX = scroller.scrollLeftMax / 6;
     52  for (var x = maxX; x > 0; x -= 71) {
     53    dump(`Scrolling scroller to ${x}\n`);
     54    scroller.scrollTo(x, 0);
     55    await promiseApzFlushedRepaints();
     56    assertNotCheckerboarded(utils, scrollerId, `At x=${x}`);
     57  }
     58 }
     59 
     60 waitUntilApzStable()
     61 .then(test)
     62 .then(subtestDone, subtestFailed);
     63 
     64 </script>
     65 </html>