Bug 1809848 - [devtools] Remove TargetMixin.isAddon. r=devtools-reviewers,nchevobbe

Ideally, the debugging context should rather be defined by the descriptor
rather than the top target.
On top of that isAddon is only an alias for isWebExtension.
So drop most usages of isAddon and otherwise use isWebExtension.

Differential Revision: https://phabricator.services.mozilla.com/D166903
This commit is contained in:
Alexandre Poirot 2023-01-18 12:32:04 +00:00
Родитель 1922ea6beb
Коммит e3887c0a39
3 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -45,9 +45,11 @@ add_task(async function testWebExtensionsToolboxNoBackgroundPage() {
);
const toolbox = getToolbox(devtoolsWindow);
ok(
toolbox.commands.descriptorFront.isWebExtensionDescriptor,
"Toolbox is debugging an addon"
);
const targetName = toolbox.target.name;
const isAddonTarget = toolbox.target.isAddon;
ok(isAddonTarget, "Toolbox target is an addon");
is(targetName, ADDON_NOBG_NAME, "Toolbox has the expected target");
const inspector = await toolbox.selectTool("inspector");

Просмотреть файл

@ -300,7 +300,11 @@ Tools.memory = {
tooltip: l10n("memory.tooltip"),
isToolSupported(toolbox) {
return !toolbox.target.isAddon && !toolbox.target.isWorkerTarget;
const { descriptorFront } = toolbox.commands;
return (
!descriptorFront.isWebExtensionDescriptor &&
!descriptorFront.isWorkerDescriptor
);
},
build(frame, toolbox, commands) {

Просмотреть файл

@ -281,7 +281,9 @@ function TargetMixin(parentClass) {
// Allows to controls which features are available against
// a chrome or a content document.
get chrome() {
return this.isAddon || this.isContentProcess || this.isParentProcess;
return (
this.isWebExtension || this.isContentProcess || this.isParentProcess
);
}
// Tells us if the related actor implements WindowGlobalTargetActor
@ -292,7 +294,7 @@ function TargetMixin(parentClass) {
}
get name() {
if (this.isAddon || this.isContentProcess) {
if (this.isWebExtension || this.isContentProcess) {
return this.targetForm.name;
}
return this.title;
@ -306,10 +308,6 @@ function TargetMixin(parentClass) {
return this._url;
}
get isAddon() {
return this.isWebExtension;
}
get isWorkerTarget() {
// XXX Remove the check on `workerDescriptor` as part of Bug 1667404.
return (