Bug 1383120 - Enable no-arbitrary-setTimeout eslint rule on xpcshell tests, r?Mossop
MozReview-Commit-ID: 6DqLaZ9n5EM
--- a/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_browsingData_cookies_cache.js
@@ -1,10 +1,11 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
"resource://gre/modules/Timer.jsm");
const COOKIE = {
host: "example.com",
name: "test_cookie",
--- a/browser/components/translation/test/unit/test_cld2.js
+++ b/browser/components/translation/test/unit/test_cld2.js
@@ -12,16 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: dsites@google.com (Dick Sites)
//
// Unit test compact language detector, CLD2
//
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
// Test strings.
const kTeststr_en =
"confiscation of goods is assigned as the penalty part most of the courts " +
"consist of members and when it is necessary to bring public cases before a " +
"jury of members two courts combine for the purpose the most important cases " +
"of all are brought jurors or";
--- a/browser/experiments/test/xpcshell/test_cacherace.js
+++ b/browser/experiments/test/xpcshell/test_cacherace.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
Cu.import("resource://testing-common/httpd.js");
Cu.import("resource://gre/modules/Timer.jsm");
const MANIFEST_HANDLER = "manifests/handler";
--- a/browser/extensions/formautofill/test/unit/test_autofillFormFields.js
+++ b/browser/extensions/formautofill/test/unit/test_autofillFormFields.js
@@ -1,11 +1,12 @@
/*
* Test for form auto fill content helper fill all inputs function.
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
Cu.import("resource://formautofill/FormAutofillHandler.jsm");
const TESTCASES = [
{
description: "Form without autocomplete property",
--- a/devtools/server/tests/unit/test_promises_object_timetosettle-02.js
+++ b/devtools/server/tests/unit/test_promises_object_timetosettle-02.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
/**
* Test that we get the expected settlement time for promise time to settle.
*/
"use strict";
const { PromisesFront } = require("devtools/shared/fronts/promises");
--- a/devtools/shared/discovery/tests/unit/test_discovery.js
+++ b/devtools/shared/discovery/tests/unit/test_discovery.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
var Cu = Components.utils;
const { require } =
Cu.import("resource://devtools/shared/Loader.jsm", {});
const Services = require("Services");
--- a/dom/indexedDB/test/unit/test_database_close_without_onclose.js
+++ b/dom/indexedDB/test/unit/test_database_close_without_onclose.js
@@ -1,12 +1,13 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
var testGenerator = testSteps();
function* testSteps()
{
const name = this.window ? window.location.pathname :
"test_database_close_without_onclose.js";
--- a/dom/indexedDB/test/unit/test_idle_maintenance.js
+++ b/dom/indexedDB/test/unit/test_idle_maintenance.js
@@ -1,12 +1,13 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
var testGenerator = testSteps();
function* testSteps()
{
let uri = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI("https://www.example.com");
--- a/dom/indexedDB/test/unit/test_temporary_storage.js
+++ b/dom/indexedDB/test/unit/test_temporary_storage.js
@@ -1,12 +1,13 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
var testGenerator = testSteps();
function* testSteps()
{
const name = this.window ?
window.location.pathname :
"test_temporary_storage.js";
--- a/dom/indexedDB/test/unit/test_writer_starvation.js
+++ b/dom/indexedDB/test/unit/test_writer_starvation.js
@@ -1,12 +1,13 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
if (!this.window) {
this.runTest = function() {
todo(false, "Test disabled in xpcshell test suite for now");
finishTest();
}
}
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms.js
@@ -1,10 +1,11 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
add_task(async function test_alarm_without_permissions() {
function backgroundScript() {
browser.test.assertTrue(!browser.alarms,
"alarm API is not available when the alarm permission is not required");
browser.test.notifyPass("alarms_permission");
}
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms_does_not_fire.js
@@ -1,10 +1,11 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
add_task(async function test_cleared_alarm_does_not_fire() {
async function backgroundScript() {
let ALARM_NAME = "test_ext_alarms";
browser.alarms.onAlarm.addListener(alarm => {
browser.test.fail("cleared alarm does not fire");
--- a/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_alarms_periodic.js
@@ -1,10 +1,11 @@
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
add_task(async function test_periodic_alarm_fires() {
function backgroundScript() {
const ALARM_NAME = "test_ext_alarms";
let count = 0;
let timer;
--- a/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
+++ b/toolkit/components/promiseworker/tests/xpcshell/test_Promise.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
var Cu = Components.utils;
Cu.import("resource://gre/modules/PromiseWorker.jsm", this);
Cu.import("resource://gre/modules/Timer.jsm", this);
--- a/toolkit/components/search/tests/xpcshell/test_searchSuggest.js
+++ b/toolkit/components/search/tests/xpcshell/test_searchSuggest.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
/**
* Testing search suggestions from SearchSuggestionController.jsm.
*/
"use strict";
Cu.import("resource://gre/modules/FormHistory.jsm");
--- a/toolkit/components/telemetry/tests/unit/test_PingSender.js
+++ b/toolkit/components/telemetry/tests/unit/test_PingSender.js
@@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
*/
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
// This tests submitting a ping using the stand-alone pingsender program.
"use strict";
Cu.import("resource://gre/modules/osfile.jsm", this);
Cu.import("resource://gre/modules/Preferences.jsm", this);
Cu.import("resource://gre/modules/PromiseUtils.jsm", this);
--- a/toolkit/components/terminator/tests/xpcshell/test_terminator_record.js
+++ b/toolkit/components/terminator/tests/xpcshell/test_terminator_record.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
// Test that the Shutdown Terminator records durations correctly
var Cu = Components.utils;
var Cc = Components.classes;
--- a/toolkit/modules/subprocess/test/xpcshell/test_subprocess.js
+++ b/toolkit/modules/subprocess/test/xpcshell/test_subprocess.js
@@ -1,8 +1,9 @@
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
const env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
--- a/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
+++ b/toolkit/modules/tests/xpcshell/test_GMPInstallManager.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu, manager: Cm} = Components;
const URL_HOST = "http://localhost";
var GMPScope = Cu.import("resource://gre/modules/GMPInstallManager.jsm", {});
var GMPInstallManager = GMPScope.GMPInstallManager;
Cu.import("resource://gre/modules/Timer.jsm");
--- a/toolkit/modules/tests/xpcshell/test_PromiseUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_PromiseUtils.js
@@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
Components.utils.import("resource://gre/modules/PromiseUtils.jsm");
Components.utils.import("resource://gre/modules/Timer.jsm");
Components.utils.import("resource://testing-common/PromiseTestUtils.jsm");
// Tests for PromiseUtils.jsm
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
@@ -64,11 +64,12 @@ module.exports = {
// eslint-disable-next-line max-len
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
"uneval": false
},
rules: {
"mozilla/import-headjs-globals": "warn",
"mozilla/mark-test-function-used": "warn",
+ "mozilla/no-arbitrary-setTimeout": "error",
"no-shadow": "error"
}
};