Bug 1589334 - Enable ESLint for all of devtools/shared (manual changes). r=Standard8,jdescottes,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D51090

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Vega 2019-12-03 08:39:59 +00:00
parent 02f9c81edb
commit 3defbe3b72
32 changed files with 110 additions and 62 deletions

View file

@ -59,9 +59,6 @@ devtools/client/performance/components/test/test_jit_optimizations_01.html
devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html
devtools/shared/qrcode/tests/mochitest/test_decode.html
devtools/shared/tests/mochitest/*.html
devtools/shared/webconsole/test/test_*.html
devtools/client/webreplay/mochitest/examples/*.html
# Ignore devtools debugger files

View file

@ -48,6 +48,7 @@ module.exports = {
"client/framework/**",
"client/shared/*.jsm",
"client/shared/widgets/*.jsm",
"shared/webconsole/test/*.html",
],
"rules": {
"mozilla/no-aArgs": "off",

View file

@ -10,7 +10,10 @@ Test decoding a simple message
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
"use strict";
window.onload = function() {
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
const QR = require("devtools/shared/qrcode/index");

View file

@ -7,6 +7,7 @@
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
"use strict";
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
const { findCssSelector } = require("devtools/shared/inspector/css-logic");
@ -30,10 +31,10 @@ window.onload = function() {
};
addTest(function findAllCssSelectors() {
var nodes = document.querySelectorAll("*");
for (var i = 0; i < nodes.length; i++) {
var selector = findCssSelector(nodes[i]);
var matches = document.querySelectorAll(selector);
const nodes = document.querySelectorAll("*");
for (let i = 0; i < nodes.length; i++) {
const selector = findCssSelector(nodes[i]);
const matches = document.querySelectorAll(selector);
is(matches.length, 1, "There is a single match: " + selector);
is(matches[0], nodes[i], "The selector matches the correct node: " + selector);
@ -43,22 +44,22 @@ addTest(function findAllCssSelectors() {
});
addTest(function findCssSelectorNotContainedInDocument() {
var unattached = document.createElement("div");
const unattached = document.createElement("div");
unattached.id = "unattached";
is(findCssSelector(unattached), "", "Unattached node returns empty string");
var unattachedChild = document.createElement("div");
const unattachedChild = document.createElement("div");
unattached.appendChild(unattachedChild);
is(findCssSelector(unattachedChild), "", "Unattached child returns empty string");
var unattachedBody = document.createElement("body");
const unattachedBody = document.createElement("body");
is(findCssSelector(unattachedBody), "", "Unattached body returns empty string");
runNextTest();
});
addTest(function findCssSelectorBasic() {
let data = [
const data = [
"#one",
"#" + CSS.escape("2"),
".three",
@ -75,11 +76,11 @@ addTest(function findCssSelectorBasic() {
"#" + CSS.escape("!, \", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \\, ], ^, `, {, |, }, ~"),
];
let container = document.querySelector("#find-css-selector");
const container = document.querySelector("#find-css-selector");
is(container.children.length, data.length, "Container has correct number of children.");
for (let i = 0; i < data.length; i++) {
let node = container.children[i];
const node = container.children[i];
is(findCssSelector(node), data[i], "matched id for index " + (i - 1));
}

View file

@ -10,6 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1323700
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
"use strict";
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
const CssLogic = require("devtools/shared/inspector/css-logic");
@ -33,15 +34,15 @@ window.onload = function() {
}
addTest(function getCssPathForUnattachedElement() {
var unattached = document.createElement("div");
const unattached = document.createElement("div");
unattached.id = "unattached";
is(CssLogic.getCssPath(unattached), "", "Unattached node returns empty string");
var unattachedChild = document.createElement("div");
const unattachedChild = document.createElement("div");
unattached.appendChild(unattachedChild);
is(CssLogic.getCssPath(unattachedChild), "", "Unattached child returns empty string");
var unattachedBody = document.createElement("body");
const unattachedBody = document.createElement("body");
is(CssLogic.getCssPath(unattachedBody), "", "Unattached body returns empty string");
runNextTest();
@ -52,7 +53,7 @@ addTest(function cssPathHasOneStepForEachAncestor() {
const splitPath = CssLogic.getCssPath(el).split(" ");
let expectedNbOfParts = 0;
var parent = el.parentNode;
let parent = el.parentNode;
while (parent) {
expectedNbOfParts ++;
parent = parent.parentNode;

View file

@ -12,6 +12,8 @@
<p>Basic Web Console Actor tests</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()

View file

@ -12,6 +12,8 @@
<p>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()
@ -48,6 +50,7 @@ function onInspect(aState, aResponse)
{
ok(!aResponse.error, "no response error");
// eslint-disable-next-line no-proto
const expectedProps = Object.getOwnPropertyNames(document.__proto__);
const props = aResponse.ownProperties;

View file

@ -12,6 +12,8 @@
<p>Test for cached messages</p>
<script class="testbody" type="application/javascript">
"use strict";
window.docShell.cssErrorReportingEnabled = true;
var ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
.getService(Ci.nsIConsoleAPIStorage);
@ -96,6 +98,8 @@ function doConsoleCalls() {
</script>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
var {ConsoleServiceListener} =
require("devtools/server/actors/webconsole/listeners/console-service");

View file

@ -12,29 +12,12 @@
<p>Test for the querySelector / querySelectorAll helpers</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gState;
let gWin;
let tests;
function evaluateJS(input) {
return gState.webConsoleFront.evaluateJSAsync(input);
}
function startTest() {
info ("Content window opened, attaching console to it");
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
ok (!gWin.document.nodePrincipal.equals(systemPrincipal),
"The test document is not using the system principal");
attachConsoleToTab([], state => {
gState = state;
runTests(tests, testEnd);
});
}
tests = [
const tests = [
async function keys() {
const response = await evaluateJS("keys({foo: 'bar'})");
checkObject(response, {
@ -61,6 +44,23 @@ tests = [
},
];
function evaluateJS(input) {
return gState.webConsoleFront.evaluateJSAsync(input);
}
function startTest() {
info ("Content window opened, attaching console to it");
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
ok (!gWin.document.nodePrincipal.equals(systemPrincipal),
"The test document is not using the system principal");
attachConsoleToTab([], state => {
gState = state;
runTests(tests, testEnd);
});
}
function testEnd() {
gWin.close();
gWin = null;

View file

@ -10,8 +10,6 @@
<script>
"use strict";
const TEST_URL = "data:text/html,<html><body>Hello</body></html>";
window.onload = async function () {
SimpleTest.waitForExplicitFinish();
let state;

View file

@ -12,6 +12,8 @@
<p>Test for the Console API and Service Workers</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
// Utils functions

View file

@ -12,6 +12,8 @@
<p>Test for getCachedMessages and Service Workers</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
const BASE_URL = "https://example.com/chrome/devtools/shared/webconsole/test/";
@ -73,7 +75,8 @@ const startTest = async function () {
// they shouldn't show up in a call to getCachedMessages.
// However, there is a fetch event which is logged due to loading the tab.
info("Adding a new tab at the same URL");
const tab2 = await addTab(FRAME_URL);
await addTab(FRAME_URL);
await new Promise(resolve => {
info("Attaching console to tab 2");
attachConsoleToTab(["ConsoleAPI"], function(state) {

View file

@ -12,6 +12,8 @@
<p>Test for console.log styling with %c</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let expectedConsoleCalls = [];

View file

@ -10,8 +10,6 @@
<script>
"use strict";
const TEST_URL = "data:text/html,<html>Test ConsoleAPI timestamp correctness";
window.onload = async function () {
SimpleTest.waitForExplicitFinish();
let state;

View file

@ -12,6 +12,8 @@
<p>Test for the Console API and Workers</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
const expectedCachedConsoleCalls = [
@ -30,9 +32,9 @@ const expectedConsoleAPICalls = [
];
window.onload = async function () {
const {state,response} = await new Promise(resolve => {
attachConsoleToWorker(["ConsoleAPI"], (state, response) => {
resolve({state,response})
const {state} = await new Promise(resolve => {
attachConsoleToWorker(["ConsoleAPI"], (s) => {
resolve({state: s})
});
});

View file

@ -12,6 +12,8 @@
<p>Test for the Console API</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let expectedConsoleCalls = [];
@ -43,8 +45,7 @@ function doConsoleCalls(aState)
(function(global, foreign) {
"use asm";
var fromAsmJS = foreign.fromAsmJS;
function inAsmJS2() { fromAsmJS() }
function inAsmJS2() { foreign.fromAsmJS() }
function inAsmJS1() { inAsmJS2() }
return inAsmJS1
})(null, { fromAsmJS:fromAsmJS })();

View file

@ -12,6 +12,8 @@
<p>Test for the Console API</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let expectedConsoleCalls = [];

View file

@ -12,6 +12,8 @@
<p>Test for file activity tracking</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");

View file

@ -14,6 +14,8 @@
<iframe id="content-iframe" src="http://example.com/chrome/devtools/shared/webconsole/test/sandboxed_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gState;
@ -181,7 +183,7 @@ async function doEvalWithBindingFrame() {
const iframeObjectActor = response.result.actor;
ok(iframeObjectActor, "There is an actor associated with the response");
const selectedObjectGlobal = await evaluateJS("this.temp1 = _self;", {
await evaluateJS("this.temp1 = _self;", {
selectedObjectActor: iframeObjectActor
});
ok(top.temp1 && top.temp1.bar === 1,

View file

@ -12,6 +12,8 @@
<p>Test for JavaScript terminal autocomplete functionality</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
const {
MAX_AUTOCOMPLETE_ATTEMPTS,

View file

@ -14,6 +14,8 @@
<iframe id="content-iframe" src="http://example.com/chrome/devtools/shared/webconsole/test/sandboxed_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gState;

View file

@ -14,6 +14,8 @@
<iframe id="content-iframe" src="http://example.com/chrome/devtools/shared/webconsole/test/sandboxed_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gState;

View file

@ -12,6 +12,8 @@
<p>Test for the querySelector / querySelectorAll helpers</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gState;
let gWin;

View file

@ -14,6 +14,8 @@
<iframe src="http://example.com/chrome/devtools/shared/webconsole/test/network_requests_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()

View file

@ -14,6 +14,8 @@
<iframe src="http://example.com/chrome/devtools/shared/webconsole/test/network_requests_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()

View file

@ -14,6 +14,8 @@
<iframe src="https://example.com/chrome/devtools/shared/webconsole/test/network_requests_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gCurrentTestCase = -1;
@ -51,8 +53,7 @@ function startTest() {
const gSSService = Cc["@mozilla.org/ssservice;1"]
.getService(Ci.nsISiteSecurityService);
const gIOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
const gIOService = Services.io;
for (const {url} of TEST_CASES) {
const uri = gIOService.newURI(url);
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);

View file

@ -14,6 +14,8 @@
<iframe src="https://example.com/chrome/devtools/shared/webconsole/test/network_requests_iframe.html"></iframe>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let gCurrentTestCase = -1;
@ -44,8 +46,7 @@ function startTest()
const gSSService = Cc["@mozilla.org/ssservice;1"]
.getService(Ci.nsISiteSecurityService);
const gIOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
const gIOService = Services.io;
const uri = gIOService.newURI(TEST_CASES[0].url);
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);

View file

@ -12,6 +12,8 @@
<p>Test for the object actor</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",

View file

@ -12,6 +12,8 @@
<p>Test for the native getters in object actors</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let expectedProps = [];

View file

@ -13,6 +13,8 @@
<p>Test for the native getters in object actors</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()

View file

@ -12,6 +12,8 @@
<p>Test for page errors</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
let expectedPageErrors = [];

View file

@ -12,6 +12,8 @@
<p>Web Console throw tests</p>
<script class="testbody" type="text/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
function startTest()
@ -20,15 +22,15 @@ function startTest()
attachConsoleToTab([], onAttach);
}
function onAttach(aState, aResponse)
function onAttach(aState)
{
const tests = [];
const falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
falsyValues.forEach(function(value) {
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
const type = aResponse.exception.type;
const response = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
const type = response.exception.type;
is(type, value, "exception.type for throw " + value);
nextTest();
});
@ -37,8 +39,8 @@ function onAttach(aState, aResponse)
const identityTestValues = [false, 0];
identityTestValues.forEach(function(value) {
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
const exception = aResponse.exception;
const response = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
const exception = response.exception;
is(exception, value, "response.exception for throw " + value);
nextTest();
});
@ -49,11 +51,11 @@ function onAttach(aState, aResponse)
DebuggerServer.LONG_STRING_INITIAL_LENGTH
);
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw '" + longString + "';")
is(aResponse.exception.initial, shortedString,
const response = await aState.webConsoleFront.evaluateJSAsync("throw '" + longString + "';")
is(response.exception.initial, shortedString,
"exception.initial for throw longString"
);
is(aResponse.exceptionMessage.initial, shortedString,
is(response.exceptionMessage.initial, shortedString,
"exceptionMessage.initial for throw longString"
);
nextTest();
@ -66,8 +68,8 @@ function onAttach(aState, aResponse)
];
symbolTestValues.forEach(function([expr, message]) {
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw " + expr + ";");
is(aResponse.exceptionMessage, message,
const response = await aState.webConsoleFront.evaluateJSAsync("throw " + expr + ";");
is(response.exceptionMessage, message,
"response.exception for throw " + expr);
nextTest();
});