tor-browser

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

helper_hittest_obscuration.html (2164B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test hit-testing on content which is revealed by async 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  <meta name="viewport" content="width=device-width"/>
      9  <style>
     10    #parent {
     11      width: 400px;
     12      height: 400px;
     13      overflow: auto;
     14    }
     15    #child {
     16      margin-top: 200px;
     17      width: 100%;
     18      height: 100px;
     19      overflow: auto;
     20    }
     21    #obscurer {
     22      position: absolute;
     23      top: 200px;
     24      width: 400px;
     25      height: 200px;
     26      background: blue;
     27    }
     28    .spacer {
     29      width: 100%;
     30      height: 1000px;
     31      background: green;
     32    }
     33  </style>
     34 </head>
     35 <body>
     36  <div id="parent">
     37    <div id="child">
     38      <div class="spacer"></div>
     39    </div>
     40    <div class="spacer"></div>
     41  </div>
     42  <div id="obscurer"></div>
     43 </body>
     44 <script type="application/javascript">
     45 
     46 async function test() {
     47  var config = getHitTestConfig();
     48  var utils = config.utils;
     49 
     50  // Create APZCs for parent and child scrollers.
     51  let parent = document.getElementById("parent");  // otherwise parent refers to window.parent
     52  utils.setDisplayPortForElement(0, 0, 400, 1000, parent, 1);
     53  utils.setDisplayPortForElement(0, 0, 400, 1000, child, 1);
     54  await promiseApzFlushedRepaints();
     55 
     56  // Async-scroll the parent scroller by 100 pixels, thereby revealing
     57  // the child which was previous covered by "obscurer".
     58  utils.setAsyncScrollOffset(parent, 0, 100);
     59  // Give WebRender a chance to sample the test async scroll offset.
     60  utils.advanceTimeAndRefresh(16);
     61  utils.restoreNormalRefresh();
     62 
     63  // Check that hit-testing on the region where the child scroller's
     64  // contents are now revealed, successfully hits the scroller.
     65  checkHitResult(hitTest({x: 200, y: 150}),
     66                 APZHitResultFlags.VISIBLE,
     67                 utils.getViewId(child),
     68                 utils.getLayersId(),
     69                 "child scroller");
     70 }
     71 
     72 waitUntilApzStable()
     73 .then(test)
     74 .then(subtestDone, subtestFailed);
     75 
     76 </script>
     77 </html>