From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- devtools/server/actors/targets/window-global.js | 59 ++++++++++++++++--------- 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'devtools/server/actors/targets/window-global.js') diff --git a/devtools/server/actors/targets/window-global.js b/devtools/server/actors/targets/window-global.js index 6719f0518d..f8f5e5f3c6 100644 --- a/devtools/server/actors/targets/window-global.js +++ b/devtools/server/actors/targets/window-global.js @@ -381,6 +381,15 @@ class WindowGlobalTargetActor extends BaseTargetActor { // (This is also probably meant to disappear once EFT is the only supported codepath) this._docShellsObserved = false; DevToolsUtils.executeSoon(() => this._watchDocshells()); + + // The `watchedByDevTools` enables gecko behavior tied to this flag, such as: + // - reporting the contents of HTML loaded in the docshells, + // - or capturing stacks for the network monitor. + // + // This flag can only be set on top level BrowsingContexts. + if (!this.browsingContext.parent) { + this.browsingContext.watchedByDevTools = true; + } } get docShell() { @@ -480,6 +489,10 @@ class WindowGlobalTargetActor extends BaseTargetActor { return this.browsingContext?.id; } + get innerWindowId() { + return this.window?.windowGlobalChild.innerWindowId; + } + get browserId() { return this.browsingContext?.browserId; } @@ -687,6 +700,11 @@ class WindowGlobalTargetActor extends BaseTargetActor { response.outerWindowID = this.outerWindowID; } + // If the actor is already being destroyed, avoid re-registering the target scoped actors + if (this.destroying) { + return response; + } + const actors = this._createExtraActors(); Object.assign(response, actors); @@ -731,6 +749,17 @@ class WindowGlobalTargetActor extends BaseTargetActor { this._touchSimulator = null; } + // The watchedByDevTools flag is only set on top level BrowsingContext + // (as it then cascades to all its children), + // and when destroying the target, we should tell the platform we no longer + // observe this BrowsingContext and set this attribute to false. + if ( + this.browsingContext?.watchedByDevTools && + !this.browsingContext.parent + ) { + this.browsingContext.watchedByDevTools = false; + } + // Check for `docShell` availability, as it can be already gone during // Firefox shutdown. if (this.docShell) { @@ -1314,10 +1343,6 @@ class WindowGlobalTargetActor extends BaseTargetActor { if (typeof options.touchEventsOverride !== "undefined") { const enableTouchSimulator = options.touchEventsOverride === "enabled"; - this.docShell.metaViewportOverride = enableTouchSimulator - ? Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_ENABLED - : Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_NONE; - // We want to reload the document if it's an "existing" top level target on which // the touch simulator will be toggled and the user has turned the // "reload on touch simulation" setting on. @@ -1384,7 +1409,14 @@ class WindowGlobalTargetActor extends BaseTargetActor { */ _restoreTargetConfiguration() { if (this._restoreFocus && this.browsingContext?.isActive) { - this.window.focus(); + try { + this.window.focus(); + } catch (e) { + // When closing devtools while navigating, focus() may throw NS_ERROR_XPC_SECURITY_MANAGER_VETO + if (e.result != Cr.NS_ERROR_XPC_SECURITY_MANAGER_VETO) { + throw e; + } + } } } @@ -1688,17 +1720,6 @@ class DebuggerProgressListener { this._knownWindowIDs.set(getWindowID(win), win); } - // The `watchedByDevTools` enables gecko behavior tied to this flag, such as: - // - reporting the contents of HTML loaded in the docshells, - // - or capturing stacks for the network monitor. - // - // This flag is also set in frame-helper but in the case of the browser toolbox, we - // don't have the watcher enabled by default yet, and as a result we need to set it - // here for the parent process window global. - // This should be removed as part of Bug 1709529. - if (this._targetActor.typeName === "parentProcessTarget") { - docShell.browsingContext.watchedByDevTools = true; - } // Immediately enable CSS error reports on new top level docshells, if this was already enabled. // This is specific to MBT and WebExtension targets (so the isRootActor check). if ( @@ -1741,12 +1762,6 @@ class DebuggerProgressListener { for (const win of windows) { this._knownWindowIDs.delete(getWindowID(win)); } - - // We only reset it for parent process target actor as the flag should be set in parent - // process, and thus is set elsewhere for other type of BrowsingContextActor. - if (this._targetActor.typeName === "parentProcessTarget") { - docShell.browsingContext.watchedByDevTools = false; - } } _getWindowsInDocShell(docShell) { -- cgit v1.2.3