summaryrefslogtreecommitdiffstats
path: root/devtools/server/actors/targets
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/server/actors/targets')
-rw-r--r--devtools/server/actors/targets/base-target-actor.js12
-rw-r--r--devtools/server/actors/targets/session-data-processors/breakpoints.js4
-rw-r--r--devtools/server/actors/targets/session-data-processors/event-breakpoints.js7
-rw-r--r--devtools/server/actors/targets/session-data-processors/index.js7
-rw-r--r--devtools/server/actors/targets/session-data-processors/thread-configuration.js7
-rw-r--r--devtools/server/actors/targets/session-data-processors/xhr-breakpoints.js5
-rw-r--r--devtools/server/actors/targets/target-actor-registry.sys.mjs13
-rw-r--r--devtools/server/actors/targets/webextension.js6
-rw-r--r--devtools/server/actors/targets/window-global.js59
-rw-r--r--devtools/server/actors/targets/worker.js6
10 files changed, 72 insertions, 54 deletions
diff --git a/devtools/server/actors/targets/base-target-actor.js b/devtools/server/actors/targets/base-target-actor.js
index f3fc2a89e7..646874c4f1 100644
--- a/devtools/server/actors/targets/base-target-actor.js
+++ b/devtools/server/actors/targets/base-target-actor.js
@@ -203,6 +203,18 @@ class BaseTargetActor extends Actor {
) {
return;
}
+ // In the browser toolbox, when debugging the parent process, we should only toggle the tracer in the Parent Process Target Actor.
+ // We have to ignore any frame target which may run in the parent process.
+ // For example DevTools documents or a tab running in the parent process.
+ // (PROCESS_TYPE_DEFAULT refers to the parent process)
+ if (
+ this.sessionContext.type == "all" &&
+ this.targetType === Targets.TYPES.FRAME &&
+ this.typeName != "parentProcessTarget" &&
+ Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT
+ ) {
+ return;
+ }
const tracerActor = this.getTargetScopedActor("tracer");
tracerActor.startTracing(options.tracerOptions);
} else if (this.hasTargetScopedActor("tracer")) {
diff --git a/devtools/server/actors/targets/session-data-processors/breakpoints.js b/devtools/server/actors/targets/session-data-processors/breakpoints.js
index 67c270654d..8ecd80ad64 100644
--- a/devtools/server/actors/targets/session-data-processors/breakpoints.js
+++ b/devtools/server/actors/targets/session-data-processors/breakpoints.js
@@ -32,11 +32,9 @@ module.exports = {
threadActor.removeAllBreakpoints();
}
const isTargetCreation = threadActor.state == THREAD_STATES.DETACHED;
- if (isTargetCreation && !targetActor.targetType.endsWith("worker")) {
+ if (isTargetCreation) {
// If addOrSetSessionDataEntry is called during target creation, attach the
// thread actor automatically and pass the initial breakpoints.
- // However, do not attach the thread actor for Workers. They use a codepath
- // which releases the worker on `attach`. For them, the client will call `attach`. (bug 1691986)
await threadActor.attach({ breakpoints: entries });
} else {
// If addOrSetSessionDataEntry is called for an existing target, set the new
diff --git a/devtools/server/actors/targets/session-data-processors/event-breakpoints.js b/devtools/server/actors/targets/session-data-processors/event-breakpoints.js
index 4eb9e4f3a8..1b2dbd847e 100644
--- a/devtools/server/actors/targets/session-data-processors/event-breakpoints.js
+++ b/devtools/server/actors/targets/session-data-processors/event-breakpoints.js
@@ -16,11 +16,8 @@ module.exports = {
updateType
) {
const { threadActor } = targetActor;
- // Same as comments for XHR breakpoints. See lines 117-118
- if (
- threadActor.state == THREAD_STATES.DETACHED &&
- !targetActor.targetType.endsWith("worker")
- ) {
+ // The thread actor has to be initialized in order to have functional breakpoints
+ if (threadActor.state == THREAD_STATES.DETACHED) {
threadActor.attach();
}
if (updateType == "set") {
diff --git a/devtools/server/actors/targets/session-data-processors/index.js b/devtools/server/actors/targets/session-data-processors/index.js
index 19b7d69302..72bc769dd1 100644
--- a/devtools/server/actors/targets/session-data-processors/index.js
+++ b/devtools/server/actors/targets/session-data-processors/index.js
@@ -4,9 +4,10 @@
"use strict";
-const {
- SessionDataHelpers,
-} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
+const { SessionDataHelpers } = ChromeUtils.importESModule(
+ "resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
+ { global: "contextual" }
+);
const { SUPPORTED_DATA } = SessionDataHelpers;
const SessionDataProcessors = {};
diff --git a/devtools/server/actors/targets/session-data-processors/thread-configuration.js b/devtools/server/actors/targets/session-data-processors/thread-configuration.js
index ad5c0fe024..381a62f640 100644
--- a/devtools/server/actors/targets/session-data-processors/thread-configuration.js
+++ b/devtools/server/actors/targets/session-data-processors/thread-configuration.js
@@ -28,12 +28,9 @@ module.exports = {
threadOptions[key] = value;
}
- if (
- !targetActor.targetType.endsWith("worker") &&
- targetActor.threadActor.state == THREAD_STATES.DETACHED
- ) {
+ if (targetActor.threadActor.state == THREAD_STATES.DETACHED) {
await targetActor.threadActor.attach(threadOptions);
- } else {
+ } else if (!targetActor.threadActor.isDestroyed()) {
// Regarding `updateType`, `entries` is always a partial set of configurations.
// We will acknowledge the passed attribute, but if we had set some other attributes
// before this call, they will stay as-is.
diff --git a/devtools/server/actors/targets/session-data-processors/xhr-breakpoints.js b/devtools/server/actors/targets/session-data-processors/xhr-breakpoints.js
index 3bbcf54aaf..81ecb72fb2 100644
--- a/devtools/server/actors/targets/session-data-processors/xhr-breakpoints.js
+++ b/devtools/server/actors/targets/session-data-processors/xhr-breakpoints.js
@@ -22,10 +22,7 @@ module.exports = {
// The thread actor has to be initialized in order to correctly
// retrieve the stack trace when hitting an XHR
- if (
- threadActor.state == THREAD_STATES.DETACHED &&
- !targetActor.targetType.endsWith("worker")
- ) {
+ if (threadActor.state == THREAD_STATES.DETACHED) {
await threadActor.attach();
}
diff --git a/devtools/server/actors/targets/target-actor-registry.sys.mjs b/devtools/server/actors/targets/target-actor-registry.sys.mjs
index 25c1ac1234..bc7adffec2 100644
--- a/devtools/server/actors/targets/target-actor-registry.sys.mjs
+++ b/devtools/server/actors/targets/target-actor-registry.sys.mjs
@@ -9,7 +9,8 @@
// are still using message manager in order to avoid being destroyed on navigation.
// And because of this, these actors aren't using JS Window Actor.
const windowGlobalTargetActors = new Set();
-let xpcShellTargetActor = null;
+
+const xpcShellTargetActors = new Set();
export var TargetActorRegistry = {
registerTargetActor(targetActor) {
@@ -21,15 +22,15 @@ export var TargetActorRegistry = {
},
registerXpcShellTargetActor(targetActor) {
- xpcShellTargetActor = targetActor;
+ xpcShellTargetActors.add(targetActor);
},
- unregisterXpcShellTargetActor() {
- xpcShellTargetActor = null;
+ unregisterXpcShellTargetActor(targetActor) {
+ xpcShellTargetActors.delete(targetActor);
},
- get xpcShellTargetActor() {
- return xpcShellTargetActor;
+ get xpcShellTargetActors() {
+ return xpcShellTargetActors;
},
/**
diff --git a/devtools/server/actors/targets/webextension.js b/devtools/server/actors/targets/webextension.js
index c717b53011..47127dc65c 100644
--- a/devtools/server/actors/targets/webextension.js
+++ b/devtools/server/actors/targets/webextension.js
@@ -162,6 +162,12 @@ class WebExtensionTargetActor extends ParentProcessTargetActor {
// URL shown in the window tittle when the addon debugger is opened).
const extensionWindow = this._searchForExtensionWindow();
this.setDocShell(extensionWindow.docShell);
+
+ // `setDocShell` will force the instantiation of the thread actor.
+ // We now have to initialize it in order to listen for new global
+ // which allows to properly detect addon reload via _shouldAddNewGlobalAsDebuggee
+ // which may call _onNewExtensionWindow.
+ this.threadActor.attach({});
}
// Override the ParentProcessTargetActor's override in order to only iterate
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) {
diff --git a/devtools/server/actors/targets/worker.js b/devtools/server/actors/targets/worker.js
index 20b60cfa24..7604b5be6e 100644
--- a/devtools/server/actors/targets/worker.js
+++ b/devtools/server/actors/targets/worker.js
@@ -126,12 +126,6 @@ class WorkerTargetActor extends BaseTargetActor {
return this._sourcesManager;
}
- // This is called from the ThreadActor#onAttach method
- onThreadAttached() {
- // This isn't an RDP event and is only listened to from startup/worker.js.
- this.emit("worker-thread-attached");
- }
-
destroy() {
super.destroy();