Bug 1294621 - Enable the no-lonely-if rule for eslint. r=gijs

MozReview-Commit-ID: 8izEqc8IyCu
This commit is contained in:
Jared Wein 2016-08-12 11:50:35 -04:00
parent d99b80b960
commit d3e296107e
42 changed files with 268 additions and 355 deletions

View File

@ -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);
}
},

View File

@ -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");
}
}

View File

@ -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();
}
}
};

View File

@ -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;
}
}

View File

@ -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();
}
},

View File

@ -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);
}
},

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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();
}
});
};

View File

@ -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);
}
},

View File

@ -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"],

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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.

View File

@ -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;
}
}
}

View File

@ -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();
}
},

View File

@ -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];
}
}

View File

@ -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);
}
},

View File

@ -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",

View File

@ -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;
}
}
}

View File

@ -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.");
}
}
}

View File

@ -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,

View File

@ -27,13 +27,11 @@
<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>
@ -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)

View File

@ -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");
}
]]>
</constructor>

View File

@ -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");

View File

@ -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);
]]>

View File

@ -130,10 +130,8 @@ RokuApp.prototype = {
if (callback) {
callback(new RemoteMedia(this.resourceURL, listener));
}
} else {
if (callback) {
callback();
}
} else if (callback) {
callback();
}
}
}

View File

@ -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]);
}
}

View File

@ -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);
}
}
};

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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);
}
}
}

View File

@ -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);
}
}
},

View File

@ -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;

View File

@ -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");
}
}

View File

@ -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.");

View File

@ -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();

View File

@ -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", "");
}
}