Bug 1395535 - update DevToolsShim.isInstalled from addon install() method;r=ochameau draft
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 05 Sep 2017 15:14:17 +0200
changeset 659093 b81455f6e068f8e825df04743ad3b18e6c57908b
parent 659092 c1fd6ed947089b3c6f86807457e526bbd9a24794
child 659094 7680b9673e9704678013d23e1345ae5cd547ff14
push id78008
push userjdescottes@mozilla.com
push dateTue, 05 Sep 2017 13:43:47 +0000
reviewersochameau
bugs1395535
milestone57.0a1
Bug 1395535 - update DevToolsShim.isInstalled from addon install() method;r=ochameau isInstalled should not really be based on the availability of the resource devtools path. This is actually linked to the addon being started. We need to distinguish the two cases in order to handle the inspectNode code path with the async initDevTools MozReview-Commit-ID: 7wQesuysWRE
devtools/bootstrap.js
devtools/shim/DevToolsShim.jsm
--- a/devtools/bootstrap.js
+++ b/devtools/bootstrap.js
@@ -52,11 +52,14 @@ function shutdown(data, reason) {
   // On browser shutdown, do not try to cleanup anything
   if (reason == APP_SHUTDOWN) {
     return;
   }
 
   unload("disable");
 }
 
-function install() {}
+function install() {
+  const {DevToolsShim} = Cu.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
+  DevToolsShim.setInstalled(true);
+}
 
 function uninstall() {}
--- a/devtools/shim/DevToolsShim.jsm
+++ b/devtools/shim/DevToolsShim.jsm
@@ -37,16 +37,17 @@ function removeItem(array, callback) {
  * the DevToolsShim will forward all the requests received until then to the real DevTools
  * instance.
  *
  * DevToolsShim.isInstalled() can also be used to know if DevTools are currently
  * installed.
  */
 this.DevToolsShim = {
   _gDevTools: null,
+  _installed: false,
   listeners: [],
   tools: [],
   themes: [],
 
   /**
    * Lazy getter for the `gDevTools` instance. Should only be called when users interacts
    * with DevTools as it will force loading them.
    *
@@ -65,19 +66,21 @@ this.DevToolsShim = {
   },
 
   /**
    * Check if DevTools are currently installed (but not necessarily initialized).
    *
    * @return {Boolean} true if DevTools are installed.
    */
   isInstalled: function () {
-    return Services.io.getProtocolHandler("resource")
-             .QueryInterface(Ci.nsIResProtocolHandler)
-             .hasSubstitution("devtools");
+    return this._installed;
+  },
+
+  setInstalled: function (installed) {
+    this._installed = installed;
   },
 
   /**
    * Check if DevTools have already been initialized.
    *
    * @return {Boolean} true if DevTools are initialized.
    */
   isInitialized: function () {