diff --git a/.eslintrc.js b/.eslintrc.js index 76aedbcc8995..35003e943c78 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -482,7 +482,6 @@ module.exports = { "layout/**", "netwerk/**", "storage/test/unit/test_vacuum.js", - "testing/**", "tools/**", "widget/tests/test_assign_event_data.html", ], diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index f99f8524be01..dbe38513832c 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -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); diff --git a/testing/mochitest/manifestLibrary.js b/testing/mochitest/manifestLibrary.js index 55a0a303275b..c9417f03d1a5 100644 --- a/testing/mochitest/manifestLibrary.js +++ b/testing/mochitest/manifestLibrary.js @@ -49,7 +49,7 @@ function parseTestManifest(testManifest, params, callback) { }); } } - if (paths.length > 0) { + if (paths.length) { callback(paths); } else { callback(links); diff --git a/testing/mochitest/tests/SimpleTest/MemoryStats.js b/testing/mochitest/tests/SimpleTest/MemoryStats.js index cedd8fe640f9..eb319b2e76d7 100644 --- a/testing/mochitest/tests/SimpleTest/MemoryStats.js +++ b/testing/mochitest/tests/SimpleTest/MemoryStats.js @@ -94,7 +94,7 @@ MemoryStats.dump = function( ); } } - if (statMessage.length > 0) { + if (statMessage.length) { info("MEMORY STAT" + statMessage); } diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index eb0dcc769271..94dd508f8c15 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -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 diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js index b850fce030de..40b36a839180 100644 --- a/testing/mochitest/tests/SimpleTest/TestRunner.js +++ b/testing/mochitest/tests/SimpleTest/TestRunner.js @@ -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); diff --git a/testing/mochitest/tests/SimpleTest/paint_listener.js b/testing/mochitest/tests/SimpleTest/paint_listener.js index 4f0388c2c323..475ac28fc9f0 100644 --- a/testing/mochitest/tests/SimpleTest/paint_listener.js +++ b/testing/mochitest/tests/SimpleTest/paint_listener.js @@ -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); } } diff --git a/testing/mochitest/tests/SimpleTest/setup.js b/testing/mochitest/tests/SimpleTest/setup.js index 836c899facc3..6d8b3bf9dc9a 100644 --- a/testing/mochitest/tests/SimpleTest/setup.js +++ b/testing/mochitest/tests/SimpleTest/setup.js @@ -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 = []; diff --git a/testing/raptor/webext/raptor/runner.js b/testing/raptor/webext/raptor/runner.js index 2973e246c284..643bb68ab51f 100644 --- a/testing/raptor/webext/raptor/runner.js +++ b/testing/raptor/webext/raptor/runner.js @@ -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; } diff --git a/testing/specialpowers/content/SpecialPowersParent.jsm b/testing/specialpowers/content/SpecialPowersParent.jsm index 7aa5de5ecd59..08b87878559a 100644 --- a/testing/specialpowers/content/SpecialPowersParent.jsm +++ b/testing/specialpowers/content/SpecialPowersParent.jsm @@ -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); diff --git a/testing/talos/talos/pageloader/chrome/pageloader.js b/testing/talos/talos/pageloader/chrome/pageloader.js index c81703122c44..382f932a75d0 100644 --- a/testing/talos/talos/pageloader/chrome/pageloader.js +++ b/testing/talos/talos/pageloader/chrome/pageloader.js @@ -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); } diff --git a/testing/talos/talos/tests/tabswitch/api.js b/testing/talos/talos/tests/tabswitch/api.js index c20f4cd36706..d21e64bb1d53 100644 --- a/testing/talos/talos/tests/tabswitch/api.js +++ b/testing/talos/talos/tests/tabswitch/api.js @@ -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" ); diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index ddc0047872aa..c9024f09f8b9 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -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()) { diff --git a/testing/xpcshell/moz-http2/moz-http2.js b/testing/xpcshell/moz-http2/moz-http2.js index 43379ef4fcd9..9a431e7b8aa2 100644 --- a/testing/xpcshell/moz-http2/moz-http2.js +++ b/testing/xpcshell/moz-http2/moz-http2.js @@ -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" ) {