Bug 1285720 - Inspector initialization causes protocol description to be requested from the server three times. r=jdescottes
authorDalimil Hajek <dalimilhajek@gmail.com>
Sat, 13 Aug 2016 04:18:00 -0400
changeset 400790 39cd9b527d38af339390f5a7d9c522facf5f3b99
parent 400789 9e8fb23fc565df8b8f002941e7dc12bced5df054
child 400791 c73cad6f6773ad295e2029da453406947be089f8
push id26284
push usermwein@mozilla.com
push dateMon, 15 Aug 2016 20:48:20 +0000
reviewersjdescottes
bugs1285720
milestone51.0a1
Bug 1285720 - Inspector initialization causes protocol description to be requested from the server three times. r=jdescottes
devtools/client/inspector/inspector-panel.js
--- a/devtools/client/inspector/inspector-panel.js
+++ b/devtools/client/inspector/inspector-panel.js
@@ -177,27 +177,31 @@ InspectorPanel.prototype = {
   /**
    * Figure out what features the backend supports
    */
   _detectActorFeatures: function () {
     this._supportsDuplicateNode = false;
     this._supportsScrollIntoView = false;
     this._supportsResolveRelativeURL = false;
 
-    return promise.all([
-      this._target.actorHasMethod("domwalker", "duplicateNode").then(value => {
-        this._supportsDuplicateNode = value;
-      }).catch(e => console.error(e)),
-      this._target.actorHasMethod("domnode", "scrollIntoView").then(value => {
-        this._supportsScrollIntoView = value;
-      }).catch(e => console.error(e)),
-      this._target.actorHasMethod("inspector", "resolveRelativeURL").then(value => {
-        this._supportsResolveRelativeURL = value;
-      }).catch(e => console.error(e)),
-    ]);
+    // Use getActorDescription first so that all actorHasMethod calls use
+    // a cached response from the server.
+    return this._target.getActorDescription("domwalker").then(desc => {
+      return promise.all([
+        this._target.actorHasMethod("domwalker", "duplicateNode").then(value => {
+          this._supportsDuplicateNode = value;
+        }).catch(e => console.error(e)),
+        this._target.actorHasMethod("domnode", "scrollIntoView").then(value => {
+          this._supportsScrollIntoView = value;
+        }).catch(e => console.error(e)),
+        this._target.actorHasMethod("inspector", "resolveRelativeURL").then(value => {
+          this._supportsResolveRelativeURL = value;
+        }).catch(e => console.error(e)),
+      ]);
+    });
   },
 
   _deferredOpen: function (defaultSelection) {
     let deferred = defer();
 
     this.walker.on("new-root", this.onNewRoot);
 
     this.selection.on("new-node-front", this.onNewSelection);