Bug 1467679 - Restore the devtools.toolbox.host value if this value is unexpected. r?gl draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 08 Jun 2018 13:18:54 +0900
changeset 805600 5c69fa52cd4aa222fa72a60efd731f9586f37a4d
parent 805551 ea21bf3e665d10066b6dce39873de9b353a12e57
push id112711
push userbmo:mantaroh@gmail.com
push dateFri, 08 Jun 2018 04:19:20 +0000
reviewersgl
bugs1467679, 1192642
milestone62.0a1
Bug 1467679 - Restore 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
--- 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 preferences 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();