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

# ignore-this-changeset

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Marco Vega 2019-12-03 10:11:13 +00:00
parent 82d4bd1aeb
commit 02f9c81edb
29 changed files with 184 additions and 184 deletions

View File

@ -30,16 +30,16 @@ window.onload = function() {
(async function () {
let result = await QR.decodeFromURI(testImage);
is(result, "HELLO", "Decoded data URI result matches");
let canvas = await drawToCanvas(testImage);
const canvas = await drawToCanvas(testImage);
result = QR.decodeFromCanvas(canvas);
is(result, "HELLO", "Decoded canvas result matches");
})().then(SimpleTest.finish, ok.bind(null, false));
function drawToCanvas(src) {
return new Promise(resolve => {
let canvas = document.createElement("canvas");
let context = canvas.getContext("2d");
let image = new Image();
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
const image = new Image();
image.onload = () => {
canvas.width = image.width;

View File

@ -11,7 +11,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1323700
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script type="application/javascript">
let { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
const CssLogic = require("devtools/shared/inspector/css-logic");
var _tests = [];
@ -48,8 +48,8 @@ addTest(function getCssPathForUnattachedElement() {
});
addTest(function cssPathHasOneStepForEachAncestor() {
for (let el of [...document.querySelectorAll('*')]) {
let splitPath = CssLogic.getCssPath(el).split(" ");
for (const el of [...document.querySelectorAll('*')]) {
const splitPath = CssLogic.getCssPath(el).split(" ");
let expectedNbOfParts = 0;
var parent = el.parentNode;
@ -65,7 +65,7 @@ addTest(function cssPathHasOneStepForEachAncestor() {
});
addTest(function getCssPath() {
let data = [{
const data = [{
selector: "#id",
path: "html body div div div.class div#id"
}, {
@ -82,8 +82,8 @@ addTest(function getCssPath() {
path: "html body span#i.c1.c2"
}];
for (let {selector, path} of data) {
let node = document.querySelector(selector);
for (const {selector, path} of data) {
const node = document.querySelector(selector);
is (CssLogic.getCssPath(node), path, `Full css path is correct for ${selector}`);
}

View File

@ -34,22 +34,22 @@ window.onload = function () {
};
addTest(function getXPathForUnattachedElement() {
let unattached = document.createElement("div");
const unattached = document.createElement("div");
unattached.id = "unattached";
is(CssLogic.getXPath(unattached), "", "Unattached node returns empty string");
let unattachedChild = document.createElement("div");
const unattachedChild = document.createElement("div");
unattached.appendChild(unattachedChild);
is(CssLogic.getXPath(unattachedChild), "", "Unattached child returns empty string");
let unattachedBody = document.createElement("body");
const unattachedBody = document.createElement("body");
is(CssLogic.getXPath(unattachedBody), "", "Unattached body returns empty string");
runNextTest();
});
addTest(function getXPath() {
let data = [{
const data = [{
// Target elements that have an ID get a short XPath.
selector: "#i-have-an-id",
path: "//*[@id=\"i-have-an-id\"]"
@ -68,8 +68,8 @@ addTest(function getXPath() {
path: "/html/body/namespace:test/namespace:body"
}];
for (let {selector, path} of data) {
let node = document.querySelector(selector);
for (const {selector, path} of data) {
const node = document.querySelector(selector);
is(CssLogic.getXPath(node), path, `Full css path is correct for ${selector}`);
}

View File

@ -37,7 +37,7 @@ function onStartPageError(aState, aResponse)
function onStartPageErrorAndConsoleAPI(aState, aResponse)
{
let startedListeners = aResponse.startedListeners;
const startedListeners = aResponse.startedListeners;
is(startedListeners.length, 2, "startedListeners.length");
isnot(startedListeners.indexOf("PageError"), -1, "startedListeners: PageError");
isnot(startedListeners.indexOf("ConsoleAPI"), -1,

View File

@ -40,7 +40,7 @@ function onEvaluate(aState, aResponse)
ok(!aResponse.helperResult, "no helper result");
onInspect = onInspect.bind(null, aState);
let client = new ObjectFront(aState.dbgClient, aResponse.result);
const client = new ObjectFront(aState.dbgClient, aResponse.result);
client.getPrototypeAndProperties().then(onInspect);
}
@ -48,9 +48,9 @@ function onInspect(aState, aResponse)
{
ok(!aResponse.error, "no response error");
let expectedProps = Object.getOwnPropertyNames(document.__proto__);
const expectedProps = Object.getOwnPropertyNames(document.__proto__);
let props = aResponse.ownProperties;
const props = aResponse.ownProperties;
ok(props, "response properties available");
if (props) {

View File

@ -106,9 +106,9 @@ let consoleAPIListener, consoleServiceListener;
let consoleAPICalls = 0;
let pageErrors = 0;
let handlers = {
const handlers = {
onConsoleAPICall: function onConsoleAPICall(message) {
for (let msg of expectedConsoleCalls) {
for (const msg of expectedConsoleCalls) {
if (msg.functionName == message.functionName &&
msg.filename.test(message.filename)) {
consoleAPICalls++;
@ -124,7 +124,7 @@ let handlers = {
if (!(message instanceof Ci.nsIScriptError)) {
return;
}
for (let msg of expectedPageErrors) {
for (const msg of expectedPageErrors) {
if (msg.category == message.category &&
msg.errorMessage.test(message.errorMessage)) {
pageErrors++;
@ -158,14 +158,14 @@ function onAttach1(state, response) {
}
function onCachedConsoleAPI(state, response) {
let msgs = response.messages;
const msgs = response.messages;
info("cached console messages: " + msgs.length);
ok(msgs.length >= expectedConsoleCalls.length,
"number of cached console messages");
for (let msg of msgs) {
for (let expected of expectedConsoleCalls) {
for (const msg of msgs) {
for (const expected of expectedConsoleCalls) {
if (expected.functionName == msg.functionName &&
expected.filename.test(msg.filename)) {
expectedConsoleCalls.splice(expectedConsoleCalls.indexOf(expected));
@ -196,14 +196,14 @@ function onAttach2(state, response) {
}
function onCachedPageErrors(state, response) {
let msgs = response.messages;
const msgs = response.messages;
info("cached page errors: " + msgs.length);
ok(msgs.length >= expectedPageErrors.length,
"number of cached page errors");
for (let msg of msgs) {
for (let expected of expectedPageErrors) {
for (const msg of msgs) {
for (const expected of expectedPageErrors) {
if (expected.category == msg.category &&
expected.errorMessage.test(msg.errorMessage)) {
expectedPageErrors.splice(expectedPageErrors.indexOf(expected));

View File

@ -24,7 +24,7 @@ function evaluateJS(input) {
function startTest() {
info ("Content window opened, attaching console to it");
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
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");
@ -36,7 +36,7 @@ function startTest() {
tests = [
async function keys() {
let response = await evaluateJS("keys({foo: 'bar'})");
const response = await evaluateJS("keys({foo: 'bar'})");
checkObject(response, {
result: {
class: "Array",
@ -48,7 +48,7 @@ tests = [
nextTest();
},
async function values() {
let response = await evaluateJS("values({foo: 'bar'})");
const response = await evaluateJS("values({foo: 'bar'})");
checkObject(response, {
result: {
class: "Array",
@ -70,7 +70,7 @@ function testEnd() {
});
}
let load = async function () {
const load = async function () {
removeEventListener("load", load);
await new Promise(resolve => {

View File

@ -39,7 +39,7 @@ window.onload = async function () {
async function testSingleCustomStyleGroup(consoleFront) {
info("Testing console.group with a custom style");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.group("%cfoobar", "color:red")
);
@ -52,7 +52,7 @@ async function testSingleCustomStyleGroup(consoleFront) {
async function testSingleCustomStyleGroupCollapsed(consoleFront) {
info("Testing console.groupCollapsed with a custom style");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.groupCollapsed("%cfoobaz", "color:blue")
);
@ -65,7 +65,7 @@ async function testSingleCustomStyleGroupCollapsed(consoleFront) {
async function testMultipleCustomStyleGroup(consoleFront) {
info("Testing console.group with multiple custom styles");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.group("%cfoo%cbar", "color:red", "color:blue")
);
@ -78,7 +78,7 @@ async function testMultipleCustomStyleGroup(consoleFront) {
async function testMultipleCustomStyleGroupCollapsed(consoleFront) {
info("Testing console.groupCollapsed with multiple custom styles");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.group("%cfoo%cbaz", "color:red", "color:green")
);
@ -91,7 +91,7 @@ async function testMultipleCustomStyleGroupCollapsed(consoleFront) {
async function testFormatterWithNoStyleGroup(consoleFront) {
info("Testing console.group with one formatter but no style");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.group("%cfoobar")
);
@ -104,7 +104,7 @@ async function testFormatterWithNoStyleGroup(consoleFront) {
async function testFormatterWithNoStyleGroupCollapsed(consoleFront) {
info("Testing console.groupCollapsed with one formatter but no style");
let packet = await consoleAPICall(
const packet = await consoleAPICall(
consoleFront,
() => top.console.groupCollapsed("%cfoobaz")
);

View File

@ -17,7 +17,7 @@ SimpleTest.waitForExplicitFinish();
// Utils functions
function withFrame(url) {
return new Promise(resolve => {
let iframe = document.createElement("iframe");
const iframe = document.createElement("iframe");
iframe.onload = function () {
resolve(iframe);
};
@ -50,7 +50,7 @@ function messageServiceWorker(win, scope, message) {
win.navigator.serviceWorker.onmessage = evt => {
resolve();
};
let sw = swr.active || swr.waiting || swr.installing;
const sw = swr.active || swr.waiting || swr.installing;
sw.postMessage({ type: "PING", message: message });
});
});
@ -63,15 +63,15 @@ function unregisterServiceWorker(win) {
}
// Test
let BASE_URL = "https://example.com/chrome/devtools/shared/webconsole/test/";
let SERVICE_WORKER_URL = BASE_URL + "helper_serviceworker.js";
let SCOPE = BASE_URL + "foo/";
let NONSCOPE_FRAME_URL = BASE_URL + "sandboxed_iframe.html";
let SCOPE_FRAME_URL = SCOPE + "fake.html";
let SCOPE_FRAME_URL2 = SCOPE + "whatsit.html";
let MESSAGE = 'Tic Tock';
const BASE_URL = "https://example.com/chrome/devtools/shared/webconsole/test/";
const SERVICE_WORKER_URL = BASE_URL + "helper_serviceworker.js";
const SCOPE = BASE_URL + "foo/";
const NONSCOPE_FRAME_URL = BASE_URL + "sandboxed_iframe.html";
const SCOPE_FRAME_URL = SCOPE + "fake.html";
const SCOPE_FRAME_URL2 = SCOPE + "whatsit.html";
const MESSAGE = 'Tic Tock';
let expectedConsoleCalls = [
const expectedConsoleCalls = [
{
level: "log",
filename: /helper_serviceworker/,
@ -100,7 +100,7 @@ let expectedConsoleCalls = [
];
let consoleCalls = [];
let startTest = async function () {
const startTest = async function () {
removeEventListener("load", startTest);
await new Promise(resolve => {
@ -114,7 +114,7 @@ let startTest = async function () {
};
addEventListener("load", startTest);
let onAttach = async function (state, response) {
const onAttach = async function (state, response) {
onConsoleAPICall = onConsoleAPICall.bind(null, state);
state.webConsoleFront.on("consoleAPICall", onConsoleAPICall);

View File

@ -14,11 +14,11 @@
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
let BASE_URL = "https://example.com/chrome/devtools/shared/webconsole/test/";
let SERVICE_WORKER_URL = BASE_URL + "helper_serviceworker.js";
let FRAME_URL = BASE_URL + "sandboxed_iframe.html";
const BASE_URL = "https://example.com/chrome/devtools/shared/webconsole/test/";
const SERVICE_WORKER_URL = BASE_URL + "helper_serviceworker.js";
const FRAME_URL = BASE_URL + "sandboxed_iframe.html";
let firstTabExpectedCalls = [
const firstTabExpectedCalls = [
{
level: "log",
filename: /helper_serviceworker/,
@ -36,7 +36,7 @@ let firstTabExpectedCalls = [
},
];
let secondTabExpectedCalls = [
const secondTabExpectedCalls = [
{
level: "log",
filename: /helper_serviceworker/,
@ -44,7 +44,7 @@ let secondTabExpectedCalls = [
}
];
let startTest = async function () {
const startTest = async function () {
removeEventListener("load", startTest);
await new Promise(resolve => {
@ -55,8 +55,8 @@ let startTest = async function () {
});
info("Adding a tab and attaching a service worker");
let tab1 = await addTab(FRAME_URL);
let swr = await withActiveServiceWorker(tab1.linkedBrowser.contentWindow,
const tab1 = await addTab(FRAME_URL);
const swr = await withActiveServiceWorker(tab1.linkedBrowser.contentWindow,
SERVICE_WORKER_URL);
await new Promise(resolve => {
@ -73,7 +73,7 @@ let 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");
let tab2 = await addTab(FRAME_URL);
const tab2 = await addTab(FRAME_URL);
await new Promise(resolve => {
info("Attaching console to tab 2");
attachConsoleToTab(["ConsoleAPI"], function(state) {
@ -92,7 +92,7 @@ addEventListener("load", startTest);
// This test needs to add tabs that are controlled by a service worker
// so use some special powers to dig around and find gBrowser
let {gBrowser} = SpecialPowers._getTopChromeWindow(SpecialPowers.window);
const {gBrowser} = SpecialPowers._getTopChromeWindow(SpecialPowers.window);
SimpleTest.registerCleanupFunction(() => {
while (gBrowser.tabs.length > 1) {
@ -103,7 +103,7 @@ SimpleTest.registerCleanupFunction(() => {
function addTab(url) {
info("Adding a new tab with URL: '" + url + "'");
return new Promise(resolve => {
let tab = gBrowser.selectedTab = gBrowser.addTab(url, {
const tab = gBrowser.selectedTab = gBrowser.addTab(url, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
gBrowser.selectedBrowser.addEventListener("load", function () {

View File

@ -14,7 +14,7 @@
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
let expectedCachedConsoleCalls = [
const expectedCachedConsoleCalls = [
{
level: "log",
filename: /console-test-worker/,
@ -22,7 +22,7 @@ let expectedCachedConsoleCalls = [
},
];
let expectedConsoleAPICalls = [
const expectedConsoleAPICalls = [
{
level: "log",
arguments: ['Log was requested from worker'],
@ -30,7 +30,7 @@ let expectedConsoleAPICalls = [
];
window.onload = async function () {
let {state,response} = await new Promise(resolve => {
const {state,response} = await new Promise(resolve => {
attachConsoleToWorker(["ConsoleAPI"], (state, response) => {
resolve({state,response})
});
@ -44,11 +44,11 @@ window.onload = async function () {
});
};
let testCachedMessages = async function (state) {
const testCachedMessages = async function (state) {
info("testCachedMessages entered");
return new Promise(resolve => {
let onCachedConsoleAPI = (response) => {
let consoleCalls = response.messages;
const onCachedConsoleAPI = (response) => {
const consoleCalls = response.messages;
info('Received cached response. Checking console calls.');
checkConsoleAPICalls(consoleCalls, expectedCachedConsoleCalls);
@ -58,10 +58,10 @@ let testCachedMessages = async function (state) {
})
};
let testConsoleAPI = async function (state) {
const testConsoleAPI = async function (state) {
info("testConsoleAPI entered");
return new Promise(resolve => {
let onConsoleAPICall = (packet) => {
const onConsoleAPICall = (packet) => {
info("received message level: " + packet.message.level);
checkConsoleAPICalls([packet.message], expectedConsoleAPICalls);
state.webConsoleFront.off("consoleAPICall", onConsoleAPICall);

View File

@ -18,7 +18,7 @@ let expectedConsoleCalls = [];
function doConsoleCalls(aState)
{
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a");
const longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a");
top.console.log("foobarBaz-log", undefined);
@ -33,8 +33,8 @@ function doConsoleCalls(aState)
top.console.dir(top.document, top.location);
top.console.log("foo", longString);
let sandbox = new Cu.Sandbox(null, { invisibleToDebugger: true });
let sandboxObj = sandbox.eval("new Object");
const sandbox = new Cu.Sandbox(null, { invisibleToDebugger: true });
const sandboxObj = sandbox.eval("new Object");
top.console.log(sandboxObj);
function fromAsmJS() {

View File

@ -18,12 +18,12 @@ let expectedConsoleCalls = [];
function doConsoleCalls(aState)
{
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let console = new ConsoleAPI({
const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
const console = new ConsoleAPI({
innerID: window.windowUtils.currentInnerWindowID
});
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a");
const longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 2)).join("a");
console.log("foobarBaz-log", undefined);
console.info("foobarBaz-info", null);

View File

@ -23,18 +23,18 @@ let gTmpFile;
function doFileActivity()
{
info("doFileActivity");
let fileContent = "<p>hello world from bug 798764";
const fileContent = "<p>hello world from bug 798764";
gTmpFile = FileUtils.getFile("TmpD", ["bug798764.html"]);
gTmpFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
let fout = FileUtils.openSafeFileOutputStream(gTmpFile,
const fout = FileUtils.openSafeFileOutputStream(gTmpFile,
FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE);
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
const converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";
let fileContentStream = converter.convertToInputStream(fileContent);
const fileContentStream = converter.convertToInputStream(fileContent);
NetUtil.asyncCopy(fileContentStream, fout, addIframe);
}
@ -44,7 +44,7 @@ function addIframe(aStatus)
ok(Components.isSuccessCode(aStatus),
"the temporary file was saved successfully");
let iframe = document.createElement("iframe");
const iframe = document.createElement("iframe");
iframe.src = NetUtil.newURI(gTmpFile).spec;
document.body.appendChild(iframe);
}

View File

@ -18,12 +18,12 @@ SimpleTest.waitForExplicitFinish();
let gState;
let {MAX_AUTOCOMPLETE_ATTEMPTS,MAX_AUTOCOMPLETIONS} = require("devtools/shared/webconsole/js-property-provider");
const {MAX_AUTOCOMPLETE_ATTEMPTS,MAX_AUTOCOMPLETIONS} = require("devtools/shared/webconsole/js-property-provider");
function evaluateJS(input, options = {}) {
return gState.webConsoleFront.evaluateJSAsync(input, options);
}
}
function startTest()
{
@ -56,7 +56,7 @@ function onAttach(aState, aResponse)
gState = aState;
let tests = [doSimpleEval, doWindowEval, doEvalWithException,
const tests = [doSimpleEval, doWindowEval, doEvalWithException,
doEvalWithHelper, doEvalString, doEvalLongString,
doEvalWithBinding, doEvalWithBindingFrame,
forceLexicalInit];
@ -66,7 +66,7 @@ function onAttach(aState, aResponse)
async function doSimpleEval() {
info("test eval '2+2'");
let response = await evaluateJS("2+2");
const response = await evaluateJS("2+2");
checkObject(response, {
input: "2+2",
result: 4,
@ -80,7 +80,7 @@ async function doSimpleEval() {
async function doWindowEval() {
info("test eval 'document'");
let response = await evaluateJS("document");
const response = await evaluateJS("document");
checkObject(response, {
input: "document",
result: {
@ -98,7 +98,7 @@ async function doWindowEval() {
async function doEvalWithException() {
info("test eval with exception");
let response = await evaluateJS("window.doTheImpossible()");
const response = await evaluateJS("window.doTheImpossible()");
checkObject(response, {
input: "window.doTheImpossible()",
result: {
@ -115,7 +115,7 @@ async function doEvalWithException() {
async function doEvalWithHelper() {
info("test eval with helper");
let response = await evaluateJS("clear()");
const response = await evaluateJS("clear()");
checkObject(response, {
input: "clear()",
result: {
@ -130,7 +130,7 @@ async function doEvalWithHelper() {
}
async function doEvalString() {
let response = await evaluateJS("window.foobarObject.strfoo");
const response = await evaluateJS("window.foobarObject.strfoo");
checkObject(response, {
input: "window.foobarObject.strfoo",
result: "foobarz",
@ -140,9 +140,9 @@ async function doEvalString() {
}
async function doEvalLongString() {
let response = await evaluateJS("window.foobarObject.omgstr");
let str = top.foobarObject.omgstr;
let initial = str.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
const response = await evaluateJS("window.foobarObject.omgstr");
const str = top.foobarObject.omgstr;
const initial = str.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
checkObject(response, {
input: "window.foobarObject.omgstr",
@ -157,11 +157,11 @@ async function doEvalLongString() {
}
async function doEvalWithBinding() {
let response = await evaluateJS("document;");
let documentActor = response.result.actor;
const response = await evaluateJS("document;");
const documentActor = response.result.actor;
info("running a command with _self as document using selectedObjectActor");
let selectedObjectSame = await evaluateJS("_self === document", {
const selectedObjectSame = await evaluateJS("_self === document", {
selectedObjectActor: documentActor
});
checkObject(selectedObjectSame, {
@ -172,16 +172,16 @@ async function doEvalWithBinding() {
}
async function doEvalWithBindingFrame() {
let frameWin = top.document.querySelector("iframe").contentWindow;
const frameWin = top.document.querySelector("iframe").contentWindow;
frameWin.fooFrame = { bar: 1 };
let response = await evaluateJS(
const response = await evaluateJS(
"document.querySelector('iframe').contentWindow.fooFrame"
);
let iframeObjectActor = response.result.actor;
const iframeObjectActor = response.result.actor;
ok(iframeObjectActor, "There is an actor associated with the response");
let selectedObjectGlobal = await evaluateJS("this.temp1 = _self;", {
const selectedObjectGlobal = await evaluateJS("this.temp1 = _self;", {
selectedObjectActor: iframeObjectActor
});
ok(top.temp1 && top.temp1.bar === 1,
@ -234,15 +234,15 @@ async function forceLexicalInit() {
}
];
for (let data of testData) {
let response = await evaluateJS(data.stmt);
for (const data of testData) {
const response = await evaluateJS(data.stmt);
checkObject(response, {
input: data.stmt,
result: undefined,
});
ok(response.exception, "expected exception");
for (let varName of data.vars) {
let response2 = await evaluateJS(varName);
for (const varName of data.vars) {
const response2 = await evaluateJS(varName);
checkObject(response2, {
input: varName,
result: undefined,

View File

@ -138,8 +138,8 @@
async function doAutocomplete1(webConsoleFront) {
info("test autocomplete for 'window.foo'");
let response = await webConsoleFront.autocomplete("window.foo");
let matches = response.matches;
const response = await webConsoleFront.autocomplete("window.foo");
const matches = response.matches;
is(response.matchProp, "foo", "matchProp");
is(matches.length, 1, "matches.length");
@ -148,8 +148,8 @@
async function doAutocomplete2(webConsoleFront) {
info("test autocomplete for 'window.foobarObject.'");
let response = await webConsoleFront.autocomplete("window.foobarObject.");
let matches = response.matches;
const response = await webConsoleFront.autocomplete("window.foobarObject.");
const matches = response.matches;
ok(!response.matchProp, "matchProp");
is(matches.length, 7, "matches.length");
@ -160,8 +160,8 @@
async function doAutocomplete3(webConsoleFront) {
// Check that completion suggestions are offered inside the string.
info("test autocomplete for 'dump(window.foobarObject.)'");
let response = await webConsoleFront.autocomplete("dump(window.foobarObject.)", 25);
let matches = response.matches;
const response = await webConsoleFront.autocomplete("dump(window.foobarObject.)", 25);
const matches = response.matches;
ok(!response.matchProp, "matchProp");
is(matches.length, 7, "matches.length");
@ -172,7 +172,7 @@
async function doAutocomplete4(webConsoleFront) {
// Check that completion requests can have no suggestions.
info("test autocomplete for 'dump(window.foobarObject.)'");
let response = await webConsoleFront.autocomplete("dump(window.foobarObject.)");
const response = await webConsoleFront.autocomplete("dump(window.foobarObject.)");
ok(!response.matchProp, "matchProp");
is(response.matches, null, "matches is null");
}
@ -181,7 +181,7 @@
// Check that completion requests with too large objects will
// have no suggestions.
info("test autocomplete for 'window.largeObject1.'");
let response = await webConsoleFront.autocomplete("window.largeObject1.");
const response = await webConsoleFront.autocomplete("window.largeObject1.");
ok(!response.matchProp, "matchProp");
info (response.matches.join("|"));
is(response.matches.length, 0, "Bailed out with too many properties");
@ -191,7 +191,7 @@
// Check that completion requests with pretty large objects will
// have MAX_AUTOCOMPLETIONS suggestions
info("test autocomplete for 'window.largeObject2.'");
let response = await webConsoleFront.autocomplete("window.largeObject2.");
const response = await webConsoleFront.autocomplete("window.largeObject2.");
ok(!response.matchProp, "matchProp");
is(response.matches.length, MAX_AUTOCOMPLETIONS, "matches.length is MAX_AUTOCOMPLETIONS");
}
@ -199,7 +199,7 @@
async function doAutocompleteProxyThrowsPrototype(webConsoleFront) {
// Check that completion provides own properties even if [[GetPrototypeOf]] throws.
info("test autocomplete for 'window.proxy1.'");
let response = await webConsoleFront.autocomplete("window.proxy1.");
const response = await webConsoleFront.autocomplete("window.proxy1.");
ok(!response.matchProp, "matchProp");
is(response.matches.length, 1, "matches.length");
checkObject(response.matches, ["foo"]);
@ -208,7 +208,7 @@
async function doAutocompleteProxyThrowsOwnKeys(webConsoleFront) {
// Check that completion provides inherited properties even if [[OwnPropertyKeys]] throws.
info("test autocomplete for 'window.proxy2.'");
let response = await webConsoleFront.autocomplete("window.proxy2.");
const response = await webConsoleFront.autocomplete("window.proxy2.");
ok(!response.matchProp, "matchProp");
is(response.matches.length, 1, "matches.length");
checkObject(response.matches, ["foo"]);
@ -217,9 +217,9 @@
async function doAutocompleteSandbox(webConsoleFront) {
// Check that completion provides inherited properties even if [[OwnPropertyKeys]] throws.
info("test autocomplete for 'Cu.Sandbox.'");
let response = await webConsoleFront.autocomplete("Cu.Sandbox.");
const response = await webConsoleFront.autocomplete("Cu.Sandbox.");
ok(!response.matchProp, "matchProp");
let keys = Object.getOwnPropertyNames(Object.prototype).sort();
const keys = Object.getOwnPropertyNames(Object.prototype).sort();
is(response.matches.length, keys.length, "matches.length");
// checkObject(response.matches, keys);
is(response.matches.join(" - "), keys.join(" - "));
@ -227,7 +227,7 @@
async function doAutocompleteArray(webConsoleFront) {
info("test autocomplete for [1,2,3]");
let response = await webConsoleFront.autocomplete("[1,2,3].");
const response = await webConsoleFront.autocomplete("[1,2,3].");
let {matches} = response;
ok(matches.length > 0, "There are completion results for the array");
@ -268,7 +268,7 @@
async function doAutocompleteString(webConsoleFront) {
info(`test autocomplete for "foo".`);
let response = await webConsoleFront.autocomplete(`"foo".`);
const response = await webConsoleFront.autocomplete(`"foo".`);
let {matches} = response;
ok(matches.length > 0, "There are completion results for the string");
@ -513,7 +513,7 @@
for (const input of inputs) {
info(`test autocomplete for "${input}"`);
let matches = (await webConsoleFront.autocomplete(input)).matches;
const matches = (await webConsoleFront.autocomplete(input)).matches;
ok(matches.includes("foobarObject"), `Expected autocomplete result for ${input}"`);
}
}
@ -609,7 +609,7 @@ async function doKeywordsAutocomplete(webConsoleFront) {
];
for (const input of inputs) {
info(`test autocomplete for "${input}"`);
let matches = (await webConsoleFront.autocomplete(input)).matches;
const matches = (await webConsoleFront.autocomplete(input)).matches;
is(matches, null, `No autocomplete result for ${input}"`);
}
}

View File

@ -35,7 +35,7 @@ function onAttach(aState, aResponse)
gState = aState;
let tests = [doCheckParent, doCdIframe, doCheckIframe,
const tests = [doCheckParent, doCdIframe, doCheckIframe,
doCdContentIframe,
doCdSandboxedIframe, doCheckSandboxedIframe,
doCdParent,
@ -125,7 +125,7 @@ function doCdSandboxedIframe()
{
// Don't use string to ensure we don't get security exception
// when passing a content window reference.
let cmd = "cd(document.getElementById('sandboxed-iframe').contentWindow)";
const cmd = "cd(document.getElementById('sandboxed-iframe').contentWindow)";
info("test " + cmd);
gState.webConsoleFront.evaluateJSAsync(cmd).then(onCdSandboxedIframe.bind(null, cmd));
}

View File

@ -26,19 +26,19 @@ function startTest()
removeEventListener("load", startTest);
attachConsoleToTab([], state => {
gState = state;
let tests = [checkUndefinedResult,checkAdditionResult,checkObjectResult];
const tests = [checkUndefinedResult,checkAdditionResult,checkObjectResult];
runTests(tests, testEnd);
});
}
let checkUndefinedResult = async function () {
const checkUndefinedResult = async function () {
info ("$_ returns undefined if nothing has evaluated yet");
let response = await evaluateJS("$_");
const response = await evaluateJS("$_");
basicResultCheck(response, "$_", undefined);
nextTest();
};
let checkAdditionResult = async function () {
const checkAdditionResult = async function () {
info ("$_ returns last value and performs basic arithmetic");
let response = await evaluateJS("2+2");
basicResultCheck(response, "2+2", 4);
@ -55,7 +55,7 @@ let checkAdditionResult = async function () {
nextTest();
};
let checkObjectResult = async function () {
const checkObjectResult = async function () {
info ("$_ has correct references to objects");
let response = await evaluateJS("var foo = {bar:1}; foo;");

View File

@ -23,13 +23,13 @@ function evaluateJS(input) {
function startTest() {
info ("Content window opened, attaching console to it");
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
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;
let tests = [
const tests = [
setupWindow,
checkQuerySelector,
checkQuerySelectorAll,
@ -41,16 +41,16 @@ function startTest() {
});
}
let setupWindow = async function () {
const setupWindow = async function () {
info ("Shimming window functions for the content privileged tab");
await evaluateJS("document.querySelector = function() { throw 'should not call qS'; }");
await evaluateJS("document.querySelectorAll = function() { throw 'should not call qSA'; }");
nextTest();
};
let checkQuerySelector = async function () {
const checkQuerySelector = async function () {
info ("$ returns an DOMNode");
let response = await evaluateJS("$('body')");
const response = await evaluateJS("$('body')");
basicResultCheck(response, "$('body')", {
type: "object",
class: "HTMLBodyElement",
@ -62,9 +62,9 @@ let checkQuerySelector = async function () {
nextTest();
};
let checkQuerySelectorAll = async function () {
const checkQuerySelectorAll = async function () {
info ("$$ returns an array");
let response = await evaluateJS("$$('body')");
const response = await evaluateJS("$$('body')");
basicResultCheck(response, "$$('body')", {
type: "object",
class: "Array",
@ -75,9 +75,9 @@ let checkQuerySelectorAll = async function () {
nextTest();
};
let checkQuerySelectorAllNotExist = async function () {
const checkQuerySelectorAllNotExist = async function () {
info ("$$ returns an array even if query yields no results");
let response = await evaluateJS("$$('foobar')");
const response = await evaluateJS("$$('foobar')");
basicResultCheck(response, "$$('foobar')", {
type: "object",
class: "Array",
@ -88,9 +88,9 @@ let checkQuerySelectorAllNotExist = async function () {
nextTest();
};
let checkQuerySelectorException = async function () {
const checkQuerySelectorException = async function () {
info ("$ returns an exception if an invalid selector was provided");
let response = await evaluateJS("$(':foo')");
const response = await evaluateJS("$(':foo')");
checkObject(response, {
input: "$(':foo')",
exceptionMessage: "SyntaxError: ':foo' is not a valid selector",
@ -107,9 +107,9 @@ let checkQuerySelectorException = async function () {
nextTest();
};
let checkQuerySelectorAllException = async function () {
const checkQuerySelectorAllException = async function () {
info ("$$ returns an exception if an invalid selector was provided");
let response = await evaluateJS("$$(':foo')");
const response = await evaluateJS("$$(':foo')");
checkObject(response, {
input: "$$(':foo')",
exceptionMessage: "SyntaxError: ':foo' is not a valid selector",
@ -144,7 +144,7 @@ function testEnd() {
});
}
let load = async function () {
const load = async function () {
removeEventListener("load", load);
await new Promise(resolve => {

View File

@ -31,7 +31,7 @@ function onAttach(aState, aResponse)
onNetworkEventUpdate = onNetworkEventUpdate.bind(null, aState);
aState.dbgClient.on("networkEventUpdate", onNetworkEventUpdate);
let iframe = document.querySelector("iframe").contentWindow;
const iframe = document.querySelector("iframe").contentWindow;
iframe.wrappedJSObject.testXhrGet();
}
@ -39,7 +39,7 @@ function onNetworkEvent(aState, aPacket)
{
info("checking the network event packet");
let netActor = aPacket.eventActor;
const netActor = aPacket.eventActor;
checkObject(netActor, {
actor: /[a-z]/,
@ -53,7 +53,7 @@ function onNetworkEvent(aState, aPacket)
aState.webConsoleFront.off("serverNetworkEvent", onNetworkEvent);
}
let updates = [];
const updates = [];
function onNetworkEventUpdate(aState, aPacket)
{

View File

@ -32,7 +32,7 @@ function onAttach(aState, aResponse)
onNetworkEventUpdate = onNetworkEventUpdate.bind(null, aState);
aState.dbgClient.on("networkEventUpdate", onNetworkEventUpdate);
let iframe = document.querySelector("iframe").contentWindow;
const iframe = document.querySelector("iframe").contentWindow;
iframe.wrappedJSObject.testXhrPost();
}
@ -40,7 +40,7 @@ function onNetworkEvent(aState, aPacket)
{
info("checking the network event packet");
let netActor = aPacket.eventActor;
const netActor = aPacket.eventActor;
checkObject(netActor, {
actor: /[a-z]/,
@ -54,7 +54,7 @@ function onNetworkEvent(aState, aPacket)
aState.webConsoleFront.off("serverNetworkEvent", onNetworkEvent);
}
let updates = [];
const updates = [];
function onNetworkEventUpdate(aState, aPacket)
{

View File

@ -48,13 +48,13 @@ function startTest() {
Services.prefs.setBoolPref(PROCESS_HPKP_FROM_NON_BUILTIN_ROOTS_PREF, false);
// Reset pinning state.
let gSSService = Cc["@mozilla.org/ssservice;1"]
const gSSService = Cc["@mozilla.org/ssservice;1"]
.getService(Ci.nsISiteSecurityService);
let gIOService = Cc["@mozilla.org/network/io-service;1"]
const gIOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
for (let {url} of TEST_CASES) {
let uri = gIOService.newURI(url);
for (const {url} of TEST_CASES) {
const uri = gIOService.newURI(url);
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
}
});
@ -79,16 +79,16 @@ function runNextCase(state) {
return;
}
let { desc, url } = TEST_CASES[gCurrentTestCase];
const { desc, url } = TEST_CASES[gCurrentTestCase];
info("Testing site with " + desc);
let iframe = document.querySelector("iframe").contentWindow;
const iframe = document.querySelector("iframe").contentWindow;
iframe.wrappedJSObject.makeXhrCallback("GET", url);
}
function onNetworkEventUpdate(state, packet) {
function onSecurityInfo(received) {
let data = TEST_CASES[gCurrentTestCase];
const data = TEST_CASES[gCurrentTestCase];
is(received.securityInfo.hpkp, data.usesPinning,
"Public Key Pinning detected correctly.");

View File

@ -41,13 +41,13 @@ function startTest()
SimpleTest.registerCleanupFunction(() => {
// Reset HSTS state.
let gSSService = Cc["@mozilla.org/ssservice;1"]
const gSSService = Cc["@mozilla.org/ssservice;1"]
.getService(Ci.nsISiteSecurityService);
let gIOService = Cc["@mozilla.org/network/io-service;1"]
const gIOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let uri = gIOService.newURI(TEST_CASES[0].url);
const uri = gIOService.newURI(TEST_CASES[0].url);
gSSService.resetState(Ci.nsISiteSecurityService.HEADER_HSTS, uri, 0);
});
@ -72,17 +72,17 @@ function runNextCase(aState) {
return;
}
let { desc, url } = TEST_CASES[gCurrentTestCase];
const { desc, url } = TEST_CASES[gCurrentTestCase];
info("Testing site with " + desc);
let iframe = document.querySelector("iframe").contentWindow;
const iframe = document.querySelector("iframe").contentWindow;
iframe.wrappedJSObject.makeXhrCallback("GET", url);
}
function onNetworkEventUpdate(aState, aPacket)
{
function onSecurityInfo(packet) {
let data = TEST_CASES[gCurrentTestCase];
const data = TEST_CASES[gCurrentTestCase];
is(packet.securityInfo.hsts, data.usesHSTS,
"Strict Transport Security detected correctly.");

View File

@ -38,14 +38,14 @@ function onAttach(aState, aResponse)
info("waiting for messages");
}
let receivedMessages = [];
const receivedMessages = [];
function onLogMessage(aState, aPacket)
{
info("received message: " + aPacket.message);
let found = false;
for (let expected of expectedMessages) {
for (const expected of expectedMessages) {
if (expected.message == aPacket.message) {
found = true;
break;

View File

@ -29,12 +29,12 @@ function onAttach(state, response) {
onConsoleCall = onConsoleCall.bind(null, state);
state.webConsoleFront.on("consoleAPICall", onConsoleCall);
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 3)).join("\u0629");
const longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 3)).join("\u0629");
// Here we put the objects in the correct window, to avoid having them all
// wrapped by proxies for cross-compartment access.
let foobarObject = top.Object.create(null);
const foobarObject = top.Object.create(null);
foobarObject.tamarbuta = longString;
foobarObject.foo = 1;
foobarObject.foobar = "hello";
@ -149,15 +149,15 @@ function onConsoleCall(state, aPacket) {
state.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
let args = aPacket.message.arguments;
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, state);
let client = new ObjectFront(state.dbgClient, args[1]);
const client = new ObjectFront(state.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
function onProperties(state, response) {
let props = response.ownProperties;
const props = response.ownProperties;
is(Object.keys(props).length, Object.keys(expectedProps).length,
"number of enumerable properties");
checkObject(props, expectedProps);

View File

@ -70,17 +70,17 @@ function onConsoleCall(aState, aPacket)
aState.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
let args = aPacket.message.arguments;
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, aState);
let client = new ObjectFront(aState.dbgClient, args[1]);
const client = new ObjectFront(aState.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
function onProperties(aState, aResponse)
{
let props = aResponse.ownProperties;
let keys = Object.keys(props);
const props = aResponse.ownProperties;
const keys = Object.keys(props);
info(keys.length + " ownProperties: " + keys);
ok(keys.length >= Object.keys(expectedProps).length, "number of properties");

View File

@ -27,7 +27,7 @@ function onAttach(aState, aResponse)
onConsoleCall = onConsoleCall.bind(null, aState);
aState.webConsoleFront.on("consoleAPICall", onConsoleCall);
let docAsProto = Object.create(document);
const docAsProto = Object.create(document);
top.console.log("hello", docAsProto);
}
@ -49,16 +49,16 @@ function onConsoleCall(aState, aPacket)
aState.webConsoleFront.off("consoleAPICall", onConsoleCall);
info("inspecting object properties");
let args = aPacket.message.arguments;
const args = aPacket.message.arguments;
onProperties = onProperties.bind(null, aState);
let client = new ObjectFront(aState.dbgClient, args[1]);
const client = new ObjectFront(aState.dbgClient, args[1]);
client.getPrototypeAndProperties().then(onProperties);
}
function onProperties(aState, aResponse)
{
let props = aResponse.ownProperties;
const props = aResponse.ownProperties;
let keys = Object.keys(props);
info(keys.length + " ownProperties: " + keys);

View File

@ -132,7 +132,7 @@ function doPageErrors() {
};
let container = document.createElement("script");
for (let stmt of Object.keys(expectedPageErrors)) {
for (const stmt of Object.keys(expectedPageErrors)) {
if (expectedPageErrors[stmt].exception) {
SimpleTest.expectUncaughtException();
}
@ -157,7 +157,7 @@ function onAttach(state, response) {
doPageErrors();
}
let pageErrors = [];
const pageErrors = [];
function onPageError(state, packet) {
if (!packet.pageError.sourceName.includes("test_page_errors")) {

View File

@ -22,29 +22,29 @@ function startTest()
function onAttach(aState, aResponse)
{
let tests = [];
const tests = [];
let falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
const falsyValues = ["-0", "null", "undefined", "Infinity", "-Infinity", "NaN"];
falsyValues.forEach(function(value) {
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
let type = aResponse.exception.type;
const type = aResponse.exception.type;
is(type, value, "exception.type for throw " + value);
nextTest();
});
});
let identityTestValues = [false, 0];
const identityTestValues = [false, 0];
identityTestValues.forEach(function(value) {
tests.push(async function() {
const aResponse = await aState.webConsoleFront.evaluateJSAsync("throw " + value + ";")
let exception = aResponse.exception;
const exception = aResponse.exception;
is(exception, value, "response.exception for throw " + value);
nextTest();
});
});
let longString = Array(DebuggerServer.LONG_STRING_LENGTH + 1).join("a"),
const longString = Array(DebuggerServer.LONG_STRING_LENGTH + 1).join("a"),
shortedString = longString.substring(0,
DebuggerServer.LONG_STRING_INITIAL_LENGTH
);
@ -59,7 +59,7 @@ function onAttach(aState, aResponse)
nextTest();
});
let symbolTestValues = [
const symbolTestValues = [
["Symbol.iterator", "Symbol(Symbol.iterator)"],
["Symbol('foo')", "Symbol(foo)"],
["Symbol()", "Symbol()"],