Bug 1294989 - Enable eslint for browser/components/preferences. r=gijs draft
authorJared Wein <jwein@mozilla.com>
Sat, 13 Aug 2016 21:58:42 -0400
changeset 400477 e135af145a2eb0fb6b8a5f9a35cf21655e19ad7c
parent 400466 d33489bb88626f512cf7aa58d631f6875aa2d696
child 400478 9adf8f91b82193c1acd731e8ef1abce620cee3c7
push id26157
push userjwein@mozilla.com
push dateSun, 14 Aug 2016 02:00:45 +0000
reviewersgijs
bugs1294989
milestone51.0a1
Bug 1294989 - Enable eslint for browser/components/preferences. r=gijs MozReview-Commit-ID: 62ymdZhluHx
.eslintignore
browser/components/preferences/connection.js
browser/components/preferences/cookies.js
browser/components/preferences/fonts.js
browser/components/preferences/in-content/advanced.js
browser/components/preferences/in-content/applications.js
browser/components/preferences/in-content/jar.mn
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/preferences.js
browser/components/preferences/in-content/privacy.js
browser/components/preferences/in-content/search.js
browser/components/preferences/in-content/security.js
browser/components/preferences/in-content/sync.js
browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js
browser/components/preferences/in-content/tests/browser_bug1018066_resetScrollPosition.js
browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
browser/components/preferences/in-content/tests/browser_bug705422.js
browser/components/preferences/in-content/tests/browser_connection_bug388287.js
browser/components/preferences/in-content/tests/browser_defaultbrowser_alwayscheck.js
browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js
browser/components/preferences/in-content/tests/browser_notifications_do_not_disturb.js
browser/components/preferences/in-content/tests/browser_permissions_urlFieldHidden.js
browser/components/preferences/in-content/tests/browser_sanitizeOnShutdown_prefLocked.js
browser/components/preferences/jar.mn
browser/components/preferences/languages.js
browser/components/preferences/permissions.js
browser/components/preferences/selectBookmark.js
toolkit/modules/AppConstants.jsm
toolkit/modules/moz.build
--- a/.eslintignore
+++ b/.eslintignore
@@ -59,17 +59,16 @@ b2g/locales/en-US/b2g-l10n.js
 browser/app/**
 browser/base/content/browser-social.js
 browser/base/content/nsContextMenu.js
 browser/base/content/sanitizeDialog.js
 browser/base/content/test/**
 browser/base/content/newtab/**
 browser/components/downloads/**
 browser/components/feeds/**
-browser/components/preferences/**
 browser/components/privatebrowsing/**
 browser/components/sessionstore/**
 browser/components/shell/**
 browser/components/tabview/**
 browser/components/translation/**
 browser/extensions/pdfjs/**
 browser/extensions/pocket/content/panels/js/vendor/**
 browser/locales/**
--- a/browser/components/preferences/connection.js
+++ b/browser/components/preferences/connection.js
@@ -41,28 +41,28 @@ var gConnectionsDialog = {
         var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]);
         var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port");
         backupServerURLPref.value = backupServerURLPref.value || proxyServerURLPref.value;
         backupPortPref.value = backupPortPref.value || proxyPortPref.value;
         proxyServerURLPref.value = httpProxyURLPref.value;
         proxyPortPref.value = httpProxyPortPref.value;
       }
     }
-    
+
     this.sanitizeNoProxiesPref();
-    
+
     return true;
   },
 
   checkForSystemProxy: function ()
   {
     if ("@mozilla.org/system-proxy-settings;1" in Components.classes)
       document.getElementById("systemPref").removeAttribute("hidden");
   },
-  
+
   proxyTypeChanged: function ()
   {
     var proxyTypePref = document.getElementById("network.proxy.type");
 
     // Update http
     var httpProxyURLPref = document.getElementById("network.proxy.http");
     httpProxyURLPref.disabled = proxyTypePref.value != 1;
     var httpProxyPortPref = document.getElementById("network.proxy.http_port");
@@ -78,27 +78,27 @@ var gConnectionsDialog = {
     var noProxiesPref = document.getElementById("network.proxy.no_proxies_on");
     noProxiesPref.disabled = proxyTypePref.value != 1;
 
     var autoconfigURLPref = document.getElementById("network.proxy.autoconfig_url");
     autoconfigURLPref.disabled = proxyTypePref.value != 2;
 
     this.updateReloadButton();
   },
-  
+
   updateDNSPref: function ()
   {
     var socksVersionPref = document.getElementById("network.proxy.socks_version");
     var socksDNSPref = document.getElementById("network.proxy.socks_remote_dns");
     var proxyTypePref = document.getElementById("network.proxy.type");
     var isDefinitelySocks4 = !socksVersionPref.disabled && socksVersionPref.value == 4;
     socksDNSPref.disabled = (isDefinitelySocks4 || proxyTypePref.value == 0);
     return undefined;
   },
-  
+
   updateReloadButton: function ()
   {
     // Disable the "Reload PAC" button if the selected proxy type is not PAC or
     // if the current value of the PAC textbox does not match the value stored
     // in prefs.  Likewise, disable the reload button if PAC is not configured
     // in prefs.
 
     var typedURL = document.getElementById("networkProxyAutoconfigURL").value;
@@ -110,33 +110,33 @@ var gConnectionsDialog = {
     var pacURL = prefs.getCharPref("network.proxy.autoconfig_url");
     var proxyType = prefs.getIntPref("network.proxy.type");
 
     var disableReloadPref =
         document.getElementById("pref.advanced.proxies.disable_button.reload");
     disableReloadPref.disabled =
         (proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL);
   },
-  
+
   readProxyType: function ()
   {
     this.proxyTypeChanged();
     return undefined;
   },
-  
+
   updateProtocolPrefs: function ()
   {
     var proxyTypePref = document.getElementById("network.proxy.type");
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
     var proxyPrefs = ["ssl", "ftp", "socks"];
     for (var i = 0; i < proxyPrefs.length; ++i) {
       var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]);
       var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port");
-      
-      // Restore previous per-proxy custom settings, if present. 
+
+      // Restore previous per-proxy custom settings, if present.
       if (!shareProxiesPref.value) {
         var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]);
         var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port");
         if (backupServerURLPref.hasUserValue) {
           proxyServerURLPref.value = backupServerURLPref.value;
           backupServerURLPref.reset();
         }
         if (backupPortPref.hasUserValue) {
@@ -150,64 +150,64 @@ var gConnectionsDialog = {
       proxyServerURLPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
       proxyPortPref.disabled = proxyServerURLPref.disabled;
     }
     var socksVersionPref = document.getElementById("network.proxy.socks_version");
     socksVersionPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
     this.updateDNSPref();
     return undefined;
   },
-  
+
   readProxyProtocolPref: function (aProtocol, aIsPort)
   {
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
     if (shareProxiesPref.value) {
-      var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : ""));    
+      var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : ""));
       return pref.value;
     }
-    
+
     var backupPref = document.getElementById("network.proxy.backup." + aProtocol + (aIsPort ? "_port" : ""));
     return backupPref.hasUserValue ? backupPref.value : undefined;
   },
 
   reloadPAC: function ()
   {
     Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
         getService().reloadPAC();
   },
-  
+
   doAutoconfigURLFixup: function ()
   {
     var autoURL = document.getElementById("networkProxyAutoconfigURL");
     var autoURLPref = document.getElementById("network.proxy.autoconfig_url");
     var URIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
                              .getService(Components.interfaces.nsIURIFixup);
     try {
       autoURLPref.value = autoURL.value = URIFixup.createFixupURI(autoURL.value, 0).spec;
-    } catch(ex) {}
+    } catch (ex) {}
   },
 
   sanitizeNoProxiesPref: function()
   {
     var noProxiesPref = document.getElementById("network.proxy.no_proxies_on");
     // replace substrings of ; and \n with commas if they're neither immediately
     // preceded nor followed by a valid separator character
     noProxiesPref.value = noProxiesPref.value.replace(/([^, \n;])[;\n]+(?![,\n;])/g, '$1,');
-    // replace any remaining ; and \n since some may follow commas, etc. 
+    // replace any remaining ; and \n since some may follow commas, etc.
     noProxiesPref.value = noProxiesPref.value.replace(/[;\n]/g, '');
   },
-  
+
   readHTTPProxyServer: function ()
   {
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
     if (shareProxiesPref.value)
       this.updateProtocolPrefs();
     return undefined;
   },
-  
+
   readHTTPProxyPort: function ()
   {
     var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
     if (shareProxiesPref.value)
       this.updateProtocolPrefs();
     return undefined;
   }
 };
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -56,19 +56,18 @@ var gCookiesWindow = {
       this._tree.view.selection.select(0);
 
     if (aInitialLoad) {
       if ("arguments" in window &&
           window.arguments[0] &&
           window.arguments[0].filterString)
         this.setFilter(window.arguments[0].filterString);
     }
-    else {
-      if (document.getElementById("filter").value != "")
-        this.filter();
+    else if (document.getElementById("filter").value != "") {
+      this.filter();
     }
 
     this._updateRemoveAllButton();
 
     this._saveState();
   },
 
   _cookieEquals: function (aCookieA, aCookieB, aStrippedHost) {
@@ -240,19 +239,19 @@ var gCookiesWindow = {
         var cacheEntry = { 'start' : i, 'count' : count };
         var cacheStart = count;
 
         if (currHost.open) {
           if (count < aIndex && aIndex <= (count + currHost.cookies.length)) {
             // We are looking for an entry within this host's children,
             // enumerate them looking for the index.
             ++count;
-            for (var i = 0; i < currHost.cookies.length; ++i) {
+            for (var j = 0; j < currHost.cookies.length; ++j) {
               if (count == aIndex) {
-                var cookie = currHost.cookies[i];
+                var cookie = currHost.cookies[j];
                 cookie.parentIndex = hostIndex;
                 return cookie;
               }
               ++count;
             }
           }
           else {
             // A host entry was open, but we weren't looking for an index
@@ -260,51 +259,51 @@ var gCookiesWindow = {
             // entry's children. We need to add one to increment for the
             // host value too.
             count += currHost.cookies.length + 1;
           }
         }
         else
           ++count;
 
-        for (var j = cacheStart; j < count; j++)
-          this._cacheItems[j] = cacheEntry;
+        for (var k = cacheStart; k < count; k++)
+          this._cacheItems[k] = cacheEntry;
         this._cacheValid = count - 1;
       }
       return null;
     },
 
     _removeItemAtIndex: function (aIndex, aCount) {
-      var removeCount = aCount === undefined ? 1 : aCount;
+      let removeCount = aCount === undefined ? 1 : aCount;
       if (this._filtered) {
         // remove the cookies from the unfiltered set so that they
         // don't reappear when the filter is changed. See bug 410863.
-        for (var i = aIndex; i < aIndex + removeCount; ++i) {
-          var item = this._filterSet[i];
-          var parent = gCookiesWindow._hosts[item.rawHost];
-          for (var j = 0; j < parent.cookies.length; ++j) {
+        for (let i = aIndex; i < aIndex + removeCount; ++i) {
+          let item = this._filterSet[i];
+          let parent = gCookiesWindow._hosts[item.rawHost];
+          for (let j = 0; j < parent.cookies.length; ++j) {
             if (item == parent.cookies[j]) {
               parent.cookies.splice(j, 1);
               break;
             }
           }
         }
         this._filterSet.splice(aIndex, removeCount);
         return;
       }
 
-      var item = this._getItemAtIndex(aIndex);
+      let item = this._getItemAtIndex(aIndex);
       if (!item) return;
       this._invalidateCache(aIndex - 1);
       if (item.container) {
         gCookiesWindow._hosts[item.rawHost] = null;
       } else {
-        var parent = this._getItemAtIndex(item.parentIndex);
-        for (var i = 0; i < parent.cookies.length; ++i) {
-          var cookie = parent.cookies[i];
+        let parent = this._getItemAtIndex(item.parentIndex);
+        for (let i = 0; i < parent.cookies.length; ++i) {
+          let cookie = parent.cookies[i];
           if (item.rawHost == cookie.rawHost &&
               item.name == cookie.name &&
               item.path == cookie.path &&
               ChromeUtils.isOriginAttributesEqual(item.originAttributes,
                                                   cookie.originAttributes)) {
             parent.cookies.splice(i, removeCount);
           }
         }
@@ -320,21 +319,20 @@ var gCookiesWindow = {
         var item = this._getItemAtIndex(aIndex);
         if (!item)
           return "";
         if (aColumn.id == "domainCol")
           return item.rawHost;
         else if (aColumn.id == "nameCol")
           return item.name;
       }
-      else {
-        if (aColumn.id == "domainCol")
-          return this._filterSet[aIndex].rawHost;
-        else if (aColumn.id == "nameCol")
-          return this._filterSet[aIndex].name;
+      else if (aColumn.id == "domainCol") {
+        return this._filterSet[aIndex].rawHost;
+      } else if (aColumn.id == "nameCol") {
+        return this._filterSet[aIndex].name;
       }
       return "";
     },
 
     _selection: null,
     get selection () { return this._selection; },
     set selection (val) { this._selection = val; return val; },
     getRowProperties: function (aIndex) { return ""; },
@@ -393,21 +391,19 @@ var gCookiesWindow = {
           if (item.container) {
             for (var i = aIndex + 1; i < this.rowCount; ++i) {
               var subsequent = this._getItemAtIndex(i);
               if (subsequent.container)
                 return true;
             }
             return false;
           }
-          else {
-            var parent = this._getItemAtIndex(item.parentIndex);
-            if (parent && parent.container)
-              return aIndex < item.parentIndex + parent.cookies.length;
-          }
+          var parent = this._getItemAtIndex(item.parentIndex);
+          if (parent && parent.container)
+            return aIndex < item.parentIndex + parent.cookies.length;
         }
       }
       return aIndex < this.rowCount - 1;
     },
     hasPreviousSibling: function (aIndex) {
       if (!this._filtered) {
         var item = this._getItemAtIndex(aIndex);
         if (!item) return false;
@@ -706,17 +702,17 @@ var gCookiesWindow = {
       }
       this._view._rowCount += rowCountImpact;
       tbo.rowCountChanged(ci, rowCountImpact);
       if (invalidateRow != -1)
         tbo.invalidateRow(invalidateRow);
     }
     else {
       var rangeCount = seln.getRangeCount();
-      // Traverse backwards through selections to avoid messing 
+      // Traverse backwards through selections to avoid messing
       // up the indices when they are deleted.
       // See bug 388079.
       for (var i = rangeCount - 1; i >= 0; --i) {
         var min = {}; var max = {};
         seln.getRangeAt(i, min, max);
         nextSelected = min.value;
         for (var j = min.value; j <= max.value; ++j) {
           deleteItems.push(this._view._getItemAtIndex(j));
@@ -756,22 +752,22 @@ var gCookiesWindow = {
     else {
       this._cm.removeAll();
     }
     this._updateRemoveAllButton();
     this.focusFilterBox();
   },
 
   onCookieKeyPress: function (aEvent) {
-    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE
-#ifdef XP_MACOSX
-        || aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE
-#endif
-       )
+    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE) {
       this.deleteCookie();
+    } else if (AppConstants.platform == "macosx" &&
+               aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE) {
+      this.deleteCookie();
+    }
   },
 
   _lastSortProperty : "",
   _lastSortAscending: false,
   sort: function (aProperty) {
     var ascending = (aProperty == this._lastSortProperty) ? !this._lastSortAscending : true;
     // Sort the Non-Filtered Host Collections
     if (aProperty == "rawHost") {
--- a/browser/components/preferences/fonts.js
+++ b/browser/components/preferences/fonts.js
@@ -35,68 +35,63 @@ var gFontsDialog = {
       if (!preference) {
         preference = document.createElement("preference");
         var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
         preference.id = name;
         preference.setAttribute("name", name);
         preference.setAttribute("type", prefs[i].type);
         preferences.appendChild(preference);
       }
-      
+
       if (!prefs[i].element)
         continue;
-        
+
       var element = document.getElementById(prefs[i].element);
       if (element) {
         element.setAttribute("preference", preference.id);
-      
+
         if (prefs[i].fonttype)
           FontBuilder.buildFontList(aLanguageGroup, prefs[i].fonttype, element);
 
         preference.setElementValue(element);
       }
     }
   },
-  
+
   readFontLanguageGroup: function ()
   {
     var languagePref = document.getElementById("font.language.group");
     this._selectLanguageGroup(languagePref.value);
     return undefined;
   },
-  
+
   readUseDocumentFonts: function ()
   {
     var preference = document.getElementById("browser.display.use_document_fonts");
     return preference.value == 1;
   },
-  
+
   writeUseDocumentFonts: function ()
   {
     var useDocumentFonts = document.getElementById("useDocumentFonts");
     return useDocumentFonts.checked ? 1 : 0;
   },
 
   onBeforeAccept: function ()
   {
-    // Only care in in-content prefs
-    if (!window.frameElement) {
-      return true;
-    }
-
     let preferences = document.querySelectorAll("preference[id*='font.minimum-size']");
     // It would be good if we could avoid touching languages the pref pages won't use, but
     // unfortunately the language group APIs (deducing language groups from language codes)
     // are C++ - only. So we just check all the things the user touched:
     // Don't care about anything up to 24px, or if this value is the same as set previously:
     preferences = Array.filter(preferences, prefEl => {
       return prefEl.value > 24 && prefEl.value != prefEl.valueFromPreferences;
     });
     if (!preferences.length) {
-      return;
+      return true;
     }
 
     let strings = document.getElementById("bundlePreferences");
     let title = strings.getString("veryLargeMinimumFontTitle");
     let confirmLabel = strings.getString("acceptVeryLargeMinimumFont");
     let warningMessage = strings.getString("veryLargeMinimumFontWarning");
     let {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
     let flags = Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL |
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -25,86 +25,86 @@ var gAdvancedPane = {
 
     this._inited = true;
     var advancedPrefs = document.getElementById("advancedPrefs");
 
     var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
     if (preference.value !== null)
         advancedPrefs.selectedIndex = preference.value;
 
-#ifdef MOZ_UPDATER
-    let onUnload = function () {
-      window.removeEventListener("unload", onUnload, false);
-      Services.prefs.removeObserver("app.update.", this);
-    }.bind(this);
-    window.addEventListener("unload", onUnload, false);
-    Services.prefs.addObserver("app.update.", this, false);
-    this.updateReadPrefs();
-#endif
+    if (AppConstants.MOZ_UPDATER) {
+      let onUnload = function () {
+        window.removeEventListener("unload", onUnload, false);
+        Services.prefs.removeObserver("app.update.", this);
+      }.bind(this);
+      window.addEventListener("unload", onUnload, false);
+      Services.prefs.addObserver("app.update.", this, false);
+      this.updateReadPrefs();
+    }
     this.updateOfflineApps();
-#ifdef MOZ_CRASHREPORTER
-    this.initSubmitCrashes();
-#endif
+    if (AppConstants.MOZ_CRASHREPORTER) {
+      this.initSubmitCrashes();
+    }
     this.initTelemetry();
-#ifdef MOZ_TELEMETRY_REPORTING
-    this.initSubmitHealthReport();
-#endif
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      this.initSubmitHealthReport();
+    }
     this.updateOnScreenKeyboardVisibility();
     this.updateCacheSizeInputField();
     this.updateActualCacheSize();
     this.updateActualAppCacheSize();
 
     setEventListener("layers.acceleration.disabled", "change",
                      gAdvancedPane.updateHardwareAcceleration);
     setEventListener("advancedPrefs", "select",
                      gAdvancedPane.tabSelectionChanged);
-#ifdef MOZ_TELEMETRY_REPORTING
-    setEventListener("submitHealthReportBox", "command",
-                     gAdvancedPane.updateSubmitHealthReport);
-#endif
-#ifdef MOZ_CRASHREPORTER
-    setEventListener("submitCrashesBox", "command",
-                     gAdvancedPane.updateSubmitCrashes);
-#endif
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      setEventListener("submitHealthReportBox", "command",
+                       gAdvancedPane.updateSubmitHealthReport);
+    }
+    if (AppConstants.MOZ_CRASHREPORTER) {
+      setEventListener("submitCrashesBox", "command",
+                       gAdvancedPane.updateSubmitCrashes);
+    }
     setEventListener("connectionSettings", "command",
                      gAdvancedPane.showConnections);
     setEventListener("clearCacheButton", "command",
                      gAdvancedPane.clearCache);
     setEventListener("clearOfflineAppCacheButton", "command",
                      gAdvancedPane.clearOfflineAppCache);
     setEventListener("offlineNotifyExceptions", "command",
                      gAdvancedPane.showOfflineExceptions);
     setEventListener("offlineAppsList", "select",
                      gAdvancedPane.offlineAppSelected);
     let bundlePrefs = document.getElementById("bundlePreferences");
     document.getElementById("offlineAppsList")
             .style.height = bundlePrefs.getString("offlineAppsList.height");
     setEventListener("offlineAppsListRemove", "command",
                      gAdvancedPane.removeOfflineApp);
-#ifdef MOZ_UPDATER
-    setEventListener("updateRadioGroup", "command",
-                     gAdvancedPane.updateWritePrefs);
-    setEventListener("showUpdateHistory", "command",
-                     gAdvancedPane.showUpdates);
-#endif
+    if (AppConstants.MOZ_UPDATER) {
+      setEventListener("updateRadioGroup", "command",
+                       gAdvancedPane.updateWritePrefs);
+      setEventListener("showUpdateHistory", "command",
+                       gAdvancedPane.showUpdates);
+    }
     setEventListener("viewCertificatesButton", "command",
                      gAdvancedPane.showCertificates);
     setEventListener("viewSecurityDevicesButton", "command",
                      gAdvancedPane.showSecurityDevices);
     setEventListener("cacheSize", "change",
                      gAdvancedPane.updateCacheSizePref);
 
-#ifdef MOZ_WIDGET_GTK
-    // GTK tabbox' allow the scroll wheel to change the selected tab,
-    // but we don't want this behavior for the in-content preferences.
-    let tabsElement = document.getElementById("tabsElement");
-    tabsElement.addEventListener("DOMMouseScroll", event => {
-      event.stopPropagation();
-    }, true);
-#endif
+    if (AppConstants.MOZ_WIDGET_GTK) {
+      // GTK tabbox' allow the scroll wheel to change the selected tab,
+      // but we don't want this behavior for the in-content preferences.
+      let tabsElement = document.getElementById("tabsElement");
+      tabsElement.addEventListener("DOMMouseScroll", event => {
+        event.stopPropagation();
+      }, true);
+    }
   },
 
   /**
    * Stores the identity of the current tab in preferences so that the selected
    * tab can be persisted between openings of the preferences window.
    */
   tabSelectionChanged: function ()
   {
@@ -169,17 +169,23 @@ var gAdvancedPane = {
   /**
    * Returns the value of the spellchecking preference represented by UI,
    * preserving the preference's "hidden" value if the preference is
    * unchanged and represents a value not strictly allowed in UI.
    */
   writeCheckSpelling: function ()
   {
     var checkbox = document.getElementById("checkSpelling");
-    return checkbox.checked ? (this._storedSpellCheck == 2 ? 2 : 1) : 0;
+    if (checkbox.checked) {
+      if (this._storedSpellCheck == 2) {
+        return 2;
+      }
+      return 1;
+    }
+    return 0;
   },
 
   /**
    * security.OCSP.enabled is an integer value for legacy reasons.
    * A value of 1 means OCSP is enabled. Any other value means it is disabled.
    */
   readEnableOCSP: function ()
   {
@@ -201,21 +207,21 @@ var gAdvancedPane = {
   },
 
   /**
    * When the user toggles the layers.acceleration.disabled pref,
    * sync its new value to the gfx.direct2d.disabled pref too.
    */
   updateHardwareAcceleration: function()
   {
-#ifdef XP_WIN
-    var fromPref = document.getElementById("layers.acceleration.disabled");
-    var toPref = document.getElementById("gfx.direct2d.disabled");
-    toPref.value = fromPref.value;
-#endif
+    if (AppConstants.platform = "win") {
+      var fromPref = document.getElementById("layers.acceleration.disabled");
+      var toPref = document.getElementById("gfx.direct2d.disabled");
+      toPref.value = fromPref.value;
+    }
   },
 
   // DATA CHOICES TAB
 
   /**
    * Set up or hide the Learn More links for various data collection options
    */
   _setupLearnMoreLink: function (pref, element) {
@@ -263,66 +269,68 @@ var gAdvancedPane = {
 
   /**
    * The preference/checkbox is configured in XUL.
    *
    * In all cases, set up the Learn More link sanely.
    */
   initTelemetry: function ()
   {
-#ifdef MOZ_TELEMETRY_REPORTING
-    this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
-#endif
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
+    }
   },
 
   /**
    * Set the status of the telemetry controls based on the input argument.
    * @param {Boolean} aEnabled False disables the controls, true enables them.
    */
   setTelemetrySectionEnabled: function (aEnabled)
   {
-#ifdef MOZ_TELEMETRY_REPORTING
-    // If FHR is disabled, additional data sharing should be disabled as well.
-    let disabled = !aEnabled;
-    document.getElementById("submitTelemetryBox").disabled = disabled;
-    if (disabled) {
-      // If we disable FHR, untick the telemetry checkbox.
-      Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      // If FHR is disabled, additional data sharing should be disabled as well.
+      let disabled = !aEnabled;
+      document.getElementById("submitTelemetryBox").disabled = disabled;
+      if (disabled) {
+        // If we disable FHR, untick the telemetry checkbox.
+        Services.prefs.setBoolPref("toolkit.telemetry.enabled", false);
+      }
+      document.getElementById("telemetryDataDesc").disabled = disabled;
     }
-    document.getElementById("telemetryDataDesc").disabled = disabled;
-#endif
   },
 
-#ifdef MOZ_TELEMETRY_REPORTING
   /**
    * Initialize the health report service reference and checkbox.
    */
   initSubmitHealthReport: function () {
-    this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      this._setupLearnMoreLink("datareporting.healthreport.infoURL", "FHRLearnMore");
 
-    let checkbox = document.getElementById("submitHealthReportBox");
+      let checkbox = document.getElementById("submitHealthReportBox");
 
-    if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
-      checkbox.setAttribute("disabled", "true");
-      return;
+      if (Services.prefs.prefIsLocked(PREF_UPLOAD_ENABLED)) {
+        checkbox.setAttribute("disabled", "true");
+        return;
+      }
+
+      checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
+      this.setTelemetrySectionEnabled(checkbox.checked);
     }
-
-    checkbox.checked = Services.prefs.getBoolPref(PREF_UPLOAD_ENABLED);
-    this.setTelemetrySectionEnabled(checkbox.checked);
   },
 
   /**
    * Update the health report preference with state from checkbox.
    */
   updateSubmitHealthReport: function () {
-    let checkbox = document.getElementById("submitHealthReportBox");
-    Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
-    this.setTelemetrySectionEnabled(checkbox.checked);
+    if (AppConstants.MOZ_TELEMETRY_REPORTING) {
+      let checkbox = document.getElementById("submitHealthReportBox");
+      Services.prefs.setBoolPref(PREF_UPLOAD_ENABLED, checkbox.checked);
+      this.setTelemetrySectionEnabled(checkbox.checked);
+    }
   },
-#endif
 
   updateOnScreenKeyboardVisibility() {
     if (AppConstants.platform == "win") {
       let minVersion = Services.prefs.getBoolPref("ui.osk.require_win10") ? 10 : 6.2;
       if (Services.vc.compare(Services.sysinfo.getProperty("version"), minVersion) >= 0) {
         document.getElementById("useOnScreenKeyboard").hidden = false;
       }
     }
@@ -458,17 +466,17 @@ var gAdvancedPane = {
    * Clears the cache.
    */
   clearCache: function ()
   {
     try {
       var cache = Components.classes["@mozilla.org/netwerk/cache-storage-service;1"]
                             .getService(Components.interfaces.nsICacheStorageService);
       cache.clear();
-    } catch(ex) {}
+    } catch (ex) {}
     this.updateActualCacheSize();
   },
 
   /**
    * Clears the application cache.
    */
   clearOfflineAppCache: function ()
   {
@@ -644,17 +652,16 @@ var gAdvancedPane = {
    * false if the user should be asked what he wants to do when an update is
    * available
    * extensions.update.enabled
    * - true if updates to extensions and themes are enabled, false otherwise
    * browser.search.update
    * - true if updates to search engines are enabled, false otherwise
    */
 
-#ifdef MOZ_UPDATER
   /**
    * Selects the item of the radiogroup based on the pref values and locked
    * states.
    *
    * UI state matrix for update preference conditions
    *
    * UI Components:                              Preferences
    * Radiogroup                                  i   = app.update.enabled
@@ -664,88 +671,93 @@ var gAdvancedPane = {
    * Element           pref  value  locked  disabled
    * radiogroup        i     t/f    f       false
    *                   i     t/f    *t*     *true*
    *                   ii    t/f    f       false
    *                   ii    t/f    *t*     *true*
    */
   updateReadPrefs: function ()
   {
-    var enabledPref = document.getElementById("app.update.enabled");
-    var autoPref = document.getElementById("app.update.auto");
-    var radiogroup = document.getElementById("updateRadioGroup");
+    if (AppConstants.MOZ_UPDATER) {
+      var enabledPref = document.getElementById("app.update.enabled");
+      var autoPref = document.getElementById("app.update.auto");
+      var radiogroup = document.getElementById("updateRadioGroup");
 
-    if (!enabledPref.value)   // Don't care for autoPref.value in this case.
-      radiogroup.value="manual";    // 3. Never check for updates.
-    else if (autoPref.value)  // enabledPref.value && autoPref.value
-      radiogroup.value="auto";      // 1. Automatically install updates
-    else                      // enabledPref.value && !autoPref.value
-      radiogroup.value="checkOnly"; // 2. Check, but let me choose
+      if (!enabledPref.value)   // Don't care for autoPref.value in this case.
+        radiogroup.value="manual";    // 3. Never check for updates.
+      else if (autoPref.value)  // enabledPref.value && autoPref.value
+        radiogroup.value="auto";      // 1. Automatically install updates
+      else                      // enabledPref.value && !autoPref.value
+        radiogroup.value="checkOnly"; // 2. Check, but let me choose
 
-    var canCheck = Components.classes["@mozilla.org/updates/update-service;1"].
-                     getService(Components.interfaces.nsIApplicationUpdateService).
-                     canCheckForUpdates;
-    // canCheck is false if the enabledPref is false and locked,
-    // or the binary platform or OS version is not known.
-    // A locked pref is sufficient to disable the radiogroup.
-    radiogroup.disabled = !canCheck || enabledPref.locked || autoPref.locked;
+      var canCheck = Components.classes["@mozilla.org/updates/update-service;1"].
+                       getService(Components.interfaces.nsIApplicationUpdateService).
+                       canCheckForUpdates;
+      // canCheck is false if the enabledPref is false and locked,
+      // or the binary platform or OS version is not known.
+      // A locked pref is sufficient to disable the radiogroup.
+      radiogroup.disabled = !canCheck || enabledPref.locked || autoPref.locked;
 
-#ifdef MOZ_MAINTENANCE_SERVICE
-    // Check to see if the maintenance service is installed.
-    // If it is don't show the preference at all.
-    var installed;
-    try {
-      var wrk = Components.classes["@mozilla.org/windows-registry-key;1"]
-                .createInstance(Components.interfaces.nsIWindowsRegKey);
-      wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
-               "SOFTWARE\\Mozilla\\MaintenanceService",
-               wrk.ACCESS_READ | wrk.WOW64_64);
-      installed = wrk.readIntValue("Installed");
-      wrk.close();
-    } catch(e) {
+      if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
+        // Check to see if the maintenance service is installed.
+        // If it is don't show the preference at all.
+        var installed;
+        try {
+          var wrk = Components.classes["@mozilla.org/windows-registry-key;1"]
+                    .createInstance(Components.interfaces.nsIWindowsRegKey);
+          wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
+                   "SOFTWARE\\Mozilla\\MaintenanceService",
+                   wrk.ACCESS_READ | wrk.WOW64_64);
+          installed = wrk.readIntValue("Installed");
+          wrk.close();
+        } catch (e) {
+        }
+        if (installed != 1) {
+          document.getElementById("useService").hidden = true;
+        }
+      }
     }
-    if (installed != 1) {
-      document.getElementById("useService").hidden = true;
-    }
-#endif
   },
 
   /**
    * Sets the pref values based on the selected item of the radiogroup.
    */
   updateWritePrefs: function ()
   {
-    var enabledPref = document.getElementById("app.update.enabled");
-    var autoPref = document.getElementById("app.update.auto");
-    var radiogroup = document.getElementById("updateRadioGroup");
-    switch (radiogroup.value) {
-      case "auto":      // 1. Automatically install updates for Desktop only
-        enabledPref.value = true;
-        autoPref.value = true;
-        break;
-      case "checkOnly": // 2. Check, but let me choose
-        enabledPref.value = true;
-        autoPref.value = false;
-        break;
-      case "manual":    // 3. Never check for updates.
-        enabledPref.value = false;
-        autoPref.value = false;
+    if (AppConstants.MOZ_UPDATER) {
+      var enabledPref = document.getElementById("app.update.enabled");
+      var autoPref = document.getElementById("app.update.auto");
+      var radiogroup = document.getElementById("updateRadioGroup");
+      switch (radiogroup.value) {
+        case "auto":      // 1. Automatically install updates for Desktop only
+          enabledPref.value = true;
+          autoPref.value = true;
+          break;
+        case "checkOnly": // 2. Check, but let me choose
+          enabledPref.value = true;
+          autoPref.value = false;
+          break;
+        case "manual":    // 3. Never check for updates.
+          enabledPref.value = false;
+          autoPref.value = false;
+      }
     }
   },
 
   /**
    * Displays the history of installed updates.
    */
   showUpdates: function ()
   {
-    var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
-                             .createInstance(Components.interfaces.nsIUpdatePrompt);
-    prompter.showUpdateHistory(window);
+    if (AppConstants.MOZ_UPDATER) {
+      var prompter = Components.classes["@mozilla.org/updates/update-prompt;1"]
+                               .createInstance(Components.interfaces.nsIUpdatePrompt);
+      prompter.showUpdateHistory(window);
+    }
   },
-#endif
 
   // ENCRYPTION TAB
 
   /*
    * Preferences:
    *
    * security.default_personal_cert
    * - a string:
@@ -771,18 +783,18 @@ var gAdvancedPane = {
    */
   showSecurityDevices: function ()
   {
     openDialog("chrome://pippki/content/device_manager.xul",
                "mozilla:devicemanager",
                "modal=yes", null);
   },
 
-#ifdef MOZ_UPDATER
   observe: function (aSubject, aTopic, aData) {
-    switch(aTopic) {
-      case "nsPref:changed":
-        this.updateReadPrefs();
-        break;
+    if (AppConstants.MOZ_UPDATER) {
+      switch (aTopic) {
+        case "nsPref:changed":
+          this.updateReadPrefs();
+          break;
+      }
     }
   },
-#endif
 };
--- a/browser/components/preferences/in-content/applications.js
+++ b/browser/components/preferences/in-content/applications.js
@@ -75,47 +75,47 @@ const ICON_URL_APP = AppConstants.platfo
 // For CSS. Can be one of "ask", "save", "plugin" or "feed". If absent, the icon URL
 // was set by us to a custom handler icon and CSS should not try to override it.
 const APP_ICON_ATTR_NAME = "appHandlerIcon";
 
 //****************************************************************************//
 // Utilities
 
 function getFileDisplayName(file) {
-#ifdef XP_WIN
-  if (file instanceof Ci.nsILocalFileWin) {
-    try {
-      return file.getVersionInfoField("FileDescription");
-    } catch (e) {}
+  if (AppConstants.platform == "win") {
+    if (file instanceof Ci.nsILocalFileWin) {
+      try {
+        return file.getVersionInfoField("FileDescription");
+      } catch (e) {}
+    }
   }
-#endif
-#ifdef XP_MACOSX
-  if (file instanceof Ci.nsILocalFileMac) {
-    try {
-      return file.bundleDisplayName;
-    } catch (e) {}
+  if (AppConstants.platform == "macosx") {
+    if (file instanceof Ci.nsILocalFileMac) {
+      try {
+        return file.bundleDisplayName;
+      } catch (e) {}
+    }
   }
-#endif
   return file.leafName;
 }
 
 function getLocalHandlerApp(aFile) {
   var localHandlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
                         createInstance(Ci.nsILocalHandlerApp);
   localHandlerApp.name = getFileDisplayName(aFile);
   localHandlerApp.executable = aFile;
 
   return localHandlerApp;
 }
 
 /**
  * An enumeration of items in a JS array.
  *
  * FIXME: use ArrayConverter once it lands (bug 380839).
- * 
+ *
  * @constructor
  */
 function ArrayEnumerator(aItems) {
   this._index = 0;
   this._contents = aItems;
 }
 
 ArrayEnumerator.prototype = {
@@ -266,18 +266,17 @@ HandlerInfoWrapper.prototype = {
     // fall back to saving to disk, which is the default action in nsMIMEInfo.
     // Note: "save to disk" is an invalid value for protocol info objects,
     // but the alwaysAskBeforeHandling getter will detect that situation
     // and always return true in that case to override this invalid value.
     if (this.wrappedHandlerInfo.preferredAction == Ci.nsIHandlerInfo.useHelperApp &&
         !gApplicationsPane.isValidHandlerApp(this.preferredApplicationHandler)) {
       if (this.wrappedHandlerInfo.hasDefaultHandler)
         return Ci.nsIHandlerInfo.useSystemDefault;
-      else
-        return Ci.nsIHandlerInfo.saveToDisk;
+      return Ci.nsIHandlerInfo.saveToDisk;
     }
 
     return this.wrappedHandlerInfo.preferredAction;
   },
 
   set preferredAction(aNewValue) {
     // If the action is to use the plugin,
     // we must set the preferred action to "save to disk".
@@ -331,17 +330,17 @@ HandlerInfoWrapper.prototype = {
   // XXX Plugin objects contain an array of MimeType objects with "suffixes"
   // properties; if this object has an associated plugin, shouldn't we check
   // those properties for an extension?
   get primaryExtension() {
     try {
       if (this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
           this.wrappedHandlerInfo.primaryExtension)
         return this.wrappedHandlerInfo.primaryExtension
-    } catch(ex) {}
+    } catch (ex) {}
 
     return null;
   },
 
 
   //**************************************************************************//
   // Plugin Handling
 
@@ -450,20 +449,20 @@ HandlerInfoWrapper.prototype = {
 
 //****************************************************************************//
 // Feed Handler Info
 
 /**
  * This object implements nsIHandlerInfo for the feed types.  It's a separate
  * object because we currently store handling information for the feed type
  * in a set of preferences rather than the nsIHandlerService-managed datastore.
- * 
+ *
  * This object inherits from HandlerInfoWrapper in order to get functionality
  * that isn't special to the feed type.
- * 
+ *
  * XXX Should we inherit from HandlerInfoWrapper?  After all, we override
  * most of that wrapper's properties and methods, and we have to dance around
  * the fact that the wrapper expects to have a wrappedHandlerInfo, which we
  * don't provide.
  */
 
 function FeedHandlerInfo(aMIMEType) {
   HandlerInfoWrapper.call(this, aMIMEType, null);
@@ -474,23 +473,17 @@ FeedHandlerInfo.prototype = {
 
   //**************************************************************************//
   // Convenience Utils
 
   _converterSvc:
     Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
     getService(Ci.nsIWebContentConverterService),
 
-  _shellSvc:
-#ifdef HAVE_SHELL_SERVICE
-    getShellService(),
-#else
-    null,
-#endif
-
+  _shellSvc: AppConstants.HAVE_SHELL_SERVICE ? getShellService() : null,
 
   //**************************************************************************//
   // nsIHandlerInfo
 
   get description() {
     return this.element("bundlePreferences").getString(this._appPrefLabel);
   },
 
@@ -602,24 +595,24 @@ FeedHandlerInfo.prototype = {
   },
 
   __defaultApplicationHandler: undefined,
   get _defaultApplicationHandler() {
     if (typeof this.__defaultApplicationHandler != "undefined")
       return this.__defaultApplicationHandler;
 
     var defaultFeedReader = null;
-#ifdef HAVE_SHELL_SERVICE
-    try {
-      defaultFeedReader = this._shellSvc.defaultFeedReader;
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      try {
+        defaultFeedReader = this._shellSvc.defaultFeedReader;
+      }
+      catch (ex) {
+        // no default reader or _shellSvc is null
+      }
     }
-    catch(ex) {
-      // no default reader or _shellSvc is null
-    }
-#endif
 
     if (defaultFeedReader) {
       let handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
                        createInstance(Ci.nsIHandlerApp);
       handlerApp.name = getFileDisplayName(defaultFeedReader);
       handlerApp.QueryInterface(Ci.nsILocalHandlerApp);
       handlerApp.executable = defaultFeedReader;
 
@@ -628,25 +621,25 @@ FeedHandlerInfo.prototype = {
     else {
       this.__defaultApplicationHandler = null;
     }
 
     return this.__defaultApplicationHandler;
   },
 
   get hasDefaultHandler() {
-#ifdef HAVE_SHELL_SERVICE
-    try {
-      if (this._shellSvc.defaultFeedReader)
-        return true;
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      try {
+        if (this._shellSvc.defaultFeedReader)
+          return true;
+      }
+      catch (ex) {
+        // no default reader or _shellSvc is null
+      }
     }
-    catch(ex) {
-      // no default reader or _shellSvc is null
-    }
-#endif
 
     return false;
   },
 
   get defaultDescription() {
     if (this.hasDefaultHandler)
       return this._defaultApplicationHandler.name;
 
@@ -772,39 +765,39 @@ FeedHandlerInfo.prototype = {
   get smallIcon() {
     return this._smallIcon;
   }
 
 };
 
 var feedHandlerInfo = {
   __proto__: new FeedHandlerInfo(TYPE_MAYBE_FEED),
-  _prefSelectedApp: PREF_FEED_SELECTED_APP, 
-  _prefSelectedWeb: PREF_FEED_SELECTED_WEB, 
-  _prefSelectedAction: PREF_FEED_SELECTED_ACTION, 
+  _prefSelectedApp: PREF_FEED_SELECTED_APP,
+  _prefSelectedWeb: PREF_FEED_SELECTED_WEB,
+  _prefSelectedAction: PREF_FEED_SELECTED_ACTION,
   _prefSelectedReader: PREF_FEED_SELECTED_READER,
   _smallIcon: "chrome://browser/skin/feeds/feedIcon16.png",
   _appPrefLabel: "webFeed"
 }
 
 var videoFeedHandlerInfo = {
   __proto__: new FeedHandlerInfo(TYPE_MAYBE_VIDEO_FEED),
-  _prefSelectedApp: PREF_VIDEO_FEED_SELECTED_APP, 
-  _prefSelectedWeb: PREF_VIDEO_FEED_SELECTED_WEB, 
-  _prefSelectedAction: PREF_VIDEO_FEED_SELECTED_ACTION, 
+  _prefSelectedApp: PREF_VIDEO_FEED_SELECTED_APP,
+  _prefSelectedWeb: PREF_VIDEO_FEED_SELECTED_WEB,
+  _prefSelectedAction: PREF_VIDEO_FEED_SELECTED_ACTION,
   _prefSelectedReader: PREF_VIDEO_FEED_SELECTED_READER,
   _smallIcon: "chrome://browser/skin/feeds/videoFeedIcon16.png",
   _appPrefLabel: "videoPodcastFeed"
 }
 
 var audioFeedHandlerInfo = {
   __proto__: new FeedHandlerInfo(TYPE_MAYBE_AUDIO_FEED),
-  _prefSelectedApp: PREF_AUDIO_FEED_SELECTED_APP, 
-  _prefSelectedWeb: PREF_AUDIO_FEED_SELECTED_WEB, 
-  _prefSelectedAction: PREF_AUDIO_FEED_SELECTED_ACTION, 
+  _prefSelectedApp: PREF_AUDIO_FEED_SELECTED_APP,
+  _prefSelectedWeb: PREF_AUDIO_FEED_SELECTED_WEB,
+  _prefSelectedAction: PREF_AUDIO_FEED_SELECTED_ACTION,
   _prefSelectedReader: PREF_AUDIO_FEED_SELECTED_READER,
   _smallIcon: "chrome://browser/skin/feeds/audioFeedIcon16.png",
   _appPrefLabel: "audioPodcastFeed"
 }
 
 /**
  * InternalHandlerInfoWrapper provides a basic mechanism to create an internal
  * mime type handler that can be enabled/disabled in the applications preference
@@ -848,17 +841,17 @@ var pdfHandlerInfo = {
 
 //****************************************************************************//
 // Prefpane Controller
 
 var gApplicationsPane = {
   // The set of types the app knows how to handle.  A hash of HandlerInfoWrapper
   // objects, indexed by type.
   _handledTypes: {},
-  
+
   // The list of types we can show, sorted by the sort column/direction.
   // An array of HandlerInfoWrapper objects.  We build this list when we first
   // load the data and then rebuild it when users change a pref that affects
   // what types we can show or change the sort column/direction.
   // Note: this isn't necessarily the list of types we *will* show; if the user
   // provides a filter string, we'll only show the subset of types in this list
   // that match that string.
   _visibleTypes: [],
@@ -949,17 +942,17 @@ var gApplicationsPane = {
     if (document.getElementById("actionColumn").hasAttribute("sortDirection")) {
       this._sortColumn = document.getElementById("actionColumn");
       // The typeColumn element always has a sortDirection attribute,
       // either because it was persisted or because the default value
       // from the xul file was used.  If we are sorting on the other
       // column, we should remove it.
       document.getElementById("typeColumn").removeAttribute("sortDirection");
     }
-    else 
+    else
       this._sortColumn = document.getElementById("typeColumn");
 
     // Load the data and build the list of handlers.
     // By doing this in a timeout, we let the preferences dialog resize itself
     // to an appropriate size before we add a bunch of items to the list.
     // Otherwise, if there are many items, and the Applications prefpane
     // is the one that gets displayed when the user first opens the dialog,
     // the dialog might stretch too much in an attempt to fit them all in.
@@ -1251,18 +1244,17 @@ var gApplicationsPane = {
   _describePreferredAction: function(aHandlerInfo) {
     // alwaysAskBeforeHandling overrides the preferred action, so if that flag
     // is set, then describe that behavior instead.  For most types, this is
     // the "alwaysAsk" string, but for the feed type we show something special.
     if (aHandlerInfo.alwaysAskBeforeHandling) {
       if (isFeedType(aHandlerInfo.type))
         return this._prefsBundle.getFormattedString("previewInApp",
                                                     [this._brandShortName]);
-      else
-        return this._prefsBundle.getString("alwaysAsk");
+      return this._prefsBundle.getString("alwaysAsk");
     }
 
     switch (aHandlerInfo.preferredAction) {
       case Ci.nsIHandlerInfo.saveToDisk:
         return this._prefsBundle.getString("saveFile");
 
       case Ci.nsIHandlerInfo.useHelperApp:
         var preferredApp = aHandlerInfo.preferredApplicationHandler;
@@ -1301,16 +1293,18 @@ var gApplicationsPane = {
       case Ci.nsIHandlerInfo.useSystemDefault:
         return this._prefsBundle.getFormattedString("useDefault",
                                                     [aHandlerInfo.defaultDescription]);
 
       case kActionUsePlugin:
         return this._prefsBundle.getFormattedString("usePluginIn",
                                                     [aHandlerInfo.pluginName,
                                                      this._brandShortName]);
+      default:
+        throw new Error(`Unexpected preferredAction: ${aHandlerInfo.preferredAction}`);
     }
   },
 
   _selectLastSelectedType: function() {
     // If the list is disabled by the pref.downloads.disable_button.edit_actions
     // preference being locked, then don't select the type, as that would cause
     // it to appear selected, with a different background and an actions menu
     // that makes it seem like you can choose an action for the type.
@@ -1347,31 +1341,31 @@ var gApplicationsPane = {
 
     if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
       return aHandlerApp.uri;
 
     return false;
   },
 
   _isValidHandlerExecutable: function(aExecutable) {
+    let leafName;
+    if (AppConstants.platform == "win") {
+      leafName = `${AppConstants.MOZ_APP_NAME}.exe`;
+    } else if (AppConstants.platform == "macosx") {
+      leafName = AppConstants.MOZ_MACBUNDLE_NAME;
+    } else {
+      leafName = `${AppConstants.MOZ_APP_NAME}-bin`;
+    }
     return aExecutable &&
            aExecutable.exists() &&
            aExecutable.isExecutable() &&
 // XXXben - we need to compare this with the running instance executable
 //          just don't know how to do that via script...
 // XXXmano TBD: can probably add this to nsIShellService
-#ifdef XP_WIN
-#expand    aExecutable.leafName != "__MOZ_APP_NAME__.exe";
-#else
-#ifdef XP_MACOSX
-#expand    aExecutable.leafName != "__MOZ_MACBUNDLE_NAME__";
-#else
-#expand    aExecutable.leafName != "__MOZ_APP_NAME__-bin";
-#endif
-#endif
+           aExecutable.leafName != leafName;
   },
 
   /**
    * Rebuild the actions menu for the selected entry.  Gets called by
    * the richlistitem constructor when an entry in the list gets selected.
    */
   rebuildActionsMenu: function() {
     var typeItem = this._list.selectedItem;
@@ -1381,17 +1375,17 @@ var gApplicationsPane = {
     var menuPopup = menu.menupopup;
 
     // Clear out existing items.
     while (menuPopup.hasChildNodes())
       menuPopup.removeChild(menuPopup.lastChild);
 
     // Add the "Preview in Firefox" option for optional internal handlers.
     if (handlerInfo instanceof InternalHandlerInfoWrapper) {
-      var internalMenuItem = document.createElement("menuitem");
+      let internalMenuItem = document.createElement("menuitem");
       internalMenuItem.setAttribute("action", Ci.nsIHandlerInfo.handleInternally);
       let label = this._prefsBundle.getFormattedString("previewInApp",
                                                        [this._brandShortName]);
       internalMenuItem.setAttribute("label", label);
       internalMenuItem.setAttribute("tooltiptext", label);
       internalMenuItem.setAttribute(APP_ICON_ATTR_NAME, "ask");
       menuPopup.appendChild(internalMenuItem);
     }
@@ -1423,17 +1417,17 @@ var gApplicationsPane = {
       saveMenuItem.setAttribute("label", label);
       saveMenuItem.setAttribute("tooltiptext", label);
       saveMenuItem.setAttribute(APP_ICON_ATTR_NAME, "save");
       menuPopup.appendChild(saveMenuItem);
     }
 
     // If this is the feed type, add a Live Bookmarks item.
     if (isFeedType(handlerInfo.type)) {
-      var internalMenuItem = document.createElement("menuitem");
+      let internalMenuItem = document.createElement("menuitem");
       internalMenuItem.setAttribute("action", Ci.nsIHandlerInfo.handleInternally);
       let label = this._prefsBundle.getFormattedString("addLiveBookmarksInApp",
                                                        [this._brandShortName]);
       internalMenuItem.setAttribute("label", label);
       internalMenuItem.setAttribute("tooltiptext", label);
       internalMenuItem.setAttribute(APP_ICON_ATTR_NAME, "feed");
       menuPopup.appendChild(internalMenuItem);
     }
@@ -1495,23 +1489,23 @@ var gApplicationsPane = {
       pluginMenuItem.setAttribute("label", label);
       pluginMenuItem.setAttribute("tooltiptext", label);
       pluginMenuItem.setAttribute(APP_ICON_ATTR_NAME, "plugin");
       menuPopup.appendChild(pluginMenuItem);
     }
 
     // Create a menu item for selecting a local application.
     let canOpenWithOtherApp = true;
-#ifdef XP_WIN
-    // On Windows, selecting an application to open another application
-    // would be meaningless so we special case executables.
-    let executableType = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
-                                                  .getTypeFromExtension("exe");
-    canOpenWithOtherApp = handlerInfo.type != executableType;
-#endif
+    if (AppConstants.platform == "win") {
+      // On Windows, selecting an application to open another application
+      // would be meaningless so we special case executables.
+      let executableType = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService)
+                                                    .getTypeFromExtension("exe");
+      canOpenWithOtherApp = handlerInfo.type != executableType;
+    }
     if (canOpenWithOtherApp)
     {
       let menuItem = document.createElement("menuitem");
       menuItem.className = "choose-app-item";
       menuItem.addEventListener("command", function(e) {
         gApplicationsPane.chooseApp(e);
       });
       let label = this._prefsBundle.getString("useOtherApp");
@@ -1543,17 +1537,17 @@ var gApplicationsPane = {
       case Ci.nsIHandlerInfo.handleInternally:
         menu.selectedItem = internalMenuItem;
         break;
       case Ci.nsIHandlerInfo.useSystemDefault:
         menu.selectedItem = defaultMenuItem;
         break;
       case Ci.nsIHandlerInfo.useHelperApp:
         if (preferredApp)
-          menu.selectedItem = 
+          menu.selectedItem =
             possibleAppMenuItems.filter(v => v.handlerApp.equals(preferredApp))[0];
         break;
       case kActionUsePlugin:
         menu.selectedItem = pluginMenuItem;
         break;
       case Ci.nsIHandlerInfo.saveToDisk:
         menu.selectedItem = saveMenuItem;
         break;
@@ -1744,72 +1738,71 @@ var gApplicationsPane = {
             actionsMenu.selectedIndex = i;
             this.onSelectAction(menuItem);
             break;
           }
         }
       }
     }.bind(this);
 
-#ifdef XP_WIN
-    var params = {};
-    var handlerInfo = this._handledTypes[this._list.selectedItem.type];
-
-    if (isFeedType(handlerInfo.type)) {
-      // MIME info will be null, create a temp object.
-      params.mimeInfo = this._mimeSvc.getFromTypeAndExtension(handlerInfo.type, 
-                                                 handlerInfo.primaryExtension);
-    } else {
-      params.mimeInfo = handlerInfo.wrappedHandlerInfo;
-    }
+    if (AppConstants.platform == "win") {
+      var params = {};
+      var handlerInfo = this._handledTypes[this._list.selectedItem.type];
 
-    params.title         = this._prefsBundle.getString("fpTitleChooseApp");
-    params.description   = handlerInfo.description;
-    params.filename      = null;
-    params.handlerApp    = null;
-
-    let onAppSelected = () => {
-      if (this.isValidHandlerApp(params.handlerApp)) {
-        handlerApp = params.handlerApp;
-
-        // Add the app to the type's list of possible handlers.
-        handlerInfo.addPossibleApplicationHandler(handlerApp);
+      if (isFeedType(handlerInfo.type)) {
+        // MIME info will be null, create a temp object.
+        params.mimeInfo = this._mimeSvc.getFromTypeAndExtension(handlerInfo.type,
+                                                   handlerInfo.primaryExtension);
+      } else {
+        params.mimeInfo = handlerInfo.wrappedHandlerInfo;
       }
 
-      chooseAppCallback(handlerApp);
-    };
-
-    gSubDialog.open("chrome://global/content/appPicker.xul",
-                    null, params, onAppSelected);
+      params.title         = this._prefsBundle.getString("fpTitleChooseApp");
+      params.description   = handlerInfo.description;
+      params.filename      = null;
+      params.handlerApp    = null;
 
-#else
-    let winTitle = this._prefsBundle.getString("fpTitleChooseApp");
-    let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
-    let fpCallback = function fpCallback_done(aResult) {
-      if (aResult == Ci.nsIFilePicker.returnOK && fp.file &&
-          this._isValidHandlerExecutable(fp.file)) {
-        handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
-                     createInstance(Ci.nsILocalHandlerApp);
-        handlerApp.name = getFileDisplayName(fp.file);
-        handlerApp.executable = fp.file;
+      let onAppSelected = () => {
+        if (this.isValidHandlerApp(params.handlerApp)) {
+          handlerApp = params.handlerApp;
 
-        // Add the app to the type's list of possible handlers.
-        let handlerInfo = this._handledTypes[this._list.selectedItem.type];
-        handlerInfo.addPossibleApplicationHandler(handlerApp);
+          // Add the app to the type's list of possible handlers.
+          handlerInfo.addPossibleApplicationHandler(handlerApp);
+        }
 
         chooseAppCallback(handlerApp);
-      }
-    }.bind(this);
+      };
+
+      gSubDialog.open("chrome://global/content/appPicker.xul",
+                      null, params, onAppSelected);
+    } else {
+      let winTitle = this._prefsBundle.getString("fpTitleChooseApp");
+      let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
+      let fpCallback = function fpCallback_done(aResult) {
+        if (aResult == Ci.nsIFilePicker.returnOK && fp.file &&
+            this._isValidHandlerExecutable(fp.file)) {
+          handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
+                       createInstance(Ci.nsILocalHandlerApp);
+          handlerApp.name = getFileDisplayName(fp.file);
+          handlerApp.executable = fp.file;
 
-    // Prompt the user to pick an app.  If they pick one, and it's a valid
-    // selection, then add it to the list of possible handlers.
-    fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
-    fp.appendFilters(Ci.nsIFilePicker.filterApps);
-    fp.open(fpCallback);
-#endif
+          // Add the app to the type's list of possible handlers.
+          let handlerInfo = this._handledTypes[this._list.selectedItem.type];
+          handlerInfo.addPossibleApplicationHandler(handlerApp);
+
+          chooseAppCallback(handlerApp);
+        }
+      }.bind(this);
+
+      // Prompt the user to pick an app.  If they pick one, and it's a valid
+      // selection, then add it to the list of possible handlers.
+      fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
+      fp.appendFilters(Ci.nsIFilePicker.filterApps);
+      fp.open(fpCallback);
+    }
   },
 
   // Mark which item in the list was last selected so we can reselect it
   // when we rebuild the list or when the user returns to the prefpane.
   onSelectionChanged: function() {
     if (this._list.selectedItem)
       this._list.setAttribute("lastSelectedType",
                               this._list.selectedItem.getAttribute("type"));
@@ -1853,17 +1846,17 @@ var gApplicationsPane = {
     switch (aHandlerInfo.preferredAction) {
       case Ci.nsIHandlerInfo.useSystemDefault:
         return this._getIconURLForSystemDefault(aHandlerInfo);
 
       case Ci.nsIHandlerInfo.useHelperApp:
         let preferredApp = aHandlerInfo.preferredApplicationHandler;
         if (this.isValidHandlerApp(preferredApp))
           return this._getIconURLForHandlerApp(preferredApp);
-        break;
+        // Explicit fall-through
 
       // This should never happen, but if preferredAction is set to some weird
       // value, then fall back to the generic application icon.
       default:
         return ICON_URL_APP;
     }
   },
 
@@ -1914,17 +1907,17 @@ var gApplicationsPane = {
 
       if (wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
           wrappedHandlerInfo instanceof Ci.nsIPropertyBag) {
         try {
           let url = wrappedHandlerInfo.getProperty("defaultApplicationIconURL");
           if (url)
             return url + "?size=16";
         }
-        catch(ex) {}
+        catch (ex) {}
       }
     }
 
     // If this isn't a MIME type object on an OS that supports retrieving
     // the icon, or if we couldn't retrieve the icon for some other reason,
     // then use a generic icon.
     return ICON_URL_APP;
   }
--- a/browser/components/preferences/in-content/jar.mn
+++ b/browser/components/preferences/in-content/jar.mn
@@ -2,16 +2,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 browser.jar:
    content/browser/preferences/in-content/preferences.js
 *  content/browser/preferences/in-content/preferences.xul
    content/browser/preferences/in-content/subdialogs.js
 
-*  content/browser/preferences/in-content/main.js
+   content/browser/preferences/in-content/main.js
    content/browser/preferences/in-content/privacy.js
-*  content/browser/preferences/in-content/advanced.js
-*  content/browser/preferences/in-content/applications.js
+   content/browser/preferences/in-content/advanced.js
+   content/browser/preferences/in-content/applications.js
    content/browser/preferences/in-content/content.js
    content/browser/preferences/in-content/sync.js
    content/browser/preferences/in-content/security.js
    content/browser/preferences/in-content/search.js
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -6,230 +6,231 @@ Components.utils.import("resource://gre/
 Components.utils.import("resource://gre/modules/FileUtils.jsm");
 Components.utils.import("resource://gre/modules/Task.jsm");
 Components.utils.import("resource:///modules/ShellService.jsm");
 Components.utils.import("resource:///modules/TransientPrefs.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 
-#ifdef E10S_TESTING_ONLY
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
-                                  "resource://gre/modules/UpdateUtils.jsm");
-#endif
+if (AppConstants.E10S_TESTING_ONLY) {
+  XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
+                                    "resource://gre/modules/UpdateUtils.jsm");
+}
 
 var gMainPane = {
   /**
    * Initialization of this.
    */
   init: function ()
   {
     function setEventListener(aId, aEventType, aCallback)
     {
       document.getElementById(aId)
               .addEventListener(aEventType, aCallback.bind(gMainPane));
     }
 
-#ifdef HAVE_SHELL_SERVICE
-    this.updateSetDefaultBrowser();
-#ifdef XP_WIN
-    // In Windows 8 we launch the control panel since it's the only
-    // way to get all file type association prefs. So we don't know
-    // when the user will select the default.  We refresh here periodically
-    // in case the default changes. On other Windows OS's defaults can also
-    // be set while the prefs are open.
-    window.setInterval(this.updateSetDefaultBrowser.bind(this), 1000);
-#endif
-#endif
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      this.updateSetDefaultBrowser();
+      if (AppConstants.platform == "win") {
+        // In Windows 8 we launch the control panel since it's the only
+        // way to get all file type association prefs. So we don't know
+        // when the user will select the default.  We refresh here periodically
+        // in case the default changes. On other Windows OS's defaults can also
+        // be set while the prefs are open.
+        window.setInterval(this.updateSetDefaultBrowser.bind(this), 1000);
+      }
+    }
 
     // set up the "use current page" label-changing listener
     this._updateUseCurrentButton();
     window.addEventListener("focus", this._updateUseCurrentButton.bind(this), false);
 
     this.updateBrowserStartupLastSession();
 
-#ifdef XP_WIN
-    // Functionality for "Show tabs in taskbar" on Windows 7 and up.
-    try {
-      let sysInfo = Cc["@mozilla.org/system-info;1"].
-                    getService(Ci.nsIPropertyBag2);
-      let ver = parseFloat(sysInfo.getProperty("version"));
-      let showTabsInTaskbar = document.getElementById("showTabsInTaskbar");
-      showTabsInTaskbar.hidden = ver < 6.1;
-    } catch (ex) {}
-#endif
+    if (AppConstants.platform == "win") {
+      // Functionality for "Show tabs in taskbar" on Windows 7 and up.
+      try {
+        let sysInfo = Cc["@mozilla.org/system-info;1"].
+                      getService(Ci.nsIPropertyBag2);
+        let ver = parseFloat(sysInfo.getProperty("version"));
+        let showTabsInTaskbar = document.getElementById("showTabsInTaskbar");
+        showTabsInTaskbar.hidden = ver < 6.1;
+      } catch (ex) {}
+    }
 
     // The "closing multiple tabs" and "opening multiple tabs might slow down
     // &brandShortName;" warnings provide options for not showing these
     // warnings again. When the user disabled them, we provide checkboxes to
     // re-enable the warnings.
     if (!TransientPrefs.prefShouldBeVisible("browser.tabs.warnOnClose"))
       document.getElementById("warnCloseMultiple").hidden = true;
     if (!TransientPrefs.prefShouldBeVisible("browser.tabs.warnOnOpen"))
       document.getElementById("warnOpenMany").hidden = true;
 
     setEventListener("browser.privatebrowsing.autostart", "change",
                      gMainPane.updateBrowserStartupLastSession);
     setEventListener("browser.download.dir", "change",
                      gMainPane.displayDownloadDirPref);
-#ifdef HAVE_SHELL_SERVICE
-    setEventListener("setDefaultButton", "command",
-                     gMainPane.setDefaultBrowser);
-#endif
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      setEventListener("setDefaultButton", "command",
+                       gMainPane.setDefaultBrowser);
+    }
     setEventListener("useCurrent", "command",
                      gMainPane.setHomePageToCurrent);
     setEventListener("useBookmark", "command",
                      gMainPane.setHomePageToBookmark);
     setEventListener("restoreDefaultHomePage", "command",
                      gMainPane.restoreDefaultHomePage);
     setEventListener("chooseFolder", "command",
                      gMainPane.chooseFolder);
 
-#ifdef E10S_TESTING_ONLY
-    setEventListener("e10sAutoStart", "command",
-                     gMainPane.enableE10SChange);
-    let e10sCheckbox = document.getElementById("e10sAutoStart");
+    if (AppConstants.E10S_TESTING_ONLY) {
+      setEventListener("e10sAutoStart", "command",
+                       gMainPane.enableE10SChange);
+      let e10sCheckbox = document.getElementById("e10sAutoStart");
 
-    let e10sPref = document.getElementById("browser.tabs.remote.autostart");
-    let e10sTempPref = document.getElementById("e10sTempPref");
-    let e10sForceEnable = document.getElementById("e10sForceEnable");
+      let e10sPref = document.getElementById("browser.tabs.remote.autostart");
+      let e10sTempPref = document.getElementById("e10sTempPref");
+      let e10sForceEnable = document.getElementById("e10sForceEnable");
 
-    let preffedOn = e10sPref.value || e10sTempPref.value || e10sForceEnable.value;
+      let preffedOn = e10sPref.value || e10sTempPref.value || e10sForceEnable.value;
 
-    if (preffedOn) {
-      // The checkbox is checked if e10s is preffed on and enabled.
-      e10sCheckbox.checked = Services.appinfo.browserTabsRemoteAutostart;
+      if (preffedOn) {
+        // The checkbox is checked if e10s is preffed on and enabled.
+        e10sCheckbox.checked = Services.appinfo.browserTabsRemoteAutostart;
 
-      // but if it's force disabled, then the checkbox is disabled.
-      e10sCheckbox.disabled = !Services.appinfo.browserTabsRemoteAutostart;
+        // but if it's force disabled, then the checkbox is disabled.
+        e10sCheckbox.disabled = !Services.appinfo.browserTabsRemoteAutostart;
+      }
     }
 
-#endif
-
-#ifdef MOZ_DEV_EDITION
-    let uAppData = OS.Constants.Path.userApplicationDataDir;
-    let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
+    if (AppConstants.MOZ_DEV_EDITION) {
+      let uAppData = OS.Constants.Path.userApplicationDataDir;
+      let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
-    setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
-    let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
-    setEventListener("getStarted", "click", gMainPane.onGetStarted);
+      setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
+      let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
+      setEventListener("getStarted", "click", gMainPane.onGetStarted);
 
-    OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
-                                             () => separateProfileModeCheckbox.checked = true);
-#endif
+      OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
+                                               () => separateProfileModeCheckbox.checked = true);
+    }
 
     // Notify observers that the UI is now ready
     Components.classes["@mozilla.org/observer-service;1"]
               .getService(Components.interfaces.nsIObserverService)
               .notifyObservers(window, "main-pane-loaded", null);
   },
 
-#ifdef E10S_TESTING_ONLY
   enableE10SChange: function ()
   {
-    let e10sCheckbox = document.getElementById("e10sAutoStart");
-    let e10sPref = document.getElementById("browser.tabs.remote.autostart");
-    let e10sTempPref = document.getElementById("e10sTempPref");
-
-    let prefsToChange;
-    if (e10sCheckbox.checked) {
-      // Enabling e10s autostart
-      prefsToChange = [e10sPref];
-    } else {
-      // Disabling e10s autostart
-      prefsToChange = [e10sPref];
-      if (e10sTempPref.value) {
-       prefsToChange.push(e10sTempPref);
-      }
-    }
-
-    let buttonIndex = confirmRestartPrompt(e10sCheckbox.checked, 0,
-                                           true, false);
-    if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
-      const Cc = Components.classes, Ci = Components.interfaces;
-      let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
-                         .createInstance(Ci.nsISupportsPRBool);
-      Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
-                                   "restart");
-      if (!cancelQuit.data) {
-        for (let prefToChange of prefsToChange) {
-          prefToChange.value = e10sCheckbox.checked;
-        }
-
-        Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit |  Ci.nsIAppStartup.eRestart);
-      }
-    }
+    if (AppConstants.E10S_TESTING_ONLY) {
+      let e10sCheckbox = document.getElementById("e10sAutoStart");
+      let e10sPref = document.getElementById("browser.tabs.remote.autostart");
+      let e10sTempPref = document.getElementById("e10sTempPref");
 
-    // Revert the checkbox in case we didn't quit
-    e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
-  },
-#endif
-
-#ifdef MOZ_DEV_EDITION
-  separateProfileModeChange: function ()
-  {
-    function quitApp() {
-      Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit |  Ci.nsIAppStartup.eRestartNotSameProfile);
-    }
-    function revertCheckbox(error) {
-      separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
-      if (error) {
-        Cu.reportError("Failed to toggle separate profile mode: " + error);
+      let prefsToChange;
+      if (e10sCheckbox.checked) {
+        // Enabling e10s autostart
+        prefsToChange = [e10sPref];
+      } else {
+        // Disabling e10s autostart
+        prefsToChange = [e10sPref];
+        if (e10sTempPref.value) {
+         prefsToChange.push(e10sTempPref);
+        }
       }
-    }
-    function createOrRemoveSpecialDevEditionFile(onSuccess) {
-      let uAppData = OS.Constants.Path.userApplicationDataDir;
-      let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
-      if (separateProfileModeCheckbox.checked) {
-        OS.File.remove(ignoreSeparateProfile).then(onSuccess, revertCheckbox);
-      } else {
-        OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(onSuccess, revertCheckbox);
-      }
-    }
-
-    let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
-    let button_index = confirmRestartPrompt(separateProfileModeCheckbox.checked,
-                                            0, false, true);
-    switch (button_index) {
-      case CONFIRM_RESTART_PROMPT_CANCEL:
-        revertCheckbox();
-        return;
-      case CONFIRM_RESTART_PROMPT_RESTART_NOW:
+      let buttonIndex = confirmRestartPrompt(e10sCheckbox.checked, 0,
+                                             true, false);
+      if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
         const Cc = Components.classes, Ci = Components.interfaces;
         let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
                            .createInstance(Ci.nsISupportsPRBool);
         Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
-                                      "restart");
+                                     "restart");
         if (!cancelQuit.data) {
-          createOrRemoveSpecialDevEditionFile(quitApp);
-          return;
+          for (let prefToChange of prefsToChange) {
+            prefToChange.value = e10sCheckbox.checked;
+          }
+
+          Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit |  Ci.nsIAppStartup.eRestart);
         }
+      }
+
+      // Revert the checkbox in case we didn't quit
+      e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
+    }
+  },
+
+  separateProfileModeChange: function ()
+  {
+    if (AppConstants.MOZ_DEV_EDITION) {
+      function quitApp() {
+        Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit |  Ci.nsIAppStartup.eRestartNotSameProfile);
+      }
+      function revertCheckbox(error) {
+        separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
+        if (error) {
+          Cu.reportError("Failed to toggle separate profile mode: " + error);
+        }
+      }
+      function createOrRemoveSpecialDevEditionFile(onSuccess) {
+        let uAppData = OS.Constants.Path.userApplicationDataDir;
+        let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
 
-        // Revert the checkbox in case we didn't quit
-        revertCheckbox();
-        return;
-      case CONFIRM_RESTART_PROMPT_RESTART_LATER:
-        createOrRemoveSpecialDevEditionFile();
-        return;
+        if (separateProfileModeCheckbox.checked) {
+          OS.File.remove(ignoreSeparateProfile).then(onSuccess, revertCheckbox);
+        } else {
+          OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(onSuccess, revertCheckbox);
+        }
+      }
+
+      let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
+      let button_index = confirmRestartPrompt(separateProfileModeCheckbox.checked,
+                                              0, false, true);
+      switch (button_index) {
+        case CONFIRM_RESTART_PROMPT_CANCEL:
+          revertCheckbox();
+          return;
+        case CONFIRM_RESTART_PROMPT_RESTART_NOW:
+          const Cc = Components.classes, Ci = Components.interfaces;
+          let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
+                             .createInstance(Ci.nsISupportsPRBool);
+          Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
+                                        "restart");
+          if (!cancelQuit.data) {
+            createOrRemoveSpecialDevEditionFile(quitApp);
+            return;
+          }
+
+          // Revert the checkbox in case we didn't quit
+          revertCheckbox();
+          return;
+        case CONFIRM_RESTART_PROMPT_RESTART_LATER:
+          createOrRemoveSpecialDevEditionFile();
+          return;
+      }
     }
   },
 
   onGetStarted: function (aEvent) {
-    const Cc = Components.classes, Ci = Components.interfaces;
-    let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-                .getService(Ci.nsIWindowMediator);
-    let win = wm.getMostRecentWindow("navigator:browser");
+    if (AppConstants.MOZ_DEV_EDITION) {
+      const Cc = Components.classes, Ci = Components.interfaces;
+      let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
+                  .getService(Ci.nsIWindowMediator);
+      let win = wm.getMostRecentWindow("navigator:browser");
 
-    if (win) {
-      let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
-      win.gBrowser.selectedTab = accountsTab;
+      if (win) {
+        let accountsTab = win.gBrowser.addTab("about:accounts?action=signin&entrypoint=dev-edition-setup");
+        win.gBrowser.selectedTab = accountsTab;
+      }
     }
   },
-#endif
 
   // HOME PAGE
 
   /*
    * Preferences:
    *
    * browser.startup.homepage
    * - the user's home page, as a string; if the home page is a set of tabs,
@@ -329,18 +330,18 @@ var gMainPane = {
     let tabs = this._getTabsForHomePage();
 
     if (tabs.length > 1)
       useCurrent.label = useCurrent.getAttribute("label2");
     else
       useCurrent.label = useCurrent.getAttribute("label1");
 
     // In this case, the button's disabled state is set by preferences.xml.
-    if (document.getElementById
-        ("pref.browser.homepage.disable_button.current_page").locked)
+    let prefName = "pref.browser.homepage.disable_button.current_page";
+    if (document.getElementById(prefName).locked)
       return;
 
     useCurrent.disabled = !tabs.length
   },
 
   _getTabsForHomePage: function ()
   {
     var win;
@@ -658,63 +659,63 @@ var gMainPane = {
    * Determines where a link which opens a new window will open.
    *
    * @returns 2 if such links should be opened in new windows,
    *          3 if such links should be opened in new tabs
    */
   writeLinkTarget: function() {
     var linkTargeting = document.getElementById("linkTargeting");
     return linkTargeting.checked ? 3 : 2;
-  }
-
-#ifdef HAVE_SHELL_SERVICE
-  ,
+  },
   /*
    * Preferences:
    *
    * browser.shell.checkDefault
    * - true if a default-browser check (and prompt to make it so if necessary)
    *   occurs at startup, false otherwise
    */
 
   /**
    * Show button for setting browser as default browser or information that
    * browser is already the default browser.
    */
   updateSetDefaultBrowser: function()
   {
-    let shellSvc = getShellService();
-    let defaultBrowserBox = document.getElementById("defaultBrowserBox");
-    if (!shellSvc) {
-      defaultBrowserBox.hidden = true;
-      return;
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      let shellSvc = getShellService();
+      let defaultBrowserBox = document.getElementById("defaultBrowserBox");
+      if (!shellSvc) {
+        defaultBrowserBox.hidden = true;
+        return;
+      }
+      let setDefaultPane = document.getElementById("setDefaultPane");
+      let isDefault = shellSvc.isDefaultBrowser(false, true);
+      setDefaultPane.selectedIndex = isDefault ? 1 : 0;
+      let alwaysCheck = document.getElementById("alwaysCheckDefault");
+      alwaysCheck.disabled = alwaysCheck.disabled ||
+                             isDefault && alwaysCheck.checked;
     }
-    let setDefaultPane = document.getElementById("setDefaultPane");
-    let isDefault = shellSvc.isDefaultBrowser(false, true);
-    setDefaultPane.selectedIndex = isDefault ? 1 : 0;
-    let alwaysCheck = document.getElementById("alwaysCheckDefault");
-    alwaysCheck.disabled = alwaysCheck.disabled ||
-                           isDefault && alwaysCheck.checked;
   },
 
   /**
    * Set browser as the operating system default browser.
    */
   setDefaultBrowser: function()
   {
-    let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser");
-    alwaysCheckPref.value = true;
+    if (AppConstants.HAVE_SHELL_SERVICE) {
+      let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser");
+      alwaysCheckPref.value = true;
 
-    let shellSvc = getShellService();
-    if (!shellSvc)
-      return;
-    try {
-      shellSvc.setDefaultBrowser(true, false);
-    } catch (ex) {
-      Cu.reportError(ex);
-      return;
+      let shellSvc = getShellService();
+      if (!shellSvc)
+        return;
+      try {
+        shellSvc.setDefaultBrowser(true, false);
+      } catch (ex) {
+        Cu.reportError(ex);
+        return;
+      }
+
+      let selectedIndex = shellSvc.isDefaultBrowser(false, true) ? 1 : 0;
+      document.getElementById("setDefaultPane").selectedIndex = selectedIndex;
     }
-
-    let selectedIndex = shellSvc.isDefaultBrowser(false, true) ? 1 : 0;
-    document.getElementById("setDefaultPane").selectedIndex = selectedIndex;
-  }
-#endif
+  },
 };
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -216,17 +216,17 @@ function confirmRestartPrompt(aRestartTo
   // Set up the third (index 2) button:
   let button2Text = null;
   if (aWantRestartLaterButton) {
     button2Text = bundle.getString("restartLater");
     buttonFlags += (Services.prompt.BUTTON_POS_2 *
                     Services.prompt.BUTTON_TITLE_IS_STRING);
   }
 
-  switch(aDefaultButtonIndex) {
+  switch (aDefaultButtonIndex) {
     case 0:
       buttonFlags += Services.prompt.BUTTON_POS_0_DEFAULT;
       break;
     case 1:
       buttonFlags += Services.prompt.BUTTON_POS_1_DEFAULT;
       break;
     case 2:
       buttonFlags += Services.prompt.BUTTON_POS_2_DEFAULT;
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -139,19 +139,23 @@ var gPrivacyPane = {
    * Selects the right item of the Tracking Protection radiogroup.
    */
   trackingProtectionReadPrefs() {
     let enabledPref = document.getElementById("privacy.trackingprotection.enabled");
     let pbmPref = document.getElementById("privacy.trackingprotection.pbmode.enabled");
     let radiogroup = document.getElementById("trackingProtectionRadioGroup");
 
     // Global enable takes precedence over enabled in Private Browsing.
-    radiogroup.value = enabledPref.value ? "always" :
-                       pbmPref.value ? "private" :
-                       "never";
+    if (enabledPref.value) {
+      radiogroup.value = "always";
+    } else if (pbmPref.value) {
+      radiogroup.value = "private";
+    } else {
+      radiogroup.value = "never";
+    }
   },
 
   /**
    * Sets the pref values based on the selected item of the radiogroup.
    */
   trackingProtectionWritePrefs() {
     let enabledPref = document.getElementById("privacy.trackingprotection.enabled");
     let pbmPref = document.getElementById("privacy.trackingprotection.pbmode.enabled");
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -525,19 +525,18 @@ EngineView.prototype = {
   drop: function(dropIndex, orientation, dataTransfer) {
     var sourceIndex = this.getSourceIndexFromDrag(dataTransfer);
     var sourceEngine = this._engineStore.engines[sourceIndex];
 
     const nsITreeView = Components.interfaces.nsITreeView;
     if (dropIndex > sourceIndex) {
       if (orientation == nsITreeView.DROP_BEFORE)
         dropIndex--;
-    } else {
-      if (orientation == nsITreeView.DROP_AFTER)
-        dropIndex++;
+    } else if (orientation == nsITreeView.DROP_AFTER) {
+      dropIndex++;
     }
 
     this._engineStore.moveEngine(sourceEngine, dropIndex);
     gSearchPane.showRestoreDefaults(true);
     gSearchPane.buildDefaultEngineDropDown();
 
     // Redraw, and adjust selection
     this.invalidate();
--- a/browser/components/preferences/in-content/security.js
+++ b/browser/components/preferences/in-content/security.js
@@ -110,21 +110,20 @@ var gSecurityPane = {
   {
     var pref = document.getElementById("signon.rememberSignons");
     var excepts = document.getElementById("passwordExceptions");
 
     if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
       document.getElementById("savePasswords").disabled = true;
       excepts.disabled = true;
       return false;
-    } else {
-      excepts.disabled = !pref.value;
-      // don't override pref value in UI
-      return undefined;
     }
+    excepts.disabled = !pref.value;
+    // don't override pref value in UI
+    return undefined;
   },
 
   /**
    * Displays a dialog in which the user can view and modify the list of sites
    * where passwords are never saved.
    */
   showPasswordExceptions: function ()
   {
--- a/browser/components/preferences/in-content/sync.js
+++ b/browser/components/preferences/in-content/sync.js
@@ -359,16 +359,17 @@ var gSyncPane = {
 
         // If the account is verified the next promise in the chain will
         // fetch profile data.
         return data.verified;
       }).then(isVerified => {
         if (isVerified) {
           return fxAccounts.getSignedInUserProfile();
         }
+        return null;
       }).then(data => {
         let fxaLoginStatus = document.getElementById("fxaLoginStatus");
         if (data && profileInfoEnabled) {
           if (data.displayName) {
             fxaLoginStatus.setAttribute("hasName", true);
             displayNameLabel.hidden = false;
             displayNameLabel.textContent = data.displayName;
           } else {
@@ -417,17 +418,17 @@ var gSyncPane = {
       document.getElementById("syncComputerName").value = Weave.Service.clientsEngine.localName;
       document.getElementById("tosPP-normal").hidden = this._usingCustomServer;
     }
   },
 
   startOver: function (showDialog) {
     if (showDialog) {
       let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
-                  Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL + 
+                  Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
                   Services.prompt.BUTTON_POS_1_DEFAULT;
       let buttonChoice =
         Services.prompt.confirmEx(window,
                                   this._stringBundle.GetStringFromName("syncUnlink.title"),
                                   this._stringBundle.GetStringFromName("syncUnlink.label"),
                                   flags,
                                   this._stringBundle.GetStringFromName("syncUnlinkConfirm.label"),
                                   null, null, null, {});
@@ -543,23 +544,19 @@ var gSyncPane = {
   reSignIn: function() {
     this._openAboutAccounts("reauth");
   },
 
 
   clickOrSpaceOrEnterPressed: function(event) {
     // Note: charCode is deprecated, but 'char' not yet implemented.
     // Replace charCode with char when implemented, see Bug 680830
-    if ((event.type == "click" && event.button == 0) ||    // button 0 = 'main button', typically left click.
-        (event.type == "keypress" &&
-        (event.charCode == KeyEvent.DOM_VK_SPACE || event.keyCode == KeyEvent.DOM_VK_RETURN))) {
-      return true;
-    } else {
-      return false;
-    }
+    return ((event.type == "click" && event.button == 0) ||
+            (event.type == "keypress" &&
+             (event.charCode == KeyEvent.DOM_VK_SPACE || event.keyCode == KeyEvent.DOM_VK_RETURN)));
   },
 
   openChangeProfileImage: function(event) {
     if (this.clickOrSpaceOrEnterPressed(event)) {
       fxAccounts.promiseAccountsChangeProfileURI(this._getEntryPoint(), "avatar")
           .then(url => {
         this.openContentInBrowser(url, {
           replaceQueryString: true
@@ -646,21 +643,21 @@ var gSyncPane = {
     fxAccounts.signOut().then(() => {
       this.updateWeavePrefs();
     });
   },
 
   openAddDevice: function () {
     if (!Weave.Utils.ensureMPUnlocked())
       return;
-    
+
     let win = Services.wm.getMostRecentWindow("Sync:AddDevice");
     if (win)
       win.focus();
-    else 
+    else
       window.openDialog("chrome://browser/content/sync/addDevice.xul",
                         "syncAddDevice", "centerscreen,chrome,resizable=no");
   },
 
   resetSync: function () {
     this.openSetup("reset");
   },
 
--- a/browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js
+++ b/browser/components/preferences/in-content/tests/browser_basic_rebuild_fonts_test.js
@@ -1,15 +1,15 @@
 Services.prefs.setBoolPref("browser.preferences.instantApply", true);
 
 registerCleanupFunction(function() {
   Services.prefs.clearUserPref("browser.preferences.instantApply");
 });
 
-add_task(function() {
+add_task(function*() {
   yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
   let doc = gBrowser.contentDocument;
   var langGroup = Services.prefs.getComplexValue("font.language.group", Ci.nsIPrefLocalizedString).data
   is(doc.getElementById("font.language.group").value, langGroup,
      "Language group should be set correctly.");
 
   let defaultFontType = Services.prefs.getCharPref("font.default." + langGroup);
   let fontFamily = Services.prefs.getCharPref("font.name." + defaultFontType + "." + langGroup);
--- a/browser/components/preferences/in-content/tests/browser_bug1018066_resetScrollPosition.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1018066_resetScrollPosition.js
@@ -1,24 +1,24 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-var originalWindowHeight;
-registerCleanupFunction(function() {
-  window.resizeTo(window.outerWidth, originalWindowHeight);
-  while (gBrowser.tabs[1])
-    gBrowser.removeTab(gBrowser.tabs[1]);
-});
-
-add_task(function() {
-  originalWindowHeight = window.outerHeight;
-  window.resizeTo(window.outerWidth, 300);
-  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneApplications", undefined, {leaveOpen: true});
-  is(prefs.selectedPane, "paneApplications", "Applications pane was selected");
-  let mainContent = gBrowser.contentDocument.querySelector(".main-content");
-  mainContent.scrollTop = 50;
-  is(mainContent.scrollTop, 50, "main-content should be scrolled 50 pixels");
-
-  gBrowser.contentWindow.gotoPref("paneGeneral");
-  is(mainContent.scrollTop, 0,
-     "Switching to a different category should reset the scroll position");
-});
-
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var originalWindowHeight;
+registerCleanupFunction(function() {
+  window.resizeTo(window.outerWidth, originalWindowHeight);
+  while (gBrowser.tabs[1])
+    gBrowser.removeTab(gBrowser.tabs[1]);
+});
+
+add_task(function*() {
+  originalWindowHeight = window.outerHeight;
+  window.resizeTo(window.outerWidth, 300);
+  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneApplications", undefined, {leaveOpen: true});
+  is(prefs.selectedPane, "paneApplications", "Applications pane was selected");
+  let mainContent = gBrowser.contentDocument.querySelector(".main-content");
+  mainContent.scrollTop = 50;
+  is(mainContent.scrollTop, 50, "main-content should be scrolled 50 pixels");
+
+  gBrowser.contentWindow.gotoPref("paneGeneral");
+  is(mainContent.scrollTop, 0,
+     "Switching to a different category should reset the scroll position");
+});
+
--- a/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
@@ -2,17 +2,17 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 Services.prefs.setBoolPref("browser.preferences.instantApply", true);
 
 registerCleanupFunction(function() {
   Services.prefs.clearUserPref("browser.preferences.instantApply");
 });
 
-add_task(function() {
+add_task(function*() {
   let prefs = yield openPreferencesViaOpenPreferencesAPI("paneContent");
   is(prefs.selectedPane, "paneContent", "Content pane was selected");
   prefs = yield openPreferencesViaOpenPreferencesAPI("advanced", "updateTab");
   is(prefs.selectedPane, "paneAdvanced", "Advanced pane was selected");
   is(prefs.selectedAdvancedTab, "updateTab", "The update tab within the advanced prefs should be selected");
   prefs = yield openPreferencesViaHash("privacy");
   is(prefs.selectedPane, "panePrivacy", "Privacy pane is selected when hash is 'privacy'");
   prefs = yield openPreferencesViaOpenPreferencesAPI("nonexistant-category");
--- a/browser/components/preferences/in-content/tests/browser_bug705422.js
+++ b/browser/components/preferences/in-content/tests/browser_bug705422.js
@@ -55,23 +55,23 @@ function isDisabled(win, expectation) {
 }
 
 function runTest(win, searchTerm, cookies, matches) {
     var cm =  Components.classes["@mozilla.org/cookiemanager;1"]
                         .getService(Components.interfaces.nsICookieManager);
 
 
     // number of cookies should match injected cookies
-    var cnt = 0,
-        enumerator = cm.enumerator;
-    while (enumerator.hasMoreElements()) {
-        cnt++;
-        enumerator.getNext();
+    var injectedCookies = 0,
+        injectedEnumerator = cm.enumerator;
+    while (injectedEnumerator.hasMoreElements()) {
+        injectedCookies++;
+        injectedEnumerator.getNext();
     }
-    is(cnt, cookies, "Number of cookies match injected cookies");
+    is(injectedCookies, cookies, "Number of cookies match injected cookies");
 
     // "delete all cookies" should be enabled
     isDisabled(win, false);
 
     // filter cookies and count matches
     win.gCookiesWindow.setFilter(searchTerm);
     is(win.gCookiesWindow._view.rowCount, matches, "Correct number of cookies shown after filter is applied");
 
@@ -121,23 +121,23 @@ function runTest(win, searchTerm, cookie
     // "delete all cookies" should be enabled
     isDisabled(win, false);
 
     // delete all cookies and count should be 0
     EventUtils.synthesizeMouseAtCenter(deleteAllButton, {}, win);
     is(win.gCookiesWindow._view.rowCount, 0, "Deleted all cookies");
 
     // check that datastore is also at 0
-    var cnt = 0,
-        enumerator = cm.enumerator;
-    while (enumerator.hasMoreElements()) {
-        cnt++;
-        enumerator.getNext();
+    var remainingCookies = 0,
+        remainingEnumerator = cm.enumerator;
+    while (remainingEnumerator.hasMoreElements()) {
+        remainingCookies++;
+        remainingEnumerator.getNext();
     }
-    is(cnt, 0, "Zero cookies remain");
+    is(remainingCookies, 0, "Zero cookies remain");
 
     // "delete all cookies" should be disabled
     isDisabled(win, true);
 
     // clean up
     win.close();
     finish();
 }
--- a/browser/components/preferences/in-content/tests/browser_connection_bug388287.js
+++ b/browser/components/preferences/in-content/tests/browser_connection_bug388287.js
@@ -35,17 +35,17 @@ function test() {
       if (proxyType == "http") {
         continue;
       }
       Services.prefs.clearUserPref("network.proxy.backup." + proxyType);
       Services.prefs.clearUserPref("network.proxy.backup." + proxyType + "_port");
     }
     try {
       Services.ww.unregisterNotification(observer);
-    } catch(e) {
+    } catch (e) {
       // Do nothing, if the test was successful the above line should fail silently.
     }
   });
 
   // this observer is registered after the pref tab loads
   let observer = {
     observe: function(aSubject, aTopic, aData) {
       if (aTopic == "domwindowopened") {
--- a/browser/components/preferences/in-content/tests/browser_defaultbrowser_alwayscheck.js
+++ b/browser/components/preferences/in-content/tests/browser_defaultbrowser_alwayscheck.js
@@ -1,103 +1,103 @@
-"use strict";
-
-const CHECK_DEFAULT_INITIAL = Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser");
-
-add_task(function* clicking_make_default_checks_alwaysCheck_checkbox() {
-  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
-
-  yield test_with_mock_shellservice({isDefault: false}, function*() {
-    let setDefaultPane = content.document.getElementById("setDefaultPane");
-    Assert.equal(setDefaultPane.selectedIndex, "0",
-      "The 'make default' pane should be visible when not default");
-    let alwaysCheck = content.document.getElementById("alwaysCheckDefault");
-    Assert.ok(!alwaysCheck.checked, "Always Check is unchecked by default");
-    Assert.ok(!Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
-      "alwaysCheck pref should be false by default in test runs");
-
-    let setDefaultButton = content.document.getElementById("setDefaultButton");
-    setDefaultButton.click();
-    content.window.gMainPane.updateSetDefaultBrowser();
-
-    yield ContentTaskUtils.waitForCondition(() => alwaysCheck.checked,
-      "'Always Check' checkbox should get checked after clicking the 'Set Default' button");
-
-    Assert.ok(alwaysCheck.checked,
-      "Clicking 'Make Default' checks the 'Always Check' checkbox");
-    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
-      "Checking the checkbox should set the pref to true");
-    Assert.ok(alwaysCheck.disabled,
-      "'Always Check' checkbox is locked with default browser and alwaysCheck=true");
-    Assert.equal(setDefaultPane.selectedIndex, "1",
-      "The 'make default' pane should not be visible when default");
-    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
-      "checkDefaultBrowser pref is now enabled");
-  });
-
-  gBrowser.removeCurrentTab();
-  Services.prefs.clearUserPref("browser.shell.checkDefaultBrowser");
-});
-
-add_task(function* clicking_make_default_checks_alwaysCheck_checkbox() {
-  Services.prefs.lockPref("browser.shell.checkDefaultBrowser");
-  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
-
-  yield test_with_mock_shellservice({isDefault: false}, function*() {
-    let setDefaultPane = content.document.getElementById("setDefaultPane");
-    Assert.equal(setDefaultPane.selectedIndex, "0",
-      "The 'make default' pane should be visible when not default");
-    let alwaysCheck = content.document.getElementById("alwaysCheckDefault");
-    Assert.ok(alwaysCheck.disabled, "Always Check is disabled when locked");
-    Assert.ok(alwaysCheck.checked,
-      "Always Check is checked because defaultPref is true and pref is locked");
-    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
-      "alwaysCheck pref should ship with 'true' by default");
-
-    let setDefaultButton = content.document.getElementById("setDefaultButton");
-    setDefaultButton.click();
-    content.window.gMainPane.updateSetDefaultBrowser();
-
-    yield ContentTaskUtils.waitForCondition(() => setDefaultPane.selectedIndex == "1",
-      "Browser is now default");
-
-    Assert.ok(alwaysCheck.checked,
-      "'Always Check' is still checked because it's locked");
-    Assert.ok(alwaysCheck.disabled,
-      "'Always Check is disabled because it's locked");
-    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
-      "The pref is locked and so doesn't get changed");
-  });
-
-  Services.prefs.unlockPref("browser.shell.checkDefaultBrowser");
-  gBrowser.removeCurrentTab();
-});
-
-registerCleanupFunction(function() {
-  Services.prefs.unlockPref("browser.shell.checkDefaultBrowser");
-  Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", CHECK_DEFAULT_INITIAL);
-});
-
-function* test_with_mock_shellservice(options, testFn) {
-  yield ContentTask.spawn(gBrowser.selectedBrowser, options, function*(options) {
-    let doc = content.document;
-    let win = doc.defaultView;
-    win.oldShellService = win.getShellService();
-    let mockShellService = {
-      _isDefault: false,
-      isDefaultBrowser() {
-        return this._isDefault;
-      },
-      setDefaultBrowser() {
-        this._isDefault = true;
-      },
-    };
-    win.getShellService = function() {
-      return mockShellService;
-    }
-    mockShellService._isDefault = options.isDefault;
-    win.gMainPane.updateSetDefaultBrowser();
-  });
-
-  yield ContentTask.spawn(gBrowser.selectedBrowser, null, testFn);
-
-  Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", CHECK_DEFAULT_INITIAL);
-}
+"use strict";
+
+const CHECK_DEFAULT_INITIAL = Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser");
+
+add_task(function* clicking_make_default_checks_alwaysCheck_checkbox() {
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
+
+  yield test_with_mock_shellservice({isDefault: false}, function*() {
+    let setDefaultPane = content.document.getElementById("setDefaultPane");
+    Assert.equal(setDefaultPane.selectedIndex, "0",
+      "The 'make default' pane should be visible when not default");
+    let alwaysCheck = content.document.getElementById("alwaysCheckDefault");
+    Assert.ok(!alwaysCheck.checked, "Always Check is unchecked by default");
+    Assert.ok(!Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
+      "alwaysCheck pref should be false by default in test runs");
+
+    let setDefaultButton = content.document.getElementById("setDefaultButton");
+    setDefaultButton.click();
+    content.window.gMainPane.updateSetDefaultBrowser();
+
+    yield ContentTaskUtils.waitForCondition(() => alwaysCheck.checked,
+      "'Always Check' checkbox should get checked after clicking the 'Set Default' button");
+
+    Assert.ok(alwaysCheck.checked,
+      "Clicking 'Make Default' checks the 'Always Check' checkbox");
+    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
+      "Checking the checkbox should set the pref to true");
+    Assert.ok(alwaysCheck.disabled,
+      "'Always Check' checkbox is locked with default browser and alwaysCheck=true");
+    Assert.equal(setDefaultPane.selectedIndex, "1",
+      "The 'make default' pane should not be visible when default");
+    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
+      "checkDefaultBrowser pref is now enabled");
+  });
+
+  gBrowser.removeCurrentTab();
+  Services.prefs.clearUserPref("browser.shell.checkDefaultBrowser");
+});
+
+add_task(function* clicking_make_default_checks_alwaysCheck_checkbox() {
+  Services.prefs.lockPref("browser.shell.checkDefaultBrowser");
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:preferences");
+
+  yield test_with_mock_shellservice({isDefault: false}, function*() {
+    let setDefaultPane = content.document.getElementById("setDefaultPane");
+    Assert.equal(setDefaultPane.selectedIndex, "0",
+      "The 'make default' pane should be visible when not default");
+    let alwaysCheck = content.document.getElementById("alwaysCheckDefault");
+    Assert.ok(alwaysCheck.disabled, "Always Check is disabled when locked");
+    Assert.ok(alwaysCheck.checked,
+      "Always Check is checked because defaultPref is true and pref is locked");
+    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
+      "alwaysCheck pref should ship with 'true' by default");
+
+    let setDefaultButton = content.document.getElementById("setDefaultButton");
+    setDefaultButton.click();
+    content.window.gMainPane.updateSetDefaultBrowser();
+
+    yield ContentTaskUtils.waitForCondition(() => setDefaultPane.selectedIndex == "1",
+      "Browser is now default");
+
+    Assert.ok(alwaysCheck.checked,
+      "'Always Check' is still checked because it's locked");
+    Assert.ok(alwaysCheck.disabled,
+      "'Always Check is disabled because it's locked");
+    Assert.ok(Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser"),
+      "The pref is locked and so doesn't get changed");
+  });
+
+  Services.prefs.unlockPref("browser.shell.checkDefaultBrowser");
+  gBrowser.removeCurrentTab();
+});
+
+registerCleanupFunction(function() {
+  Services.prefs.unlockPref("browser.shell.checkDefaultBrowser");
+  Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", CHECK_DEFAULT_INITIAL);
+});
+
+function* test_with_mock_shellservice(options, testFn) {
+  yield ContentTask.spawn(gBrowser.selectedBrowser, options, function*(options) {
+    let doc = content.document;
+    let win = doc.defaultView;
+    win.oldShellService = win.getShellService();
+    let mockShellService = {
+      _isDefault: false,
+      isDefaultBrowser() {
+        return this._isDefault;
+      },
+      setDefaultBrowser() {
+        this._isDefault = true;
+      },
+    };
+    win.getShellService = function() {
+      return mockShellService;
+    }
+    mockShellService._isDefault = options.isDefault;
+    win.gMainPane.updateSetDefaultBrowser();
+  });
+
+  yield ContentTask.spawn(gBrowser.selectedBrowser, null, testFn);
+
+  Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", CHECK_DEFAULT_INITIAL);
+}
--- a/browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js
+++ b/browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js
@@ -1,20 +1,20 @@
-add_task(function() {
-  is(gBrowser.currentURI.spec, "about:blank", "Test starts with about:blank open");
-  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
-  yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
-  let doc = gBrowser.contentDocument;
-  is(gBrowser.currentURI.spec, "about:preferences#general",
-     "#general should be in the URI for about:preferences");
-  let oldHomepagePref = Services.prefs.getCharPref("browser.startup.homepage");
-
-  let useCurrent = doc.getElementById("useCurrent");
-  useCurrent.click();
-
-  is(gBrowser.tabs.length, 3, "Three tabs should be open");
-  is(Services.prefs.getCharPref("browser.startup.homepage"), "about:blank|about:home",
-     "about:blank and about:home should be the only homepages set");
-
-  Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
-  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
-  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
-});
+add_task(function*() {
+  is(gBrowser.currentURI.spec, "about:blank", "Test starts with about:blank open");
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:home");
+  yield openPreferencesViaOpenPreferencesAPI("paneGeneral", null, {leaveOpen: true});
+  let doc = gBrowser.contentDocument;
+  is(gBrowser.currentURI.spec, "about:preferences#general",
+     "#general should be in the URI for about:preferences");
+  let oldHomepagePref = Services.prefs.getCharPref("browser.startup.homepage");
+
+  let useCurrent = doc.getElementById("useCurrent");
+  useCurrent.click();
+
+  is(gBrowser.tabs.length, 3, "Three tabs should be open");
+  is(Services.prefs.getCharPref("browser.startup.homepage"), "about:blank|about:home",
+     "about:blank and about:home should be the only homepages set");
+
+  Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
--- a/browser/components/preferences/in-content/tests/browser_notifications_do_not_disturb.js
+++ b/browser/components/preferences/in-content/tests/browser_notifications_do_not_disturb.js
@@ -1,44 +1,44 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-
-registerCleanupFunction(function() {
-  while (gBrowser.tabs[1])
-    gBrowser.removeTab(gBrowser.tabs[1]);
-});
-
-add_task(function() {
-  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneContent", undefined, {leaveOpen: true});
-  is(prefs.selectedPane, "paneContent", "Content pane was selected");
-
-  let doc = gBrowser.contentDocument;
-  let notificationsDoNotDisturbRow = doc.getElementById("notificationsDoNotDisturbRow");
-  if (notificationsDoNotDisturbRow.hidden) {
-    todo(false, "Do not disturb is not available on this platform");
-    return;
-  }
-
-  let alertService;
-  try {
-    alertService = Cc["@mozilla.org/alerts-service;1"]
-                     .getService(Ci.nsIAlertsService)
-                     .QueryInterface(Ci.nsIAlertsDoNotDisturb);
-  } catch (ex) {
-    ok(true, "Do not disturb is not available on this platform: " + ex.message);
-    return;
-  }
-
-  let checkbox = doc.getElementById("notificationsDoNotDisturb");
-  ok(!checkbox.checked, "Checkbox should not be checked by default");
-  ok(!alertService.manualDoNotDisturb, "Do not disturb should be off by default");
-
-  let checkboxChanged = waitForEvent(checkbox, "command")
-  checkbox.click();
-  yield checkboxChanged;
-  ok(alertService.manualDoNotDisturb, "Do not disturb should be enabled when checked");
-
-  checkboxChanged = waitForEvent(checkbox, "command")
-  checkbox.click();
-  yield checkboxChanged;
-  ok(!alertService.manualDoNotDisturb, "Do not disturb should be disabled when unchecked");
-});
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+
+registerCleanupFunction(function() {
+  while (gBrowser.tabs[1])
+    gBrowser.removeTab(gBrowser.tabs[1]);
+});
+
+add_task(function*() {
+  let prefs = yield openPreferencesViaOpenPreferencesAPI("paneContent", undefined, {leaveOpen: true});
+  is(prefs.selectedPane, "paneContent", "Content pane was selected");
+
+  let doc = gBrowser.contentDocument;
+  let notificationsDoNotDisturbRow = doc.getElementById("notificationsDoNotDisturbRow");
+  if (notificationsDoNotDisturbRow.hidden) {
+    todo(false, "Do not disturb is not available on this platform");
+    return;
+  }
+
+  let alertService;
+  try {
+    alertService = Cc["@mozilla.org/alerts-service;1"]
+                     .getService(Ci.nsIAlertsService)
+                     .QueryInterface(Ci.nsIAlertsDoNotDisturb);
+  } catch (ex) {
+    ok(true, "Do not disturb is not available on this platform: " + ex.message);
+    return;
+  }
+
+  let checkbox = doc.getElementById("notificationsDoNotDisturb");
+  ok(!checkbox.checked, "Checkbox should not be checked by default");
+  ok(!alertService.manualDoNotDisturb, "Do not disturb should be off by default");
+
+  let checkboxChanged = waitForEvent(checkbox, "command")
+  checkbox.click();
+  yield checkboxChanged;
+  ok(alertService.manualDoNotDisturb, "Do not disturb should be enabled when checked");
+
+  checkboxChanged = waitForEvent(checkbox, "command")
+  checkbox.click();
+  yield checkboxChanged;
+  ok(!alertService.manualDoNotDisturb, "Do not disturb should be disabled when unchecked");
+});
--- a/browser/components/preferences/in-content/tests/browser_permissions_urlFieldHidden.js
+++ b/browser/components/preferences/in-content/tests/browser_permissions_urlFieldHidden.js
@@ -1,45 +1,45 @@
-"use strict";
-
-const PERMISSIONS_URL = "chrome://browser/content/preferences/permissions.xul";
-
-add_task(function* urlFieldVisibleForPopupPermissions(finish) {
-  yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
-  let win = gBrowser.selectedBrowser.contentWindow;
-  let doc = win.document;
-  let popupPolicyCheckbox = doc.getElementById("popupPolicy");
-  ok(!popupPolicyCheckbox.checked, "popupPolicyCheckbox should be unchecked by default");
-  popupPolicyCheckbox.click();
-  let popupPolicyButton = doc.getElementById("popupPolicyButton");
-  ok(popupPolicyButton, "popupPolicyButton found");
-  let dialogPromise = promiseLoadSubDialog(PERMISSIONS_URL);
-  popupPolicyButton.click();
-  let dialog = yield dialogPromise;
-  ok(dialog, "dialog loaded");
-
-  let urlLabel = dialog.document.getElementById("urlLabel");
-  ok(!urlLabel.hidden, "urlLabel should be visible when one of block/session/allow visible");
-  let url = dialog.document.getElementById("url");
-  ok(!url.hidden, "url should be visible when one of block/session/allow visible");
-
-  popupPolicyCheckbox.click();
-  gBrowser.removeCurrentTab();
-});
-
-add_task(function* urlFieldHiddenForNotificationPermissions() {
-  yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
-  let win = gBrowser.selectedBrowser.contentWindow;
-  let doc = win.document;
-  let notificationsPolicyButton = doc.getElementById("notificationsPolicyButton");
-  ok(notificationsPolicyButton, "notificationsPolicyButton found");
-  let dialogPromise = promiseLoadSubDialog(PERMISSIONS_URL);
-  notificationsPolicyButton.click();
-  let dialog = yield dialogPromise;
-  ok(dialog, "dialog loaded");
-
-  let urlLabel = dialog.document.getElementById("urlLabel");
-  ok(urlLabel.hidden, "urlLabel should be hidden as requested");
-  let url = dialog.document.getElementById("url");
-  ok(url.hidden, "url should be hidden as requested");
-
-  gBrowser.removeCurrentTab();
-});
+"use strict";
+
+const PERMISSIONS_URL = "chrome://browser/content/preferences/permissions.xul";
+
+add_task(function* urlFieldVisibleForPopupPermissions(finish) {
+  yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
+  let win = gBrowser.selectedBrowser.contentWindow;
+  let doc = win.document;
+  let popupPolicyCheckbox = doc.getElementById("popupPolicy");
+  ok(!popupPolicyCheckbox.checked, "popupPolicyCheckbox should be unchecked by default");
+  popupPolicyCheckbox.click();
+  let popupPolicyButton = doc.getElementById("popupPolicyButton");
+  ok(popupPolicyButton, "popupPolicyButton found");
+  let dialogPromise = promiseLoadSubDialog(PERMISSIONS_URL);
+  popupPolicyButton.click();
+  let dialog = yield dialogPromise;
+  ok(dialog, "dialog loaded");
+
+  let urlLabel = dialog.document.getElementById("urlLabel");
+  ok(!urlLabel.hidden, "urlLabel should be visible when one of block/session/allow visible");
+  let url = dialog.document.getElementById("url");
+  ok(!url.hidden, "url should be visible when one of block/session/allow visible");
+
+  popupPolicyCheckbox.click();
+  gBrowser.removeCurrentTab();
+});
+
+add_task(function* urlFieldHiddenForNotificationPermissions() {
+  yield openPreferencesViaOpenPreferencesAPI("paneContent", null, {leaveOpen: true});
+  let win = gBrowser.selectedBrowser.contentWindow;
+  let doc = win.document;
+  let notificationsPolicyButton = doc.getElementById("notificationsPolicyButton");
+  ok(notificationsPolicyButton, "notificationsPolicyButton found");
+  let dialogPromise = promiseLoadSubDialog(PERMISSIONS_URL);
+  notificationsPolicyButton.click();
+  let dialog = yield dialogPromise;
+  ok(dialog, "dialog loaded");
+
+  let urlLabel = dialog.document.getElementById("urlLabel");
+  ok(urlLabel.hidden, "urlLabel should be hidden as requested");
+  let url = dialog.document.getElementById("url");
+  ok(url.hidden, "url should be hidden as requested");
+
+  gBrowser.removeCurrentTab();
+});
--- a/browser/components/preferences/in-content/tests/browser_sanitizeOnShutdown_prefLocked.js
+++ b/browser/components/preferences/in-content/tests/browser_sanitizeOnShutdown_prefLocked.js
@@ -1,37 +1,37 @@
-"use strict";
-
-function switchToCustomHistoryMode(doc) {
-  // Select the last item in the menulist.
-  let menulist = doc.getElementById("historyMode");
-  menulist.focus();
-  EventUtils.sendKey("UP");
-}
-
-function testPrefStateMatchesLockedState() {
-  let win = gBrowser.contentWindow;
-  let doc = win.document;
-  switchToCustomHistoryMode(doc);
-
-  let checkbox = doc.getElementById("alwaysClear");
-  let preference = doc.getElementById("privacy.sanitize.sanitizeOnShutdown");
-  is(checkbox.disabled, preference.locked, "Always Clear checkbox should be enabled when preference is not locked.");
-
-  gBrowser.removeCurrentTab();
-}
-
-add_task(function setup() {
-  registerCleanupFunction(function resetPreferences() {
-    Services.prefs.unlockPref("privacy.sanitize.sanitizeOnShutdown");
-  });
-});
-
-add_task(function test_preference_enabled_when_unlocked() {
-  yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
-  testPrefStateMatchesLockedState();
-});
-
-add_task(function test_preference_disabled_when_locked() {
-  Services.prefs.lockPref("privacy.sanitize.sanitizeOnShutdown");
-  yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
-  testPrefStateMatchesLockedState();
-});
+"use strict";
+
+function switchToCustomHistoryMode(doc) {
+  // Select the last item in the menulist.
+  let menulist = doc.getElementById("historyMode");
+  menulist.focus();
+  EventUtils.sendKey("UP");
+}
+
+function testPrefStateMatchesLockedState() {
+  let win = gBrowser.contentWindow;
+  let doc = win.document;
+  switchToCustomHistoryMode(doc);
+
+  let checkbox = doc.getElementById("alwaysClear");
+  let preference = doc.getElementById("privacy.sanitize.sanitizeOnShutdown");
+  is(checkbox.disabled, preference.locked, "Always Clear checkbox should be enabled when preference is not locked.");
+
+  gBrowser.removeCurrentTab();
+}
+
+add_task(function setup() {
+  registerCleanupFunction(function resetPreferences() {
+    Services.prefs.unlockPref("privacy.sanitize.sanitizeOnShutdown");
+  });
+});
+
+add_task(function* test_preference_enabled_when_unlocked() {
+  yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
+  testPrefStateMatchesLockedState();
+});
+
+add_task(function* test_preference_disabled_when_locked() {
+  Services.prefs.lockPref("privacy.sanitize.sanitizeOnShutdown");
+  yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
+  testPrefStateMatchesLockedState();
+});
--- a/browser/components/preferences/jar.mn
+++ b/browser/components/preferences/jar.mn
@@ -4,26 +4,26 @@
 
 browser.jar:
     content/browser/preferences/applicationManager.xul
     content/browser/preferences/applicationManager.js
     content/browser/preferences/blocklists.xul
     content/browser/preferences/blocklists.js
 *   content/browser/preferences/colors.xul
 *   content/browser/preferences/cookies.xul
-*   content/browser/preferences/cookies.js
+    content/browser/preferences/cookies.js
 *   content/browser/preferences/connection.xul
     content/browser/preferences/connection.js
     content/browser/preferences/donottrack.xul
 *   content/browser/preferences/fonts.xul
     content/browser/preferences/fonts.js
     content/browser/preferences/handlers.xml
     content/browser/preferences/handlers.css
 *   content/browser/preferences/languages.xul
     content/browser/preferences/languages.js
     content/browser/preferences/permissions.xul
-*   content/browser/preferences/permissions.js
+    content/browser/preferences/permissions.js
     content/browser/preferences/sanitize.xul
     content/browser/preferences/sanitize.js
     content/browser/preferences/selectBookmark.xul
     content/browser/preferences/selectBookmark.js
     content/browser/preferences/translation.xul
     content/browser/preferences/translation.js
--- a/browser/components/preferences/languages.js
+++ b/browser/components/preferences/languages.js
@@ -2,19 +2,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var gLanguagesDialog = {
 
   _availableLanguagesList : [],
   _acceptLanguages        : { },
-  
+
   _selectedItemID         : null,
-  
+
   init: function ()
   {
     if (!this._availableLanguagesList.length)
       this._loadAvailableLanguages();
   },
 
   // Ugly hack used to trigger extra reflow in order to work around XUL bug 1194844;
   // see bug 1194346.
@@ -23,22 +23,22 @@ var gLanguagesDialog = {
     this._activeLanguages.style.fontKerning = "none";
     setTimeout("gLanguagesDialog._activeLanguages.style.removeProperty('font-kerning')", 0);
   },
 
   get _activeLanguages()
   {
     return document.getElementById("activeLanguages");
   },
-  
+
   get _availableLanguages()
   {
     return document.getElementById("availableLanguages");
   },
-  
+
   _loadAvailableLanguages: function ()
   {
     // This is a parser for: resource://gre/res/language.properties
     // The file is formatted like so:
     // ab[-cd].accept=true|false
     //  ab = language
     //  cd = region
     var bundleAccepted    = document.getElementById("bundleAccepted");
@@ -54,245 +54,245 @@ var gLanguagesDialog = {
     }
 
     // 1) Read the available languages out of language.properties
     var strings = bundleAccepted.strings;
     while (strings.hasMoreElements()) {
       var currString = strings.getNext();
       if (!(currString instanceof Components.interfaces.nsIPropertyElement))
         break;
-      
+
       var property = currString.key.split("."); // ab[-cd].accept
       if (property[1] == "accept") {
         var abCD = property[0];
         var abCDPairs = abCD.split("-");      // ab[-cd]
         var useABCDFormat = abCDPairs.length > 1;
         var ab = useABCDFormat ? abCDPairs[0] : abCD;
         var cd = useABCDFormat ? abCDPairs[1] : "";
         if (ab) {
           var language = "";
           try {
             language = bundleLanguages.getString(ab);
-          } 
-          catch (e) { continue; };
-          
+          }
+          catch (e) { continue; }
+
           var region = "";
           if (useABCDFormat) {
             try {
               region = bundleRegions.getString(cd);
             }
             catch (e) { continue; }
           }
-          
+
           var name = "";
           if (useABCDFormat)
-            name = bundlePreferences.getFormattedString("languageRegionCodeFormat", 
+            name = bundlePreferences.getFormattedString("languageRegionCodeFormat",
                                                         [language, region, abCD]);
           else
-            name = bundlePreferences.getFormattedString("languageCodeFormat", 
+            name = bundlePreferences.getFormattedString("languageCodeFormat",
                                                         [language, abCD]);
-          
+
           if (name && abCD) {
-            var isVisible = currString.value == "true" && 
+            var isVisible = currString.value == "true" &&
                             (!(abCD in this._acceptLanguages) || !this._acceptLanguages[abCD]);
             var li = new LanguageInfo(name, abCD, isVisible);
             this._availableLanguagesList.push(li);
           }
         }
       }
     }
     this._buildAvailableLanguageList();
   },
-  
+
   _buildAvailableLanguageList: function ()
   {
     var availableLanguagesPopup = document.getElementById("availableLanguagesPopup");
     while (availableLanguagesPopup.hasChildNodes())
       availableLanguagesPopup.removeChild(availableLanguagesPopup.firstChild);
-      
+
     // Sort the list of languages by name
     this._availableLanguagesList.sort(function (a, b) {
                                         return a.name.localeCompare(b.name);
                                       });
-                                  
+
     // Load the UI with the data
     for (var i = 0; i < this._availableLanguagesList.length; ++i) {
       var abCD = this._availableLanguagesList[i].abcd;
-      if (this._availableLanguagesList[i].isVisible && 
+      if (this._availableLanguagesList[i].isVisible &&
           (!(abCD in this._acceptLanguages) || !this._acceptLanguages[abCD])) {
         var menuitem = document.createElement("menuitem");
         menuitem.id = this._availableLanguagesList[i].abcd;
         availableLanguagesPopup.appendChild(menuitem);
         menuitem.setAttribute("label", this._availableLanguagesList[i].name);
       }
     }
   },
-  
+
   readAcceptLanguages: function ()
   {
     while (this._activeLanguages.hasChildNodes())
       this._activeLanguages.removeChild(this._activeLanguages.firstChild);
-    
+
     var selectedIndex = 0;
     var preference = document.getElementById("intl.accept_languages");
-    if (preference.value == "") 
+    if (preference.value == "")
       return undefined;
     var languages = preference.value.toLowerCase().split(/\s*,\s*/);
     for (var i = 0; i < languages.length; ++i) {
       var name = this._getLanguageName(languages[i]);
       if (!name)
         name = "[" + languages[i] + "]";
       var listitem = document.createElement("listitem");
       listitem.id = languages[i];
       if (languages[i] == this._selectedItemID)
         selectedIndex = i;
       this._activeLanguages.appendChild(listitem);
       listitem.setAttribute("label", name);
 
       // Hash this language as an "Active" language so we don't
-      // show it in the list that can be added. 
+      // show it in the list that can be added.
       this._acceptLanguages[languages[i]] = true;
     }
 
     if (this._activeLanguages.childNodes.length > 0) {
       this._activeLanguages.ensureIndexIsVisible(selectedIndex);
       this._activeLanguages.selectedIndex = selectedIndex;
     }
 
     return undefined;
   },
-  
+
   writeAcceptLanguages: function ()
   {
     return undefined;
   },
-  
+
   onAvailableLanguageSelect: function ()
   {
     var addButton = document.getElementById("addButton");
     addButton.disabled = false;
-    
+
     this._availableLanguages.removeAttribute("accesskey");
   },
-  
+
   addLanguage: function ()
   {
     var selectedID = this._availableLanguages.selectedItem.id;
     var preference = document.getElementById("intl.accept_languages");
     var arrayOfPrefs = preference.value.toLowerCase().split(/\s*,\s*/);
-    for (var i = 0; i < arrayOfPrefs.length; ++i ){
+    for (var i = 0; i < arrayOfPrefs.length; ++i ) {
       if (arrayOfPrefs[i] == selectedID)
         return;
     }
 
     this._selectedItemID = selectedID;
 
-    if (preference.value == "") 
+    if (preference.value == "")
       preference.value = selectedID;
     else {
       arrayOfPrefs.unshift(selectedID);
       preference.value = arrayOfPrefs.join(",");
     }
-  
+
     this._acceptLanguages[selectedID] = true;
     this._availableLanguages.selectedItem = null;
-    
+
     // Rebuild the available list with the added item removed...
-    this._buildAvailableLanguageList(); 
-    
+    this._buildAvailableLanguageList();
+
     this._availableLanguages.setAttribute("label", this._availableLanguages.getAttribute("label2"));
   },
-  
+
   removeLanguage: function ()
   {
     // Build the new preference value string.
     var languagesArray = [];
     for (var i = 0; i < this._activeLanguages.childNodes.length; ++i) {
       var item = this._activeLanguages.childNodes[i];
-      if (!item.selected) 
+      if (!item.selected)
         languagesArray.push(item.id);
-      else  
+      else
         this._acceptLanguages[item.id] = false;
     }
     var string = languagesArray.join(",");
 
-    // Get the item to select after the remove operation completes.     
+    // Get the item to select after the remove operation completes.
     var selection = this._activeLanguages.selectedItems;
     var lastSelected = selection[selection.length-1];
     var selectItem = lastSelected.nextSibling || lastSelected.previousSibling;
     selectItem = selectItem ? selectItem.id : null;
-    
+
     this._selectedItemID = selectItem;
 
     // Update the preference and force a UI rebuild
     var preference = document.getElementById("intl.accept_languages");
     preference.value = string;
 
-    this._buildAvailableLanguageList(); 
+    this._buildAvailableLanguageList();
   },
-  
+
   _getLanguageName: function (aABCD)
   {
     if (!this._availableLanguagesList.length)
       this._loadAvailableLanguages();
     for (var i = 0; i < this._availableLanguagesList.length; ++i) {
-      if (aABCD == this._availableLanguagesList[i].abcd) 
+      if (aABCD == this._availableLanguagesList[i].abcd)
         return this._availableLanguagesList[i].name;
     }
     return "";
   },
-  
+
   moveUp: function ()
   {
     var selectedItem = this._activeLanguages.selectedItems[0];
     var previousItem = selectedItem.previousSibling;
-    
+
     var string = "";
     for (var i = 0; i < this._activeLanguages.childNodes.length; ++i) {
       var item = this._activeLanguages.childNodes[i];
       string += (i == 0 ? "" : ",");
-      if (item.id == previousItem.id) 
+      if (item.id == previousItem.id)
         string += selectedItem.id;
       else if (item.id == selectedItem.id)
         string += previousItem.id;
       else
         string += item.id;
     }
-    
+
     this._selectedItemID = selectedItem.id;
 
     // Update the preference and force a UI rebuild
     var preference = document.getElementById("intl.accept_languages");
     preference.value = string;
   },
-  
+
   moveDown: function ()
   {
     var selectedItem = this._activeLanguages.selectedItems[0];
     var nextItem = selectedItem.nextSibling;
-    
+
     var string = "";
     for (var i = 0; i < this._activeLanguages.childNodes.length; ++i) {
       var item = this._activeLanguages.childNodes[i];
       string += (i == 0 ? "" : ",");
-      if (item.id == nextItem.id) 
+      if (item.id == nextItem.id)
         string += selectedItem.id;
       else if (item.id == selectedItem.id)
         string += nextItem.id;
       else
         string += item.id;
     }
-    
+
     this._selectedItemID = selectedItem.id;
 
     // Update the preference and force a UI rebuild
     var preference = document.getElementById("intl.accept_languages");
     preference.value = string;
   },
-  
+
   onLanguageSelect: function ()
   {
     var upButton = document.getElementById("up");
     var downButton = document.getElementById("down");
     var removeButton = document.getElementById("remove");
     switch (this._activeLanguages.selectedCount) {
     case 0:
       upButton.disabled = downButton.disabled = removeButton.disabled = true;
--- a/browser/components/preferences/permissions.js
+++ b/browser/components/preferences/permissions.js
@@ -39,24 +39,24 @@ var gPermissionManager = {
       else if (aColumn.id == "statusCol")
         return gPermissionManager._permissions[aRow].capability;
       return "";
     },
 
     isSeparator: function(aIndex) { return false; },
     isSorted: function() { return false; },
     isContainer: function(aIndex) { return false; },
-    setTree: function(aTree){},
+    setTree: function(aTree) {},
     getImageSrc: function(aRow, aColumn) {},
     getProgressMode: function(aRow, aColumn) {},
     getCellValue: function(aRow, aColumn) {},
     cycleHeader: function(column) {},
-    getRowProperties: function(row){ return ""; },
-    getColumnProperties: function(column){ return ""; },
-    getCellProperties: function(row,column){
+    getRowProperties: function(row) { return ""; },
+    getColumnProperties: function(column) { return ""; },
+    getCellProperties: function(row,column) {
       if (column.element.getAttribute("id") == "siteCol")
         return "ltr";
 
       return "";
     }
   },
 
   _getCapabilityString: function (aCapability)
@@ -93,23 +93,23 @@ var gPermissionManager = {
       // permission manager for storage, so this won't prevent any valid
       // permissions from being entered by the user.
       let uri;
       try {
         uri = Services.io.newURI(input_url, null, null);
         principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
         // If we have ended up with an unknown scheme, the following will throw.
         principal.origin;
-      } catch(ex) {
+      } catch (ex) {
         uri = Services.io.newURI("http://" + input_url, null, null);
         principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
         // If we have ended up with an unknown scheme, the following will throw.
         principal.origin;
       }
-    } catch(ex) {
+    } catch (ex) {
       var message = this._bundle.getString("invalidURI");
       var title = this._bundle.getString("invalidURITitle");
       Services.prompt.alert(window, title, message);
       return;
     }
 
     var capabilityString = this._getCapabilityString(aCapability);
 
@@ -344,22 +344,22 @@ var gPermissionManager = {
       this._removePermission(p);
     }
     document.getElementById("removePermission").disabled = true;
     document.getElementById("removeAllPermissions").disabled = true;
   },
 
   onPermissionKeyPress: function (aEvent)
   {
-    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE
-#ifdef XP_MACOSX
-        || aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE
-#endif
-       )
+    if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE) {
       this.onPermissionDeleted();
+    } else if (AppConstants.platform == "macosx" &&
+               aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE) {
+      this.onPermissionDeleted();
+    }
   },
 
   _lastPermissionSortColumn: "",
   _lastPermissionSortAscending: false,
   _permissionsComparator : function (a, b)
   {
     return a.toLowerCase().localeCompare(b.toLowerCase());
   },
--- a/browser/components/preferences/selectBookmark.js
+++ b/browser/components/preferences/selectBookmark.js
@@ -1,36 +1,36 @@
 //* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * SelectBookmarkDialog controls the user interface for the "Use Bookmark for
- * Home Page" dialog. 
- * 
+ * Home Page" dialog.
+ *
  * The caller (gMainPane.setHomePageToBookmark in main.js) invokes this dialog
  * with a single argument - a reference to an object with a .urls property and
  * a .names property.  This dialog is responsible for updating the contents of
  * the .urls property with an array of URLs to use as home pages and for
  * updating the .names property with an array of names for those URLs before it
  * closes.
- */ 
+ */
 var SelectBookmarkDialog = {
   init: function SBD_init() {
     document.getElementById("bookmarks").place =
       "place:queryType=1&folder=" + PlacesUIUtils.allBookmarksFolderId;
 
     // Initial update of the OK button.
     this.selectionChanged();
   },
 
-  /** 
-   * Update the disabled state of the OK button as the user changes the 
-   * selection within the view. 
+  /**
+   * Update the disabled state of the OK button as the user changes the
+   * selection within the view.
    */
   selectionChanged: function SBD_selectionChanged() {
     var accept = document.documentElement.getButton("accept");
     var bookmarks = document.getElementById("bookmarks");
     var disableAcceptButton = true;
     if (bookmarks.hasSelection) {
       if (!PlacesUtils.nodeIsSeparator(bookmarks.selectedNode))
         disableAcceptButton = false;
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -125,16 +125,23 @@ this.AppConstants = Object.freeze({
 
   MOZ_WEBRTC:
 #ifdef MOZ_WEBRTC
   true,
 #else
   false,
 #endif
 
+  MOZ_WIDGET_GTK:
+#ifdef MOZ_WIDGET_GTK
+  true,
+#else
+  false,
+#endif
+
 # MOZ_B2G covers both device and desktop b2g
   MOZ_B2G:
 #ifdef MOZ_B2G
   true,
 #else
   false,
 #endif
 
@@ -320,9 +327,16 @@ this.AppConstants = Object.freeze({
   SOURCE_REVISION_URL: "@MOZ_SOURCE_URL@",
 
   HAVE_USR_LIB64_DIR:
 #ifdef HAVE_USR_LIB64_DIR
     true,
 #else
     false,
 #endif
+
+  HAVE_SHELL_SERVICE:
+#ifdef HAVE_SHELL_SERVICE
+    true,
+#else
+    false,
+#endif
 });
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -97,16 +97,19 @@ EXTRA_JS_MODULES += [
 EXTRA_JS_MODULES.third_party.jsesc += ['third_party/jsesc/jsesc.js']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
     DEFINES['CAN_DRAW_IN_TITLEBAR'] = 1
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3'):
     DEFINES['MENUBAR_CAN_AUTOHIDE'] = 1
 
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk2', 'gtk3', 'cocoa'):
+    DEFINES['HAVE_SHELL_SERVICE'] = 1
+
 EXTRA_PP_JS_MODULES += [
     'AppConstants.jsm',
 ]
 
 if 'Android' != CONFIG['OS_TARGET']:
     EXTRA_JS_MODULES += [
         'LightweightThemeConsumer.jsm',
     ]