Skip to content

Commit 1a5b135

Browse files
masayuki-nakanomoz-wptsync-bot
authored andcommitted
Make Event::GetPrimaryFrameOfEventTarget return nullptr if target is moved outside the original `nsPresContext
Chrome returns some computed value for `offsetX` and `offsetY` even in this hacky case, but we should return `{0, 0}` for now to keep the traditional behavior [1] and avoid the crash because Chrome's behavior is also tricky because they cache offset values at first access. Let's change the behavior in a separated bug. 1. https://searchfox.org/mozilla-central/rev/80343eb85f0bda693730a394496ce66e48eae561/dom/events/Event.cpp#683,702-704 Differential Revision: https://phabricator.services.mozilla.com/D237172 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1946461 gecko-commit: c9b281a867f33bb3aa88dd8318abe1c50d22e81d gecko-reviewers: smaug, emilio
1 parent 54db559 commit 1a5b135

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!doctype html>
2+
<html class="test-wait">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Retrieve coordinates after event target is moved to outside the subdocument and hide the subdocument</title>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-vendor.js"></script>
8+
<script>
9+
"use strict";
10+
11+
addEventListener("load", async () => {
12+
const iframe = document.querySelector("iframe");
13+
const div = iframe.contentDocument.getElementById("target");
14+
let clickEvent;
15+
div.addEventListener("click", event => clickEvent = event, {once: true});
16+
await test_driver.click(div);
17+
document.body.appendChild(div);
18+
iframe.hidden = true;
19+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
20+
div.innerText = clickEvent.screenX;
21+
div.innerText = clickEvent.screenY;
22+
div.innerText = clickEvent.clientX;
23+
div.innerText = clickEvent.clientY;
24+
div.innerText = clickEvent.offsetX;
25+
div.innerText = clickEvent.offsetY;
26+
div.innerText = clickEvent.pageX;
27+
div.innerText = clickEvent.pageY;
28+
div.innerText = clickEvent.layerX;
29+
div.innerText = clickEvent.layerY;
30+
document.documentElement.removeAttribute("class");
31+
}, {once: true});
32+
</script>
33+
</head>
34+
<body>
35+
<iframe srcdoc="<body><div id='target' style='height:32px'></div></body>"></iframe>
36+
</body>
37+
</html>

0 commit comments

Comments
 (0)