Bug 1509781 - Check if server supports changes actor to enable Changes panel;r=yulia,rcaliman
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 26 Nov 2018 13:20:18 +0000
changeset 504406 f2f2f8b59557b9cd3781222d2329039c031a6032
parent 504405 693821f7cf935d9ad882af4b12f699562a6e7ea7
child 504419 6c10213a8924b377ea37a37385698ebb09773a30
child 504420 136df6dc6423ca3454e973a945d68460e34dc637
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia, rcaliman
bugs1509781
milestone65.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 1509781 - Check if server supports changes actor to enable Changes panel;r=yulia,rcaliman This will enable connecting to Firefox 63 (and 64? not sure in which release the changes actor was introduced) from Nightly. Pinging yulia for review to check if there is a better way to handle such backward compatible code when using the getFront API. Differential Revision: https://phabricator.services.mozilla.com/D12872
devtools/client/inspector/inspector.js
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -243,16 +243,27 @@ Inspector.prototype = {
     return this._search;
   },
 
   get cssProperties() {
     return this._cssProperties.cssProperties;
   },
 
   /**
+   * Check if the changes panel is enabled and supported by the server.
+   */
+  _supportsChangesPanel() {
+    // The changes actor was introduced in Fx65, we are checking this for backward
+    // compatibility when connecting to an older server. Can be removed once Fx65 hit the
+    // release channel.
+    return this._target.hasActor("changes") &&
+      Services.prefs.getBoolPref(TRACK_CHANGES_PREF);
+  },
+
+  /**
    * Handle promise rejections for various asynchronous actions, and only log errors if
    * the inspector panel still exists.
    * This is useful to silence useless errors that happen when the inspector is closed
    * while still initializing (and making protocol requests).
    */
   _handleRejectionIfNotDestroyed: function(e) {
     if (!this._panelDestroyer) {
       console.error(e);
@@ -264,17 +275,17 @@ Inspector.prototype = {
     this.isReady = false;
 
     // Set the node front so that the markup and sidebar panels will have the selected
     // nodeFront ready when they're initialized.
     if (this._defaultNode) {
       this.selection.setNodeFront(this._defaultNode, { reason: "inspector-open" });
     }
 
-    if (Services.prefs.getBoolPref(TRACK_CHANGES_PREF)) {
+    if (this._supportsChangesPanel()) {
       // Get the Changes front, then call a method on it, which will instantiate
       // the ChangesActor. We want the ChangesActor to be guaranteed available before
       // the user makes any changes.
       this.changesFront = await this.toolbox.target.getFront("changes");
       this.changesFront.start();
     }
 
     // Setup the splitter before the sidebar is displayed so, we don't miss any events.
@@ -936,17 +947,17 @@ Inspector.prototype = {
         title: INSPECTOR_L10N.getStr("inspector.sidebar.animationInspectorTitle"),
       },
       {
         id: "fontinspector",
         title: INSPECTOR_L10N.getStr("inspector.sidebar.fontInspectorTitle"),
       },
     ];
 
-    if (Services.prefs.getBoolPref(TRACK_CHANGES_PREF)) {
+    if (this._supportsChangesPanel()) {
       // Insert Changes as third tab, right after Computed.
       // TODO: move this inline to `sidebarPanels` above when addressing Bug 1491887.
       sidebarPanels.splice(2, 0, {
         id: "changesview",
         title: INSPECTOR_L10N.getStr("inspector.sidebar.changesViewTitle"),
       });
     }