summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective-2.html
blob: 9838a02aa93c3ddd22ad5c47d90fb5bfb76f102b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<head>
  <meta name="viewport" content="width=device-width; initial-scale=1.0">
  <title>Test that events are delivered to the correct document near an iframe inide a perspective transform</title>
  <script src="apz_test_native_event_utils.js"></script>
  <script src="apz_test_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <style>
    div {
      position: absolute;
    }
    .outer {
      left: 300px;
      top: 300px;
      transform: translate3d(0px, 0px, -500px) perspective(500px);
    }
    .inner {
      left: -100px;
      top: -100px;
    }
    iframe {
      border: 0;
    }
  </style>
</head>
<body>
  <div class="outer">
    <div class="inner">
      <iframe id="iframe" width="300px" height="200px" src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_hittest_iframe_perspective_child.html"></iframe>
    </div>
  </div>
  <script type="application/javascript">
async function test() {
  // Wait for iframe to receive content transforms.
  await SpecialPowers.spawn(iframe, [], async () => {
    await SpecialPowers.contentTransformsReceived(content.window);
  });

  let eventPromise = new Promise(resolve => {
    window.addEventListener("message", event => {
      let data = JSON.parse(event.data);
      if ("type" in data && data.type == "got-mouse-down") {
        ok(false, "Child document should not have received mouse-down");
        resolve();
      }
    });

    window.addEventListener("mousedown", event => {
      ok(true, "Parent document should have received mouse-down");
      resolve();
    });
  });

  // Click a bit above the iframe, and check the event is delivered
  // to the parent document, not the iframe.
  await synthesizeNativeMouseEventWithAPZ({
    type: "click",
    target: document.documentElement,
    offsetX: 350,
    offsetY: 175
  });
  await eventPromise;
}

waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);

  </script>
</body>