зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1786197 - Turn on ESLint rule for prefer-boolean-length-check for testing. r=jmaher,perftest-reviewers,AlexandruIonescu
Differential Revision: https://phabricator.services.mozilla.com/D155175
This commit is contained in:
Родитель
db6a9a6b64
Коммит
365f6e8e10
|
@ -482,7 +482,6 @@ module.exports = {
|
|||
"layout/**",
|
||||
"netwerk/**",
|
||||
"storage/test/unit/test_vacuum.js",
|
||||
"testing/**",
|
||||
"tools/**",
|
||||
"widget/tests/test_assign_event_data.html",
|
||||
],
|
||||
|
|
|
@ -593,7 +593,7 @@ Tester.prototype = {
|
|||
// Run cleanup functions for the current test before moving on to the
|
||||
// next one.
|
||||
let testScope = this.currentTest.scope;
|
||||
while (testScope.__cleanupFunctions.length > 0) {
|
||||
while (testScope.__cleanupFunctions.length) {
|
||||
let func = testScope.__cleanupFunctions.shift();
|
||||
try {
|
||||
let result = await func.apply(testScope);
|
||||
|
|
|
@ -49,7 +49,7 @@ function parseTestManifest(testManifest, params, callback) {
|
|||
});
|
||||
}
|
||||
}
|
||||
if (paths.length > 0) {
|
||||
if (paths.length) {
|
||||
callback(paths);
|
||||
} else {
|
||||
callback(links);
|
||||
|
|
|
@ -94,7 +94,7 @@ MemoryStats.dump = function(
|
|||
);
|
||||
}
|
||||
}
|
||||
if (statMessage.length > 0) {
|
||||
if (statMessage.length) {
|
||||
info("MEMORY STAT" + statMessage);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ if (typeof partial == "undefined") {
|
|||
args.push(arguments[i]);
|
||||
}
|
||||
return function() {
|
||||
if (arguments.length > 0) {
|
||||
if (arguments.length) {
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
|
@ -1409,7 +1409,7 @@ SimpleTest.finish = function() {
|
|||
"expectUncaughtException was called but no uncaught exception was detected!"
|
||||
);
|
||||
}
|
||||
if (SimpleTest._tests.length == 0) {
|
||||
if (!SimpleTest._tests.length) {
|
||||
SimpleTest.ok(
|
||||
false,
|
||||
"[SimpleTest.finish()] No checks actually run. " +
|
||||
|
@ -1429,7 +1429,7 @@ SimpleTest.finish = function() {
|
|||
"This test is expected to leave a service worker registered"
|
||||
);
|
||||
}
|
||||
} else if (workers.length > 0) {
|
||||
} else if (workers.length) {
|
||||
let FULL_PROFILE_WORKERS_TO_IGNORE = [];
|
||||
if (parentRunner.conditionedProfile) {
|
||||
// Full profile has service workers in the profile, without clearing the profile
|
||||
|
|
|
@ -942,7 +942,7 @@ TestRunner.displayLoopErrors = function(tableName, tests) {
|
|||
if (TestRunner.countResults(tests).notOK > 0) {
|
||||
var table = $(tableName);
|
||||
var curtest;
|
||||
if (table.rows.length == 0) {
|
||||
if (!table.rows.length) {
|
||||
//if table headers are not yet generated, make them
|
||||
var row = table.insertRow(table.rows.length);
|
||||
var cell = row.insertCell(0);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
if (debug) {
|
||||
dump("Dispatching " + onpaint.length + " onpaint listeners\n");
|
||||
}
|
||||
while (onpaint.length > 0) {
|
||||
while (onpaint.length) {
|
||||
window.setTimeout(onpaint.pop(), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ if (!("SpecialPowers" in window)) {
|
|||
function parseQueryString(encodedString, useArrays) {
|
||||
// strip a leading '?' from the encoded string
|
||||
var qstr =
|
||||
encodedString.length > 0 && encodedString[0] == "?"
|
||||
encodedString.length && encodedString[0] == "?"
|
||||
? encodedString.substring(1)
|
||||
: encodedString;
|
||||
var pairs = qstr.replace(/\+/g, "%20").split(/(\&\;|\&\#38\;|\&|\&)/);
|
||||
|
@ -296,7 +296,7 @@ function hookup() {
|
|||
}
|
||||
|
||||
function hookupTests(testList) {
|
||||
if (testList.length > 0) {
|
||||
if (testList.length) {
|
||||
gTestList = testList;
|
||||
} else {
|
||||
gTestList = [];
|
||||
|
|
|
@ -233,7 +233,7 @@ async function closeTab(tabId) {
|
|||
|
||||
async function getCurrentTabId() {
|
||||
const tabs = await queryForTabs({ currentWindow: true, active: true });
|
||||
if (tabs.length == 0) {
|
||||
if (!tabs.length) {
|
||||
throw new Error("No active tab has been found.");
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,7 @@ function resultListener(request, sender, sendResponse) {
|
|||
const index = pendingHeroes.indexOf(_found);
|
||||
if (index > -1) {
|
||||
pendingHeroes.splice(index, 1);
|
||||
if (pendingHeroes.length == 0) {
|
||||
if (!pendingHeroes.length) {
|
||||
raptorLog("measured all expected hero elements");
|
||||
isHeroPending = false;
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ class SpecialPowersParent extends JSWindowActorParent {
|
|||
return false;
|
||||
}
|
||||
|
||||
var success = aFilenames.length != 0;
|
||||
var success = !!aFilenames.length;
|
||||
aFilenames.forEach(function(crashFilename) {
|
||||
var file = crashDumpDir.clone();
|
||||
file.append(crashFilename);
|
||||
|
|
|
@ -173,7 +173,7 @@ async function plInit() {
|
|||
plStop(true);
|
||||
}
|
||||
|
||||
if (pages.length == 0) {
|
||||
if (!pages.length) {
|
||||
dumpLine("tp: no pages to test, quitting");
|
||||
plStop(true);
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ async function test(window) {
|
|||
} catch (ex) {
|
||||
/* error condition handled below */
|
||||
}
|
||||
if (!testURLs || testURLs.length == 0) {
|
||||
if (!testURLs || !testURLs.length) {
|
||||
dump(
|
||||
"no tabs to test, 'addon.test.tabswitch.urlfile' pref isn't set to page set path\n"
|
||||
);
|
||||
|
|
|
@ -651,7 +651,7 @@ function _execute_test() {
|
|||
});
|
||||
};
|
||||
|
||||
let complete = _cleanupFunctions.length == 0;
|
||||
let complete = !_cleanupFunctions.length;
|
||||
let cleanupStartTime = complete ? 0 : Cu.now();
|
||||
(async () => {
|
||||
for (let func of _cleanupFunctions.reverse()) {
|
||||
|
|
|
@ -312,7 +312,7 @@ function handleRequest(req, res) {
|
|||
|
||||
function responseType(packet, responseIP) {
|
||||
if (
|
||||
packet.questions.length > 0 &&
|
||||
!!packet.questions.length &&
|
||||
packet.questions[0].name == "confirm.example.com" &&
|
||||
packet.questions[0].type == "NS"
|
||||
) {
|
||||
|
@ -343,24 +343,18 @@ function handleRequest(req, res) {
|
|||
|
||||
function createDNSAnswer(response, packet, responseIP, requestPayload) {
|
||||
// This shuts down the connection so we can test if the client reconnects
|
||||
if (
|
||||
packet.questions.length > 0 &&
|
||||
packet.questions[0].name == "closeme.com"
|
||||
) {
|
||||
if (packet.questions.length && packet.questions[0].name == "closeme.com") {
|
||||
response.stream.connection.close("INTERNAL_ERROR", response.stream.id);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (
|
||||
packet.questions.length > 0 &&
|
||||
packet.questions[0].name.endsWith(".pd")
|
||||
) {
|
||||
if (packet.questions.length && packet.questions[0].name.endsWith(".pd")) {
|
||||
// Bug 1543811: test edns padding extension. Return whether padding was
|
||||
// included via the first half of the ip address (1.1 vs 2.2) and the
|
||||
// size of the request in the second half of the ip address allowing to
|
||||
// verify that the correct amount of padding was added.
|
||||
if (
|
||||
packet.additionals.length > 0 &&
|
||||
!!packet.additionals.length &&
|
||||
packet.additionals[0].type == "OPT" &&
|
||||
packet.additionals[0].options.some(o => o.type === "PADDING")
|
||||
) {
|
||||
|
@ -394,7 +388,7 @@ function handleRequest(req, res) {
|
|||
|
||||
function responseData() {
|
||||
if (
|
||||
packet.questions.length > 0 &&
|
||||
!!packet.questions.length &&
|
||||
packet.questions[0].name == "confirm.example.com" &&
|
||||
packet.questions[0].type == "NS"
|
||||
) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче