tor-browser

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

commit 631b1cd7b76395fccb98bb2081bfb2b60f421950
parent 04285ccad74dc0766778495a5c6a486b2a1887ca
Author: Timothy Nikkel <tnikkel@gmail.com>
Date:   Tue,  4 Nov 2025 05:57:12 +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:
Mgfx/layers/apz/test/mochitest/apz_test_native_event_utils.js | 16++++++++++------
1 file changed, 10 insertions(+), 6 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; } @@ -338,7 +340,9 @@ async function coordinatesRelativeToScreen(aParams) { const rect = _getTargetRect(target); - const utils = SpecialPowers.getDOMWindowUtils(getInProcessRootWindow(window)); + const utils = SpecialPowers.wrap( + SpecialPowers.getDOMWindowUtils(getInProcessRootWindow(window)) + ); const positionInScreenCoords = utils.toScreenRect( rect.left + (atCenter ? rect.width / 2 : offsetX), rect.top + (atCenter ? rect.height / 2 : offsetY),