--- a/testing/mochitest/browser.eslintrc.js
+++ b/testing/mochitest/browser.eslintrc.js
@@ -1,23 +1,26 @@
// Parent config file for all browser-chrome files.
module.exports = {
"rules": {
"mozilla/import-headjs-globals": "warn",
"mozilla/import-browserjs-globals": "warn",
+ "mozilla/import-test-globals": "warn",
"mozilla/mark-test-function-used": "warn",
},
"env": {
"browser": true,
//"node": true
},
// All globals made available in the test environment.
"globals": {
+ // `$` is defined in SimpleTest.js
+ "$": false,
"add_task": false,
"addLoadEvent": false,
"Assert": false,
"BrowserTestUtils": false,
"content": false,
"ContentTask": false,
"ContentTaskUtils": false,
"EventUtils": false,
@@ -33,17 +36,16 @@ module.exports = {
"info": false,
"ignoreAllUncaughtExceptions": false,
"is": false,
"isnot": false,
"ok": false,
"privateNoteIntentionalCrash": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SimpleTest": false,
"SpecialPowers": false,
"TestUtils": false,
"thisTestLeaksUncaughtRejectionsAndShouldBeFixed": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
--- a/testing/mochitest/chrome.eslintrc.js
+++ b/testing/mochitest/chrome.eslintrc.js
@@ -1,21 +1,24 @@
// Parent config file for all mochitest files.
module.exports = {
rules: {
"mozilla/import-headjs-globals": "warn",
+ "mozilla/import-test-globals": "warn",
"mozilla/mark-test-function-used": "warn",
},
"env": {
"browser": true,
},
// All globals made available in the test environment.
"globals": {
+ // `$` is defined in SimpleTest.js
+ "$": false,
"add_task": false,
"addLoadEvent": false,
"Assert": false,
"EventUtils": false,
"executeSoon": false,
"export_assertions": false,
"finish": false,
"getRootDirectory": false,
@@ -24,17 +27,16 @@ module.exports = {
"info": false,
"is": false,
"isnot": false,
"ok": false,
"privateNoteIntentionalCrash": false,
"promise": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SimpleTest": false,
"SpecialPowers": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
"waitForFocus": false,
}
--- a/testing/mochitest/mochitest.eslintrc.js
+++ b/testing/mochitest/mochitest.eslintrc.js
@@ -1,23 +1,24 @@
// Parent config file for all mochitest files.
module.exports = {
rules: {
"mozilla/import-headjs-globals": "warn",
+ "mozilla/import-test-globals": "warn",
"mozilla/mark-test-function-used": "warn",
"no-shadow": "error",
},
"env": {
"browser": true,
},
// All globals made available in the test environment.
"globals": {
- // $ is defined in SimpleTest.js
+ // `$` is defined in SimpleTest.js
"$": false,
"add_task": false,
"addLoadEvent": false,
"Assert": false,
"EventUtils": false,
"executeSoon": false,
"export_assertions": false,
"finish": false,
@@ -28,17 +29,16 @@ module.exports = {
"is": false,
"isDeeply": false,
"isnot": false,
"netscape": false,
"ok": false,
"promise": false,
"registerCleanupFunction": false,
"requestLongerTimeout": false,
- "SimpleTest": false,
"SpecialPowers": false,
"todo": false,
"todo_is": false,
"todo_isnot": false,
"waitForClipboard": false,
"waitForExplicitFinish": false,
"waitForFocus": false,
}
--- a/toolkit/.eslintrc.js
+++ b/toolkit/.eslintrc.js
@@ -244,12 +244,19 @@ module.exports = {
},
"globals": {
"ChromeWorker": false,
"ChromeUtils": false,
"Components": false,
"dump": true,
"KeyEvent": false,
"openDialog": false,
+ "MenuBoxObject": false,
"sizeToContent": false,
"SharedArrayBuffer": false,
+ // Note: StopIteration will likely be removed as part of removing legacy
+ // generators, see bug 968038.
+ "StopIteration": false,
+ // Specific to Firefox
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
+ "uneval": false
}
};
new file mode 100644
--- /dev/null
+++ b/toolkit/components/windowcreator/test/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = { // eslint-disable-line no-undef
+ "extends": [
+ "../../../../testing/mochitest/mochitest.eslintrc.js",
+ ]
+};
--- a/toolkit/components/windowcreator/test/test_nsFind.html
+++ b/toolkit/components/windowcreator/test/test_nsFind.html
@@ -9,17 +9,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
<p id="display">This is the text to search i<b>n­t</b>o</p>
<p id="quotes">"straight" and “curly” and ‘didn't’ and 'doesn’t'</p>
<div id="content" style="display: none">
-
+
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 450048 **/
// Check nsFind class and its nsIFind interface.
@@ -139,29 +139,29 @@ https://bugzilla.mozilla.org/show_bug.cg
ok(retRange, "\"" + searchValue + "\" not found (backward)");
// Curly quotes and straight quotes should match.
rf.caseSensitive = false;
rf.findBackwards = false;
- function find(node, searchValue) {
+ function find(node, value) {
var range = document.createRange();
range.setStart(node, 0);
range.setEnd(node, node.childNodes.length);
- return rf.Find(searchValue, range, range, range);
+ return rf.Find(value, range, range, range);
}
- function assertFound(node, searchValue) {
- ok(find(node, searchValue), "\"" + searchValue + "\" not found");
+ function assertFound(node, value) {
+ ok(find(node, value), "\"" + value + "\" not found");
}
- function assertNotFound(node, searchValue) {
- ok(!find(node, searchValue), "\"" + searchValue + "\" found");
+ function assertNotFound(node, value) {
+ ok(!find(node, value), "\"" + value + "\" found");
}
var quotes = document.getElementById("quotes");
assertFound(quotes, "\"straight\"");
assertFound(quotes, "\u201Cstraight\u201D");
assertNotFound(quotes, "'straight'");
new file mode 100644
--- /dev/null
+++ b/toolkit/components/windowcreator/tests/unit/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = { // eslint-disable-line no-undef
+ "extends": [
+ "../../../../../testing/xpcshell/xpcshell.eslintrc.js",
+ ]
+};
new file mode 100644
--- /dev/null
+++ b/toolkit/components/windowwatcher/test/.eslintrc.js
@@ -0,0 +1,9 @@
+"use strict";
+
+module.exports = { // eslint-disable-line no-undef
+ "extends": [
+ "../../../../testing/mochitest/browser.eslintrc.js",
+ "../../../../testing/mochitest/chrome.eslintrc.js",
+ "../../../../testing/mochitest/mochitest.eslintrc.js",
+ ]
+};
--- a/toolkit/content/tests/unit/test_contentAreaUtils.js
+++ b/toolkit/content/tests/unit/test_contentAreaUtils.js
@@ -5,16 +5,17 @@
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
function loadUtilsScript() {
var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
+ /* import-globals-from ../../contentAreaUtils.js */
loader.loadSubScript("chrome://global/content/contentAreaUtils.js");
}
function test_urlSecurityCheck() {
var nullPrincipal = Cc["@mozilla.org/nullprincipal;1"].
createInstance(Ci.nsIPrincipal);
const HTTP_URI = "http://www.mozilla.org/";
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
@@ -13,34 +13,36 @@
//------------------------------------------------------------------------------
module.exports = {
processors: {
".xml": require("../lib/processors/xbl-bindings"),
},
rules: {
"balanced-listeners": require("../lib/rules/balanced-listeners"),
+ "import-browserjs-globals": require("../lib/rules/import-browserjs-globals"),
"import-globals": require("../lib/rules/import-globals"),
"import-headjs-globals": require("../lib/rules/import-headjs-globals"),
- "import-browserjs-globals": require("../lib/rules/import-browserjs-globals"),
+ "import-test-globals": require("../lib/rules/import-test-globals"),
"mark-test-function-used": require("../lib/rules/mark-test-function-used"),
"no-aArgs": require("../lib/rules/no-aArgs"),
"no-cpows-in-tests": require("../lib/rules/no-cpows-in-tests"),
"no-single-arg-cu-import": require("../lib/rules/no-single-arg-cu-import"),
"no-import-into-var-and-global": require("../lib/rules/no-import-into-var-and-global.js"),
"no-useless-parameters": require("../lib/rules/no-useless-parameters"),
"reject-importGlobalProperties": require("../lib/rules/reject-importGlobalProperties"),
"reject-some-requires": require("../lib/rules/reject-some-requires"),
"var-only-at-top-level": require("../lib/rules/var-only-at-top-level")
},
rulesConfig: {
"balanced-listeners": 0,
+ "import-browserjs-globals": 0,
"import-globals": 0,
"import-headjs-globals": 0,
- "import-browserjs-globals": 0,
+ "import-test-globals": 0,
"mark-test-function-used": 0,
"no-aArgs": 0,
"no-cpows-in-tests": 0,
"no-single-arg-cu-import": 0,
"no-import-into-var-and-global": 0,
"no-useless-parameters": 0,
"reject-importGlobalProperties": 0,
"reject-some-requires": 0,
new file mode 100644
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-test-globals.js
@@ -0,0 +1,41 @@
+/**
+ * @fileoverview Import globals from common mochitest files, so that we
+ * don't need to specify them individually.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+"use strict";
+
+// -----------------------------------------------------------------------------
+// Rule Definition
+// -----------------------------------------------------------------------------
+
+var fs = require("fs");
+var path = require("path");
+var helpers = require("../helpers");
+var globals = require("../globals");
+
+const simpleTestFiles = [
+ "EventUtils.js",
+ "SimpleTest.js"
+];
+const simpleTestPath = "testing/mochitest/tests/SimpleTest";
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ Program: function(node) {
+ for (let file of simpleTestFiles) {
+ let newGlobals =
+ globals.getGlobalsForFile(path.join(simpleTestPath, file));
+ helpers.addGlobals(newGlobals, context.getScope());
+ }
+ }
+ };
+};
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
{
"name": "eslint-plugin-mozilla",
- "version": "0.2.10",
+ "version": "0.2.11",
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
"keywords": [
"eslint",
"eslintplugin",
"eslint-plugin",
"mozilla",
"firefox"
],