tor-browser

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

helper_hittest_iframe_perspective-3.html (1891B)


      1 <head>
      2  <meta name="viewport" content="width=device-width; initial-scale=1.0">
      3  <title>Test that events are delivered with correct coordinates to an iframe inide a perspective transform</title>
      4  <script src="apz_test_native_event_utils.js"></script>
      5  <script src="apz_test_utils.js"></script>
      6  <script src="/tests/SimpleTest/paint_listener.js"></script>
      7  <style>
      8  html, body {
      9    margin: 0;
     10    padding: 0;
     11  }
     12  #outer {
     13    margin-top: 50px;
     14    margin-left: 50px;
     15    perspective: 500px;
     16  }
     17  #inner {
     18    transform: translate3d(0,0,-100px);
     19    transform-style: preserve-3d;
     20  }
     21  iframe {
     22    border: 0;
     23    background-color: blue;
     24    transform: translate3d(0,0,100px);
     25  }
     26  </style>
     27 </head>
     28 <body>
     29  <div id="outer">
     30    <div id="inner">
     31      <iframe id="iframe" src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective_child.html"></iframe>
     32    </div>
     33  </div>
     34  <script type="application/javascript">
     35 async function test() {
     36  // Wait for iframe to receive content transforms.
     37  await SpecialPowers.spawn(iframe, [], async () => {
     38    await SpecialPowers.contentTransformsReceived(content.window);
     39  });
     40 
     41  let clickCoordsInChild = {
     42    offsetX: 0,
     43    offsetY: 0
     44  };
     45  let childMessagePromise = new Promise(resolve => {
     46    window.addEventListener("message", event => {
     47      let data = JSON.parse(event.data);
     48      if ("type" in data && data.type == "got-mouse-down") {
     49        clickCoordsInChild = data.coords;
     50        resolve();
     51      }
     52    })
     53  });
     54  await synthesizeNativeMouseEventWithAPZ({
     55    type: "click",
     56    target: outer,
     57    offsetX: 100,
     58    offsetY: 100
     59  });
     60  await childMessagePromise;
     61  is(clickCoordsInChild.offsetX, 100, "x coordinate is correct");
     62  is(clickCoordsInChild.offsetY, 100, "y coordinate is correct");
     63 }
     64 
     65 waitUntilApzStable()
     66 .then(test)
     67 .then(subtestDone, subtestFailed);
     68 
     69  </script>
     70 </body>