Bug 1944104 - [devtools] Flag Content Script and WindowGlobal targets with related addon-id. r=devtools-reviewers,bomsy
Differential Revision: https://phabricator.services.mozilla.com/D235679
This commit is contained in:
@@ -46,6 +46,7 @@ class WindowGlobalTargetFront extends TargetMixin(
|
|||||||
this.innerWindowId = json.innerWindowId;
|
this.innerWindowId = json.innerWindowId;
|
||||||
this.processID = json.processID;
|
this.processID = json.processID;
|
||||||
this.isFallbackExtensionDocument = json.isFallbackExtensionDocument;
|
this.isFallbackExtensionDocument = json.isFallbackExtensionDocument;
|
||||||
|
this.addonId = json.addonId;
|
||||||
|
|
||||||
// Save the full form for Target class usage.
|
// Save the full form for Target class usage.
|
||||||
// Do not use `form` name to avoid colliding with protocol.js's `form` method
|
// Do not use `form` name to avoid colliding with protocol.js's `form` method
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class WebExtensionContentScriptTargetActor extends BaseTargetActor {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
actor: this.actorID,
|
actor: this.actorID,
|
||||||
|
addonId: this.addonId,
|
||||||
|
|
||||||
// Use the related extension as content script title
|
// Use the related extension as content script title
|
||||||
// as content scripts have no name, they are just a group of JS files
|
// as content scripts have no name, they are just a group of JS files
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ ChromeUtils.defineESModuleGetters(
|
|||||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||||
WEBEXTENSION_FALLBACK_DOC_URL:
|
WEBEXTENSION_FALLBACK_DOC_URL:
|
||||||
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
|
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
|
||||||
|
getAddonIdForWindowGlobal:
|
||||||
|
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
|
||||||
},
|
},
|
||||||
{ global: "contextual" }
|
{ global: "contextual" }
|
||||||
);
|
);
|
||||||
@@ -691,6 +693,7 @@ class WindowGlobalTargetActor extends BaseTargetActor {
|
|||||||
|
|
||||||
// Specific to Web Extension documents
|
// Specific to Web Extension documents
|
||||||
isFallbackExtensionDocument: this.#isFallbackExtensionDocument,
|
isFallbackExtensionDocument: this.#isFallbackExtensionDocument,
|
||||||
|
addonId: lazy.getAddonIdForWindowGlobal(this.window.windowGlobalChild),
|
||||||
|
|
||||||
traits: {
|
traits: {
|
||||||
// @backward-compat { version 64 } Exposes a new trait to help identify
|
// @backward-compat { version 64 } Exposes a new trait to help identify
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ add_task(async function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const targets = await targetCommand.getAllTargets(targetCommand.ALL_TYPES);
|
||||||
|
for(const targetFront of targets) {
|
||||||
|
is(targetFront.addonId, extension.id, `Target ${targetFront.actorID} has the right addonId attribute`);
|
||||||
|
}
|
||||||
|
|
||||||
await targetCommand.reloadTopLevelTarget();
|
await targetCommand.reloadTopLevelTarget();
|
||||||
|
|
||||||
info("Wait for next dom-loading DOCUMENT_EVENT");
|
info("Wait for next dom-loading DOCUMENT_EVENT");
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ async function testWebExtension() {
|
|||||||
"the web extension target is of frame type, because it inherits from WindowGlobalTargetActor"
|
"the web extension target is of frame type, because it inherits from WindowGlobalTargetActor"
|
||||||
);
|
);
|
||||||
is(targetFront.isTopLevel, true, "This is flagged as top level");
|
is(targetFront.isTopLevel, true, "This is flagged as top level");
|
||||||
|
is(targetFront.addonId, extension.id, "The addonId attribute is correct");
|
||||||
|
|
||||||
targetCommand.destroy();
|
targetCommand.destroy();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user