From 9788800512947c5082f22f4b32522dfacd5d4578 Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Thu, 8 Feb 2018 13:35:53 -0500 Subject: [PATCH] Bug 1436575 - Manually fix the errors from no-compare-against-boolean-literal that the autofix couldn't change. r=standard8 MozReview-Commit-ID: 6NtfU76sPKv --HG-- extra : rebase_source : 143891b98995658a5683e01631eba9f6a2bb7b6f --- browser/base/content/tabbrowser.xml | 4 ++-- browser/components/enterprisepolicies/Policies.jsm | 6 +++--- mobile/android/components/BlocklistPrompt.js | 2 +- mobile/android/components/NSSDialogService.js | 2 +- .../tests/browser/robocop/testVideoControls.js | 2 +- .../sandbox/test/browser_content_sandbox_fs.js | 14 +++++++------- services/common/blocklist-clients.js | 2 +- storage/test/unit/test_statement_executeAsync.js | 4 ++-- testing/marionette/listener.js | 4 ++-- testing/specialpowers/content/specialpowersAPI.js | 4 ++-- .../talos/talos/pageloader/chrome/pageloader.js | 8 ++++---- .../osfile/tests/xpcshell/test_constants.js | 2 +- .../test/browser/browser_formless_submit_chrome.js | 4 ++-- .../places/tests/unit/test_null_interfaces.js | 2 +- .../telemetry/tests/unit/test_TelemetryEvents.js | 2 +- toolkit/content/preferencesBindings.js | 2 +- .../browser_bug295977_autoscroll_overflow.js | 2 +- toolkit/content/widgets/colorpicker.xml | 4 ++-- toolkit/content/widgets/dialog.xml | 2 +- toolkit/mozapps/extensions/content/extensions.js | 2 +- .../extensions/test/browser/browser_webapi.js | 2 +- .../extensions/test/xpcshell/test_filepointer.js | 2 +- 22 files changed, 39 insertions(+), 39 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 4c45decd5422..1e8a6e8730e3 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -499,12 +499,12 @@ if (!aBrowser) aBrowser = this.mCurrentBrowser; - if (aCallGlobalListeners != false && + if (aCallGlobalListeners && aBrowser == this.mCurrentBrowser) { callListeners(this.mProgressListeners, aArguments); } - if (aCallTabsListeners != false) { + if (aCallTabsListeners) { aArguments.unshift(aBrowser); callListeners(this.mTabsProgressListeners, aArguments); diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index f0ab2e2a3824..1716fcca115d 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -39,7 +39,7 @@ this.Policies = { "DisableAppUpdate": { onBeforeAddons(manager, param) { - if (param == true) { + if (param) { manager.disallowFeature("appUpdate"); } } @@ -97,7 +97,7 @@ this.Policies = { "DisableFirefoxStudies": { onBeforeAddons(manager, param) { - if (param == true) { + if (param) { manager.disallowFeature("Shield"); } } @@ -105,7 +105,7 @@ this.Policies = { "DisableFormHistory": { onBeforeUIStartup(manager, param) { - if (param == true) { + if (param) { setAndLockPref("browser.formfill.enable", false); } } diff --git a/mobile/android/components/BlocklistPrompt.js b/mobile/android/components/BlocklistPrompt.js index 67051f8854ac..cf6177817bf3 100644 --- a/mobile/android/components/BlocklistPrompt.js +++ b/mobile/android/components/BlocklistPrompt.js @@ -26,7 +26,7 @@ BlocklistPrompt.prototype = { Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); // If nothing aborted, quit the app - if (cancelQuit.data == false) { + if (!cancelQuit.data) { let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup); appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit); } diff --git a/mobile/android/components/NSSDialogService.js b/mobile/android/components/NSSDialogService.js index ccbfb6854771..3b96ccbe4f32 100644 --- a/mobile/android/components/NSSDialogService.js +++ b/mobile/android/components/NSSDialogService.js @@ -258,7 +258,7 @@ NSSDialogs.prototype = { this.viewCertDetails(certDetailsList[selectedIndex.value], ctx); continue; } else if (response.button == 0 /* buttons[0] */) { - if (response.rememberBox == true) { + if (response.rememberBox) { let caud = ctx.QueryInterface(Ci.nsIClientAuthUserDecision); if (caud) { caud.rememberClientAuthCertificate = true; diff --git a/mobile/android/tests/browser/robocop/testVideoControls.js b/mobile/android/tests/browser/robocop/testVideoControls.js index 95bb9c7d1d4e..772478604a74 100644 --- a/mobile/android/tests/browser/robocop/testVideoControls.js +++ b/mobile/android/tests/browser/robocop/testVideoControls.js @@ -89,7 +89,7 @@ function testLoad() { function testPlay(aEvent) { video.removeEventListener("play", testPlay); let playButton = getButtonByAttribute("class", "playButton"); - ok(playButton.hasAttribute("paused") == false, "Play button is not paused"); + ok(!playButton.hasAttribute("paused"), "Play button is not paused"); // Let the video play for 2 seconds, then pause it chromeWin.setTimeout(function() { diff --git a/security/sandbox/test/browser_content_sandbox_fs.js b/security/sandbox/test/browser_content_sandbox_fs.js index 245147ed2774..abbd89eb9c06 100644 --- a/security/sandbox/test/browser_content_sandbox_fs.js +++ b/security/sandbox/test/browser_content_sandbox_fs.js @@ -218,8 +218,8 @@ async function createFileInHome() { let homeFile = fileInHomeDir(); let path = homeFile.path; let fileCreated = await ContentTask.spawn(browser, path, createFile); - ok(fileCreated == false, "creating a file in home dir is not permitted"); - if (fileCreated == true) { + ok(!fileCreated, "creating a file in home dir is not permitted"); + if (fileCreated) { // content process successfully created the file, now remove it homeFile.remove(false); } @@ -233,9 +233,9 @@ async function createTempFile() { let path = fileInTempDir().path; let fileCreated = await ContentTask.spawn(browser, path, createFile); if (isMac()) { - ok(fileCreated == false, "creating a file in content temp is not permitted"); + ok(!fileCreated, "creating a file in content temp is not permitted"); } else { - ok(fileCreated == true, "creating a file in content temp is permitted"); + ok(!!fileCreated, "creating a file in content temp is permitted"); } // now delete the file let fileDeleted = await ContentTask.spawn(browser, path, deleteFile); @@ -243,15 +243,15 @@ async function createTempFile() { // On macOS we do not allow file deletion - it is not needed by the content // process itself, and macOS uses a different permission to control access // so revoking it is easy. - ok(fileDeleted == false, + ok(!fileDeleted, "deleting a file in content temp is not permitted"); let path = fileInTempDir().path; let symlinkCreated = await ContentTask.spawn(browser, path, createSymlink); - ok(symlinkCreated == false, + ok(!symlinkCreated, "created a symlink in content temp is not permitted"); } else { - ok(fileDeleted == true, "deleting a file in content temp is permitted"); + ok(!!fileDeleted, "deleting a file in content temp is permitted"); } } diff --git a/services/common/blocklist-clients.js b/services/common/blocklist-clients.js index 96e389ab92f2..04e88284a117 100644 --- a/services/common/blocklist-clients.js +++ b/services/common/blocklist-clients.js @@ -63,7 +63,7 @@ function mergeChanges(collection, localRecords, changes) { return Object.values(records) // Filter out deleted records. - .filter((record) => record.deleted != true) + .filter((record) => !record.deleted) // Sort list by record id. .sort((a, b) => { if (a.id < b.id) { diff --git a/storage/test/unit/test_statement_executeAsync.js b/storage/test/unit/test_statement_executeAsync.js index 642aac1ff51f..fe2e94c47426 100644 --- a/storage/test/unit/test_statement_executeAsync.js +++ b/storage/test/unit/test_statement_executeAsync.js @@ -95,7 +95,7 @@ function execAsync(aStmt, aOptions, aResults) { do_throw("handleResult invoked with 0 result rows!"); }, handleError(aError) { - if (errorCodeSeen != false) + if (errorCodeSeen) do_throw("handleError called when we already had an error!"); errorCodeSeen = aError.result; }, @@ -107,7 +107,7 @@ function execAsync(aStmt, aOptions, aResults) { do_throw("Expected " + resultsExpected + " rows of results but " + "got " + resultsSeen + " rows!", caller); - if (errorCodeExpected == true && errorCodeSeen == false) + if (errorCodeExpected && !errorCodeSeen) do_throw("Expected an error, but did not see one.", caller); else if (errorCodeExpected != errorCodeSeen) do_throw("Expected error code " + errorCodeExpected + " but got " + diff --git a/testing/marionette/listener.js b/testing/marionette/listener.js index 0fbd4e72e45f..ec6fc02eca3a 100644 --- a/testing/marionette/listener.js +++ b/testing/marionette/listener.js @@ -1399,7 +1399,7 @@ function switchToFrame(msg) { sendSyncMessage("Marionette:switchedToFrame", {frameValue: null}); curContainer.frame = content; - if (msg.json.focus == true) { + if (msg.json.focus) { curContainer.frame.focus(); } @@ -1464,7 +1464,7 @@ function switchToFrame(msg) { sendSyncMessage("Marionette:switchedToFrame", {frameValue: null}); curContainer.frame = content; - if (msg.json.focus == true) { + if (msg.json.focus) { curContainer.frame.focus(); } diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 6fc5dc844e6c..d658db2e6cfd 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -819,7 +819,7 @@ SpecialPowersAPI.prototype = { : Ci.nsIPermissionManager.DENY_ACTION; } - if (permission.remove == true) + if (permission.remove) perm = Ci.nsIPermissionManager.UNKNOWN_ACTION; if (originalValue == perm) { @@ -838,7 +838,7 @@ SpecialPowersAPI.prototype = { var cleanupTodo = Object.assign({}, todo); - if (permission.remove == true) + if (permission.remove) todo.op = "remove"; pendingPermissions.push(todo); diff --git a/testing/talos/talos/pageloader/chrome/pageloader.js b/testing/talos/talos/pageloader/chrome/pageloader.js index 86816e2b89ce..22db00017350 100644 --- a/testing/talos/talos/pageloader/chrome/pageloader.js +++ b/testing/talos/talos/pageloader/chrome/pageloader.js @@ -406,7 +406,7 @@ var plNextPage = async function() { doNextPage = true; } - if (doNextPage == true) { + if (doNextPage) { if (forceCC) { var tccstart = new Date(); window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) @@ -540,7 +540,7 @@ function plWaitForPaintingCapturing() { .getInterface(Components.interfaces.nsIDOMWindowUtils); if (utils.isMozAfterPaintPending && useMozAfterPaint) { - if (gPaintListener == false) + if (!gPaintListener) gPaintWindow.addEventListener("MozAfterPaint", plPaintedCapturing, true); gPaintListener = true; return; @@ -601,7 +601,7 @@ function waitForPainted() { return; } - if (gPaintListener == false) + if (!gPaintListener) gPaintWindow.addEventListener("MozAfterPaint", plPainted, true); gPaintListener = true; } @@ -703,7 +703,7 @@ function plStop(force) { function plStopAll(force) { try { - if (force == false) { + if (!force) { pageIndex = 0; pageCycle = 1; if (cycle < NUM_CYCLES - 1) { diff --git a/toolkit/components/osfile/tests/xpcshell/test_constants.js b/toolkit/components/osfile/tests/xpcshell/test_constants.js index 6c3f05be6828..88a5824b21f7 100644 --- a/toolkit/components/osfile/tests/xpcshell/test_constants.js +++ b/toolkit/components/osfile/tests/xpcshell/test_constants.js @@ -14,7 +14,7 @@ add_task(async function check_definition() { Assert.equal(Services.appinfo.OS, OS.Constants.Sys.Name); // check if using DEBUG build - if (Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).isDebugBuild == true) { + if (Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).isDebugBuild) { Assert.ok(OS.Constants.Sys.DEBUG); } else { Assert.ok(typeof(OS.Constants.Sys.DEBUG) == "undefined"); diff --git a/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js b/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js index 9ba71a467454..09ac7e967f31 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js +++ b/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js @@ -88,7 +88,7 @@ add_task(async function test_backButton_forwardButton() { } await BrowserTestUtils.waitForCondition(() => { - return forwardButton.disabled == false; + return !forwardButton.disabled; }); let forwardPromise = BrowserTestUtils.browserStopped(aBrowser); info("click the forward button"); @@ -106,7 +106,7 @@ add_task(async function test_reloadButton() { "formless_basic.html"); await BrowserTestUtils.waitForCondition(() => { - return reloadButton.disabled == false; + return !reloadButton.disabled; }); EventUtils.synthesizeMouseAtCenter(reloadButton, {}); await loadPromise; diff --git a/toolkit/components/places/tests/unit/test_null_interfaces.js b/toolkit/components/places/tests/unit/test_null_interfaces.js index 488edc0c1201..6aae84189d0f 100644 --- a/toolkit/components/places/tests/unit/test_null_interfaces.js +++ b/toolkit/components/places/tests/unit/test_null_interfaces.js @@ -62,7 +62,7 @@ function run_test() { let args = Array(num).fill(null); let tryAgain = true; - while (tryAgain == true) { + while (tryAgain) { try { info(`Calling with args: ${JSON.stringify(args)}`); func.apply(s, args); diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js index da1eda837de9..2412bcb6dbe9 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js @@ -152,7 +152,7 @@ add_task(async function test_recording() { // Check serializing only opt-out events. snapshot = Telemetry.snapshotEvents(OPTOUT, false); Assert.ok(("parent" in snapshot), "Should have entry for main process."); - let filtered = expected.filter(e => e.optout == true); + let filtered = expected.filter(e => !!e.optout); checkEvents(snapshot.parent, filtered); }); diff --git a/toolkit/content/preferencesBindings.js b/toolkit/content/preferencesBindings.js index dff3b34dd7d9..62173d9b462b 100644 --- a/toolkit/content/preferencesBindings.js +++ b/toolkit/content/preferencesBindings.js @@ -226,7 +226,7 @@ const Preferences = window.Preferences = (function() { if (aTarget.hasAttribute("on" + aEventName)) { const fn = new Function("event", aTarget.getAttribute("on" + aEventName)); const rv = fn.call(aTarget, event); - if (rv == false) + if (!rv) cancel = true; } return !cancel; diff --git a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js index 25d32da3b3dd..63226834aa39 100644 --- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js +++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js @@ -97,7 +97,7 @@ body > div > div {width: 1000px;height: 1000px;}\ continue; } - let prefsChanged = (test.middlemousepastepref == false || test.middlemousepastepref == true); + let prefsChanged = "middlemousepastepref" in test; if (prefsChanged) { await pushPrefs([["middlemouse.paste", test.middlemousepastepref]]); } diff --git a/toolkit/content/widgets/colorpicker.xml b/toolkit/content/widgets/colorpicker.xml index d2e3d2311f7c..35818d061ad4 100644 --- a/toolkit/content/widgets/colorpicker.xml +++ b/toolkit/content/widgets/colorpicker.xml @@ -231,7 +231,7 @@ if (aTarget.hasAttribute("on" + aEventName)) { var fn = new Function("event", aTarget.getAttribute("on" + aEventName)); var rv = fn.call(aTarget, event); - if (rv == false) + if (!rv) cancel = true; } return !cancel; @@ -486,7 +486,7 @@ if (aTarget.hasAttribute("on" + aEventName)) { var fn = new Function("event", aTarget.getAttribute("on" + aEventName)); var rv = fn.call(aTarget, event); - if (rv == false) + if (!rv) cancel = true; } return !cancel; diff --git a/toolkit/content/widgets/dialog.xml b/toolkit/content/widgets/dialog.xml index f54c1fe8cefc..063714c66e62 100644 --- a/toolkit/content/widgets/dialog.xml +++ b/toolkit/content/widgets/dialog.xml @@ -420,7 +420,7 @@ if (handler != "") { var fn = new Function("event", handler); var returned = fn(event); - if (returned == false) + if (!returned) noCancel = false; } diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 585429fcc4b2..a525a101ba27 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -2116,7 +2116,7 @@ var gDiscoverView = { notifyInitialized(); }; - if (Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED) == false) { + if (!Services.prefs.getBoolPref(PREF_GETADDONS_CACHE_ENABLED)) { setURL(url); return; } diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi.js b/toolkit/mozapps/extensions/test/browser/browser_webapi.js index 9c72f4e98dbe..fb2e0d0b84da 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_webapi.js +++ b/toolkit/mozapps/extensions/test/browser/browser_webapi.js @@ -114,7 +114,7 @@ add_task(testWithAPI(async function(browser) { } const PERM = "extensions.webextPermissionPrompts"; - if (Services.prefs.getBoolPref(PERM, false) == false) { + if (!Services.prefs.getBoolPref(PERM, false)) { await SpecialPowers.pushPrefEnv({clear: [[PERM]]}); await check(false, `mozAddonManager.permissionPromptsEnabled is false when ${PERM} is unset`); } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js index 0c33292752d3..b6931c1846c8 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js @@ -84,7 +84,7 @@ function writeRelativePointer(aId, aName) { function run_test() { // pointer files only work with unpacked directories - if (Services.prefs.getBoolPref("extensions.alwaysUnpack") == false) + if (!Services.prefs.getBoolPref("extensions.alwaysUnpack")) return; do_test_pending();