summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/file_pointercapture_xorigin_iframe.html
blob: 88690748e54feffc1bef3d1658ab495eafca0b98 (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1671849
-->
<head>
<title>Bug 1671849</title>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="pointerevent_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
#target {
  width: 100px;
  height: 100px;
  background-color: green;
}
iframe {
  width: 400px;
  height: 300px;
  border: 1px solid blue;
}
</style>
</head>
<body>
<a target="_blank"href="https://bugzilla.mozilla.org/show_bug.cgi?id=1671849">Mozilla Bug 1671849</a>
<div id="target"></div>
<iframe src="https://example.com/tests/dom/events/test/pointerevents/iframe.html"></iframe>

<pre id="test">
<script type="text/javascript">
/**
 * Test for Bug 1671849
 */
add_task(async function test_pointer_capture_xorigin_iframe() {
  let iframe = document.querySelector("iframe");
  await SpecialPowers.spawn(iframe.contentWindow, [], () => {
    let unexpected = function(e) {
      ok(false, `iframe shoule not get any ${e.type} event`);
    };
    content.document.body.addEventListener("pointermove", unexpected);
    content.document.body.addEventListener("pointerup", unexpected);
  });

  let target = document.getElementById("target");
  synthesizeMouse(target, 10, 10, { type: "mousedown" });
  await waitForEvent(target, "pointerdown", function(e) {
    target.setPointerCapture(e.pointerId);
  });

  synthesizeMouse(iframe, 10, 10, { type: "mousemove" });
  await Promise.all([waitForEvent(target, "gotpointercapture"),
                     waitForEvent(target, "pointermove")]);

  synthesizeMouse(iframe, 10, 10, { type: "mouseup" });
  await Promise.all([waitForEvent(target, "lostpointercapture"),
                     waitForEvent(target, "pointerup")]);
});
</script>
</pre>
</body>
</html>