tor-browser

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

helper_hittest_iframe_perspective-4.html (2219B)


      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1888904
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <meta name="viewport" content="width=device-width; initial-scale=1.0">
      9  <title>Test that events are delivered with correct coordinates to an iframe inide a no-op perspective transform</title>
     10  <script src="apz_test_native_event_utils.js"></script>
     11  <script src="apz_test_utils.js"></script>
     12  <script src="/tests/SimpleTest/paint_listener.js"></script>
     13  <style>
     14  html, body {
     15    margin: 0;
     16    padding: 0;
     17  }
     18  iframe {
     19    border: 0;
     20    background-color: blue;
     21  }
     22  .modal-dialog {
     23    position: absolute;
     24    top: 500px;
     25    left: 500px;
     26    transform: translate(-50%, -50%);
     27    border: 1px solid black;
     28  }
     29  .item {
     30    perspective: 1000px;
     31    transform: translate3d(0, 0, 0);
     32  }
     33  .g-recaptcha {
     34    transform-origin: 0 0;
     35    transform: scale(0.91);
     36  }
     37  </style>
     38 </head>
     39 <body>
     40  <div class="modal-dialog">
     41    <div class="item">
     42      <div class="g-recaptcha">
     43        <iframe id="iframe" src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective_child.html"></iframe>
     44      </div>
     45    </div>
     46      </div>
     47    </div>
     48  </div>
     49  <script type="application/javascript">
     50 async function test() {
     51  // Wait for iframe to receive content transforms.
     52  await SpecialPowers.spawn(iframe, [], async () => {
     53    await SpecialPowers.contentTransformsReceived(content.window);
     54  });
     55 
     56  let clickCoordsInChild = {
     57    offsetX: 0,
     58    offsetY: 0
     59  };
     60  let childMessagePromise = new Promise(resolve => {
     61    window.addEventListener("message", event => {
     62      let data = JSON.parse(event.data);
     63      if ("type" in data && data.type == "got-mouse-down") {
     64        clickCoordsInChild = data.coords;
     65        resolve();
     66      }
     67    })
     68  });
     69  await synthesizeNativeMouseEventWithAPZ({
     70    type: "click",
     71    target: iframe,
     72    offsetX: 100,
     73    offsetY: 100
     74  });
     75  await childMessagePromise;
     76  is(clickCoordsInChild.offsetX, 110 /* 100 / 0.91 */, "x coordinate is correct");
     77  is(clickCoordsInChild.offsetY, 110 /* 100 / 0.91 */, "y coordinate is correct");
     78 }
     79 
     80 waitUntilApzStable()
     81 .then(test)
     82 .then(subtestDone, subtestFailed);
     83 
     84  </script>
     85 </body>
     86 </html>