Bug 1737865 - [devtools] Do not treat xpcshell targets as parent process targets r=ochameau,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D130212
This commit is contained in:
@@ -31,9 +31,14 @@ export async function onConnect(_commands, _resourceCommand, _actions, store) {
|
||||
|
||||
const { descriptorFront } = commands;
|
||||
const { targetFront } = targetCommand;
|
||||
|
||||
// For tab, browser and webextension toolboxes, we want to enable watching for
|
||||
// worker targets as soon as the debugger is opened.
|
||||
// And also for service workers, if the related experimental feature is enabled
|
||||
if (
|
||||
targetFront.isBrowsingContext ||
|
||||
descriptorFront.isParentProcessDescriptor
|
||||
descriptorFront.isTabDescriptor ||
|
||||
descriptorFront.isWebExtensionDescriptor ||
|
||||
descriptorFront.isBrowserProcessDescriptor
|
||||
) {
|
||||
targetCommand.listenForWorkers = true;
|
||||
if (descriptorFront.isLocalTab && features.windowlessServiceWorkers) {
|
||||
@@ -108,7 +113,7 @@ export function onDisconnect() {
|
||||
}
|
||||
|
||||
async function onTargetAvailable({ targetFront, isTargetSwitching }) {
|
||||
const isBrowserToolbox = commands.descriptorFront.isParentProcessDescriptor;
|
||||
const isBrowserToolbox = commands.descriptorFront.isBrowserProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
||||
@@ -38,7 +38,11 @@ add_task(async () => {
|
||||
const descriptor = await client.mainRoot.getProcess(osPid);
|
||||
ok(descriptor, "Got the process descriptor");
|
||||
is(descriptor.id, osPid, "descriptor id is the PID");
|
||||
is(descriptor.isParent, false, "isParent is false for content processes");
|
||||
is(
|
||||
descriptor.isParentProcessDescriptor,
|
||||
false,
|
||||
"isParentProcessDescriptor is false for content processes"
|
||||
);
|
||||
|
||||
// Force getting the target, otherwise we don't connect to the process
|
||||
// via the connector and don't know when the process is destroyed.
|
||||
|
||||
@@ -25,14 +25,15 @@ class ProcessDescriptorFront extends DescriptorMixin(
|
||||
) {
|
||||
constructor(client, targetFront, parentFront) {
|
||||
super(client, targetFront, parentFront);
|
||||
this.isParent = false;
|
||||
this._isParent = false;
|
||||
this._processTargetFront = null;
|
||||
this._targetFrontPromise = null;
|
||||
}
|
||||
|
||||
form(json) {
|
||||
this.id = json.id;
|
||||
this.isParent = json.isParent;
|
||||
this._isParent = json.isParent;
|
||||
this._isWindowlessParent = json.isWindowlessParent;
|
||||
this.traits = json.traits || {};
|
||||
}
|
||||
|
||||
@@ -64,8 +65,23 @@ class ProcessDescriptorFront extends DescriptorMixin(
|
||||
return front;
|
||||
}
|
||||
|
||||
/**
|
||||
* This flag should be true for parent process descriptors of a regular
|
||||
* browser instance, where you can expect the target to be associated with a
|
||||
* window global.
|
||||
*
|
||||
* This will typically be true for the descriptor used by the Browser Toolbox
|
||||
* or the Browser Console opened against a regular Firefox instance.
|
||||
*
|
||||
* On the contrary this will be false for parent process descriptors created
|
||||
* for xpcshell debugging or for background task debugging.
|
||||
*/
|
||||
get isBrowserProcessDescriptor() {
|
||||
return this._isParent && !this._isWindowlessParent;
|
||||
}
|
||||
|
||||
get isParentProcessDescriptor() {
|
||||
return this.isParent;
|
||||
return this._isParent;
|
||||
}
|
||||
|
||||
get isProcessDescriptor() {
|
||||
|
||||
@@ -166,7 +166,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
||||
const processWorkers = await Promise.all(
|
||||
processes.map(async processDescriptorFront => {
|
||||
// Ignore parent process
|
||||
if (processDescriptorFront.isParent) {
|
||||
if (processDescriptorFront.isParentProcessDescriptor) {
|
||||
return [];
|
||||
}
|
||||
const front = await processDescriptorFront.getTarget();
|
||||
|
||||
@@ -502,7 +502,7 @@ function TargetMixin(parentClass) {
|
||||
}
|
||||
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!this.isTopLevel && this.targetType === targetCommand.TYPES.FRAME;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class WebConsoleUI {
|
||||
this.isBrowserConsole = this.hud.isBrowserConsole;
|
||||
|
||||
this.isBrowserToolboxConsole =
|
||||
this.hud.commands.descriptorFront.isParentProcessDescriptor &&
|
||||
this.hud.commands.descriptorFront.isBrowserProcessDescriptor &&
|
||||
!this.isBrowserConsole;
|
||||
this.fissionSupport = Services.prefs.getBoolPref(
|
||||
constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
|
||||
|
||||
@@ -57,13 +57,20 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
|
||||
return null;
|
||||
},
|
||||
|
||||
_parentProcessConnect() {
|
||||
get isWindowlessParent() {
|
||||
return this.isParent && this.isXpcshell;
|
||||
},
|
||||
|
||||
get isXpcshell() {
|
||||
const env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
||||
const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
||||
return env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
||||
},
|
||||
|
||||
_parentProcessConnect() {
|
||||
let targetActor;
|
||||
if (isXpcshell) {
|
||||
if (this.isXpcshell) {
|
||||
// Check if we are running on xpcshell.
|
||||
// When running on xpcshell, there is no valid browsing context to attach to
|
||||
// and so ParentProcessTargetActor doesn't make sense as it inherits from
|
||||
@@ -163,19 +170,20 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
|
||||
actor: this.actorID,
|
||||
id: this.id,
|
||||
isParent: this.isParent,
|
||||
isWindowlessParent: this.isWindowlessParent,
|
||||
traits: {
|
||||
// Supports the Watcher actor. Can be removed as part of Bug 1680280.
|
||||
watcher: true,
|
||||
// ParentProcessTargetActor can be reloaded.
|
||||
supportsReloadDescriptor: this.isParent,
|
||||
supportsReloadDescriptor: this.isParent && !this.isWindowlessParent,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
async reloadDescriptor({ bypassCache }) {
|
||||
if (!this.isParent) {
|
||||
if (!this.isParent || this.isWindowlessParent) {
|
||||
throw new Error(
|
||||
"reloadDescriptor is not available for content process descriptors"
|
||||
"reloadDescriptor is only available for parent process descriptors linked to a window"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ add_task(async () => {
|
||||
ok(descriptor, "Got the new process descriptor");
|
||||
|
||||
// Connect to the first content process available
|
||||
const content = processes.filter(p => !p.isParent)[0];
|
||||
const content = processes.filter(p => !p.isParentProcessDescriptor)[0];
|
||||
|
||||
const processDescriptor = await client.mainRoot.getProcess(content.id);
|
||||
const front = await processDescriptor.getTarget();
|
||||
|
||||
@@ -25,7 +25,7 @@ const ResourceCommand = require("devtools/shared/commands/resource/resource-comm
|
||||
*/
|
||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
||||
@@ -8,7 +8,7 @@ const ResourceCommand = require("devtools/shared/commands/resource/resource-comm
|
||||
|
||||
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||
const isBrowserToolbox =
|
||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
||||
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||
const isNonTopLevelFrameTarget =
|
||||
!targetFront.isTopLevel &&
|
||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||
|
||||
@@ -861,11 +861,11 @@ class ResourceCommand {
|
||||
* @return {Boolean} True, if the server supports this type.
|
||||
*/
|
||||
hasResourceCommandSupport(resourceType) {
|
||||
// If the targetCommand top level target is a parent process, we're in the browser console or browser toolbox.
|
||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
||||
// If we're in the browser console or browser toolbox and the browser
|
||||
// toolbox fission pref is disabled, we don't want to use watchers
|
||||
// (even if traits on the server are enabled).
|
||||
if (
|
||||
this.targetCommand.descriptorFront.isParentProcessDescriptor &&
|
||||
this.targetCommand.descriptorFront.isBrowserProcessDescriptor &&
|
||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||
) {
|
||||
return false;
|
||||
|
||||
@@ -293,7 +293,7 @@ class LegacyServiceWorkersWatcher extends LegacyWorkersWatcher {
|
||||
// Check if the registration is relevant for the current target, ie
|
||||
// corresponds to the same domain.
|
||||
_isRegistrationValidForTarget(registration) {
|
||||
if (this.targetCommand.descriptorFront.isParentProcessDescriptor) {
|
||||
if (this.targetCommand.descriptorFront.isBrowserProcessDescriptor) {
|
||||
// All registrations are valid for main process debugging.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ class TargetCommand extends EventEmitter {
|
||||
* optional targetTypeOrTrait
|
||||
*/
|
||||
hasTargetWatcherSupport(targetTypeOrTrait) {
|
||||
// If the top level target is a parent process, we're in the browser console or browser toolbox.
|
||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
||||
// If we're in the browser console or browser toolbox and the browser
|
||||
// toolbox fission pref is disabled, we don't want to use watchers
|
||||
// (even if traits on the server are enabled).
|
||||
if (
|
||||
this.descriptorFront.isParentProcessDescriptor &&
|
||||
this.descriptorFront.isBrowserProcessDescriptor &&
|
||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||
) {
|
||||
return false;
|
||||
@@ -460,7 +460,7 @@ class TargetCommand extends EventEmitter {
|
||||
|
||||
if (this.descriptorFront.isLocalTab) {
|
||||
types = [TargetCommand.TYPES.FRAME];
|
||||
} else if (this.descriptorFront.isParentProcessDescriptor) {
|
||||
} else if (this.descriptorFront.isBrowserProcessDescriptor) {
|
||||
const fissionBrowserToolboxEnabled = Services.prefs.getBoolPref(
|
||||
BROWSERTOOLBOX_FISSION_ENABLED
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user