Bug 1467679 - Clear the devtools.toolbox.host value if this value is unexpected. r=gl
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 08 Jun 2018 13:18:54 +0900
changeset 476243 ee8699581c1666e449ee5a2fc15ea6ecf664e97a
parent 476242 7f5ff1e7158b39524f142e368b458a4b9dbffa0e
child 476244 621b7afe0d4a78a7ba897dd4d7734eb25a137cf9
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1467679, 1192642
milestone62.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 1467679 - Clear the devtools.toolbox.host value if this value is unexpected. r=gl Bug 1192642 introduced new host type. If updating to this version, previous preference value will be unexpected. This patch will restore this preference to default value if this pref is unexpected value. MozReview-Commit-ID: LO3R6fFHWh6
devtools/client/framework/toolbox-host-manager.js
devtools/client/framework/toolbox-hosts.js
--- a/devtools/client/framework/toolbox-host-manager.js
+++ b/devtools/client/framework/toolbox-host-manager.js
@@ -39,16 +39,21 @@ let ID_COUNTER = 1;
 
 function ToolboxHostManager(target, hostType, hostOptions) {
   this.target = target;
 
   this.frameId = ID_COUNTER++;
 
   if (!hostType) {
     hostType = Services.prefs.getCharPref(LAST_HOST);
+    if (!Hosts[hostType]) {
+      // If the preference value is unexpected, restore to the default value.
+      Services.prefs.clearUserPref(LAST_HOST);
+      hostType = Services.prefs.getCharPref(LAST_HOST);
+    }
   }
   this.host = this.createHost(hostType, hostOptions);
   this.hostType = hostType;
 }
 
 ToolboxHostManager.prototype = {
   async create(toolId) {
     await this.host.create();
--- a/devtools/client/framework/toolbox-hosts.js
+++ b/devtools/client/framework/toolbox-hosts.js
@@ -119,19 +119,19 @@ BottomHost.prototype = {
     return promise.resolve(null);
   }
 };
 
 /**
  * Base Host object for the in-browser sidebar
  */
 class SidebarHost {
-  constructor(hostTab, hostType) {
+  constructor(hostTab, type) {
     this.hostTab = hostTab;
-    this.type = hostType;
+    this.type = type;
     this.widthPref = "devtools.toolbox.sidebar.width";
 
     EventEmitter.decorate(this);
   }
 
   /**
    * Create a box in the sidebar of the host tab.
    */
@@ -149,17 +149,17 @@ class SidebarHost {
     this.frame.flex = 1; // Required to be able to shrink when the window shrinks
     this.frame.className = "devtools-toolbox-side-iframe";
 
     this.frame.width = Math.min(
       Services.prefs.getIntPref(this.widthPref),
       this._sidebar.clientWidth - MIN_PAGE_SIZE
     );
 
-    if (this.hostType == "right") {
+    if (this.type == "right") {
       this._sidebar.appendChild(this._splitter);
       this._sidebar.appendChild(this.frame);
     } else {
       this._sidebar.insertBefore(this.frame, this._browser);
       this._sidebar.insertBefore(this._splitter, this._browser);
     }
 
     this.frame.tooltip = "aHTMLTooltip";