зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1571656 - Use Assert.jsm numeric comparison functions in tests r=mixedpuppy,MattN
Differential Revision: https://phabricator.services.mozilla.com/D40614 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f1ab766964
Коммит
975648e245
|
@ -38,7 +38,7 @@ add_task(async function() {
|
|||
},
|
||||
dialog => {
|
||||
let savedItemId = dialog.gEditItemOverlay.itemId;
|
||||
Assert.ok(savedItemId > 0, "Found the itemId");
|
||||
Assert.greater(savedItemId, 0, "Found the itemId");
|
||||
return PlacesTestUtils.waitForNotification(
|
||||
"onItemRemoved",
|
||||
id => id === savedItemId
|
||||
|
|
|
@ -145,7 +145,7 @@ add_task(async function test_query_on_toolbar() {
|
|||
});
|
||||
|
||||
// Get first child and check it is the just inserted query.
|
||||
Assert.ok(toolbarNode.childCount > 0, "Toolbar node has children");
|
||||
Assert.greater(toolbarNode.childCount, 0, "Toolbar node has children");
|
||||
let queryNode = toolbarNode.getChild(0);
|
||||
Assert.equal(
|
||||
queryNode.title,
|
||||
|
|
|
@ -132,7 +132,7 @@ add_task(async function test_separator_first() {
|
|||
await promiseReady;
|
||||
|
||||
let children = gToolbarContent.children;
|
||||
Assert.ok(children.length > 2, "Multiple elements are visible");
|
||||
Assert.greater(children.length, 2, "Multiple elements are visible");
|
||||
Assert.equal(
|
||||
children[1]._placesNode.uri,
|
||||
"http://test.places.0/",
|
||||
|
|
|
@ -21,7 +21,7 @@ add_task(async function test() {
|
|||
);
|
||||
|
||||
let resultCount = UrlbarTestUtils.getResultCount(window);
|
||||
Assert.ok(resultCount > 0, "At least one result");
|
||||
Assert.greater(resultCount, 0, "At least one result");
|
||||
|
||||
for (let i = 0; i < resultCount; i++) {
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown");
|
||||
|
|
|
@ -575,7 +575,7 @@ add_task(async function test_dont_decrement_chances_on_same_day() {
|
|||
let initChances = UnsubmittedCrashHandler.prefs.getIntPref(
|
||||
"chancesUntilSuppress"
|
||||
);
|
||||
Assert.ok(initChances > 1, "We should start with at least 1 chance.");
|
||||
Assert.greater(initChances, 1, "We should start with at least 1 chance.");
|
||||
|
||||
await createPendingCrashReports(1);
|
||||
let notification = await UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
|
||||
|
@ -625,7 +625,7 @@ add_task(async function test_decrement_chances_on_other_day() {
|
|||
let initChances = UnsubmittedCrashHandler.prefs.getIntPref(
|
||||
"chancesUntilSuppress"
|
||||
);
|
||||
Assert.ok(initChances > 1, "We should start with at least 1 chance.");
|
||||
Assert.greater(initChances, 1, "We should start with at least 1 chance.");
|
||||
|
||||
await createPendingCrashReports(1);
|
||||
let notification = await UnsubmittedCrashHandler.checkForUnsubmittedCrashReports();
|
||||
|
|
|
@ -148,14 +148,14 @@ add_task(async function test() {
|
|||
let results = await ChromeUtils.requestPerformanceMetrics();
|
||||
exploreResults(results);
|
||||
|
||||
Assert.ok(workerDuration > 0, "Worker duration should be positive");
|
||||
Assert.ok(workerTotal > 0, "Worker count should be positive");
|
||||
Assert.ok(duration > 0, "Duration should be positive");
|
||||
Assert.ok(total > 0, "Should get a positive count");
|
||||
Assert.greater(workerDuration, 0, "Worker duration should be positive");
|
||||
Assert.greater(workerTotal, 0, "Worker count should be positive");
|
||||
Assert.greater(duration, 0, "Duration should be positive");
|
||||
Assert.greater(total, 0, "Should get a positive count");
|
||||
Assert.ok(parentProcessEvent, "parent process sent back some events");
|
||||
Assert.ok(isTopLevel, "example.com as a top level window");
|
||||
Assert.ok(aboutMemoryFound, "about:memory");
|
||||
Assert.ok(heapUsage > 0, "got some memory value reported");
|
||||
Assert.greater(heapUsage, 0, "got some memory value reported");
|
||||
Assert.ok(sharedWorker, "We got some info from a shared worker");
|
||||
let numCounters = counterIds.length;
|
||||
Assert.ok(
|
||||
|
@ -185,8 +185,8 @@ add_task(async function test() {
|
|||
workerTotal > previousWorkerTotal,
|
||||
"Worker count should be positive"
|
||||
);
|
||||
Assert.ok(duration > previousDuration, "Duration should be positive");
|
||||
Assert.ok(total > previousTotal, "Should get a positive count");
|
||||
Assert.greater(duration, previousDuration, "Duration should be positive");
|
||||
Assert.greater(total, previousTotal, "Should get a positive count");
|
||||
|
||||
// load a tab with a setInterval, we should get counters on TaskCategory::Timer
|
||||
await BrowserTestUtils.withNewTab(
|
||||
|
@ -196,7 +196,7 @@ add_task(async function test() {
|
|||
let previousTimerCalls = timerCalls;
|
||||
results = await ChromeUtils.requestPerformanceMetrics();
|
||||
exploreResults(results, tabId);
|
||||
Assert.ok(timerCalls > previousTimerCalls, "Got timer calls");
|
||||
Assert.greater(timerCalls, previousTimerCalls, "Got timer calls");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -208,7 +208,7 @@ add_task(async function test() {
|
|||
let previousTimerCalls = timerCalls;
|
||||
results = await ChromeUtils.requestPerformanceMetrics();
|
||||
exploreResults(results, tabId);
|
||||
Assert.ok(timerCalls > previousTimerCalls, "Got timer calls");
|
||||
Assert.greater(timerCalls, previousTimerCalls, "Got timer calls");
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -219,7 +219,7 @@ add_task(async function test() {
|
|||
let tabId = gBrowser.selectedBrowser.outerWindowID;
|
||||
results = await ChromeUtils.requestPerformanceMetrics();
|
||||
exploreResults(results, tabId);
|
||||
Assert.ok(mediaMemory > 0, "Got some memory used for media");
|
||||
Assert.greater(mediaMemory, 0, "Got some memory used for media");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -244,7 +244,11 @@ function run_test() {
|
|||
numMigrated += 1;
|
||||
}
|
||||
// check we found at least 1 record that was migrated.
|
||||
Assert.ok(numMigrated > 0, "we found at least 1 record that was migrated");
|
||||
Assert.greater(
|
||||
numMigrated,
|
||||
0,
|
||||
"we found at least 1 record that was migrated"
|
||||
);
|
||||
|
||||
// This permission should always be there.
|
||||
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(
|
||||
|
|
|
@ -33,7 +33,7 @@ function run_test()
|
|||
const pattern = osprefs.getDateTimePattern(...test);
|
||||
if (test[0] !== osprefs.dateTimeFormatStyleNone &&
|
||||
test[1] !== osprefs.dateTImeFormatStyleNone) {
|
||||
Assert.ok(pattern.length > 0, "pattern is not empty.");
|
||||
Assert.greater(pattern.length, 0, "pattern is not empty.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ async function testBody() {
|
|||
do_log_info("now: " + now / 1000000);
|
||||
do_log_info("startHibernation: " + startHibernation / 1000000);
|
||||
do_log_info("stopHibernation: " + stopHibernation / 1000000);
|
||||
Assert.ok(startHibernation < now, "startHibernation ok");
|
||||
Assert.ok(stopHibernation < now, "stopHibernation ok");
|
||||
Assert.less(startHibernation, now, "startHibernation ok");
|
||||
Assert.less(stopHibernation, now, "stopHibernation ok");
|
||||
|
||||
// When the watchdog runs, it hibernates if there's been no activity for the
|
||||
// last 2 seconds, otherwise it sleeps for 1 second. As such, given perfect
|
||||
|
@ -42,8 +42,8 @@ async function testBody() {
|
|||
// making sure this behavior is roughly as expected on the macro scale,
|
||||
// so we add a 1 second fuzz factor here.
|
||||
const FUZZ_FACTOR = 1 * 1000 * 1000;
|
||||
Assert.ok(stateChange > now + 10*1000*1000 - FUZZ_FACTOR, "stateChange ok");
|
||||
Assert.ok(startHibernation > now + 2*1000*1000 - FUZZ_FACTOR, "startHibernation ok");
|
||||
Assert.ok(startHibernation < now + 5*1000*1000 + FUZZ_FACTOR, "startHibernation ok");
|
||||
Assert.ok(stopHibernation > now + 10*1000*1000 - FUZZ_FACTOR, "stopHibernation ok");
|
||||
Assert.greater(stateChange, now + 10*1000*1000 - FUZZ_FACTOR, "stateChange ok");
|
||||
Assert.greater(startHibernation, now + 2*1000*1000 - FUZZ_FACTOR, "startHibernation ok");
|
||||
Assert.less(startHibernation, now + 5*1000*1000 + FUZZ_FACTOR, "startHibernation ok");
|
||||
Assert.greater(stopHibernation, now + 10*1000*1000 - FUZZ_FACTOR, "stopHibernation ok");
|
||||
}
|
||||
|
|
|
@ -1001,7 +1001,7 @@ function CustomPipe(name) {
|
|||
"])"
|
||||
);
|
||||
|
||||
Assert.ok(increments.length > 0, "bad increments");
|
||||
Assert.greater(increments.length, 0, "bad increments");
|
||||
Assert.ok(
|
||||
increments.every(function(v) {
|
||||
return v > 0;
|
||||
|
|
|
@ -611,7 +611,7 @@ add_task(async function test_ignore_system() {
|
|||
let addon = reconciler.getAddonStateFromSyncGUID(guid);
|
||||
Assert.notEqual(addon.id, SYSTEM_ADDON_ID);
|
||||
}
|
||||
Assert.ok(num > 1, "should have seen at least one.");
|
||||
Assert.greater(num, 1, "should have seen at least one.");
|
||||
});
|
||||
|
||||
add_task(async function test_incoming_system() {
|
||||
|
|
|
@ -382,7 +382,7 @@ add_task(async function create_bookmark_frecency() {
|
|||
checkBookmarkObject(bm);
|
||||
|
||||
await PlacesTestUtils.promiseAsyncUpdates();
|
||||
Assert.ok(frecencyForUrl(bm.url) > 0, "Check frecency has been updated");
|
||||
Assert.greater(frecencyForUrl(bm.url), 0, "Check frecency has been updated");
|
||||
});
|
||||
|
||||
add_task(async function create_bookmark_without_type() {
|
||||
|
|
|
@ -308,7 +308,7 @@ add_task(async function update_url() {
|
|||
checkBookmarkObject(bm);
|
||||
let lastModified = bm.lastModified;
|
||||
let frecency = frecencyForUrl(bm.url);
|
||||
Assert.ok(frecency > 0, "Check frecency has been updated");
|
||||
Assert.greater(frecency, 0, "Check frecency has been updated");
|
||||
|
||||
bm = await PlacesUtils.bookmarks.update({
|
||||
guid: bm.guid,
|
||||
|
|
|
@ -13,7 +13,7 @@ add_task(async function setup() {
|
|||
}
|
||||
version--;
|
||||
}
|
||||
Assert.ok(version > 0, "Found a valid database version");
|
||||
Assert.greater(version, 0, "Found a valid database version");
|
||||
await setupPlacesDatabase(`places_v${version}.sqlite`);
|
||||
// Downgrade the schema version to the first supported one.
|
||||
let path = OS.Path.join(OS.Constants.Path.profileDir, DB_FILENAME);
|
||||
|
|
|
@ -33,7 +33,7 @@ add_task(async function test_eraseEverything() {
|
|||
Assert.equal(root.childCount, 4, "The folder should have 4 children");
|
||||
for (let i = 0; i < root.childCount; ++i) {
|
||||
let node = root.getChild(i);
|
||||
Assert.ok(node.itemId > 0, "The node should have an itemId");
|
||||
Assert.greater(node.itemId, 0, "The node should have an itemId");
|
||||
}
|
||||
Assert.equal(root.getChild(0).title, "title 1");
|
||||
Assert.equal(root.getChild(1).title, "title 2");
|
||||
|
|
|
@ -280,14 +280,14 @@ add_task(async function groupByHost() {
|
|||
let httpFrec = frecencyForUrl("http://example.com/");
|
||||
let httpsFrec = frecencyForUrl("https://example.com/");
|
||||
let otherFrec = frecencyForUrl("https://mozilla.org/");
|
||||
Assert.ok(httpFrec < httpsFrec, "Sanity check");
|
||||
Assert.ok(httpsFrec < otherFrec, "Sanity check");
|
||||
Assert.less(httpFrec, httpsFrec, "Sanity check");
|
||||
Assert.less(httpsFrec, otherFrec, "Sanity check");
|
||||
|
||||
// Make sure the frecencies of the three origins are as expected in relation
|
||||
// to the threshold.
|
||||
let threshold = await getOriginAutofillThreshold();
|
||||
Assert.ok(httpFrec < threshold, "http origin should be < threshold");
|
||||
Assert.ok(httpsFrec < threshold, "https origin should be < threshold");
|
||||
Assert.less(httpFrec, threshold, "http origin should be < threshold");
|
||||
Assert.less(httpsFrec, threshold, "https origin should be < threshold");
|
||||
Assert.ok(threshold <= otherFrec, "Other origin should cross threshold");
|
||||
|
||||
Assert.ok(
|
||||
|
@ -349,14 +349,14 @@ add_task(async function groupByHostNonDefaultStddevMultiplier() {
|
|||
let httpFrec = frecencyForUrl("http://example.com/");
|
||||
let httpsFrec = frecencyForUrl("https://example.com/");
|
||||
let otherFrec = frecencyForUrl("https://mozilla.org/");
|
||||
Assert.ok(httpFrec < httpsFrec, "Sanity check");
|
||||
Assert.ok(httpsFrec < otherFrec, "Sanity check");
|
||||
Assert.less(httpFrec, httpsFrec, "Sanity check");
|
||||
Assert.less(httpsFrec, otherFrec, "Sanity check");
|
||||
|
||||
// Make sure the frecencies of the three origins are as expected in relation
|
||||
// to the threshold.
|
||||
let threshold = await getOriginAutofillThreshold();
|
||||
Assert.ok(httpFrec < threshold, "http origin should be < threshold");
|
||||
Assert.ok(httpsFrec < threshold, "https origin should be < threshold");
|
||||
Assert.less(httpFrec, threshold, "http origin should be < threshold");
|
||||
Assert.less(httpsFrec, threshold, "https origin should be < threshold");
|
||||
Assert.ok(threshold <= otherFrec, "Other origin should cross threshold");
|
||||
|
||||
Assert.ok(
|
||||
|
|
|
@ -1053,7 +1053,7 @@ add_task(async function getTopFrencentSites_maxLimit() {
|
|||
links.length < MANY_LINKS,
|
||||
"query default limited to less than many"
|
||||
);
|
||||
Assert.ok(links.length > 6, "query default to more than visible count");
|
||||
Assert.greater(links.length, 6, "query default to more than visible count");
|
||||
});
|
||||
|
||||
add_task(async function getTopFrencentSites_allowedProtocols() {
|
||||
|
|
|
@ -14,7 +14,7 @@ add_task(async function test_setTimeout() {
|
|||
100
|
||||
);
|
||||
Assert.equal(typeof timeout1, "number", "setTimeout returns a number");
|
||||
Assert.ok(timeout1 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(timeout1, 0, "setTimeout returns a positive number");
|
||||
|
||||
imported.clearTimeout(timeout1);
|
||||
|
||||
|
@ -32,7 +32,7 @@ add_task(async function test_setTimeout() {
|
|||
);
|
||||
|
||||
Assert.equal(typeof timeout2, "number", "setTimeout returns a number");
|
||||
Assert.ok(timeout2 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(timeout2, 0, "setTimeout returns a positive number");
|
||||
Assert.notEqual(
|
||||
timeout1,
|
||||
timeout2,
|
||||
|
@ -49,7 +49,7 @@ add_task(async function test_setTimeoutWithTarget() {
|
|||
target
|
||||
);
|
||||
Assert.equal(typeof timeout1, "number", "setTimeout returns a number");
|
||||
Assert.ok(timeout1 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(timeout1, 0, "setTimeout returns a positive number");
|
||||
|
||||
imported.clearTimeout(timeout1);
|
||||
|
||||
|
@ -68,7 +68,7 @@ add_task(async function test_setTimeoutWithTarget() {
|
|||
);
|
||||
|
||||
Assert.equal(typeof timeout2, "number", "setTimeout returns a number");
|
||||
Assert.ok(timeout2 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(timeout2, 0, "setTimeout returns a positive number");
|
||||
Assert.notEqual(
|
||||
timeout1,
|
||||
timeout2,
|
||||
|
@ -83,7 +83,7 @@ add_task(async function test_setInterval() {
|
|||
100
|
||||
);
|
||||
Assert.equal(typeof interval1, "number", "setInterval returns a number");
|
||||
Assert.ok(interval1 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(interval1, 0, "setTimeout returns a positive number");
|
||||
|
||||
imported.clearInterval(interval1);
|
||||
|
||||
|
@ -117,7 +117,7 @@ add_task(async function test_setIntervalWithTarget() {
|
|||
target
|
||||
);
|
||||
Assert.equal(typeof interval1, "number", "setInterval returns a number");
|
||||
Assert.ok(interval1 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(interval1, 0, "setTimeout returns a positive number");
|
||||
|
||||
imported.clearInterval(interval1);
|
||||
|
||||
|
@ -177,7 +177,7 @@ add_task(async function test_requestIdleCallback() {
|
|||
"number",
|
||||
"requestIdleCallback returns a number"
|
||||
);
|
||||
Assert.ok(request1 > 0, "setTimeout returns a positive number");
|
||||
Assert.greater(request1, 0, "setTimeout returns a positive number");
|
||||
|
||||
imported.cancelIdleCallback(request1);
|
||||
|
||||
|
@ -205,7 +205,11 @@ add_task(async function test_requestIdleCallback() {
|
|||
"number",
|
||||
"requestIdleCallback returns a number"
|
||||
);
|
||||
Assert.ok(request2 > 0, "requestIdleCallback returns a positive number");
|
||||
Assert.greater(
|
||||
request2,
|
||||
0,
|
||||
"requestIdleCallback returns a positive number"
|
||||
);
|
||||
Assert.notEqual(
|
||||
request1,
|
||||
request2,
|
||||
|
|
|
@ -8,7 +8,7 @@ add_task(async function test_long_id() {
|
|||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
|
||||
await promiseStartupManager();
|
||||
|
||||
Assert.ok(ID.length > 64, "ID is > 64 characters");
|
||||
Assert.greater(ID.length, 64, "ID is > 64 characters");
|
||||
|
||||
await promiseInstallFile(do_get_file("data/signing_checks/long.xpi"));
|
||||
let addon = await promiseAddonByID(ID);
|
||||
|
|
|
@ -51,9 +51,9 @@ add_task(async function test_proc_info() {
|
|||
}
|
||||
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1529023
|
||||
if (!MAC) {
|
||||
Assert.ok(cpuThreads > 0, "Got some cpu time in the threads");
|
||||
Assert.greater(cpuThreads, 0, "Got some cpu time in the threads");
|
||||
}
|
||||
Assert.ok(cpuUser > 0, "Got some cpu time");
|
||||
Assert.greater(cpuUser, 0, "Got some cpu time");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ function test_getSharingProviders() {
|
|||
Ci.nsIMacSharingService
|
||||
);
|
||||
let providers = sharingService.getSharingProviders("http://example.org");
|
||||
Assert.ok(providers.length > 1, "There are providers returned");
|
||||
Assert.greater(providers.length, 1, "There are providers returned");
|
||||
providers.forEach(provider => {
|
||||
Assert.ok("name" in provider, "Provider has name");
|
||||
Assert.ok("menuItemTitle" in provider, "Provider has menuItemTitle");
|
||||
|
|
Загрузка…
Ссылка в новой задаче