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 { descriptorFront } = commands;
|
||||||
const { targetFront } = targetCommand;
|
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 (
|
if (
|
||||||
targetFront.isBrowsingContext ||
|
descriptorFront.isTabDescriptor ||
|
||||||
descriptorFront.isParentProcessDescriptor
|
descriptorFront.isWebExtensionDescriptor ||
|
||||||
|
descriptorFront.isBrowserProcessDescriptor
|
||||||
) {
|
) {
|
||||||
targetCommand.listenForWorkers = true;
|
targetCommand.listenForWorkers = true;
|
||||||
if (descriptorFront.isLocalTab && features.windowlessServiceWorkers) {
|
if (descriptorFront.isLocalTab && features.windowlessServiceWorkers) {
|
||||||
@@ -108,7 +113,7 @@ export function onDisconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onTargetAvailable({ targetFront, isTargetSwitching }) {
|
async function onTargetAvailable({ targetFront, isTargetSwitching }) {
|
||||||
const isBrowserToolbox = commands.descriptorFront.isParentProcessDescriptor;
|
const isBrowserToolbox = commands.descriptorFront.isBrowserProcessDescriptor;
|
||||||
const isNonTopLevelFrameTarget =
|
const isNonTopLevelFrameTarget =
|
||||||
!targetFront.isTopLevel &&
|
!targetFront.isTopLevel &&
|
||||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ add_task(async () => {
|
|||||||
const descriptor = await client.mainRoot.getProcess(osPid);
|
const descriptor = await client.mainRoot.getProcess(osPid);
|
||||||
ok(descriptor, "Got the process descriptor");
|
ok(descriptor, "Got the process descriptor");
|
||||||
is(descriptor.id, osPid, "descriptor id is the PID");
|
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
|
// Force getting the target, otherwise we don't connect to the process
|
||||||
// via the connector and don't know when the process is destroyed.
|
// via the connector and don't know when the process is destroyed.
|
||||||
|
|||||||
@@ -25,14 +25,15 @@ class ProcessDescriptorFront extends DescriptorMixin(
|
|||||||
) {
|
) {
|
||||||
constructor(client, targetFront, parentFront) {
|
constructor(client, targetFront, parentFront) {
|
||||||
super(client, targetFront, parentFront);
|
super(client, targetFront, parentFront);
|
||||||
this.isParent = false;
|
this._isParent = false;
|
||||||
this._processTargetFront = null;
|
this._processTargetFront = null;
|
||||||
this._targetFrontPromise = null;
|
this._targetFrontPromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
form(json) {
|
form(json) {
|
||||||
this.id = json.id;
|
this.id = json.id;
|
||||||
this.isParent = json.isParent;
|
this._isParent = json.isParent;
|
||||||
|
this._isWindowlessParent = json.isWindowlessParent;
|
||||||
this.traits = json.traits || {};
|
this.traits = json.traits || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +65,23 @@ class ProcessDescriptorFront extends DescriptorMixin(
|
|||||||
return front;
|
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() {
|
get isParentProcessDescriptor() {
|
||||||
return this.isParent;
|
return this._isParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isProcessDescriptor() {
|
get isProcessDescriptor() {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class RootFront extends FrontClassWithSpec(rootSpec) {
|
|||||||
const processWorkers = await Promise.all(
|
const processWorkers = await Promise.all(
|
||||||
processes.map(async processDescriptorFront => {
|
processes.map(async processDescriptorFront => {
|
||||||
// Ignore parent process
|
// Ignore parent process
|
||||||
if (processDescriptorFront.isParent) {
|
if (processDescriptorFront.isParentProcessDescriptor) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const front = await processDescriptorFront.getTarget();
|
const front = await processDescriptorFront.getTarget();
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ function TargetMixin(parentClass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isBrowserToolbox =
|
const isBrowserToolbox =
|
||||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||||
const isNonTopLevelFrameTarget =
|
const isNonTopLevelFrameTarget =
|
||||||
!this.isTopLevel && this.targetType === targetCommand.TYPES.FRAME;
|
!this.isTopLevel && this.targetType === targetCommand.TYPES.FRAME;
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class WebConsoleUI {
|
|||||||
this.isBrowserConsole = this.hud.isBrowserConsole;
|
this.isBrowserConsole = this.hud.isBrowserConsole;
|
||||||
|
|
||||||
this.isBrowserToolboxConsole =
|
this.isBrowserToolboxConsole =
|
||||||
this.hud.commands.descriptorFront.isParentProcessDescriptor &&
|
this.hud.commands.descriptorFront.isBrowserProcessDescriptor &&
|
||||||
!this.isBrowserConsole;
|
!this.isBrowserConsole;
|
||||||
this.fissionSupport = Services.prefs.getBoolPref(
|
this.fissionSupport = Services.prefs.getBoolPref(
|
||||||
constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
|
constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
|
||||||
|
|||||||
@@ -57,13 +57,20 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_parentProcessConnect() {
|
get isWindowlessParent() {
|
||||||
|
return this.isParent && this.isXpcshell;
|
||||||
|
},
|
||||||
|
|
||||||
|
get isXpcshell() {
|
||||||
const env = Cc["@mozilla.org/process/environment;1"].getService(
|
const env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||||
Ci.nsIEnvironment
|
Ci.nsIEnvironment
|
||||||
);
|
);
|
||||||
const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
return env.exists("XPCSHELL_TEST_PROFILE_DIR");
|
||||||
|
},
|
||||||
|
|
||||||
|
_parentProcessConnect() {
|
||||||
let targetActor;
|
let targetActor;
|
||||||
if (isXpcshell) {
|
if (this.isXpcshell) {
|
||||||
// Check if we are running on xpcshell.
|
// Check if we are running on xpcshell.
|
||||||
// When running on xpcshell, there is no valid browsing context to attach to
|
// When running on xpcshell, there is no valid browsing context to attach to
|
||||||
// and so ParentProcessTargetActor doesn't make sense as it inherits from
|
// and so ParentProcessTargetActor doesn't make sense as it inherits from
|
||||||
@@ -163,19 +170,20 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
|
|||||||
actor: this.actorID,
|
actor: this.actorID,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
isParent: this.isParent,
|
isParent: this.isParent,
|
||||||
|
isWindowlessParent: this.isWindowlessParent,
|
||||||
traits: {
|
traits: {
|
||||||
// Supports the Watcher actor. Can be removed as part of Bug 1680280.
|
// Supports the Watcher actor. Can be removed as part of Bug 1680280.
|
||||||
watcher: true,
|
watcher: true,
|
||||||
// ParentProcessTargetActor can be reloaded.
|
// ParentProcessTargetActor can be reloaded.
|
||||||
supportsReloadDescriptor: this.isParent,
|
supportsReloadDescriptor: this.isParent && !this.isWindowlessParent,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
async reloadDescriptor({ bypassCache }) {
|
async reloadDescriptor({ bypassCache }) {
|
||||||
if (!this.isParent) {
|
if (!this.isParent || this.isWindowlessParent) {
|
||||||
throw new Error(
|
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");
|
ok(descriptor, "Got the new process descriptor");
|
||||||
|
|
||||||
// Connect to the first content process available
|
// 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 processDescriptor = await client.mainRoot.getProcess(content.id);
|
||||||
const front = await processDescriptor.getTarget();
|
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 }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
const isBrowserToolbox =
|
const isBrowserToolbox =
|
||||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||||
const isNonTopLevelFrameTarget =
|
const isNonTopLevelFrameTarget =
|
||||||
!targetFront.isTopLevel &&
|
!targetFront.isTopLevel &&
|
||||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
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 }) {
|
module.exports = async function({ targetCommand, targetFront, onAvailable }) {
|
||||||
const isBrowserToolbox =
|
const isBrowserToolbox =
|
||||||
targetCommand.descriptorFront.isParentProcessDescriptor;
|
targetCommand.descriptorFront.isBrowserProcessDescriptor;
|
||||||
const isNonTopLevelFrameTarget =
|
const isNonTopLevelFrameTarget =
|
||||||
!targetFront.isTopLevel &&
|
!targetFront.isTopLevel &&
|
||||||
targetFront.targetType === targetCommand.TYPES.FRAME;
|
targetFront.targetType === targetCommand.TYPES.FRAME;
|
||||||
|
|||||||
@@ -861,11 +861,11 @@ class ResourceCommand {
|
|||||||
* @return {Boolean} True, if the server supports this type.
|
* @return {Boolean} True, if the server supports this type.
|
||||||
*/
|
*/
|
||||||
hasResourceCommandSupport(resourceType) {
|
hasResourceCommandSupport(resourceType) {
|
||||||
// If the targetCommand top level target is a parent process, we're in the browser console or browser toolbox.
|
// If we're in the browser console or browser toolbox and the browser
|
||||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
// toolbox fission pref is disabled, we don't want to use watchers
|
||||||
// (even if traits on the server are enabled).
|
// (even if traits on the server are enabled).
|
||||||
if (
|
if (
|
||||||
this.targetCommand.descriptorFront.isParentProcessDescriptor &&
|
this.targetCommand.descriptorFront.isBrowserProcessDescriptor &&
|
||||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class LegacyServiceWorkersWatcher extends LegacyWorkersWatcher {
|
|||||||
// Check if the registration is relevant for the current target, ie
|
// Check if the registration is relevant for the current target, ie
|
||||||
// corresponds to the same domain.
|
// corresponds to the same domain.
|
||||||
_isRegistrationValidForTarget(registration) {
|
_isRegistrationValidForTarget(registration) {
|
||||||
if (this.targetCommand.descriptorFront.isParentProcessDescriptor) {
|
if (this.targetCommand.descriptorFront.isBrowserProcessDescriptor) {
|
||||||
// All registrations are valid for main process debugging.
|
// All registrations are valid for main process debugging.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,11 +339,11 @@ class TargetCommand extends EventEmitter {
|
|||||||
* optional targetTypeOrTrait
|
* optional targetTypeOrTrait
|
||||||
*/
|
*/
|
||||||
hasTargetWatcherSupport(targetTypeOrTrait) {
|
hasTargetWatcherSupport(targetTypeOrTrait) {
|
||||||
// If the top level target is a parent process, we're in the browser console or browser toolbox.
|
// If we're in the browser console or browser toolbox and the browser
|
||||||
// In such case, if the browser toolbox fission pref is disabled, we don't want to use watchers
|
// toolbox fission pref is disabled, we don't want to use watchers
|
||||||
// (even if traits on the server are enabled).
|
// (even if traits on the server are enabled).
|
||||||
if (
|
if (
|
||||||
this.descriptorFront.isParentProcessDescriptor &&
|
this.descriptorFront.isBrowserProcessDescriptor &&
|
||||||
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
!Services.prefs.getBoolPref(BROWSERTOOLBOX_FISSION_ENABLED, false)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
@@ -460,7 +460,7 @@ class TargetCommand extends EventEmitter {
|
|||||||
|
|
||||||
if (this.descriptorFront.isLocalTab) {
|
if (this.descriptorFront.isLocalTab) {
|
||||||
types = [TargetCommand.TYPES.FRAME];
|
types = [TargetCommand.TYPES.FRAME];
|
||||||
} else if (this.descriptorFront.isParentProcessDescriptor) {
|
} else if (this.descriptorFront.isBrowserProcessDescriptor) {
|
||||||
const fissionBrowserToolboxEnabled = Services.prefs.getBoolPref(
|
const fissionBrowserToolboxEnabled = Services.prefs.getBoolPref(
|
||||||
BROWSERTOOLBOX_FISSION_ENABLED
|
BROWSERTOOLBOX_FISSION_ENABLED
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user