Bug 1261857 - [webext] Add existent WebExtensions ContentScript globals in the Tab DevTools debuggees. r=ochameau
MozReview-Commit-ID: K5YESAVRikO
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -23,16 +23,17 @@ Cu.import("resource://gre/modules/XPCOMU
loader.lazyRequireGetter(this, "RootActor", "devtools/server/actors/root", true);
loader.lazyRequireGetter(this, "ThreadActor", "devtools/server/actors/script", true);
loader.lazyRequireGetter(this, "unwrapDebuggerObjectGlobal", "devtools/server/actors/script", true);
loader.lazyRequireGetter(this, "BrowserAddonActor", "devtools/server/actors/addon", true);
loader.lazyRequireGetter(this, "WorkerActorList", "devtools/server/actors/worker", true);
loader.lazyRequireGetter(this, "ServiceWorkerRegistrationActorList", "devtools/server/actors/worker", true);
loader.lazyRequireGetter(this, "ProcessActorList", "devtools/server/actors/process", true);
loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
+loader.lazyImporter(this, "ExtensionContent", "resource://gre/modules/ExtensionContent.jsm");
// Assumptions on events module:
// events needs to be dispatched synchronously,
// by calling the listeners in the order or registration.
loader.lazyRequireGetter(this, "events", "sdk/event/core");
loader.lazyRequireGetter(this, "StyleSheetActor", "devtools/server/actors/stylesheets", true);
@@ -713,17 +714,19 @@ function TabActor(aConnection)
this._sources = null;
// Map of DOM stylesheets to StyleSheetActors
this._styleSheetActors = new Map();
this._shouldAddNewGlobalAsDebuggee = this._shouldAddNewGlobalAsDebuggee.bind(this);
this.makeDebugger = makeDebugger.bind(null, {
- findDebuggees: () => this.windows,
+ findDebuggees: () => {
+ return this.windows.concat(this.webextensionsContentScriptGlobals);
+ },
shouldAddNewGlobalAsDebuggee: this._shouldAddNewGlobalAsDebuggee
});
// Flag eventually overloaded by sub classes in order to watch new docshells
// Used on b2g to catch activity frames and in chrome to list all frames
this.listenForNewDocShells = Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
this.traits = {
@@ -801,16 +804,29 @@ TabActor.prototype = {
return this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
}
return null;
},
/**
+ * Getter for the WebExtensions ContentScript globals related to the
+ * current tab content's DOM window.
+ */
+ get webextensionsContentScriptGlobals() {
+ // Ignore xpcshell runtime which spawn TabActors without a window.
+ if (this.window) {
+ return ExtensionContent.getContentScriptGlobalsForWindow(this.window);
+ }
+
+ return [];
+ },
+
+ /**
* Getter for the list of all content DOM windows in this tabActor
* @return {Array}
*/
get windows() {
return this.docShells.map(docShell => {
return docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
});