Skip to content

Commit 96fbfbd

Browse files
committed
Bug 1780071 - autofix browser/ violations of no-comparison-or-assignment-inside-ok, r=Standard8,webcompat-reviewers,extension-reviewers,settings-reviewers,credential-management-reviewers,fxview-reviewers,sessionstore-reviewers,places-reviewers,sgalich,dao,twisniewski,mconley,sclements
Differential Revision: https://phabricator.services.mozilla.com/D198974
1 parent 91da301 commit 96fbfbd

File tree

137 files changed

+900
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+900
-532
lines changed

browser/base/content/test/about/browser_aboutCertError_offlineSupport.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ add_task(async function testOfflineSupportPage() {
2828

2929
let learnMoreLink = doc.getElementById("learnMoreLink");
3030
let supportPageURL = learnMoreLink.getAttribute("href");
31-
ok(
32-
supportPageURL == expectedURL + "time-errors",
31+
Assert.equal(
32+
supportPageURL,
33+
expectedURL + "time-errors",
3334
"Correct support page URL has been set"
3435
);
3536
await EventUtils.synthesizeMouseAtCenter(learnMoreLink, {}, content);

browser/base/content/test/about/browser_aboutNetError_native_fallback.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ async function verifyLoad(url, testName) {
3030

3131
await SpecialPowers.spawn(browser, [{ url, testName }], function (args) {
3232
const doc = content.document;
33-
ok(
34-
doc.documentURI == args.url,
33+
Assert.equal(
34+
doc.documentURI,
35+
args.url,
3536
"Should have loaded page: " + args.testName
3637
);
3738
});
@@ -84,8 +85,9 @@ async function verifyError(url, fallbackWarning, testName) {
8485
"Correct fallback warning error page title is set: " + args.testName
8586
);
8687
} else {
87-
ok(
88-
actualDataL10nID != "dns-not-found-native-fallback-title2",
88+
Assert.notEqual(
89+
actualDataL10nID,
90+
"dns-not-found-native-fallback-title2",
8991
"Should not show fallback warning: " + args.testName
9092
);
9193
}

browser/base/content/test/alerts/browser_notification_close.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ add_task(async function test_notificationClose() {
8888
let currentTime = alertWindow.Date.now();
8989
// The notification will self-close at 12 seconds, so this checks
9090
// that the notification closed before the timeout.
91-
ok(
92-
currentTime - closedTime < 5000,
91+
Assert.less(
92+
currentTime - closedTime,
93+
5000,
9394
"Close requested at " +
9495
closedTime +
9596
", actually closed at " +

browser/base/content/test/captivePortal/browser_captivePortalTabReference.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ async function checkCaptivePortalTabReference(evt, currState) {
2121
gBrowser.removeTab(errorTab);
2222

2323
await portalDetected();
24-
ok(CPS.state == CPS.LOCKED_PORTAL, "Captive portal is locked again");
24+
Assert.equal(CPS.state, CPS.LOCKED_PORTAL, "Captive portal is locked again");
2525
errorTab = await openCaptivePortalErrorTab();
2626
let portalTab2 = await openCaptivePortalLoginTab(errorTab);
27-
ok(
28-
portalTab != portalTab2,
27+
Assert.notEqual(
28+
portalTab,
29+
portalTab2,
2930
"waitForNewTab in openCaptivePortalLoginTab should not have completed at this point if references were held to the old captive portal tab after login/abort."
3031
);
3132
gBrowser.removeTab(portalTab);

browser/base/content/test/forms/browser_selectpopup.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,14 @@ add_task(async function test_somehidden() {
724724
let selectPopup = await openSelectPopup("click");
725725

726726
// The exact number is not needed; just ensure the height is larger than 4 items to accommodate any popup borders.
727-
ok(
728-
selectPopup.getBoundingClientRect().height >=
729-
selectPopup.lastElementChild.getBoundingClientRect().height * 4,
727+
Assert.greaterOrEqual(
728+
selectPopup.getBoundingClientRect().height,
729+
selectPopup.lastElementChild.getBoundingClientRect().height * 4,
730730
"Height contains at least 4 items"
731731
);
732-
ok(
733-
selectPopup.getBoundingClientRect().height <
734-
selectPopup.lastElementChild.getBoundingClientRect().height * 5,
732+
Assert.less(
733+
selectPopup.getBoundingClientRect().height,
734+
selectPopup.lastElementChild.getBoundingClientRect().height * 5,
735735
"Height doesn't contain 5 items"
736736
);
737737

@@ -823,8 +823,9 @@ add_task(async function test_zoom() {
823823
);
824824
info("Zoomed font-size is " + zoomedFontSize);
825825

826-
ok(
827-
Math.abs(zoomedFontSize - nonZoomedFontSize * 2.0) < 0.01,
826+
Assert.less(
827+
Math.abs(zoomedFontSize - nonZoomedFontSize * 2.0),
828+
0.01,
828829
`Zoom should affect menu popup size, got ${zoomedFontSize}, ` +
829830
`expected ${nonZoomedFontSize * 2.0}`
830831
);

browser/base/content/test/forms/browser_selectpopup_large.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,14 @@ async function performLargePopupTests(win) {
219219
let rect = selectPopup.getBoundingClientRect();
220220
let marginBottom = parseFloat(getComputedStyle(selectPopup).marginBottom);
221221
let marginTop = parseFloat(getComputedStyle(selectPopup).marginTop);
222-
ok(
223-
rect.top - marginTop >= browserRect.top,
222+
Assert.greaterOrEqual(
223+
rect.top - marginTop,
224+
browserRect.top,
224225
"Popup top position in within browser area"
225226
);
226-
ok(
227-
rect.bottom + marginBottom <= browserRect.bottom,
227+
Assert.lessOrEqual(
228+
rect.bottom + marginBottom,
229+
browserRect.bottom,
228230
"Popup bottom position in within browser area"
229231
);
230232

browser/base/content/test/general/browser_alltabslistener.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ var gAllProgressListener = {
133133
};
134134

135135
function assertCorrectBrowserAndEventOrderForAll(aState, aBrowser) {
136-
ok(
137-
aBrowser == gTestBrowser,
136+
Assert.equal(
137+
aBrowser,
138+
gTestBrowser,
138139
aState + " notification came from the correct browser"
139140
);
140141
Assert.less(

browser/base/content/test/general/browser_bug356571.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ var gProgressListener = {
5353
// Check we failed on unknown protocol (received an alert from docShell)
5454
ok(didFail, "Correctly failed on unknown protocol");
5555
// Check we opened all tabs
56-
ok(
57-
gBrowser.tabs.length == kURIs.length,
56+
Assert.equal(
57+
gBrowser.tabs.length,
58+
kURIs.length,
5859
"Correctly opened all expected tabs"
5960
);
6061
finishTest();

browser/base/content/test/general/browser_drag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function test() {
2222
},
2323
expected
2424
);
25-
ok(result === true, "dragging dataTransfer should be expected");
25+
Assert.strictEqual(result, true, "dragging dataTransfer should be expected");
2626
gURLBar.setPageProxyState(oldstate);
2727
// Now, the identity information panel is opened by the proxy icon click.
2828
// We need to close it for next tests.

browser/base/content/test/general/browser_gestureSupport.js

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ async function test_emitLatchedEvents(eventPrefix, initialDelta, cmd) {
409409
cmd[dir].callCount = expect[dir] = 0;
410410
}
411411

412-
let check = (aDir, aMsg) => ok(cmd[aDir].callCount == expect[aDir], aMsg);
412+
let check = (aDir, aMsg) =>
413+
Assert.equal(cmd[aDir].callCount, expect[aDir], aMsg);
413414
let checkBoth = function (aNum, aInc, aDec) {
414415
let prefix = "Step " + aNum + ": ";
415416
check("inc", prefix + aInc);
@@ -633,8 +634,8 @@ async function test_thresholdGesture(gesture, inc, dec, eventPrefix) {
633634
0,
634635
0
635636
);
636-
ok(cmdInc.callCount == 0, "Increasing command was triggered");
637-
ok(cmdDec.callCount == 0, "Decreasing command was triggered");
637+
Assert.equal(cmdInc.callCount, 0, "Increasing command was triggered");
638+
Assert.equal(cmdDec.callCount, 0, "Decreasing command was triggered");
638639

639640
// Now trigger the threshold.
640641
cmdInc.callCount = cmdDec.callCount = 0;
@@ -648,8 +649,8 @@ async function test_thresholdGesture(gesture, inc, dec, eventPrefix) {
648649
0,
649650
0
650651
);
651-
ok(cmdInc.callCount == 1, "Increasing command was not triggered");
652-
ok(cmdDec.callCount == 0, "Decreasing command was triggered");
652+
Assert.equal(cmdInc.callCount, 1, "Increasing command was not triggered");
653+
Assert.equal(cmdDec.callCount, 0, "Decreasing command was triggered");
653654

654655
// The tracking counter should go to zero. Go back the other way and
655656
// stop short of triggering the threshold.
@@ -664,8 +665,8 @@ async function test_thresholdGesture(gesture, inc, dec, eventPrefix) {
664665
0,
665666
0
666667
);
667-
ok(cmdInc.callCount == 0, "Increasing command was triggered");
668-
ok(cmdDec.callCount == 0, "Decreasing command was triggered");
668+
Assert.equal(cmdInc.callCount, 0, "Increasing command was triggered");
669+
Assert.equal(cmdDec.callCount, 0, "Decreasing command was triggered");
669670

670671
// Now cross the threshold and trigger the decreasing command.
671672
cmdInc.callCount = cmdDec.callCount = 0;
@@ -679,8 +680,8 @@ async function test_thresholdGesture(gesture, inc, dec, eventPrefix) {
679680
0,
680681
0
681682
);
682-
ok(cmdInc.callCount == 0, "Increasing command was triggered");
683-
ok(cmdDec.callCount == 1, "Decreasing command was not triggered");
683+
Assert.equal(cmdInc.callCount, 0, "Increasing command was triggered");
684+
Assert.equal(cmdDec.callCount, 1, "Decreasing command was not triggered");
684685

685686
// Send the wrap-up event. No commands should trigger.
686687
cmdInc.callCount = cmdDec.callCount = 0;
@@ -694,8 +695,8 @@ async function test_thresholdGesture(gesture, inc, dec, eventPrefix) {
694695
0,
695696
0
696697
);
697-
ok(cmdInc.callCount == 0, "Increasing command was triggered");
698-
ok(cmdDec.callCount == 0, "Decreasing command was triggered");
698+
Assert.equal(cmdInc.callCount, 0, "Increasing command was triggered");
699+
Assert.equal(cmdDec.callCount, 0, "Decreasing command was triggered");
699700

700701
// Restore the gesture to its original configuration.
701702
Services.prefs.setBoolPref(branch + "latched", oldLatchedValue);
@@ -738,10 +739,10 @@ async function test_swipeGestures() {
738739
0,
739740
0
740741
);
741-
ok(cmdUp.callCount == 1, "Step 1: Up command was not triggered");
742-
ok(cmdDown.callCount == 0, "Step 1: Down command was triggered");
743-
ok(cmdLeft.callCount == 0, "Step 1: Left command was triggered");
744-
ok(cmdRight.callCount == 0, "Step 1: Right command was triggered");
742+
Assert.equal(cmdUp.callCount, 1, "Step 1: Up command was not triggered");
743+
Assert.equal(cmdDown.callCount, 0, "Step 1: Down command was triggered");
744+
Assert.equal(cmdLeft.callCount, 0, "Step 1: Left command was triggered");
745+
Assert.equal(cmdRight.callCount, 0, "Step 1: Right command was triggered");
745746

746747
// DOWN
747748
resetCounts();
@@ -755,10 +756,10 @@ async function test_swipeGestures() {
755756
0,
756757
0
757758
);
758-
ok(cmdUp.callCount == 0, "Step 2: Up command was triggered");
759-
ok(cmdDown.callCount == 1, "Step 2: Down command was not triggered");
760-
ok(cmdLeft.callCount == 0, "Step 2: Left command was triggered");
761-
ok(cmdRight.callCount == 0, "Step 2: Right command was triggered");
759+
Assert.equal(cmdUp.callCount, 0, "Step 2: Up command was triggered");
760+
Assert.equal(cmdDown.callCount, 1, "Step 2: Down command was not triggered");
761+
Assert.equal(cmdLeft.callCount, 0, "Step 2: Left command was triggered");
762+
Assert.equal(cmdRight.callCount, 0, "Step 2: Right command was triggered");
762763

763764
// LEFT
764765
resetCounts();
@@ -772,10 +773,10 @@ async function test_swipeGestures() {
772773
0,
773774
0
774775
);
775-
ok(cmdUp.callCount == 0, "Step 3: Up command was triggered");
776-
ok(cmdDown.callCount == 0, "Step 3: Down command was triggered");
777-
ok(cmdLeft.callCount == 1, "Step 3: Left command was not triggered");
778-
ok(cmdRight.callCount == 0, "Step 3: Right command was triggered");
776+
Assert.equal(cmdUp.callCount, 0, "Step 3: Up command was triggered");
777+
Assert.equal(cmdDown.callCount, 0, "Step 3: Down command was triggered");
778+
Assert.equal(cmdLeft.callCount, 1, "Step 3: Left command was not triggered");
779+
Assert.equal(cmdRight.callCount, 0, "Step 3: Right command was triggered");
779780

780781
// RIGHT
781782
resetCounts();
@@ -789,10 +790,14 @@ async function test_swipeGestures() {
789790
0,
790791
0
791792
);
792-
ok(cmdUp.callCount == 0, "Step 4: Up command was triggered");
793-
ok(cmdDown.callCount == 0, "Step 4: Down command was triggered");
794-
ok(cmdLeft.callCount == 0, "Step 4: Left command was triggered");
795-
ok(cmdRight.callCount == 1, "Step 4: Right command was not triggered");
793+
Assert.equal(cmdUp.callCount, 0, "Step 4: Up command was triggered");
794+
Assert.equal(cmdDown.callCount, 0, "Step 4: Down command was triggered");
795+
Assert.equal(cmdLeft.callCount, 0, "Step 4: Left command was triggered");
796+
Assert.equal(
797+
cmdRight.callCount,
798+
1,
799+
"Step 4: Right command was not triggered"
800+
);
796801

797802
// Make sure combinations do not trigger events.
798803
let combos = [up | left, up | right, down | left, down | right];
@@ -808,11 +813,24 @@ async function test_swipeGestures() {
808813
0,
809814
0
810815
);
811-
ok(cmdUp.callCount == 0, "Step 5-" + i + ": Up command was triggered");
812-
ok(cmdDown.callCount == 0, "Step 5-" + i + ": Down command was triggered");
813-
ok(cmdLeft.callCount == 0, "Step 5-" + i + ": Left command was triggered");
814-
ok(
815-
cmdRight.callCount == 0,
816+
Assert.equal(
817+
cmdUp.callCount,
818+
0,
819+
"Step 5-" + i + ": Up command was triggered"
820+
);
821+
Assert.equal(
822+
cmdDown.callCount,
823+
0,
824+
"Step 5-" + i + ": Down command was triggered"
825+
);
826+
Assert.equal(
827+
cmdLeft.callCount,
828+
0,
829+
"Step 5-" + i + ": Left command was triggered"
830+
);
831+
Assert.equal(
832+
cmdRight.callCount,
833+
0,
816834
"Step 5-" + i + ": Right command was triggered"
817835
);
818836
}

browser/base/content/test/general/browser_lastAccessedTab.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const CURRENT_TIME_TOLERANCE_MS = 15;
88

99
function isCurrent(tab, msg) {
1010
const DIFF = Math.abs(Date.now() - tab.lastAccessed);
11-
ok(DIFF <= CURRENT_TIME_TOLERANCE_MS, msg + " (difference: " + DIFF + ")");
11+
Assert.lessOrEqual(
12+
DIFF,
13+
CURRENT_TIME_TOLERANCE_MS,
14+
msg + " (difference: " + DIFF + ")"
15+
);
1216
}
1317

1418
function nextStep(fn) {
@@ -41,15 +45,20 @@ function step2() {
4145
}
4246

4347
function step3() {
44-
ok(newTab.lastAccessed < Date.now(), "new tab hasn't been selected so far");
48+
Assert.less(
49+
newTab.lastAccessed,
50+
Date.now(),
51+
"new tab hasn't been selected so far"
52+
);
4553
gBrowser.selectedTab = newTab;
4654
isCurrent(newTab, "new tab has the current timestamp after being selected");
4755
nextStep(step4);
4856
}
4957

5058
function step4() {
51-
ok(
52-
originalTab.lastAccessed < Date.now(),
59+
Assert.less(
60+
originalTab.lastAccessed,
61+
Date.now(),
5362
"original tab has old timestamp after being deselected"
5463
);
5564
isCurrent(

browser/base/content/test/notificationbox/browser_tabnotificationbox_switch_tabs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ function assertNotificationBoxHidden(reason, browser) {
1515
ok(name, `Notification box has a name ${reason}`);
1616

1717
let { selectedViewName } = notificationBox._stack.parentElement;
18-
ok(
19-
selectedViewName != name,
18+
Assert.notEqual(
19+
selectedViewName,
20+
name,
2021
`Box is not shown ${reason} ${selectedViewName} != ${name}`
2122
);
2223
}

browser/base/content/test/pageinfo/browser_pageinfo_iframe_media.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ add_task(async function test_all_images_mentioned() {
2020
let imageRowsNum = imageTree.view.rowCount;
2121

2222
ok(imageTree, "Image tree is null (media tab is broken)");
23-
ok(
24-
imageRowsNum == 2,
23+
Assert.equal(
24+
imageRowsNum,
25+
2,
2526
"Number of media items listed: " + imageRowsNum + ", should be 2"
2627
);
2728

browser/base/content/test/pageinfo/browser_pageinfo_images.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ add_task(async function test_all_images_mentioned() {
2121

2222
ok(imageTree, "Image tree is null (media tab is broken)");
2323

24-
ok(
25-
imageRowsNum == 7,
24+
Assert.equal(
25+
imageRowsNum,
26+
7,
2627
"Number of images listed: " + imageRowsNum + ", should be 7"
2728
);
2829

browser/base/content/test/performance/browser_startup_content_mainthreadio.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ add_task(async function () {
410410
} else {
411411
message += `${entry[op] * -1} more times than expected`;
412412
}
413-
ok(entry[op] >= 0, `${message} in ${procName} process`);
413+
Assert.greaterOrEqual(
414+
entry[op],
415+
0,
416+
`${message} in ${procName} process`
417+
);
414418
}
415419
if (!("_used" in entry) && !entry.ignoreIfUnused) {
416420
ok(

0 commit comments

Comments
 (0)