Bug 1261857 - [webext] Add existent WebExtensions ContentScript globals in the Tab DevTools debuggees. r=ochameau
authorLuca Greco <lgreco@mozilla.com>
Wed, 20 Apr 2016 16:36:29 +0200
changeset 294116 ebb346387330bcbc4d11c28b9208b9ae1bec21cf
parent 294115 95fc7c29de20dc3a4fe15c2847e7077342bdaaa1
child 294117 a724f54757cbdce5e1c2b26bb96a5a4ef877cadb
push id30200
push userkwierso@gmail.com
push dateThu, 21 Apr 2016 21:25:48 +0000
treeherdermozilla-central@6e5771e2760a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1261857
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1261857 - [webext] Add existent WebExtensions ContentScript globals in the Tab DevTools debuggees. r=ochameau MozReview-Commit-ID: K5YESAVRikO
devtools/server/actors/webbrowser.js
--- 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);
     });