From d3e296107e8f9711303b8bde3e1ba0d255135da6 Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Fri, 12 Aug 2016 11:50:35 -0400 Subject: [PATCH 1/7] Bug 1294621 - Enable the no-lonely-if rule for eslint. r=gijs MozReview-Commit-ID: 8izEqc8IyCu --- .../base/content/browser-gestureSupport.js | 18 ++- .../base/content/browser-tabsintitlebar.js | 18 ++- browser/base/content/browser.js | 11 +- browser/base/content/safeMode.js | 10 +- .../customizableui/CustomizableUI.jsm | 37 +++-- .../places/content/browserPlacesViews.js | 5 +- .../places/content/editBookmarkOverlay.js | 5 +- .../browser_drag_bookmarks_on_toolbar.js | 10 +- .../pocket/content/panels/js/saved.js | 6 +- browser/modules/PluginContent.jsm | 26 ++-- toolkit/.eslintrc | 2 +- .../alerts/resources/content/alert.js | 6 +- .../filepicker/content/filepicker.js | 5 +- .../microformats/microformat-shiv.js | 16 +-- .../passwordmgr/InsecurePasswordUtils.jsm | 12 +- .../passwordmgr/LoginManagerContent.jsm | 35 +++-- .../components/passwordmgr/storage-json.js | 8 +- .../perfmonitoring/AddonWatcher.jsm | 10 +- .../printing/content/printjoboptions.js | 8 +- .../components/prompts/src/CommonDialog.jsm | 21 ++- toolkit/components/satchel/FormHistory.jsm | 8 +- .../timermanager/nsUpdateTimerManager.js | 5 +- .../viewsource/ViewSourceBrowser.jsm | 6 +- .../viewsource/content/viewSource-content.js | 24 ++-- ...r_mediaPlayback_suspended_multipleAudio.js | 18 ++- .../chrome/content/TileManager.js | 11 +- toolkit/content/widgets/button.xml | 18 +-- toolkit/content/widgets/resizer.xml | 6 +- toolkit/content/widgets/scrollbox.xml | 12 +- toolkit/content/widgets/tree.xml | 8 +- toolkit/modules/secondscreen/RokuApp.jsm | 6 +- toolkit/modules/tests/xpcshell/test_Log.js | 8 +- toolkit/mozapps/downloads/DownloadLastDir.jsm | 9 +- toolkit/mozapps/downloads/DownloadUtils.jsm | 16 +-- .../extensions/LightweightThemeManager.jsm | 10 +- toolkit/mozapps/extensions/addonManager.js | 6 +- .../mozapps/extensions/content/extensions.js | 12 +- .../extensions/internal/XPIProvider.jsm | 17 ++- .../test/xpcshell/test_bug299716.js | 5 +- .../test/xpcshell/test_system_update.js | 5 +- toolkit/mozapps/update/nsUpdateService.js | 128 +++++++++--------- .../update/tests/data/xpcshellUtilsAUS.js | 16 +-- 42 files changed, 268 insertions(+), 355 deletions(-) diff --git a/browser/base/content/browser-gestureSupport.js b/browser/base/content/browser-gestureSupport.js index d684d200bd84..dae400b6a6aa 100644 --- a/browser/base/content/browser-gestureSupport.js +++ b/browser/base/content/browser-gestureSupport.js @@ -714,22 +714,20 @@ var gHistorySwipeAnimation = { // 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); } }, diff --git a/browser/base/content/browser-tabsintitlebar.js b/browser/base/content/browser-tabsintitlebar.js index b90929ee86c2..7098fc021eb7 100644 --- a/browser/base/content/browser-tabsintitlebar.js +++ b/browser/base/content/browser-tabsintitlebar.js @@ -55,11 +55,9 @@ var TabsInTitlebar = { 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); } }, @@ -298,11 +296,11 @@ function updateTitlebarDisplay() { } 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"); } } diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 758686d72aa9..ed8c122b0461 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -4108,10 +4108,8 @@ function updateCharacterEncodingMenuState() if (charsetMenu) { charsetMenu.removeAttribute("disabled"); } - } else { - if (charsetMenu) { - charsetMenu.setAttribute("disabled", "true"); - } + } else if (charsetMenu) { + charsetMenu.setAttribute("disabled", "true"); } } @@ -7829,9 +7827,8 @@ var MousePosTracker = { if (hover) { if (listener.onMouseEnter) listener.onMouseEnter(); - } else { - if (listener.onMouseLeave) - listener.onMouseLeave(); + } else if (listener.onMouseLeave) { + listener.onMouseLeave(); } } }; diff --git a/browser/base/content/safeMode.js b/browser/base/content/safeMode.js index 9d7a11e3e4b3..cc5852d6ef37 100644 --- a/browser/base/content/safeMode.js +++ b/browser/base/content/safeMode.js @@ -75,11 +75,9 @@ function onLoad() { // 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; } } diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index 64b4e030bf53..4dbd2bf02343 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -4325,31 +4325,26 @@ OverflowableToolbar.prototype = { // 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); + 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); - } + 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(); } }, diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js index d325f483c61f..3b33563036f9 100644 --- a/browser/components/places/content/browserPlacesViews.js +++ b/browser/components/places/content/browserPlacesViews.js @@ -481,10 +481,9 @@ PlacesViewBase.prototype = { 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); } }, diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index fc27c6c24f10..7e62b6140519 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -979,9 +979,8 @@ var gEditItemOverlay = { 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(); diff --git a/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js b/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js index 755d8325bb83..d80f92910d21 100644 --- a/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js +++ b/browser/components/places/tests/browser/browser_drag_bookmarks_on_toolbar.js @@ -232,13 +232,11 @@ function nextTest() { 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(); } } diff --git a/browser/extensions/pocket/content/panels/js/saved.js b/browser/extensions/pocket/content/panels/js/saved.js index 6608f824b8a5..50a3e7614963 100644 --- a/browser/extensions/pocket/content/panels/js/saved.js +++ b/browser/extensions/pocket/content/panels/js/saved.js @@ -267,10 +267,8 @@ var PKT_SAVED_OVERLAY = function (options) 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(); } }); }; diff --git a/browser/modules/PluginContent.jsm b/browser/modules/PluginContent.jsm index bee55a0e4fd6..7693bfc9c83c 100644 --- a/browser/modules/PluginContent.jsm +++ b/browser/modules/PluginContent.jsm @@ -716,13 +716,11 @@ PluginContent.prototype = { 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(); } } } @@ -1026,17 +1024,15 @@ PluginContent.prototype = { .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); } }, diff --git a/toolkit/.eslintrc b/toolkit/.eslintrc index c58566b6ef13..8d86b6119502 100644 --- a/toolkit/.eslintrc +++ b/toolkit/.eslintrc @@ -98,7 +98,7 @@ "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"], diff --git a/toolkit/components/alerts/resources/content/alert.js b/toolkit/components/alerts/resources/content/alert.js index 014d8a80f228..edfd13bdacab 100644 --- a/toolkit/components/alerts/resources/content/alert.js +++ b/toolkit/components/alerts/resources/content/alert.js @@ -256,10 +256,8 @@ function onAlertBeforeUnload() { 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); } } } diff --git a/toolkit/components/filepicker/content/filepicker.js b/toolkit/components/filepicker/content/filepicker.js index 268b9ad52ac9..783e6fedd49e 100644 --- a/toolkit/components/filepicker/content/filepicker.js +++ b/toolkit/components/filepicker/content/filepicker.js @@ -775,10 +775,9 @@ function processPath(path) } ++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; diff --git a/toolkit/components/microformats/microformat-shiv.js b/toolkit/components/microformats/microformat-shiv.js index a3c1a180f7ec..d88340c66e96 100644 --- a/toolkit/components/microformats/microformat-shiv.js +++ b/toolkit/components/microformats/microformat-shiv.js @@ -1211,10 +1211,8 @@ var Microformats; // jshint ignore:line 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']); } } } @@ -3403,12 +3401,10 @@ 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; } } } diff --git a/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm b/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm index fbd51f6bcfee..48141b9d0577 100644 --- a/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm +++ b/toolkit/components/passwordmgr/InsecurePasswordUtils.jsm @@ -127,14 +127,12 @@ this.InsecurePasswordUtils = { } 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); diff --git a/toolkit/components/passwordmgr/LoginManagerContent.jsm b/toolkit/components/passwordmgr/LoginManagerContent.jsm index 25c2395ba9ce..267548246878 100644 --- a/toolkit/components/passwordmgr/LoginManagerContent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm @@ -387,17 +387,15 @@ var LoginManagerContent = { // 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(); - }); - } + }); } }, @@ -787,16 +785,15 @@ var LoginManagerContent = { 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); diff --git a/toolkit/components/passwordmgr/storage-json.js b/toolkit/components/passwordmgr/storage-json.js index f1f8f1b6cea9..e74415d450a8 100644 --- a/toolkit/components/passwordmgr/storage-json.js +++ b/toolkit/components/passwordmgr/storage-json.js @@ -410,11 +410,9 @@ this.LoginManagerStorage_json.prototype = { 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); diff --git a/toolkit/components/perfmonitoring/AddonWatcher.jsm b/toolkit/components/perfmonitoring/AddonWatcher.jsm index 320f19309c4f..58decba85722 100644 --- a/toolkit/components/perfmonitoring/AddonWatcher.jsm +++ b/toolkit/components/perfmonitoring/AddonWatcher.jsm @@ -182,13 +182,11 @@ this.AddonWatcher = { // 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. diff --git a/toolkit/components/printing/content/printjoboptions.js b/toolkit/components/printing/content/printjoboptions.js index 293c18229665..d766e1b6f166 100644 --- a/toolkit/components/printing/content/printjoboptions.js +++ b/toolkit/components/printing/content/printjoboptions.js @@ -22,12 +22,10 @@ function checkDouble(element, maxVal) 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; } } } diff --git a/toolkit/components/prompts/src/CommonDialog.jsm b/toolkit/components/prompts/src/CommonDialog.jsm index f9baed6d49bc..6cde47d9b0ed 100644 --- a/toolkit/components/prompts/src/CommonDialog.jsm +++ b/toolkit/components/prompts/src/CommonDialog.jsm @@ -241,20 +241,17 @@ CommonDialog.prototype = { 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(); } }, diff --git a/toolkit/components/satchel/FormHistory.jsm b/toolkit/components/satchel/FormHistory.jsm index 17a540849a18..435af1d61eb2 100644 --- a/toolkit/components/satchel/FormHistory.jsm +++ b/toolkit/components/satchel/FormHistory.jsm @@ -423,11 +423,9 @@ function dbCreateAsyncStatement(aQuery, aParams, aBindingArrays) { } 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]; } } diff --git a/toolkit/components/timermanager/nsUpdateTimerManager.js b/toolkit/components/timermanager/nsUpdateTimerManager.js index 16b6742e30e2..48be236f0afa 100644 --- a/toolkit/components/timermanager/nsUpdateTimerManager.js +++ b/toolkit/components/timermanager/nsUpdateTimerManager.js @@ -271,9 +271,8 @@ TimerManager.prototype = { 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); } }, diff --git a/toolkit/components/viewsource/ViewSourceBrowser.jsm b/toolkit/components/viewsource/ViewSourceBrowser.jsm index a8ea13f1b0a4..b3ca7910f91d 100644 --- a/toolkit/components/viewsource/ViewSourceBrowser.jsm +++ b/toolkit/components/viewsource/ViewSourceBrowser.jsm @@ -189,10 +189,8 @@ ViewSourceBrowser.prototype = { // 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", diff --git a/toolkit/components/viewsource/content/viewSource-content.js b/toolkit/components/viewsource/content/viewSource-content.js index ff0ffd6b21d7..fe6f5b64635e 100644 --- a/toolkit/components/viewsource/content/viewSource-content.js +++ b/toolkit/components/viewsource/content/viewSource-content.js @@ -648,21 +648,19 @@ var ViewSourceContent = { 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; } } } diff --git a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js index dd94d0a5df8d..a76493daaef3 100644 --- a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js +++ b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js @@ -59,17 +59,15 @@ function check_autoplay_audio_pause_state(expectedPauseState) { } 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."); } } } diff --git a/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js b/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js index 731c8ded4ed9..d44ec69a73c0 100644 --- a/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js +++ b/toolkit/content/tests/fennec-tile-testapp/chrome/content/TileManager.js @@ -785,13 +785,10 @@ TileManager.Tile.prototype = { 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, diff --git a/toolkit/content/widgets/button.xml b/toolkit/content/widgets/button.xml index 3f36c8afb1bd..e338d67de0c9 100644 --- a/toolkit/content/widgets/button.xml +++ b/toolkit/content/widgets/button.xml @@ -27,13 +27,11 @@ @@ -292,11 +290,9 @@ 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) diff --git a/toolkit/content/widgets/resizer.xml b/toolkit/content/widgets/resizer.xml index 6f205d75c26f..006877a4f6f6 100644 --- a/toolkit/content/widgets/resizer.xml +++ b/toolkit/content/widgets/resizer.xml @@ -26,12 +26,10 @@ 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"); } ]]> diff --git a/toolkit/content/widgets/scrollbox.xml b/toolkit/content/widgets/scrollbox.xml index d4b6989e871e..6820306c3b2c 100644 --- a/toolkit/content/widgets/scrollbox.xml +++ b/toolkit/content/widgets/scrollbox.xml @@ -605,9 +605,9 @@ 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"); @@ -640,9 +640,9 @@ if (event.detail == 1) return; } - else { // horizontal scrollbox - if (event.detail == 0) - return; + else if (event.detail == 0) { + // horizontal scrollbox + return; } this.removeAttribute("notoverflowing"); diff --git a/toolkit/content/widgets/tree.xml b/toolkit/content/widgets/tree.xml index 8a4fa5de4d67..f921728dc609 100644 --- a/toolkit/content/widgets/tree.xml +++ b/toolkit/content/widgets/tree.xml @@ -539,11 +539,9 @@ } 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); ]]> diff --git a/toolkit/modules/secondscreen/RokuApp.jsm b/toolkit/modules/secondscreen/RokuApp.jsm index 34793a1ba7b9..479dfff29539 100644 --- a/toolkit/modules/secondscreen/RokuApp.jsm +++ b/toolkit/modules/secondscreen/RokuApp.jsm @@ -130,10 +130,8 @@ RokuApp.prototype = { if (callback) { callback(new RemoteMedia(this.resourceURL, listener)); } - } else { - if (callback) { - callback(); - } + } else if (callback) { + callback(); } } } diff --git a/toolkit/modules/tests/xpcshell/test_Log.js b/toolkit/modules/tests/xpcshell/test_Log.js index a2c6c11a6424..94b66270bdc3 100644 --- a/toolkit/modules/tests/xpcshell/test_Log.js +++ b/toolkit/modules/tests/xpcshell/test_Log.js @@ -102,12 +102,10 @@ function checkObjects(expected, actual) { 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]); } } diff --git a/toolkit/mozapps/downloads/DownloadLastDir.jsm b/toolkit/mozapps/downloads/DownloadLastDir.jsm index a053710f8d8b..552fd3ef1da4 100644 --- a/toolkit/mozapps/downloads/DownloadLastDir.jsm +++ b/toolkit/mozapps/downloads/DownloadLastDir.jsm @@ -186,11 +186,10 @@ DownloadLastDir.prototype = { 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); } } }; diff --git a/toolkit/mozapps/downloads/DownloadUtils.jsm b/toolkit/mozapps/downloads/DownloadUtils.jsm index b03c5e8e1fd7..34e99b3833f1 100644 --- a/toolkit/mozapps/downloads/DownloadUtils.jsm +++ b/toolkit/mozapps/downloads/DownloadUtils.jsm @@ -482,16 +482,14 @@ this.DownloadUtils = { // 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); } } diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm index 98d29b7c2d53..fba60382aaf8 100644 --- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -365,12 +365,10 @@ this.LightweightThemeManager = { 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) { diff --git a/toolkit/mozapps/extensions/addonManager.js b/toolkit/mozapps/extensions/addonManager.js index 11b3740d18d6..f204bbf6174f 100644 --- a/toolkit/mozapps/extensions/addonManager.js +++ b/toolkit/mozapps/extensions/addonManager.js @@ -247,10 +247,8 @@ amManager.prototype = { }; } AddonManager.addAddonListener(this.addonListener); - } else { - if (this.addonListener) { - AddonManager.removeAddonListener(this.addonListener); - } + } else if (this.addonListener) { + AddonManager.removeAddonListener(this.addonListener); } } } diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 3dda632f2b34..1f2c2d9b794f 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -480,9 +480,8 @@ var gEventManager = { : addonItem.mAddon.version); } } - else { - if (shouldShowVersionNumber(addonItem.mInstall)) - tiptext += " " + addonItem.mInstall.version; + else if (shouldShowVersionNumber(addonItem.mInstall)) { + tiptext += " " + addonItem.mInstall.version; } addonTooltip.label = tiptext; @@ -677,11 +676,10 @@ var gViewController = { gHistory.back(); else gViewController.replaceView(gViewDefault); + } else if (gHistory.canGoForward) { + gHistory.forward(); } else { - if (gHistory.canGoForward) - gHistory.forward(); - else - gViewController.replaceView(gViewDefault); + gViewController.replaceView(gViewDefault); } } }, diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index f540ca96a766..c10f7ca2f1ea 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -6094,13 +6094,13 @@ AddonInstall.prototype = { this.downloadFailed(error, message); }); } + else if (aRequest instanceof Ci.nsIHttpChannel) { + this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, + aRequest.responseStatus + " " + + aRequest.responseStatusText); + } else { - if (aRequest instanceof Ci.nsIHttpChannel) - this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, - aRequest.responseStatus + " " + - aRequest.responseStatusText); - else - this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, aStatus); + this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE, aStatus); } } else { @@ -7522,10 +7522,9 @@ AddonWrapper.prototype = { 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; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js index 2a19ab6bfdee..66656abe695c 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js @@ -105,9 +105,8 @@ function do_check_item(aItem, aVersion, aAddonsEntry) { 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"); } } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js index 4eb62c194a4f..0b02d6439f32 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js @@ -417,10 +417,9 @@ function* verify_state(initialState, finalState = undefined) { 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."); diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index af06d1ad6133..6e5ecb44cb02 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -4197,69 +4197,67 @@ Downloader.prototype = { // 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; @@ -4269,10 +4267,8 @@ Downloader.prototype = { 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(); diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index 4da591ecb015..a25c6084d40f 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -4307,15 +4307,13 @@ function resetEnvironment() { 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", ""); } } From afecf17f560c23f8957e73116507e2851902df51 Mon Sep 17 00:00:00 2001 From: Paolo Amadini Date: Fri, 12 Aug 2016 11:52:29 -0400 Subject: [PATCH 2/7] Bug 1294619 - Update jsdownloads code to enable the no-ex-assign rule for ESLint. r=jaws MozReview-Commit-ID: DiFGriLUdQq --- toolkit/.eslintrc | 2 +- toolkit/components/jsdownloads/src/DownloadCore.jsm | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/toolkit/.eslintrc b/toolkit/.eslintrc index 8d86b6119502..12857900cf09 100644 --- a/toolkit/.eslintrc +++ b/toolkit/.eslintrc @@ -80,7 +80,7 @@ "no-empty-pattern": 2, // No assiging to exception variable - // "no-ex-assign": 2, + "no-ex-assign": 2, // No using !! where casting to boolean is already happening // "no-extra-boolean-cast": 2, diff --git a/toolkit/components/jsdownloads/src/DownloadCore.jsm b/toolkit/components/jsdownloads/src/DownloadCore.jsm index 642ca2272d34..4804af3f84f6 100644 --- a/toolkit/components/jsdownloads/src/DownloadCore.jsm +++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm @@ -509,7 +509,12 @@ this.Download.prototype = { this.progress = 100; this.succeeded = true; this.hasPartialData = false; - } catch (ex) { + } catch (originalEx) { + // We may choose a different exception to propagate in the code below, + // or wrap the original one. We do this mutation in a different variable + // because of the "no-ex-assign" ESLint rule. + let ex = originalEx; + // Fail with a generic status code on cancellation, so that the caller // is forced to actually check the status properties to see if the // download was canceled or failed because of other reasons. From 51baff5088ed6d23342d7701eb8cfe72749f68be Mon Sep 17 00:00:00 2001 From: Katie Broida Date: Fri, 12 Aug 2016 13:48:59 -0400 Subject: [PATCH 3/7] Bug 565718 - Adds module for a zoom indicator in the browser's URL bar. r=dao MozReview-Commit-ID: 7jcAhgUp8RP --- browser/base/content/browser-fullZoom.js | 22 +++--- browser/base/content/browser.xul | 4 + browser/components/nsBrowserGlue.js | 2 + .../locales/en-US/chrome/browser/browser.dtd | 2 + .../en-US/chrome/browser/browser.properties | 4 + browser/modules/URLBarZoom.jsm | 51 +++++++++++++ browser/modules/moz.build | 1 + browser/modules/test/browser.ini | 1 + browser/modules/test/browser_urlBar_zoom.js | 73 +++++++++++++++++++ browser/themes/linux/browser.css | 37 ++++++++++ browser/themes/osx/browser.css | 35 +++++++++ browser/themes/windows/browser.css | 37 ++++++++++ 12 files changed, 258 insertions(+), 11 deletions(-) create mode 100644 browser/modules/URLBarZoom.jsm create mode 100644 browser/modules/test/browser_urlBar_zoom.js diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index a01888d866ba..bc4d5a9e7e98 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -194,14 +194,14 @@ var FullZoom = { this._ignorePendingZoomAccesses(browser); if (!aURI || (aIsTabSwitch && !this.siteSpecific)) { - this._notifyOnLocationChange(); + this._notifyOnLocationChange(browser); return; } // Avoid the cps roundtrip and apply the default/global pref. if (aURI.spec == "about:blank") { this._applyPrefToZoom(undefined, browser, - this._notifyOnLocationChange.bind(this)); + this._notifyOnLocationChange.bind(this, browser)); return; } @@ -209,7 +209,7 @@ var FullZoom = { if (!aIsTabSwitch && browser.isSyntheticDocument) { ZoomManager.setZoomForBrowser(browser, 1); // _ignorePendingZoomAccesses already called above, so no need here. - this._notifyOnLocationChange(); + this._notifyOnLocationChange(browser); return; } @@ -218,7 +218,7 @@ var FullZoom = { let pref = this._cps2.getCachedByDomainAndName(aURI.spec, this.name, ctxt); if (pref) { this._applyPrefToZoom(pref.value, browser, - this._notifyOnLocationChange.bind(this)); + this._notifyOnLocationChange.bind(this, browser)); return; } @@ -229,11 +229,11 @@ var FullZoom = { handleResult: function (resultPref) { value = resultPref.value; }, handleCompletion: function () { if (!token.isCurrent) { - this._notifyOnLocationChange(); + this._notifyOnLocationChange(browser); return; } this._applyPrefToZoom(value, browser, - this._notifyOnLocationChange.bind(this)); + this._notifyOnLocationChange.bind(this, browser)); }.bind(this) }); }, @@ -291,7 +291,7 @@ var FullZoom = { if (token.isCurrent) { ZoomManager.setZoomForBrowser(browser, value === undefined ? 1 : value); this._ignorePendingZoomAccesses(browser); - Services.obs.notifyObservers(null, "browser-fullZoom:zoomReset", ""); + Services.obs.notifyObservers(browser, "browser-fullZoom:zoomReset", ""); } }); this._removePref(browser); @@ -359,7 +359,7 @@ var FullZoom = { * @param browser The zoom of this browser will be saved. Required. */ _applyZoomToPref: function FullZoom__applyZoomToPref(browser) { - Services.obs.notifyObservers(null, "browser-fullZoom:zoomChange", ""); + Services.obs.notifyObservers(browser, "browser-fullZoom:zoomChange", ""); if (!this.siteSpecific || gInPrintPreviewMode || browser.isSyntheticDocument) @@ -380,7 +380,7 @@ var FullZoom = { * @param browser The zoom of this browser will be removed. Required. */ _removePref: function FullZoom__removePref(browser) { - Services.obs.notifyObservers(null, "browser-fullZoom:zoomReset", ""); + Services.obs.notifyObservers(browser, "browser-fullZoom:zoomReset", ""); if (browser.isSyntheticDocument) return; let ctxt = this._loadContextFromBrowser(browser); @@ -517,9 +517,9 @@ var FullZoom = { * The notification is always asynchronous so that observers are guaranteed a * consistent behavior. */ - _notifyOnLocationChange: function FullZoom__notifyOnLocationChange() { + _notifyOnLocationChange: function FullZoom__notifyOnLocationChange(browser) { this._executeSoon(function () { - Services.obs.notifyObservers(null, "browser-fullZoom:location-change", ""); + Services.obs.notifyObservers(browser, "browser-fullZoom:location-change", ""); }); }, diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 983b32863cad..dafc337df1ab 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -782,6 +782,10 @@ class="urlbar-icon" hidden="true" onclick="ReaderParent.buttonClick(event);"/> +