Bug 1294621 - Enable the no-lonely-if rule for eslint. r?gijs draft
authorJared Wein <jwein@mozilla.com>
Fri, 12 Aug 2016 01:33:53 -0400
changeset 399801 aebcafdd70e971ae2ffcad6d1847849ce8fa7a32
parent 399800 615ff7a6a24effbe61d9a39cdd99aac7ed3bb7ce
child 528075 f5a267d2932e2696dfab9d0245736eaacfd21b3d
push id25998
push userjwein@mozilla.com
push dateFri, 12 Aug 2016 05:34:27 +0000
reviewersgijs
bugs1294621
milestone51.0a1
Bug 1294621 - Enable the no-lonely-if rule for eslint. r?gijs MozReview-Commit-ID: 8izEqc8IyCu
browser/base/content/browser-gestureSupport.js
browser/base/content/browser-tabsintitlebar.js
browser/base/content/browser.js
browser/base/content/safeMode.js
browser/components/customizableui/CustomizableUI.jsm
browser/components/places/content/browserPlacesViews.js
browser/components/places/content/editBookmarkOverlay.js
browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js
browser/extensions/pocket/content/panels/js/saved.js
browser/modules/PluginContent.jsm
toolkit/.eslintrc
toolkit/components/alerts/resources/content/alert.js
toolkit/components/filepicker/content/filepicker.js
toolkit/components/microformats/microformat-shiv.js
toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
toolkit/components/passwordmgr/LoginManagerContent.jsm
toolkit/components/passwordmgr/storage-json.js
toolkit/components/perfmonitoring/AddonWatcher.jsm
toolkit/components/printing/content/printjoboptions.js
toolkit/components/prompts/src/CommonDialog.jsm
toolkit/components/satchel/FormHistory.jsm
toolkit/components/timermanager/nsUpdateTimerManager.js
toolkit/components/viewsource/ViewSourceBrowser.jsm
toolkit/components/viewsource/content/viewSource-content.js
toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js
toolkit/content/widgets/button.xml
toolkit/content/widgets/resizer.xml
toolkit/content/widgets/scrollbox.xml
toolkit/content/widgets/tree.xml
toolkit/modules/secondscreen/RokuApp.jsm
toolkit/modules/tests/xpcshell/test_Log.js
toolkit/mozapps/downloads/DownloadLastDir.jsm
toolkit/mozapps/downloads/DownloadUtils.jsm
toolkit/mozapps/extensions/LightweightThemeManager.jsm
toolkit/mozapps/extensions/addonManager.js
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
toolkit/mozapps/update/nsUpdateService.js
toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -709,32 +709,30 @@ var gHistorySwipeAnimation = {
 
       // The current page is pushed to the right (LTR) or left (RTL),
       // the intention is to go back.
       // If there is a page to go back to, it should show in the background.
       this._positionBox(this._curBox, aVal / tempDampValue);
 
       // The forward page should be pushed offscreen all the way to the right.
       this._positionBox(this._nextBox, 1);
-    } else {
+    } else if (this._canGoForward) {
       // The intention is to go forward. If there is a page to go forward to,
       // it should slide in from the right (LTR) or left (RTL).
       // Otherwise, the current page should slide to the left (LTR) or
       // right (RTL) and the backdrop should appear in the background.
       // For the backdrop to be visible in that case, the previous page needs
       // to be hidden (if it exists).
-      if (this._canGoForward) {
-        this._nextBox.collapsed = false;
-        let offset = this.isLTR ? 1 : -1;
-        this._positionBox(this._curBox, 0);
-        this._positionBox(this._nextBox, offset + aVal);
-      } else {
-        this._prevBox.collapsed = true;
-        this._positionBox(this._curBox, aVal / dampValue);
-      }
+      this._nextBox.collapsed = false;
+      let offset = this.isLTR ? 1 : -1;
+      this._positionBox(this._curBox, 0);
+      this._positionBox(this._nextBox, offset + aVal);
+    } else {
+      this._prevBox.collapsed = true;
+      this._positionBox(this._curBox, aVal / dampValue);
     }
   },
 
   _getCurrentHistoryIndex: function() {
     return SessionStore.getSessionHistory(gBrowser.selectedTab).index;
   },
 
   /**
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -50,21 +50,19 @@ var TabsInTitlebar = {
   },
 
   allowedBy: function (condition, allow) {
     if (allow) {
       if (condition in this._disallowed) {
         delete this._disallowed[condition];
         this._update(true);
       }
-    } else {
-      if (!(condition in this._disallowed)) {
-        this._disallowed[condition] = null;
-        this._update(true);
-      }
+    } else if (!(condition in this._disallowed)) {
+      this._disallowed[condition] = null;
+      this._update(true);
     }
   },
 
   updateAppearance: function updateAppearance(aForce) {
     this._update(aForce);
   },
 
   get enabled() {
@@ -293,21 +291,21 @@ function updateTitlebarDisplay() {
       let isCustomizing = document.documentElement.hasAttribute("customizing");
       let hasLWTheme = document.documentElement.hasAttribute("lwtheme");
       let isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
       if ((!hasLWTheme || isCustomizing) && !isPrivate) {
         document.documentElement.removeAttribute("chromemargin");
       }
       document.documentElement.setAttribute("drawtitle", "true");
     }
-  } else { // not OS X
-    if (TabsInTitlebar.enabled)
-      document.documentElement.setAttribute("chromemargin", "0,2,2,2");
-    else
-      document.documentElement.removeAttribute("chromemargin");
+  } else if (TabsInTitlebar.enabled) {
+    // not OS X
+    document.documentElement.setAttribute("chromemargin", "0,2,2,2");
+  } else {
+    document.documentElement.removeAttribute("chromemargin");
   }
 }
 
 function onTitlebarMaxClick() {
   if (window.windowState == window.STATE_MAXIMIZED)
     window.restore();
   else
     window.maximize();
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4103,20 +4103,18 @@ function updateCharacterEncodingMenuStat
   let charsetMenu = document.getElementById("charsetMenu");
   // gBrowser is null on Mac when the menubar shows in the context of
   // non-browser windows. The above elements may be null depending on
   // what parts of the menubar are present. E.g. no app menu on Mac.
   if (gBrowser && gBrowser.selectedBrowser.mayEnableCharacterEncodingMenu) {
     if (charsetMenu) {
       charsetMenu.removeAttribute("disabled");
     }
-  } else {
-    if (charsetMenu) {
-      charsetMenu.setAttribute("disabled", "true");
-    }
+  } else if (charsetMenu) {
+    charsetMenu.setAttribute("disabled", "true");
   }
 }
 
 var XULBrowserWindow = {
   // Stored Status, Link and Loading values
   status: "",
   defaultStatus: "",
   overLink: "",
@@ -7824,19 +7822,18 @@ var MousePosTracker = {
     if (hover == listener._hover)
       return;
 
     listener._hover = hover;
 
     if (hover) {
       if (listener.onMouseEnter)
         listener.onMouseEnter();
-    } else {
-      if (listener.onMouseLeave)
-        listener.onMouseLeave();
+    } else if (listener.onMouseLeave) {
+      listener.onMouseLeave();
     }
   }
 };
 
 function BrowserOpenNewTabOrWindow(event) {
   if (event.shiftKey) {
     OpenBrowserWindow();
   } else {
--- a/browser/base/content/safeMode.js
+++ b/browser/base/content/safeMode.js
@@ -70,16 +70,14 @@ function onLoad() {
     document.getElementById("autoSafeMode").hidden = false;
     document.getElementById("safeMode").hidden = true;
     if (ResetProfile.resetSupported()) {
       document.getElementById("resetProfile").hidden = false;
     } else {
       // Hide the reset button is it's not supported.
       document.documentElement.getButton("extra1").hidden = true;
     }
-  } else {
-    if (!ResetProfile.resetSupported()) {
-      // Hide the reset button and text if it's not supported.
-      document.documentElement.getButton("extra1").hidden = true;
-      document.getElementById("resetProfileInstead").hidden = true;
-    }
+  } else if (!ResetProfile.resetSupported()) {
+    // Hide the reset button and text if it's not supported.
+    document.documentElement.getButton("extra1").hidden = true;
+    document.getElementById("resetProfileInstead").hidden = true;
   }
 }
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -4320,41 +4320,36 @@ OverflowableToolbar.prototype = {
       // Let's try to move stuff back:
       else if (!nowInBar) {
         this._moveItemsBackToTheirOrigin(true);
       }
       // If it's in the toolbar now, then we don't care. An overflow event may
       // fire afterwards; that's ok!
     }
     // If it used to be overflowed...
-    else {
+    else if (!nowOverflowed) {
       // ... and isn't anymore, let's remove our bookkeeping:
-      if (!nowOverflowed) {
-        this._collapsed.delete(aNode.id);
-        aNode.removeAttribute("cui-anchorid");
-        aNode.removeAttribute("overflowedItem");
-        CustomizableUIInternal.notifyListeners("onWidgetUnderflow", aNode, this._target);
-
-        if (!this._collapsed.size) {
-          this._toolbar.removeAttribute("overflowing");
-          CustomizableUI.removeListener(this);
-        }
+      this._collapsed.delete(aNode.id);
+      aNode.removeAttribute("cui-anchorid");
+      aNode.removeAttribute("overflowedItem");
+      CustomizableUIInternal.notifyListeners("onWidgetUnderflow", aNode, this._target);
+
+      if (!this._collapsed.size) {
+        this._toolbar.removeAttribute("overflowing");
+        CustomizableUI.removeListener(this);
       }
+    } else if (aNode.previousSibling) {
       // but if it still is, it must have changed places. Bookkeep:
-      else {
-        if (aNode.previousSibling) {
-          let prevId = aNode.previousSibling.id;
-          let minSize = this._collapsed.get(prevId);
-          this._collapsed.set(aNode.id, minSize);
-        } else {
-          // If it's now the first item in the overflow list,
-          // maybe we can return it:
-          this._moveItemsBackToTheirOrigin();
-        }
-      }
+      let prevId = aNode.previousSibling.id;
+      let minSize = this._collapsed.get(prevId);
+      this._collapsed.set(aNode.id, minSize);
+    } else {
+      // If it's now the first item in the overflow list,
+      // maybe we can return it:
+      this._moveItemsBackToTheirOrigin();
     }
   },
 
   findOverflowedInsertionPoints: function(aNode) {
     let newNodeCanOverflow = aNode.getAttribute("overflows") != "false";
     let areaId = this._toolbar.id;
     let placements = gPlacements.get(areaId);
     let nodeIndex = placements.indexOf(aNode.id);
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -476,20 +476,19 @@ PlacesViewBase.prototype = {
         aStatus == Ci.mozILivemark.STATUS_FAILED) {
       // Status has changed, update the cached status menuitem.
       let stringId = aStatus == Ci.mozILivemark.STATUS_LOADING ?
                        "bookmarksLivemarkLoading" : "bookmarksLivemarkFailed";
       statusMenuitem.setAttribute("label", PlacesUIUtils.getString(stringId));
       if (aPopup._startMarker.nextSibling != statusMenuitem)
         aPopup.insertBefore(statusMenuitem, aPopup._startMarker.nextSibling);
     }
-    else {
+    else if (aPopup._statusMenuitem.parentNode == aPopup) {
       // The livemark has finished loading.
-      if (aPopup._statusMenuitem.parentNode == aPopup)
-        aPopup.removeChild(aPopup._statusMenuitem);
+      aPopup.removeChild(aPopup._statusMenuitem);
     }
   },
 
   toggleCutNode: function PVB_toggleCutNode(aPlacesNode, aValue) {
     let elt = this._getDOMNodeForPlacesNode(aPlacesNode);
 
     // We may get the popup for menus, but we need the menu itself.
     if (elt.localName == "menupopup")
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -974,19 +974,18 @@ var gEditItemOverlay = {
       let curTagIndex = tags.indexOf(tagCheckbox.label);
       let tagsSelector = this._element("tagsSelector");
       tagsSelector.selectedItem = tagCheckbox;
 
       if (tagCheckbox.checked) {
         if (curTagIndex == -1)
           tags.push(tagCheckbox.label);
       }
-      else {
-        if (curTagIndex != -1)
-          tags.splice(curTagIndex, 1);
+      else if (curTagIndex != -1) {
+        tags.splice(curTagIndex, 1);
       }
       this._element("tagsField").value = tags.join(", ");
       this._updateTags();
       break;
     case "unload":
       this.uninitPanel(false);
       break;
     }
--- a/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js
+++ b/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js
@@ -227,23 +227,21 @@ var gTests = [
 function nextTest() {
   if (gTests.length) {
     var test = gTests.shift();
     waitForFocus(function() {
       info("Start of test: " + test.desc);
       test.run();
     });
   }
-  else {
+  else if (wasCollapsed) {
     // Collapse the personal toolbar if needed.
-    if (wasCollapsed) {
-      promiseSetToolbarVisibility(toolbar, false).then(finish);
-    } else {
-      finish();
-    }
+    promiseSetToolbarVisibility(toolbar, false).then(finish);
+  } else {
+    finish();
   }
 }
 
 var toolbar = document.getElementById("PersonalToolbar");
 var wasCollapsed = toolbar.collapsed;
 
 function test() {
   waitForExplicitFinish();
--- a/browser/extensions/pocket/content/panels/js/saved.js
+++ b/browser/extensions/pocket/content/panels/js/saved.js
@@ -262,20 +262,18 @@ var PKT_SAVED_OVERLAY = function (option
             if (key == 8) {
                 var selected = $('.token-input-selected-token');
                 if (selected.length) {
                     e.preventDefault();
                     e.stopImmediatePropagation();
                     inputwrapper.find('.pkt_ext_tag_input').tokenInput('remove', {name:selected.find('p').text()});
                 }
             }
-            else {
-                if ($(e.target).parent().hasClass('token-input-input-token')) {
-                    e.stopImmediatePropagation();
-                }
+            else if ($(e.target).parent().hasClass('token-input-input-token')) {
+                e.stopImmediatePropagation();
             }
         });
     };
     this.disableInput = function() {
         this.wrapper.find('.pkt_ext_item_actions').addClass('pkt_ext_item_actions_disabled');
         this.wrapper.find('.pkt_ext_btn').addClass('pkt_ext_btn_disabled');
         this.wrapper.find('.pkt_ext_tag_input_wrapper').addClass('pkt_ext_tag_input_wrapper_disabled');
         if (this.wrapper.find('.pkt_ext_suggestedtag_detail').length) {
--- a/browser/modules/PluginContent.jsm
+++ b/browser/modules/PluginContent.jsm
@@ -711,23 +711,21 @@ PluginContent.prototype = {
       if (pluginInfo.permissionString == pluginHost.getPermissionStringForType(plugin.actualType)) {
         let overlay = this.getPluginUI(plugin, "main");
         pluginFound = true;
         if (newState == "block") {
           if (overlay) {
             overlay.addEventListener("click", this, true);
           }
           plugin.reload(true);
-        } else {
-          if (this.canActivatePlugin(plugin)) {
-            if (overlay) {
-              overlay.removeEventListener("click", this, true);
-            }
-            plugin.playPlugin();
+        } else if (this.canActivatePlugin(plugin)) {
+          if (overlay) {
+            overlay.removeEventListener("click", this, true);
           }
+          plugin.playPlugin();
         }
       }
     }
 
     // If there are no instances of the plugin on the page any more, what the
     // user probably needs is for us to allow and then refresh.
     if (newState != "block" && !pluginFound) {
       this.reloadPage();
@@ -1021,27 +1019,25 @@ PluginContent.prototype = {
       doc.mozNoPluginCrashedNotification = true;
 
       // Notify others that the crash reporter UI is now ready.
       // Currently, this event is only used by tests.
       let winUtils = this.content.QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsIDOMWindowUtils);
       let event = new this.content.CustomEvent("PluginCrashReporterDisplayed", {bubbles: true});
       winUtils.dispatchEventToChromeOnly(plugin, event);
-    } else {
+    } else if (!doc.mozNoPluginCrashedNotification) {
       // If another plugin on the page was large enough to show our UI, we don't
       // want to show a notification bar.
-      if (!doc.mozNoPluginCrashedNotification) {
-        this.global.sendAsyncMessage("PluginContent:ShowPluginCrashedNotification",
-                                     { messageString: message, pluginID: runID });
-        // Remove the notification when the page is reloaded.
-        doc.defaultView.top.addEventListener("unload", event => {
-          this.hideNotificationBar("plugin-crashed");
-        }, false);
-      }
+      this.global.sendAsyncMessage("PluginContent:ShowPluginCrashedNotification",
+                                   { messageString: message, pluginID: runID });
+      // Remove the notification when the page is reloaded.
+      doc.defaultView.top.addEventListener("unload", event => {
+        this.hideNotificationBar("plugin-crashed");
+      }, false);
     }
   },
 
   NPAPIPluginCrashReportSubmitted: function({ runID, state }) {
     this.pluginCrashData.delete(runID);
     let contentWindow = this.global.content;
     let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils);
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -93,17 +93,17 @@
 
     // No invalid regular expresions
     "no-invalid-regexp": 2,
 
     // No odd whitespace characters
     "no-irregular-whitespace": 2,
 
     // No single if block inside an else block
-    // "no-lonely-if": 2,
+    "no-lonely-if": 2,
 
     // No mixing spaces and tabs in indent
     "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
 
     // No unnecessary spacing
     // "no-multi-spaces": [2, { exceptions: { "AssignmentExpression": true, "VariableDeclarator": true, "ArrayExpression": true, "ObjectExpression": true } }],
 
     // No reassigning native JS objects
--- a/toolkit/components/alerts/resources/content/alert.js
+++ b/toolkit/components/alerts/resources/content/alert.js
@@ -251,20 +251,18 @@ function onAlertBeforeUnload() {
     let windows = Services.wm.getEnumerator("alert:alert");
     while (windows.hasMoreElements()) {
       let alertWindow = windows.getNext();
       if (alertWindow != window) {
         if (gOrigin & NS_ALERT_TOP) {
           if (alertWindow.screenY > window.screenY) {
             alertWindow.moveTo(alertWindow.screenX, alertWindow.screenY - heightDelta);
           }
-        } else {
-          if (window.screenY > alertWindow.screenY) {
-            alertWindow.moveTo(alertWindow.screenX, alertWindow.screenY + heightDelta);
-          }
+        } else if (window.screenY > alertWindow.screenY) {
+          alertWindow.moveTo(alertWindow.screenX, alertWindow.screenY + heightDelta);
         }
       }
     }
   }
 
   if (gAlertListener) {
     gAlertListener.observe(null, "alertfinished", gAlertCookie);
   }
--- a/toolkit/components/filepicker/content/filepicker.js
+++ b/toolkit/components/filepicker/content/filepicker.js
@@ -770,20 +770,19 @@ function processPath(path)
 
         if (nextQuote < strLength - 1)
           if (!processPathEntry(path.substring(nextQuote + 1), fileArray))
             return false;
         break;
       }
       ++curFileStart;
     }
-  } else {
+  } else if (!processPathEntry(path, fileArray)) {
     // If we didn't start with a quote, assume we just have a single file.
-    if (!processPathEntry(path, fileArray))
-      return false;
+    return false;
   }
 
   return fileArray;
 }
 
 function processPathEntry(path, fileArray)
 {
   var filePath;
--- a/toolkit/components/microformats/microformat-shiv.js
+++ b/toolkit/components/microformats/microformat-shiv.js
@@ -1206,20 +1206,18 @@ var Microformats; // jshint ignore:line
                                                             out.typeVersion = 'v1';
                                                         }
                                                         y++;
                                                     }
                                                     //only add property once
                                                     if (out.properties.indexOf(propName) === -1) {
                                                         out.properties.push([propName, 'v1']);
                                                     }
-                                                } else {
-                                                    if (out.properties.indexOf(propName) === -1) {
-                                                        out.properties.push([propName, 'v1']);
-                                                    }
+                                                } else if (out.properties.indexOf(propName) === -1) {
+                                                    out.properties.push([propName, 'v1']);
                                                 }
                                             }
                                         }
 
                                     }
                                 }
                             }
 
@@ -3398,22 +3396,20 @@ var Microformats; // jshint ignore:line
                         }
                     }
 
 
 
                     // time zone offset
                     if (this.z) {
                         out += this.tzZulu;
-                    } else {
-                        if (this.tzH && this.tzH > -1 && this.tzH < 25) {
-                            out += this.tzPN + this.tzH;
-                            if (this.tzM > -1 && this.tzM < 61) {
-                                out += this.tzsep + this.tzM;
-                            }
+                    } else if (this.tzH && this.tzH > -1 && this.tzH < 25) {
+                        out += this.tzPN + this.tzH;
+                        if (this.tzM > -1 && this.tzM < 61) {
+                            out += this.tzsep + this.tzM;
                         }
                     }
                 }
             }
             return out;
         },
 
 
--- a/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
+++ b/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm
@@ -122,21 +122,19 @@ this.InsecurePasswordUtils = {
     if (isSafePage) {
       if (isFormSubmitSecure) {
         passwordSafety = 0;
       } else if (isFormSubmitHTTP) {
         passwordSafety = 1;
       } else {
         passwordSafety = 2;
       }
+    } else if (isFormSubmitSecure) {
+      passwordSafety = 3;
+    } else if (isFormSubmitHTTP) {
+      passwordSafety = 4;
     } else {
-      if (isFormSubmitSecure) {
-        passwordSafety = 3;
-      } else if (isFormSubmitHTTP) {
-        passwordSafety = 4;
-      } else {
-        passwordSafety = 5;
-      }
+      passwordSafety = 5;
     }
 
     Services.telemetry.getHistogramById("PWMGR_LOGIN_PAGE_SAFETY").add(passwordSafety);
   },
 };
--- a/toolkit/components/passwordmgr/LoginManagerContent.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm
@@ -382,27 +382,25 @@ var LoginManagerContent = {
       this._deferredPasswordAddedTasksByRootElement.set(formLike.rootElement, deferredTask);
     }
 
     if (deferredTask.isArmed) {
       log("DeferredTask is already armed so just updating the FormLike");
       // We update the FormLike so it (most important .elements) is fresh when the task eventually
       // runs since changes to the elements could affect our field heuristics.
       this._formLikeByRootElement.set(formLike.rootElement, formLike);
+    } else if (window.document.readyState == "complete") {
+      log("Arming the DeferredTask we just created since document.readyState == 'complete'");
+      deferredTask.arm();
     } else {
-      if (window.document.readyState == "complete") {
-        log("Arming the DeferredTask we just created since document.readyState == 'complete'");
+      window.addEventListener("DOMContentLoaded", function armPasswordAddedTask() {
+        window.removeEventListener("DOMContentLoaded", armPasswordAddedTask);
+        log("Arming the onDOMInputPasswordAdded DeferredTask due to DOMContentLoaded");
         deferredTask.arm();
-      } else {
-        window.addEventListener("DOMContentLoaded", function armPasswordAddedTask() {
-          window.removeEventListener("DOMContentLoaded", armPasswordAddedTask);
-          log("Arming the onDOMInputPasswordAdded DeferredTask due to DOMContentLoaded");
-          deferredTask.arm();
-        });
-      }
+      });
     }
   },
 
   /**
    * Fetch logins from the parent for a given form and then attempt to fill it.
    *
    * @param {FormLike} form to fetch the logins for then try autofill.
    * @param {Window} window
@@ -782,26 +780,25 @@ var LoginManagerContent = {
         // A bit odd, but could make sense with the right page layout.
         newPasswordField = pwFields[0].element;
         oldPasswordField = pwFields[1].element;
       } else {
         // We can't tell which of the 3 passwords should be saved.
         log("(form ignored -- all 3 pw fields differ)");
         return [null, null, null];
       }
-    } else { // pwFields.length == 2
-      if (pw1 == pw2) {
-        // Treat as if 1 pw field
-        newPasswordField = pwFields[0].element;
-        oldPasswordField = null;
-      } else {
-        // Just assume that the 2nd password is the new password
-        oldPasswordField = pwFields[0].element;
-        newPasswordField = pwFields[1].element;
-      }
+    } else if (pw1 == pw2) {
+      // pwFields.length == 2
+      // Treat as if 1 pw field
+      newPasswordField = pwFields[0].element;
+      oldPasswordField = null;
+    } else {
+      // Just assume that the 2nd password is the new password
+      oldPasswordField = pwFields[0].element;
+      newPasswordField = pwFields[1].element;
     }
 
     log("Password field (new) id/name is: ", newPasswordField.id, " / ", newPasswordField.name);
     if (oldPasswordField) {
       log("Password field (old) id/name is: ", oldPasswordField.id, " / ", oldPasswordField.name);
     } else {
       log("Password field (old):", oldPasswordField);
     }
--- a/toolkit/components/passwordmgr/storage-json.js
+++ b/toolkit/components/passwordmgr/storage-json.js
@@ -405,21 +405,19 @@ this.LoginManagerStorage_json.prototype 
 
     this.log("Setting login saving enabled for", hostname, "to", enabled);
     let foundIndex = this._store.data.disabledHosts.indexOf(hostname);
     if (enabled) {
       if (foundIndex != -1) {
         this._store.data.disabledHosts.splice(foundIndex, 1);
         this._store.saveSoon();
       }
-    } else {
-      if (foundIndex == -1) {
-        this._store.data.disabledHosts.push(hostname);
-        this._store.saveSoon();
-      }
+    } else if (foundIndex == -1) {
+      this._store.data.disabledHosts.push(hostname);
+      this._store.saveSoon();
     }
 
     this._sendNotification(enabled ? "hostSavingEnabled" : "hostSavingDisabled", hostname);
   },
 
   findLogins(count, hostname, formSubmitURL, httpRealm) {
     let loginData = {
       hostname: hostname,
--- a/toolkit/components/perfmonitoring/AddonWatcher.jsm
+++ b/toolkit/components/perfmonitoring/AddonWatcher.jsm
@@ -177,23 +177,21 @@ this.AddonWatcher = {
             // interested in repeat offenders. Store the data for future use.
             continue;
           }
           if (now - alerts.latestNotificationTimeStamp <= delayBetweenAlerts) {
             // We have already displayed an alert for this add-on recently.
             // Wait a little before displaying another one.
             continue;
           }
-        } else {
+        } else if (now - alerts.latestNotificationTimeStamp <= delayBetweenFreezeAlerts) {
           // Even in case of freeze, we want to avoid needlessly spamming the user.
-          if (now - alerts.latestNotificationTimeStamp <= delayBetweenFreezeAlerts) {
-            // We have already displayed an alert for this add-on recently.
-            // Wait a little before displaying another one.
-            continue;
-          }
+          // We have already displayed an alert for this add-on recently.
+          // Wait a little before displaying another one.
+          continue;
         }
 
         // Ok, time to inform the user.
         alerts.latestNotificationTimeStamp = now;
         alerts.occurrencesSinceLastNotification = 0;
         Services.obs.notifyObservers(null, this.TOPIC_SLOW_ADDON_DETECTED, addonId);
 
         highestNumberOfAddonsToReport--;
--- a/toolkit/components/printing/content/printjoboptions.js
+++ b/toolkit/components/printing/content/printjoboptions.js
@@ -17,22 +17,20 @@ var doDebug            = true;
 //---------------------------------------------------
 function checkDouble(element, maxVal)
 {
   var value = element.value;
   if (value && value.length > 0) {
     value = value.replace(/[^\.|^0-9]/g, "");
     if (!value) {
       element.value = "";
+    } else if (value > maxVal) {
+      element.value = maxVal;
     } else {
-      if (value > maxVal) {
-        element.value = maxVal;
-      } else {
-        element.value = value;
-      }
+      element.value = value;
     }
   }
 }
 
 //---------------------------------------------------
 function isListOfPrinterFeaturesAvailable()
 {
   var has_printerfeatures = false;
--- a/toolkit/components/prompts/src/CommonDialog.jsm
+++ b/toolkit/components/prompts/src/CommonDialog.jsm
@@ -236,30 +236,27 @@ CommonDialog.prototype = {
         let button = this.ui["button" + b];
 
         if (!this.hasInputField) {
             let isOSX = ("nsILocalFileMac" in Components.interfaces);
             if (isOSX)
                 this.ui.infoBody.focus();
             else
                 button.focus();
-        } else {
+        } else if (this.args.promptType == "promptPassword") {
             // When the prompt is initialized, focus and select the textbox
             // contents. Afterwards, only focus the textbox.
-            if (this.args.promptType == "promptPassword") {
-                if (isInitialLoad)
-                    this.ui.password1Textbox.select();
-                else
-                    this.ui.password1Textbox.focus();
-            } else {
-                if (isInitialLoad)
-                    this.ui.loginTextbox.select();
-                else
-                    this.ui.loginTextbox.focus();
-            }
+            if (isInitialLoad)
+                this.ui.password1Textbox.select();
+            else
+                this.ui.password1Textbox.focus();
+        } else if (isInitialLoad) {
+                this.ui.loginTextbox.select();
+        } else {
+                this.ui.loginTextbox.focus();
         }
     },
 
     onCheckbox : function() {
         this.args.checked = this.ui.checkbox.checked;
     },
 
     onButton0 : function() {
--- a/toolkit/components/satchel/FormHistory.jsm
+++ b/toolkit/components/satchel/FormHistory.jsm
@@ -418,21 +418,19 @@ function dbCreateAsyncStatement(aQuery, 
 
     if (aParams) {
       let bindingParams = bindingArray.newBindingParams();
       for (let field in aParams) {
         bindingParams.bindByName(field, aParams[field]);
       }
       bindingArray.addParams(bindingParams);
     }
-  } else {
-    if (aParams) {
-      for (let field in aParams) {
-        stmt.params[field] = aParams[field];
-      }
+  } else if (aParams) {
+    for (let field in aParams) {
+      stmt.params[field] = aParams[field];
     }
   }
 
   return stmt;
 }
 
 /**
  * dbInit
--- a/toolkit/components/timermanager/nsUpdateTimerManager.js
+++ b/toolkit/components/timermanager/nsUpdateTimerManager.js
@@ -266,19 +266,18 @@ TimerManager.prototype = {
   _ensureTimer: function(interval) {
     if (!this._canEnsureTimer)
       return;
     if (!this._timer) {
       this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       this._timer.initWithCallback(this, interval,
                                    Ci.nsITimer.TYPE_REPEATING_SLACK);
       this.lastTimerReset = Date.now();
-    } else {
-      if (Date.now() + interval < this.lastTimerReset + this._timer.delay)
-        this._timer.delay = Math.max(this.lastTimerReset + interval - Date.now(), 0);
+    } else if (Date.now() + interval < this.lastTimerReset + this._timer.delay) {
+      this._timer.delay = Math.max(this.lastTimerReset + interval - Date.now(), 0);
     }
   },
 
   /**
    * Stops the timer, if it is running.
    */
   _cancelTimer: function() {
     if (this._timer) {
--- a/toolkit/components/viewsource/ViewSourceBrowser.jsm
+++ b/toolkit/components/viewsource/ViewSourceBrowser.jsm
@@ -184,20 +184,18 @@ ViewSourceBrowser.prototype = {
     if (!URL) {
       throw new Error("Must supply a URL when opening view source.");
     }
 
     if (browser) {
       // If we're dealing with a remote browser, then the browser
       // for view source needs to be remote as well.
       this.updateBrowserRemoteness(browser.isRemoteBrowser);
-    } else {
-      if (outerWindowID) {
-        throw new Error("Must supply the browser if passing the outerWindowID");
-      }
+    } else if (outerWindowID) {
+      throw new Error("Must supply the browser if passing the outerWindowID");
     }
 
     this.sendAsyncMessage("ViewSource:LoadSource",
                           { URL, outerWindowID, lineNumber });
   },
 
   /**
    * Loads a view source selection showing the given view-source url and
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -643,31 +643,29 @@ var ViewSourceContent = {
               result.line = curLine;
               result.col = (i == 0 ? firstCol : 1) + offset - curPos;
             }
             found = true;
 
             break;
           }
 
-        } else {
-          if (curLine == lineNumber && !("range" in result)) {
-            result.range = content.document.createRange();
-            result.range.setStart(textNode, curPos);
+        } else if (curLine == lineNumber && !("range" in result)) {
+          result.range = content.document.createRange();
+          result.range.setStart(textNode, curPos);
 
-            // This will always be overridden later, except when we look for
-            // the very last line in the file (this is the only line that does
-            // not end with \n).
-            result.range.setEndAfter(pre.lastChild);
+          // This will always be overridden later, except when we look for
+          // the very last line in the file (this is the only line that does
+          // not end with \n).
+          result.range.setEndAfter(pre.lastChild);
 
-          } else if (curLine == lineNumber + 1) {
-            result.range.setEnd(textNode, curPos - 1);
-            found = true;
-            break;
-          }
+        } else if (curLine == lineNumber + 1) {
+          result.range.setEnd(textNode, curPos - 1);
+          found = true;
+          break;
         }
       }
     }
 
     return found || ("range" in result);
   },
 
   /**
--- a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
+++ b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js
@@ -54,27 +54,25 @@ function check_autoplay_audio_pause_stat
   }
 
   if (autoPlay.paused == expectedPauseState) {
     if (expectedPauseState) {
       ok(true, "Audio is paused correctly.");
     } else {
       ok(true, "Audio is resumed correctly.");
     }
+  } else if (expectedPauseState) {
+    autoPlay.onpause = function () {
+      autoPlay.onpause = null;
+      ok(true, "Audio is paused correctly, checking from onpause.");
+    }
   } else {
-    if (expectedPauseState) {
-      autoPlay.onpause = function () {
-        autoPlay.onpause = null;
-        ok(true, "Audio is paused correctly, checking from onpause.");
-      }
-    } else {
-      autoPlay.onplay = function () {
-        autoPlay.onplay = null;
-        ok(true, "Audio is resumed correctly, checking from onplay.");
-      }
+    autoPlay.onplay = function () {
+      autoPlay.onplay = null;
+      ok(true, "Audio is resumed correctly, checking from onplay.");
     }
   }
 }
 
 function play_nonautoplay_audio_should_be_paused() {
   var nonAutoPlay = content.document.getElementById('nonautoplay');
   if (!nonAutoPlay) {
     ok(false, "Can't get the audio element!");
--- a/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js
+++ b/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js
@@ -780,23 +780,20 @@ TileManager.Tile.prototype = {
   updateDirtyRegion: function updateDirtyRegion(dirtyRect) {
     if (!dirtyRect) {
 
       if (!this._dirtyTileCanvasRect)
         this._dirtyTileCanvasRect = this.boundRect.clone();
       else
         this._dirtyTileCanvasRect.copyFrom(this.boundRect);
 
-    } else {
-
-      if (!this._dirtyTileCanvasRect)
-        this._dirtyTileCanvasRect = dirtyRect.intersect(this.boundRect);
-      else if (dirtyRect.intersects(this.boundRect))
-        this._dirtyTileCanvasRect.expandToContain(dirtyRect.intersect(this.boundRect));
-
+    } else if (!this._dirtyTileCanvasRect) {
+      this._dirtyTileCanvasRect = dirtyRect.intersect(this.boundRect);
+    } else if (dirtyRect.intersects(this.boundRect)) {
+      this._dirtyTileCanvasRect.expandToContain(dirtyRect.intersect(this.boundRect));
     }
 
     // TODO if after the above, the dirty rectangle is large enough,
     // mark the whole tile dirty.
 
     if (this._dirtyTileCanvasRect)
       this._dirtyTileCanvas = true;
   },
--- a/toolkit/content/widgets/button.xml
+++ b/toolkit/content/widgets/button.xml
@@ -22,23 +22,21 @@
       <property name="group"
                 onget="return this.getAttribute('group');"
                 onset="this.setAttribute('group', val); return val;"/>
 
       <property name="open" onget="return this.hasAttribute('open');">
         <setter><![CDATA[
           if (this.boxObject instanceof MenuBoxObject) {
             this.boxObject.openMenu(val);
-          } else {
+          } else if (val) {
             // Fall back to just setting the attribute
-            if (val) {
-              this.setAttribute('open', 'true');
-            } else {
-              this.removeAttribute('open');
-            }
+            this.setAttribute('open', 'true');
+          } else {
+            this.removeAttribute('open');
           }
           return val;
         ]]></setter>
       </property>
 
       <property name="checked" onget="return this.hasAttribute('checked');">
         <setter><![CDATA[
           if (this.type == "checkbox") {
@@ -287,21 +285,19 @@
       <property name="buttonover" onget="return this.getAttribute('buttonover');">
         <setter>
         <![CDATA[
           var v = val || val == "true";
           if (!v && this.buttondown) {
             this.buttondown = false;
             this._pendingActive = true;
           }
-          else {
-            if (this._pendingActive) {
-              this.buttondown = true;
-              this._pendingActive = false;
-            }
+          else if (this._pendingActive) {
+            this.buttondown = true;
+            this._pendingActive = false;
           }
 
           if (v)
             this.setAttribute("buttonover", "true");
           else
             this.removeAttribute("buttonover");
           return val;
         ]]>
--- a/toolkit/content/widgets/resizer.xml
+++ b/toolkit/content/widgets/resizer.xml
@@ -21,21 +21,19 @@
 
         // if the direction is rtl, set the rtl attribute so that the
         // stylesheet can use this to make the cursor appear properly
         var cs = window.getComputedStyle(this, "");
         if (cs.writingMode === undefined || cs.writingMode == "horizontal-tb") {
           if (cs.direction == "rtl") {
             this.setAttribute("rtl", "true");
           }
-        } else {
+        } else if (cs.writingMode.endsWith("-rl")) {
           // writing-modes 'vertical-rl' and 'sideways-rl' want rtl resizers,
           // as they will appear at the bottom left of the element
-          if (cs.writingMode.endsWith("-rl")) {
-            this.setAttribute("rtl", "true");
-          }
+          this.setAttribute("rtl", "true");
         }
       ]]>
       </constructor>
     </implementation>
   </binding>
 
 </bindings>
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -600,19 +600,19 @@
         // Scrollport event orientation:
         //   0: vertical
         //   1: horizontal
         //   2: both
         if (this.orient == "vertical") {
           if (event.detail == 1)
             return;
         }
-        else {    // horizontal scrollbox
-          if (event.detail == 0)
-            return;
+        else if (event.detail == 0) {
+          // horizontal scrollbox
+          return;
         }
 
         this.setAttribute("notoverflowing", "true");
 
         try {
           // See bug 341047 and comments in overflow handler as to why
           // try..catch is needed here
           this._updateScrollButtonsDisabledState();
@@ -635,19 +635,19 @@
         // Scrollport event orientation:
         //   0: vertical
         //   1: horizontal
         //   2: both
         if (this.orient == "vertical") {
           if (event.detail == 1)
             return;
         }
-        else {    // horizontal scrollbox
-          if (event.detail == 0)
-            return;
+        else if (event.detail == 0) {
+          // horizontal scrollbox
+          return;
         }
 
         this.removeAttribute("notoverflowing");
 
         try {
           // See bug 341047, the overflow event is dispatched when the
           // scrollbox already is mostly destroyed. This causes some code in
           // _updateScrollButtonsDisabledState() to throw an error. It also
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -534,21 +534,19 @@
             if (offset > 0) {
               i += p - 1;
               if (c >= i) {
                  i = c + p;
                  this.treeBoxObject.ensureRowIsVisible(i > edge ? edge : i);
               }
               i = i > edge ? edge : i;
 
-            } else {
-              if (c <= i) {
-                 i = c <= p ? 0 : c - p;
-                 this.treeBoxObject.ensureRowIsVisible(i);
-              }
+            } else if (c <= i) {
+               i = c <= p ? 0 : c - p;
+               this.treeBoxObject.ensureRowIsVisible(i);
             }
             this.view.selection.timedSelect(i, this._selectDelay);
           ]]>
         </body>
       </method>
 
       <method name="_moveByPageShift">
         <parameter name="offset"/>
--- a/toolkit/modules/secondscreen/RokuApp.jsm
+++ b/toolkit/modules/secondscreen/RokuApp.jsm
@@ -125,20 +125,18 @@ RokuApp.prototype = {
     xhr.send(null);
   },
 
   remoteMedia: function remoteMedia(callback, listener) {
     if (this.mediaAppID != -1) {
       if (callback) {
         callback(new RemoteMedia(this.resourceURL, listener));
       }
-    } else {
-      if (callback) {
-        callback();
-      }
+    } else if (callback) {
+      callback();
     }
   }
 }
 
 /* RemoteMedia provides a wrapper for using TCP socket to control Roku apps.
  * The server implementation must be built into the Roku receiver app.
  */
 function RemoteMedia(url, listener) {
--- a/toolkit/modules/tests/xpcshell/test_Log.js
+++ b/toolkit/modules/tests/xpcshell/test_Log.js
@@ -97,22 +97,20 @@ add_test(function test_LoggerWithMessage
  */
 function checkObjects(expected, actual) {
   do_check_true(expected instanceof Object);
   do_check_true(actual instanceof Object);
   for (let key in expected) {
     do_check_neq(actual[key], undefined);
     if (expected[key] instanceof RegExp) {
       do_check_true(expected[key].test(actual[key].toString()));
+    } else if (expected[key] instanceof Object) {
+      checkObjects(expected[key], actual[key]);
     } else {
-      if (expected[key] instanceof Object) {
-        checkObjects(expected[key], actual[key]);
-      } else {
-        do_check_eq(expected[key], actual[key]);
-      }
+      do_check_eq(expected[key], actual[key]);
     }
   }
 
   for (let key in actual) {
     do_check_neq(expected[key], undefined);
   }
 }
 
--- a/toolkit/mozapps/downloads/DownloadLastDir.jsm
+++ b/toolkit/mozapps/downloads/DownloadLastDir.jsm
@@ -181,16 +181,15 @@ DownloadLastDir.prototype = {
       else
         cps2.removeByDomainAndName(uri, LAST_DIR_PREF, this.fakeContext);
     }
     if (this.isPrivate()) {
       if (aFile instanceof Components.interfaces.nsIFile)
         gDownloadLastDirFile = aFile.clone();
       else
         gDownloadLastDirFile = null;
-    } else {
-      if (aFile instanceof Components.interfaces.nsIFile)
-        Services.prefs.setComplexValue(LAST_DIR_PREF, nsIFile, aFile);
-      else if (Services.prefs.prefHasUserValue(LAST_DIR_PREF))
-        Services.prefs.clearUserPref(LAST_DIR_PREF);
+    } else if (aFile instanceof Components.interfaces.nsIFile) {
+      Services.prefs.setComplexValue(LAST_DIR_PREF, nsIFile, aFile);
+    } else if (Services.prefs.prefHasUserValue(LAST_DIR_PREF)) {
+      Services.prefs.clearUserPref(LAST_DIR_PREF);
     }
   }
 };
--- a/toolkit/mozapps/downloads/DownloadUtils.jsm
+++ b/toolkit/mozapps/downloads/DownloadUtils.jsm
@@ -477,26 +477,24 @@ this.DownloadUtils = {
     // Get rid of insignificant bits by truncating to 1 or 0 decimal points
     // 0 -> 0; 1.2 -> 1.2; 12.3 -> 12.3; 123.4 -> 123; 234.5 -> 235
     // added in bug 462064: (unitIndex != 0) makes sure that no decimal digit for bytes appears when aBytes < 100
     let fractionDigits = (aBytes > 0) && (aBytes < 100) && (unitIndex != 0) ? 1 : 0;
 
     // Don't try to format Infinity values using NumberFormat.
     if (aBytes === Infinity) {
       aBytes = "Infinity";
+    } else if (typeof Intl != "undefined") {
+      aBytes = getLocaleNumberFormat(fractionDigits)
+                 .format(aBytes);
     } else {
-      if (typeof Intl != "undefined") {
-        aBytes = getLocaleNumberFormat(fractionDigits)
-                   .format(aBytes);
-      } else {
-        // FIXME: Fall back to the old hack, will be fixed in bug 1200494.
-        aBytes = aBytes.toFixed(fractionDigits);
-        if (gDecimalSymbol != ".") {
-          aBytes = aBytes.replace(".", gDecimalSymbol);
-        }
+      // FIXME: Fall back to the old hack, will be fixed in bug 1200494.
+      aBytes = aBytes.toFixed(fractionDigits);
+      if (gDecimalSymbol != ".") {
+        aBytes = aBytes.replace(".", gDecimalSymbol);
       }
     }
 
     return [aBytes, gBundle.GetStringFromName(gStr.units[unitIndex])];
   },
 
   /**
    * Converts a number of seconds to the two largest units. Time values are
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -360,22 +360,20 @@ this.LightweightThemeManager = {
       if (id == next && aPendingRestart)
         return;
 
       Services.prefs.clearUserPref(PREF_LWTHEME_TO_SELECT);
       if (next) {
         AddonManagerPrivate.callAddonListeners("onOperationCancelled",
                                                new AddonWrapper(this.getUsedTheme(next)));
       }
-      else {
-        if (id == current.id) {
-          AddonManagerPrivate.callAddonListeners("onOperationCancelled",
-                                                 new AddonWrapper(current));
-          return;
-        }
+      else if (id == current.id) {
+        AddonManagerPrivate.callAddonListeners("onOperationCancelled",
+                                               new AddonWrapper(current));
+        return;
       }
     }
     catch (e) {
     }
 
     if (current) {
       if (current.id == id)
         return;
--- a/toolkit/mozapps/extensions/addonManager.js
+++ b/toolkit/mozapps/extensions/addonManager.js
@@ -242,20 +242,18 @@ amManager.prototype = {
               onInstalling: (addon, needsRestart) => handler("onInstalling", addon.id, needsRestart),
               onInstalled: (addon) => handler("onInstalled", addon.id, false),
               onUninstalling: (addon, needsRestart) => handler("onUninstalling", addon.id, needsRestart),
               onUninstalled: (addon) => handler("onUninstalled", addon.id, false),
               onOperationCancelled: (addon) => handler("onOperationCancelled", addon.id, false),
             };
           }
           AddonManager.addAddonListener(this.addonListener);
-        } else {
-          if (this.addonListener) {
-            AddonManager.removeAddonListener(this.addonListener);
-          }
+        } else if (this.addonListener) {
+          AddonManager.removeAddonListener(this.addonListener);
         }
       }
     }
     return undefined;
   },
 
   sendEvent(target, data) {
     target.sendAsyncMessage(MSG_INSTALL_EVENT, data);
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -484,19 +484,18 @@ var gEventManager = {
       let tiptext = addonItem.getAttribute("name");
 
       if (addonItem.mAddon) {
         if (shouldShowVersionNumber(addonItem.mAddon)) {
           tiptext += " " + (addonItem.hasAttribute("upgrade") ? addonItem.mManualUpdate.version
                                                               : addonItem.mAddon.version);
         }
       }
-      else {
-        if (shouldShowVersionNumber(addonItem.mInstall))
-          tiptext += " " + addonItem.mInstall.version;
+      else if (shouldShowVersionNumber(addonItem.mInstall)) {
+        tiptext += " " + addonItem.mInstall.version;
       }
 
       addonTooltip.label = tiptext;
     }, false);
   },
 
   shutdown: function() {
     AddonManager.removeManagerListener(this);
@@ -681,22 +680,20 @@ var gViewController = {
     }
     catch (e) {
       // The attempt to load the view failed, try moving further along history
       if (this.lastHistoryIndex > gHistory.index) {
         if (gHistory.canGoBack)
           gHistory.back();
         else
           gViewController.replaceView(gViewDefault);
-      } else {
-        if (gHistory.canGoForward)
-          gHistory.forward();
-        else
-          gViewController.replaceView(gViewDefault);
-      }
+      } else if (gHistory.canGoForward)
+        gHistory.forward();
+      else
+        gViewController.replaceView(gViewDefault);
     }
   },
 
   parseViewId: function(aViewId) {
     var matchRegex = /^addons:\/\/([^\/]+)\/(.*)$/;
     var [, viewType, viewParam] = aViewId.match(matchRegex) || [];
     return {type: viewType, param: decodeURIComponent(viewParam)};
   },
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -6104,24 +6104,22 @@ AddonInstall.prototype = {
             new UpdateChecker(this.addon, {
               onUpdateFinished: aAddon => this.downloadCompleted(),
             }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
           }
         }, ([error, message]) => {
           this.downloadFailed(error, message);
         });
       }
-      else {
-        if (aRequest instanceof Ci.nsIHttpChannel)
-          this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE,
-                              aRequest.responseStatus + " " +
-                              aRequest.responseStatusText);
-        else
-          this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, aStatus);
-      }
+      else if (aRequest instanceof Ci.nsIHttpChannel)
+        this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE,
+                            aRequest.responseStatus + " " +
+                            aRequest.responseStatusText);
+      else
+        this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, aStatus);
     }
     else {
       this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, aStatus);
     }
   },
 
   /**
    * Notify listeners that the download failed.
@@ -7506,21 +7504,19 @@ AddonWrapper.prototype = {
         if (addon.internalName == XPIProvider.defaultSkin)
           throw new Error("Cannot disable the default theme");
         XPIProvider.enableDefaultTheme();
       }
       else {
         XPIProvider.updateAddonDisabledState(addon, undefined, val);
       }
     }
-    else {
+    else if (!addon.userDisabled)
       // Only set softDisabled if not already disabled
-      if (!addon.userDisabled)
-        addon.softDisabled = val;
-    }
+      addon.softDisabled = val;
 
     return val;
   },
 
   get hidden() {
     let addon = addonFor(this);
     if (addon._installLocation.name == KEY_APP_TEMPORARY)
       return false;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
@@ -100,20 +100,18 @@ var ADDONS = [
 var next_test = function() {};
 
 function do_check_item(aItem, aVersion, aAddonsEntry) {
   if (aAddonsEntry.installed) {
     if (aItem == null)
       do_throw("Addon " + aAddonsEntry.id + " wasn't detected");
     if (aItem.version != aVersion)
       do_throw("Addon " + aAddonsEntry.id + " was version " + aItem.version + " instead of " + aVersion);
-  } else {
-    if (aItem != null)
-      do_throw("Addon " + aAddonsEntry.id + " was detected");
-  }
+  } else if (aItem != null)
+    do_throw("Addon " + aAddonsEntry.id + " was detected");
 }
 
 /**
  * Start the test by installing extensions.
  */
 function run_test() {
   do_test_pending();
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
@@ -412,21 +412,19 @@ function* verify_state(initialState, fin
   // If the initial state was using the profile set then that directory will
   // still exist.
   if (initialState[0])
     expectedDirs++;
 
   if (finalState == undefined) {
     finalState = initialState;
   }
-  else {
+  else if (finalState[0])
     // If the new state is using the profile then that directory will exist.
-    if (finalState[0])
-      expectedDirs++;
-  }
+    expectedDirs++;
 
   do_print("Checking final state.");
 
   let dirs = yield get_directories();
   do_check_eq(dirs.length, expectedDirs);
 
   // Bug 1204156: Currently switching to the new state requires a restart
   // yield check_installed(...finalState);
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -4192,92 +4192,88 @@ Downloader.prototype = {
         this._update.statusText = message;
 
         if (this._update.isCompleteUpdate || this._update.patchCount != 2)
           deleteActiveUpdate = true;
 
         // Destroy the updates directory, since we're done with it.
         cleanUpUpdatesDir();
       }
-    } else {
-      if (status == Cr.NS_ERROR_OFFLINE) {
-        // Register an online observer to try again.
-        // The online observer will continue the incremental download by
-        // calling downloadUpdate on the active update which continues
-        // downloading the file from where it was.
-        LOG("Downloader:onStopRequest - offline, register online observer: true");
-        AUSTLMY.pingDownloadCode(this.isCompleteUpdate,
-                                 AUSTLMY.DWNLD_RETRY_OFFLINE);
-        shouldRegisterOnlineObserver = true;
-        deleteActiveUpdate = false;
-      // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED,
-      // NS_ERROR_NET_RESET and NS_ERROR_DOCUMENT_NOT_CACHED can be returned
-      // when disconnecting the internet while a download of a MAR is in
-      // progress.  There may be others but I have not encountered them during
-      // testing.
-      } else if ((status == Cr.NS_ERROR_NET_TIMEOUT ||
-                  status == Cr.NS_ERROR_CONNECTION_REFUSED ||
-                  status == Cr.NS_ERROR_NET_RESET ||
-                  status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) &&
-                 this.updateService._consecutiveSocketErrors < maxFail) {
-        LOG("Downloader:onStopRequest - socket error, shouldRetrySoon: true");
-        let dwnldCode = AUSTLMY.DWNLD_RETRY_CONNECTION_REFUSED;
-        if (status == Cr.NS_ERROR_NET_TIMEOUT) {
-          dwnldCode = AUSTLMY.DWNLD_RETRY_NET_TIMEOUT;
-        } else if (status == Cr.NS_ERROR_NET_RESET) {
-          dwnldCode = AUSTLMY.DWNLD_RETRY_NET_RESET;
-        } else if (status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) {
-          dwnldCode = AUSTLMY.DWNLD_ERR_DOCUMENT_NOT_CACHED;
-        }
-        AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode);
-        shouldRetrySoon = true;
-        deleteActiveUpdate = false;
-      } else if (status != Cr.NS_BINDING_ABORTED &&
-                 status != Cr.NS_ERROR_ABORT) {
-        LOG("Downloader:onStopRequest - non-verification failure");
-        let dwnldCode = AUSTLMY.DWNLD_ERR_BINDING_ABORTED;
-        if (status == Cr.NS_ERROR_ABORT) {
-          dwnldCode = AUSTLMY.DWNLD_ERR_ABORT;
-        }
-        AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode);
-
-        // Some sort of other failure, log this in the |statusText| property
-        state = STATE_DOWNLOAD_FAILED;
-
-        // XXXben - if |request| (The Incremental Download) provided a means
-        // for accessing the http channel we could do more here.
-
-        this._update.statusText = getStatusTextFromCode(status,
-                                                        Cr.NS_BINDING_FAILED);
-
-        if (AppConstants.platform == "gonk") {
-          // bug891009: On FirefoxOS, manaully retry OTA download will reuse
-          // the Update object. We need to remove selected patch so that download
-          // can be triggered again successfully.
-          this._update.selectedPatch.selected = false;
-        }
-
-        // Destroy the updates directory, since we're done with it.
-        cleanUpUpdatesDir();
-
-        deleteActiveUpdate = true;
+    } else if (status == Cr.NS_ERROR_OFFLINE) {
+      // Register an online observer to try again.
+      // The online observer will continue the incremental download by
+      // calling downloadUpdate on the active update which continues
+      // downloading the file from where it was.
+      LOG("Downloader:onStopRequest - offline, register online observer: true");
+      AUSTLMY.pingDownloadCode(this.isCompleteUpdate,
+                               AUSTLMY.DWNLD_RETRY_OFFLINE);
+      shouldRegisterOnlineObserver = true;
+      deleteActiveUpdate = false;
+    // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED,
+    // NS_ERROR_NET_RESET and NS_ERROR_DOCUMENT_NOT_CACHED can be returned
+    // when disconnecting the internet while a download of a MAR is in
+    // progress.  There may be others but I have not encountered them during
+    // testing.
+    } else if ((status == Cr.NS_ERROR_NET_TIMEOUT ||
+                status == Cr.NS_ERROR_CONNECTION_REFUSED ||
+                status == Cr.NS_ERROR_NET_RESET ||
+                status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) &&
+               this.updateService._consecutiveSocketErrors < maxFail) {
+      LOG("Downloader:onStopRequest - socket error, shouldRetrySoon: true");
+      let dwnldCode = AUSTLMY.DWNLD_RETRY_CONNECTION_REFUSED;
+      if (status == Cr.NS_ERROR_NET_TIMEOUT) {
+        dwnldCode = AUSTLMY.DWNLD_RETRY_NET_TIMEOUT;
+      } else if (status == Cr.NS_ERROR_NET_RESET) {
+        dwnldCode = AUSTLMY.DWNLD_RETRY_NET_RESET;
+      } else if (status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) {
+        dwnldCode = AUSTLMY.DWNLD_ERR_DOCUMENT_NOT_CACHED;
       }
+      AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode);
+      shouldRetrySoon = true;
+      deleteActiveUpdate = false;
+    } else if (status != Cr.NS_BINDING_ABORTED &&
+               status != Cr.NS_ERROR_ABORT) {
+      LOG("Downloader:onStopRequest - non-verification failure");
+      let dwnldCode = AUSTLMY.DWNLD_ERR_BINDING_ABORTED;
+      if (status == Cr.NS_ERROR_ABORT) {
+        dwnldCode = AUSTLMY.DWNLD_ERR_ABORT;
+      }
+      AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode);
+
+      // Some sort of other failure, log this in the |statusText| property
+      state = STATE_DOWNLOAD_FAILED;
+
+      // XXXben - if |request| (The Incremental Download) provided a means
+      // for accessing the http channel we could do more here.
+
+      this._update.statusText = getStatusTextFromCode(status,
+                                                      Cr.NS_BINDING_FAILED);
+
+      if (AppConstants.platform == "gonk") {
+        // bug891009: On FirefoxOS, manaully retry OTA download will reuse
+        // the Update object. We need to remove selected patch so that download
+        // can be triggered again successfully.
+        this._update.selectedPatch.selected = false;
+      }
+
+      // Destroy the updates directory, since we're done with it.
+      cleanUpUpdatesDir();
+
+      deleteActiveUpdate = true;
     }
     LOG("Downloader:onStopRequest - setting state to: " + state);
     this._patch.state = state;
     var um = Cc["@mozilla.org/updates/update-manager;1"].
              getService(Ci.nsIUpdateManager);
     if (deleteActiveUpdate) {
       this._update.installDate = (new Date()).getTime();
       um.activeUpdate = null;
     }
-    else {
-      if (um.activeUpdate) {
-        um.activeUpdate.state = state;
-      }
+    else if (um.activeUpdate) {
+      um.activeUpdate.state = state;
     }
     um.saveUpdates();
 
     // Only notify listeners about the stopped state if we
     // aren't handling an internal retry.
     if (!shouldRetrySoon && !shouldRegisterOnlineObserver) {
       var listeners = this._listeners.concat();
       var listenerCount = listeners.length;
--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
+++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
@@ -4302,25 +4302,23 @@ function resetEnvironment() {
       if (gEnvDyldLibraryPath) {
         debugDump("setting DYLD_LIBRARY_PATH environment variable value " +
                   "back to " + gEnvDyldLibraryPath);
         gEnv.set("DYLD_LIBRARY_PATH", gEnvDyldLibraryPath);
       } else if (gEnvDyldLibraryPath !== null) {
         debugDump("removing DYLD_LIBRARY_PATH environment variable");
         gEnv.set("DYLD_LIBRARY_PATH", "");
       }
-    } else {
-      if (gEnvLdLibraryPath) {
-        debugDump("setting LD_LIBRARY_PATH environment variable value back " +
-                  "to " + gEnvLdLibraryPath);
-        gEnv.set("LD_LIBRARY_PATH", gEnvLdLibraryPath);
-      } else if (gEnvLdLibraryPath !== null) {
-        debugDump("removing LD_LIBRARY_PATH environment variable");
-        gEnv.set("LD_LIBRARY_PATH", "");
-      }
+    } else if (gEnvLdLibraryPath) {
+      debugDump("setting LD_LIBRARY_PATH environment variable value back " +
+                "to " + gEnvLdLibraryPath);
+      gEnv.set("LD_LIBRARY_PATH", gEnvLdLibraryPath);
+    } else if (gEnvLdLibraryPath !== null) {
+      debugDump("removing LD_LIBRARY_PATH environment variable");
+      gEnv.set("LD_LIBRARY_PATH", "");
     }
   }
 
   if (IS_WIN && gAddedEnvXRENoWindowsCrashDialog) {
     debugDump("removing the XRE_NO_WINDOWS_CRASH_DIALOG environment " +
               "variable");
     gEnv.set("XRE_NO_WINDOWS_CRASH_DIALOG", "");
   }