Bug 1311315 - General small fixes for no-undef eslint issues in browser/. r=jaws

Drop linting of the .eslintrc.js config files.
Fix some minor errors in the code (missing let/const, undefined vars).
Let eslint know that some files get their globals from other places (typically via xul script tags).

MozReview-Commit-ID: CwxuwPtRUr6

--HG--
rename : browser/components/contextualidentity/test/browser/.eslintrc.js => browser/components/syncedtabs/test/browser/.eslintrc.js
rename : browser/components/contextualidentity/test/browser/.eslintrc.js => browser/extensions/webcompat/test/browser/.eslintrc.js
extra : rebase_source : 9026aac49953d941853022cbab3e33d7d2f2fa21
This commit is contained in:
Mark Banner 2016-10-18 12:34:35 +01:00
parent 1b71b782de
commit b2464f8fa0
30 changed files with 125 additions and 48 deletions

View file

@ -1,6 +1,3 @@
# Allow linting of .eslintrc.js files.
!**/.eslintrc.js
# Always ignore node_modules.
**/node_modules/**/*.*

View file

@ -101,7 +101,7 @@
}
function toggleDisplay(node) {
toggle = {
const toggle = {
"": "block",
"none": "block",
"block": "none"

View file

@ -4,6 +4,8 @@
"use strict";
/* import-globals-from ../contentSearchUI.js */
// The process of adding a new default snippet involves:
// * add a new entity to aboutHome.dtd
// * add a <span/> for it in aboutHome.xhtml

View file

@ -3,5 +3,9 @@
module.exports = {
"extends": [
"../../../../../testing/mochitest/browser.eslintrc.js"
]
],
"rules": {
"no-undef": 2
}
};

View file

@ -40,7 +40,7 @@ add_task(function* test() {
// Let's try to open a window from tab1 with a name 'tab-2'.
info("Opening a window from the first tab...");
yield ContentTask.spawn(browser1, { url: BASE_URI + '?new' }, function(opts) {
yield ContentTask.spawn(browser1, { url: BASE_URI + '?new' }, function* (opts) {
yield (new content.window.wrappedJSObject.Promise(resolve => {
let w = content.window.wrappedJSObject.open(opts.url, 'tab-2');
w.onload = function() { resolve(); }

View file

@ -1259,8 +1259,9 @@ if (AppConstants.E10S_TESTING_ONLY) {
id: "e10s-button",
defaultArea: CustomizableUI.AREA_PANEL,
onBuild: function(aDocument) {
node.setAttribute("label", CustomizableUI.getLocalizedProperty(this, "label"));
node.setAttribute("tooltiptext", CustomizableUI.getLocalizedProperty(this, "tooltiptext"));
let node = aDocument.createElementNS(kNSXUL, "toolbarbutton");
node.setAttribute("label", CustomizableUI.getLocalizedProperty(this, "label"));
node.setAttribute("tooltiptext", CustomizableUI.getLocalizedProperty(this, "tooltiptext"));
},
onCommand: function(aEvent) {
let win = aEvent.view;

View file

@ -137,7 +137,7 @@ function add_sidebar_task(description, setup, teardown) {
add_sidebar_task(
"Check that a sidebar that uses a command event listener works",
function*() {
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.addEventListener("command", window.sawEvent);
}, function*() {
checkExpectedEvents({ command: 1 });
});
@ -145,7 +145,7 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses a click event listener works",
function*() {
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ click: 1 });
});
@ -153,8 +153,8 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses both click and command event listeners works",
function*() {
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.addEventListener("command", window.sawEvent);
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ command: 1, click: 1 });
});
@ -162,7 +162,7 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses an oncommand attribute works",
function*() {
gTestSidebarItem.setAttribute("oncommand", "sawEvent(event, true)");
gTestSidebarItem.setAttribute("oncommand", "window.sawEvent(event, true)");
}, function*() {
checkExpectedEvents({ oncommand: 1 });
});
@ -170,7 +170,7 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses an onclick attribute works",
function*() {
gTestSidebarItem.setAttribute("onclick", "sawEvent(event, true)");
gTestSidebarItem.setAttribute("onclick", "window.sawEvent(event, true)");
}, function*() {
checkExpectedEvents({ onclick: 1 });
});
@ -178,8 +178,8 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses both onclick and oncommand attributes works",
function*() {
gTestSidebarItem.setAttribute("onclick", "sawEvent(event, true)");
gTestSidebarItem.setAttribute("oncommand", "sawEvent(event, true)");
gTestSidebarItem.setAttribute("onclick", "window.sawEvent(event, true)");
gTestSidebarItem.setAttribute("oncommand", "window.sawEvent(event, true)");
}, function*() {
checkExpectedEvents({ onclick: 1, oncommand: 1 });
});
@ -187,8 +187,8 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses an onclick attribute and a command listener works",
function*() {
gTestSidebarItem.setAttribute("onclick", "sawEvent(event, true)");
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.setAttribute("onclick", "window.sawEvent(event, true)");
gTestSidebarItem.addEventListener("command", window.sawEvent);
}, function*() {
checkExpectedEvents({ onclick: 1, command: 1 });
});
@ -196,8 +196,8 @@ function*() {
add_sidebar_task(
"Check that a sidebar that uses an oncommand attribute and a click listener works",
function*() {
gTestSidebarItem.setAttribute("oncommand", "sawEvent(event, true)");
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.setAttribute("oncommand", "window.sawEvent(event, true)");
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ click: 1, oncommand: 1 });
});
@ -205,8 +205,8 @@ function*() {
add_sidebar_task(
"A sidebar with both onclick attribute and click listener sees only one event :(",
function*() {
gTestSidebarItem.setAttribute("onclick", "sawEvent(event, true)");
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.setAttribute("onclick", "window.sawEvent(event, true)");
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ onclick: 1 });
});
@ -214,8 +214,8 @@ function*() {
add_sidebar_task(
"A sidebar with both oncommand attribute and command listener sees only one event :(",
function*() {
gTestSidebarItem.setAttribute("oncommand", "sawEvent(event, true)");
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.setAttribute("oncommand", "window.sawEvent(event, true)");
gTestSidebarItem.addEventListener("command", window.sawEvent);
}, function*() {
checkExpectedEvents({ oncommand: 1 });
});
@ -225,7 +225,7 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("oncommand", "sawEvent(event, true)");
broadcaster.setAttribute("oncommand", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
@ -240,7 +240,7 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("onclick", "sawEvent(event, true)");
broadcaster.setAttribute("onclick", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
@ -255,8 +255,8 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("onclick", "sawEvent(event, true)");
broadcaster.setAttribute("oncommand", "sawEvent(event, true)");
broadcaster.setAttribute("onclick", "window.sawEvent(event, true)");
broadcaster.setAttribute("oncommand", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
@ -271,12 +271,12 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("oncommand", "sawEvent(event, true)");
broadcaster.setAttribute("oncommand", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
gTestSidebarItem.setAttribute("observes", "testbroadcaster");
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ click: 1, oncommand: 1 });
document.getElementById("testbroadcaster").remove();
@ -287,12 +287,12 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("onclick", "sawEvent(event, true)");
broadcaster.setAttribute("onclick", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
gTestSidebarItem.setAttribute("observes", "testbroadcaster");
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.addEventListener("command", window.sawEvent);
}, function*() {
checkExpectedEvents({ onclick: 1, command: 1 });
document.getElementById("testbroadcaster").remove();
@ -304,12 +304,12 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("onclick", "sawEvent(event, true)");
broadcaster.setAttribute("onclick", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
gTestSidebarItem.setAttribute("observes", "testbroadcaster");
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ onclick: 1 });
document.getElementById("testbroadcaster").remove();
@ -321,12 +321,12 @@ add_sidebar_task(
function*() {
let broadcaster = document.createElement("broadcaster");
broadcaster.setAttribute("id", "testbroadcaster");
broadcaster.setAttribute("oncommand", "sawEvent(event, true)");
broadcaster.setAttribute("oncommand", "window.sawEvent(event, true)");
broadcaster.setAttribute("label", "Test Sidebar");
document.getElementById("mainBroadcasterSet").appendChild(broadcaster);
gTestSidebarItem.setAttribute("observes", "testbroadcaster");
gTestSidebarItem.addEventListener("command", sawEvent);
gTestSidebarItem.addEventListener("command", window.sawEvent);
}, function*() {
checkExpectedEvents({ oncommand: 1 });
document.getElementById("testbroadcaster").remove();
@ -338,7 +338,7 @@ function*() {
let command = document.createElement("command");
command.setAttribute("id", "testcommand");
document.getElementById("mainCommandSet").appendChild(command);
command.addEventListener("command", sawEvent);
command.addEventListener("command", window.sawEvent);
gTestSidebarItem.setAttribute("command", "testcommand");
}, function*() {
@ -351,7 +351,7 @@ add_sidebar_task(
function*() {
let command = document.createElement("command");
command.setAttribute("id", "testcommand");
command.setAttribute("oncommand", "sawEvent(event, true)");
command.setAttribute("oncommand", "window.sawEvent(event, true)");
document.getElementById("mainCommandSet").appendChild(command);
gTestSidebarItem.setAttribute("command", "testcommand");
@ -365,9 +365,9 @@ add_sidebar_task("Check that a sidebar that uses a command element with a " +
function*() {
let command = document.createElement("command");
command.setAttribute("id", "testcommand");
command.setAttribute("oncommand", "sawEvent(event, true)");
command.setAttribute("oncommand", "window.sawEvent(event, true)");
document.getElementById("mainCommandSet").appendChild(command);
command.addEventListener("command", sawEvent);
command.addEventListener("command", window.sawEvent);
gTestSidebarItem.setAttribute("command", "testcommand");
}, function*() {
@ -380,12 +380,12 @@ add_sidebar_task(
function*() {
let command = document.createElement("command");
command.setAttribute("id", "testcommand");
command.setAttribute("oncommand", "sawEvent(event, true)");
command.setAttribute("oncommand", "window.sawEvent(event, true)");
document.getElementById("mainCommandSet").appendChild(command);
command.addEventListener("command", sawEvent);
command.addEventListener("command", window.sawEvent);
gTestSidebarItem.setAttribute("command", "testcommand");
gTestSidebarItem.addEventListener("click", sawEvent);
gTestSidebarItem.addEventListener("click", window.sawEvent);
}, function*() {
checkExpectedEvents({ click: 1, command: 1, oncommand: 1 });
document.getElementById("testcommand").remove();

View file

@ -1,5 +1,7 @@
self.randomValue = Math.random();
/* global onconnect:true */
onconnect = function (e) {
let port = e.ports[0];
port.postMessage(self.randomValue);

View file

@ -2,6 +2,8 @@
// 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/.
/* import-globals-from in-content/applications.js */
var Cc = Components.classes;
var Ci = Components.interfaces;

View file

@ -3,6 +3,8 @@
* 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/. */
/* import-globals-from ../../../toolkit/mozapps/preferences/fontbuilder.js */
// browser.display.languageList LOCK ALL when LOCKED
const kDefaultFontType = "font.default.%LANG%";
@ -101,4 +103,3 @@ var gFontsDialog = {
return buttonChosen == 0;
},
};

View file

@ -3,6 +3,7 @@
<!-- 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/. -->
<!-- import-globals-from in-content/applications.js -->
<!DOCTYPE overlay [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">

View file

@ -2,6 +2,18 @@
- 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/. */
// Import globals from the files imported by the .xul files.
/* import-globals-from subdialogs.js */
/* import-globals-from advanced.js */
/* import-globals-from main.js */
/* import-globals-from search.js */
/* import-globals-from content.js */
/* import-globals-from privacy.js */
/* import-globals-from applications.js */
/* import-globals-from security.js */
/* import-globals-from sync.js */
/* import-globals-from ../../../base/content/utilityOverlay.js */
"use strict";
var Cc = Components.classes;

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../../testing/mochitest/browser.eslintrc.js"
]
};

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};

View file

@ -9,6 +9,7 @@ Cu.import("resource://gre/modules/LoadContextInfo.jsm");
// Import common head.
var commonFile = do_get_file("../../../../toolkit/components/places/tests/head_common.js", false);
/* import-globals-from ../../../../toolkit/components/places/tests/head_common.js */
if (commonFile) {
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);

View file

@ -242,7 +242,7 @@ let performLongSpinnerCheck = Task.async(function*() {
let histogram = ping.payload.histograms[LONG_SPINNER_HISTOGRAM];
for (spinnerTime of Object.keys(histogram.values)) {
for (let spinnerTime of Object.keys(histogram.values)) {
// Only consider spinners that took more than 2 seconds.
// Note: the first bucket size that fits this criteria is
// 2297ms. And the largest bucket is 64000ms, meaning that

View file

@ -1,5 +1,5 @@
{
"extends": [
"../../../../../testing/xpcshell/xpcshell.eslintrc"
"../../../../../testing/xpcshell/xpcshell.eslintrc.js"
],
}

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../testing/mochitest/browser.eslintrc.js"
]
};

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"../../../../../testing/mochitest/browser.eslintrc.js"
]
};

View file

@ -606,7 +606,7 @@ TabWindow.prototype = {
if (aIconURL) {
let shouldRequestFaviconURL = true;
try {
urlObject = NetUtil.newURI(aIconURL);
let urlObject = NetUtil.newURI(aIconURL);
shouldRequestFaviconURL =
!this.directRequestProtocols.has(urlObject.scheme);
} catch (ex) {}

View file

@ -29,6 +29,6 @@ function waitForConditionPromise(condition, timeoutMsg, tryCount=NUMBER_OF_TRIES
function waitForCondition(condition, nextTest, errorMsg) {
waitForConditionPromise(condition, errorMsg).then(nextTest, (reason) => {
ok(false, reason + (reason.stack ? "\n" + e.stack : ""));
ok(false, reason + (reason.stack ? "\n" + reason.stack : ""));
});
}

View file

@ -0,0 +1,7 @@
"use strict";
module.exports = { // eslint-disable-line no-undef
"extends": [
"../../../testing/mochitest/browser.eslintrc.js"
],
};

View file

@ -2,6 +2,8 @@
* 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/. */
/* import-globals-from ../head.js */
"use strict";
add_task(function* capture() {

View file

@ -2,6 +2,8 @@
* 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/. */
/* import-globals-from ../head.js */
"use strict";
add_task(function* capture() {

View file

@ -2,6 +2,8 @@
* 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/. */
/* import-globals-from ../head.js */
"use strict";
add_task(function* capture() {

View file

@ -2,6 +2,8 @@
* 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/. */
/* import-globals-from ../head.js */
"use strict";
add_task(function* capture() {

View file

@ -2,6 +2,8 @@
* 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/. */
/* import-globals-from ../head.js */
"use strict";
add_task(function* capture() {

View file

@ -29,6 +29,7 @@ module.exports = {
"getTestFilePath": false,
"gTestPath": false,
"info": false,
"ignoreAllUncaughtExceptions": false,
"is": false,
"isnot": false,
"ok": false,

View file

@ -20,6 +20,7 @@ module.exports = {
"do_get_file": false,
"do_get_idle": false,
"do_get_profile": false,
"do_get_tempdir": false,
"do_load_module": false,
"do_parse_document": false,
"do_print": false,