commit 2132f219cb77ce83611db4aac4bcfd2362e63b98
parent fe245261056488655d56e5d1a24d7e2fb24a3c0f
Author: Timothy Nikkel <tnikkel@gmail.com>
Date: Mon, 3 Nov 2025 04:51:54 +0000
Bug 1997722. Allow coordinatesRelativeToScreen in apz_test_native_event_utils.js to always be able to walk up the in process document hierarchy. r=hiro
The test for bug 1995207 re-creates a situation where we have a root content document that is in the parent process (because that is what happens with about:preferences). For some reason this prevents ownerDocument.defaultView.frameElement from working across the content/chrome boundary, even with SpecialPowers.wrap. Going through browsingContext.embedderElement works though. I added SpecialPowers.wrap just in case.
Differential Revision: https://phabricator.services.mozilla.com/D270949
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
@@ -240,8 +240,10 @@ function _getTargetRect(aTarget) {
// Iterate up the window hierarchy until we reach the root
// content window, adding the offsets of any iframe windows
// relative to their parent window.
- while (aTarget.ownerDocument.defaultView.frameElement) {
- const iframe = aTarget.ownerDocument.defaultView.frameElement;
+ aTarget = SpecialPowers.wrap(aTarget);
+ while (aTarget.ownerDocument.defaultView.browsingContext.embedderElement) {
+ const iframe =
+ aTarget.ownerDocument.defaultView.browsingContext.embedderElement;
// The offset of the iframe window relative to the parent window
// includes the iframe's border, and the iframe's origin in its
// containing document.
@@ -283,9 +285,9 @@ function _getTargetRect(aTarget) {
// Returns the in-process root window for the given |aWindow|.
function getInProcessRootWindow(aWindow) {
- let window = aWindow;
- while (window.frameElement) {
- window = window.frameElement.ownerDocument.defaultView;
+ let window = SpecialPowers.wrap(aWindow);
+ while (window.browsingContext.embedderElement) {
+ window = window.browsingContext.embedderElement.ownerDocument.defaultView;
}
return window;
}