tor-browser

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

helper_fixed_html_hittest.html (2000B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <meta name="viewport" content="width=device-width">
      6  <title>Hittest position:fixed zoomed scroll</title>
      7  <script type="application/javascript" src="apz_test_utils.js"></script>
      8  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
      9  <script src="/tests/SimpleTest/paint_listener.js"></script>
     10  <style>
     11    html {
     12      position: fixed;
     13    }
     14    body {
     15      margin: 0;
     16    }
     17    #fixed {
     18      position: fixed;
     19      top: 100px;
     20      left: 100px;
     21    }
     22  </style>
     23 </head>
     24 <body>
     25  <div id="fixed"><input type="button" value="Button" /></div>
     26  <script>
     27    async function test() {
     28      // Create an offset between the visual and layout viewports.
     29      // The offset is 50 CSS pixels = 100 screen pixels at 2x zoom
     30      // in either direction.
     31      let transformEndPromise = promiseTransformEnd();
     32      await synthesizeNativeTouchDrag(document.body, 10, 10, -50, -50);
     33      await transformEndPromise;
     34 
     35      await promiseApzFlushedRepaints();
     36 
     37      let clickPromise = new Promise(resolve => {
     38        window.addEventListener("click", resolve);
     39      });
     40      let input = document.querySelector("input");
     41      // Provide the input in window-relative coordinates,
     42      // otherwise coordinatesRelativeToScreen() will run into the
     43      // same bug as the hit-test, and the two bugs cancel out.
     44      await synthesizeNativeMouseEventWithAPZ({
     45        type: "click",
     46        target: window,
     47        // The visual viewport is already offset (50, 50) CSS pixels
     48        // into the layout viewport. An additional (50, 50) CSS pixels
     49        // gives us (100, 100), the offset of #fixed, in total.
     50        offsetX: 55,
     51        offsetY: 55
     52      });
     53      let e = await clickPromise;
     54      is(e.target, input, "got click");
     55    }
     56 
     57    SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0);
     58    waitUntilApzStable().then(test).then(subtestDone, subtestFailed);
     59  </script>
     60 </body>
     61 </html>