commit b5a1d0ac85783af43ebe690565459e76c47dddca parent c72f89659963348d9ae01aea95e2dbdc1e65098e Author: Julian Descottes <jdescottes@mozilla.com> Date: Wed, 15 Oct 2025 16:44:57 +0000 Bug 1275096 - [devtools] Fix eslint no aArgs violations r=frontend-codestyle-reviewers,devtools-reviewers,nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D268679 Diffstat:
16 files changed, 115 insertions(+), 121 deletions(-)
diff --git a/devtools/.eslintrc.mjs b/devtools/.eslintrc.mjs @@ -172,12 +172,6 @@ export default [ }, }, { - files: ["client/framework/**", "shared/webconsole/test/chrome/*.html"], - rules: { - "mozilla/no-aArgs": "off", - }, - }, - { files: ["client/framework/test/**"], rules: { "mozilla/var-only-at-top-level": "off", diff --git a/devtools/client/framework/test/browser_devtools_api_destroy.js b/devtools/client/framework/test/browser_devtools_api_destroy.js @@ -7,7 +7,7 @@ function test() { addTab("about:blank").then(runTests); } -async function runTests(aTab) { +async function runTests(tab) { const toolDefinition = { id: "testTool", visibilityswitch: "devtools.testTool.enabled", @@ -33,7 +33,7 @@ async function runTests(aTab) { const collectedEvents = []; gDevTools - .showToolboxForTab(aTab, { toolId: toolDefinition.id }) + .showToolboxForTab(tab, { toolId: toolDefinition.id }) .then(function (toolbox) { const panel = toolbox.getPanel(toolDefinition.id); ok(panel, "Tool open"); diff --git a/devtools/client/framework/test/browser_new_activation_workflow.js b/devtools/client/framework/test/browser_new_activation_workflow.js @@ -3,7 +3,7 @@ // Tests devtools API -var toolbox; +var gToolbox; function test() { addTab("about:blank").then(async function () { @@ -18,15 +18,15 @@ function loadWebConsole() { const tab = gBrowser.selectedTab; return gDevTools .showToolboxForTab(tab, { toolId: "webconsole" }) - .then(function (aToolbox) { - toolbox = aToolbox; + .then(function (toolbox) { + gToolbox = toolbox; checkToolLoading(); }); } function checkToolLoading() { - is(toolbox.currentToolId, "webconsole", "The web console is selected"); - ok(toolbox.isReady, "toolbox is ready"); + is(gToolbox.currentToolId, "webconsole", "The web console is selected"); + ok(gToolbox.isReady, "toolbox is ready"); selectAndCheckById("jsdebugger").then(function () { selectAndCheckById("styleeditor").then(function () { @@ -36,8 +36,8 @@ function checkToolLoading() { } function selectAndCheckById(id) { - return toolbox.selectTool(id).then(function () { - const tab = toolbox.doc.getElementById("toolbox-tab-" + id); + return gToolbox.selectTool(id).then(function () { + const tab = gToolbox.doc.getElementById("toolbox-tab-" + id); is( tab.classList.contains("selected"), true, @@ -52,14 +52,14 @@ function selectAndCheckById(id) { } function testToggle() { - toolbox.once("destroyed", async () => { + gToolbox.once("destroyed", async () => { // Cannot reuse a target after it's destroyed. gDevTools .showToolboxForTab(gBrowser.selectedTab, { toolId: "styleeditor" }) - .then(function (aToolbox) { - toolbox = aToolbox; + .then(function (toolbox) { + gToolbox = toolbox; is( - toolbox.currentToolId, + gToolbox.currentToolId, "styleeditor", "The style editor is selected" ); @@ -67,12 +67,12 @@ function testToggle() { }); }); - toolbox.destroy(); + gToolbox.destroy(); } function finishUp() { - toolbox.destroy().then(function () { - toolbox = null; + gToolbox.destroy().then(function () { + gToolbox = null; gBrowser.removeCurrentTab(); finish(); }); diff --git a/devtools/client/framework/test/browser_toolbox_dynamic_registration.js b/devtools/client/framework/test/browser_toolbox_dynamic_registration.js @@ -4,7 +4,7 @@ const TEST_URL = "data:text/html,test for dynamically registering and unregistering tools"; -var toolbox; +var gToolbox; function test() { addTab(TEST_URL).then(async tab => { @@ -12,8 +12,8 @@ function test() { }); } -function testRegister(aToolbox) { - toolbox = aToolbox; +function testRegister(toolbox) { + gToolbox = toolbox; gDevTools.once("tool-registered", toolRegistered); gDevTools.registerTool({ @@ -31,7 +31,7 @@ function toolRegistered(toolId) { ok(gDevTools.getToolDefinitionMap().has(toolId), "tool added to map"); // test that it appeared in the UI - const doc = toolbox.doc; + const doc = gToolbox.doc; const tab = getToolboxTab(doc, toolId); ok(tab, "new tool's tab exists in toolbox UI"); @@ -63,7 +63,7 @@ function toolUnregistered(toolId) { ok(!gDevTools.getToolDefinitionMap().has(toolId), "tool removed from map"); // test that it disappeared from the UI - const doc = toolbox.doc; + const doc = gToolbox.doc; const tab = getToolboxTab(doc, toolId); ok(!tab, "tool's tab was removed from the toolbox UI"); @@ -79,8 +79,8 @@ function toolUnregistered(toolId) { } function cleanup() { - toolbox.destroy().then(() => { - toolbox = null; + gToolbox.destroy().then(() => { + gToolbox = null; gBrowser.removeCurrentTab(); finish(); }); diff --git a/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js b/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js @@ -8,13 +8,13 @@ const TEST_URL = "data:text/html;charset=utf8,test page for toolbar keyboard navigation"; -function containsFocus(aDoc, aElm) { - let elm = aDoc.activeElement; - while (elm) { - if (elm === aElm) { +function containsFocus(doc, expectedElement) { + let el = doc.activeElement; + while (el) { + if (el === expectedElement) { return true; } - elm = elm.parentNode; + el = el.parentNode; } return false; } diff --git a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js @@ -12,7 +12,7 @@ const TEST_URL = `data:text/html,<!DOCTYPE html> </html>`; const TOOL_ID = "test-toolbox-tool"; -var toolbox; +var gToolbox; function test() { addTab(TEST_URL).then(async tab => { @@ -33,8 +33,8 @@ var waitForToolInstanceDestroyed = new Promise(resolve => { resolveToolInstanceDestroyed = resolve; }); -function toolboxRegister(aToolbox) { - toolbox = aToolbox; +function toolboxRegister(toolbox) { + gToolbox = toolbox; waitForToolInstanceBuild = new Promise(resolve => { resolveToolInstanceBuild = resolve; @@ -42,7 +42,7 @@ function toolboxRegister(aToolbox) { info("add per-toolbox tool in the opened toolbox."); - toolbox.addAdditionalTool({ + gToolbox.addAdditionalTool({ id: TOOL_ID, // The size of the label can make the test fail if it's too long. // See ok(tab, ...) assert below and Bug 1596345. @@ -70,12 +70,12 @@ function testToolRegistered() { "per-toolbox tool is not registered globally" ); ok( - toolbox.hasAdditionalTool(TOOL_ID), + gToolbox.hasAdditionalTool(TOOL_ID), "per-toolbox tool registered to the specific toolbox" ); // Test that the tool appeared in the UI. - const doc = toolbox.doc; + const doc = gToolbox.doc; const tab = getToolboxTab(doc, TOOL_ID); ok(tab, "new tool's tab exists in toolbox UI"); @@ -107,19 +107,19 @@ function getAllBrowserWindows() { function testUnregister() { info("remove per-toolbox tool in the opened toolbox."); - toolbox.removeAdditionalTool(TOOL_ID); + gToolbox.removeAdditionalTool(TOOL_ID); Promise.all([waitForToolInstanceDestroyed]).then(toolboxToolUnregistered); } function toolboxToolUnregistered() { ok( - !toolbox.hasAdditionalTool(TOOL_ID), + !gToolbox.hasAdditionalTool(TOOL_ID), "per-toolbox tool unregistered from the specific toolbox" ); // test that it disappeared from the UI - const doc = toolbox.doc; + const doc = gToolbox.doc; const tab = getToolboxTab(doc, TOOL_ID); ok(!tab, "tool's tab was removed from the toolbox UI"); @@ -130,8 +130,8 @@ function toolboxToolUnregistered() { } function cleanup() { - toolbox.destroy().then(() => { - toolbox = null; + gToolbox.destroy().then(() => { + gToolbox = null; gBrowser.removeCurrentTab(); finish(); }); diff --git a/devtools/client/framework/test/browser_toolbox_view_source_01.js b/devtools/client/framework/test/browser_toolbox_view_source_01.js @@ -24,8 +24,8 @@ async function viewSource() { } function test() { - viewSource().then(finish, aError => { - ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + viewSource().then(finish, error => { + ok(false, "Got an error: " + error.message + "\n" + error.stack); finish(); }); } diff --git a/devtools/client/framework/test/browser_toolbox_view_source_02.js b/devtools/client/framework/test/browser_toolbox_view_source_02.js @@ -31,8 +31,8 @@ async function viewSource() { } function test() { - viewSource().then(finish, aError => { - ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + viewSource().then(finish, error => { + ok(false, "Got an error: " + error.message + "\n" + error.stack); finish(); }); } diff --git a/devtools/client/framework/test/browser_toolbox_view_source_03.js b/devtools/client/framework/test/browser_toolbox_view_source_03.js @@ -44,8 +44,8 @@ async function viewSource() { } function test() { - viewSource().then(finish, aError => { - ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + viewSource().then(finish, error => { + ok(false, "Got an error: " + error.message + "\n" + error.stack); finish(); }); } diff --git a/devtools/client/framework/test/browser_toolbox_window_shortcuts.js b/devtools/client/framework/test/browser_toolbox_window_shortcuts.js @@ -8,7 +8,7 @@ var Startup = Cc["@mozilla.org/devtools/startup-clh;1"].getService( ).wrappedJSObject; var { Toolbox } = require("resource://devtools/client/framework/toolbox.js"); -var toolbox, +var gToolbox, toolIDs, toolShortcuts = [], idIndex, @@ -46,20 +46,20 @@ async function test() { }); } -function testShortcuts(aToolbox, aIndex) { - if (aIndex === undefined) { - aIndex = 1; - } else if (aIndex == toolIDs.length) { +function testShortcuts(toolbox, index) { + if (index === undefined) { + index = 1; + } else if (index == toolIDs.length) { tidyUp(); return; } - toolbox = aToolbox; + gToolbox = toolbox; info("Toolbox fired a `ready` event"); - toolbox.once("select", selectCB); + gToolbox.once("select", selectCB); - const shortcut = toolShortcuts[aIndex]; + const shortcut = toolShortcuts[index]; const key = shortcut.shortcut; const toolModifiers = shortcut.modifiers; const modifiers = { @@ -67,16 +67,16 @@ function testShortcuts(aToolbox, aIndex) { altKey: toolModifiers.includes("alt"), shiftKey: toolModifiers.includes("shift"), }; - idIndex = aIndex; + idIndex = index; info( "Testing shortcut for tool " + - aIndex + + index + ":" + - toolIDs[aIndex] + + toolIDs[index] + " using key " + key ); - EventUtils.synthesizeKey(key, modifiers, toolbox.win.parent); + EventUtils.synthesizeKey(key, modifiers, gToolbox.win.parent); } function selectCB(id) { @@ -88,17 +88,17 @@ function selectCB(id) { "Correct tool is selected on pressing the shortcut for " + id ); - testShortcuts(toolbox, idIndex + 1); + testShortcuts(gToolbox, idIndex + 1); } function tidyUp() { - toolbox.destroy().then(function () { + gToolbox.destroy().then(function () { gBrowser.removeCurrentTab(); for (const pref of modifiedPrefs) { Services.prefs.clearUserPref(pref); } - toolbox = toolIDs = idIndex = modifiedPrefs = Toolbox = null; + gToolbox = toolIDs = idIndex = modifiedPrefs = Toolbox = null; finish(); }); } diff --git a/devtools/client/framework/test/head.js b/devtools/client/framework/test/head.js @@ -65,8 +65,8 @@ async function getParentProcessActors(callback) { callback(commands.client, mainProcessTargetFront); } -function getSourceActor(aSources, aURL) { - const item = aSources.getItemForAttachment(a => a.source.url === aURL); +function getSourceActor(sources, url) { + const item = sources.getItemForAttachment(a => a.source.url === url); return item && item.value; } diff --git a/devtools/shared/webconsole/test/chrome/test_console_styling.html b/devtools/shared/webconsole/test/chrome/test_console_styling.html @@ -89,30 +89,30 @@ async function startTest() onAttach(state, response); } -function onAttach(aState) +function onAttach(state) { - onConsoleAPICall = onConsoleAPICall.bind(null, aState); - aState.webConsoleFront.on("consoleAPICall", onConsoleAPICall); - doConsoleCalls(aState.actor); + onConsoleAPICall = onConsoleAPICall.bind(null, state); + state.webConsoleFront.on("consoleAPICall", onConsoleAPICall); + doConsoleCalls(state.actor); } let consoleCalls = []; -function onConsoleAPICall(aState, aPacket) +function onConsoleAPICall(state, packet) { - info("received message level: " + aPacket.message.level); + info("received message level: " + packet.message.level); - consoleCalls.push(aPacket.message); + consoleCalls.push(packet.message); if (consoleCalls.length != expectedConsoleCalls.length) { return; } - aState.webConsoleFront.off("consoleAPICall", onConsoleAPICall); + state.webConsoleFront.off("consoleAPICall", onConsoleAPICall); - expectedConsoleCalls.forEach(function(aMessage, aIndex) { - info("checking received console call #" + aIndex); - const expected = expectedConsoleCalls[aIndex]; - const consoleCall = consoleCalls[aIndex]; + expectedConsoleCalls.forEach(function(message, index) { + info("checking received console call #" + index); + const expected = expectedConsoleCalls[index]; + const consoleCall = consoleCalls[index]; if (expected.styles == undefined) { delete expected.styles; is(consoleCall.styles, undefined, "No 'styles' property") @@ -123,7 +123,7 @@ function onConsoleAPICall(aState, aPacket) consoleCalls = []; - closeDebugger(aState, function() { + closeDebugger(state, function() { SimpleTest.finish(); }); } diff --git a/devtools/shared/webconsole/test/chrome/test_consoleapi.html b/devtools/shared/webconsole/test/chrome/test_consoleapi.html @@ -199,35 +199,35 @@ async function startTest() onAttach(state, response); } -function onAttach(aState) +function onAttach(state) { - onConsoleAPICall = onConsoleAPICall.bind(null, aState); - aState.webConsoleFront.on("consoleAPICall", onConsoleAPICall); - doConsoleCalls(aState.actor); + onConsoleAPICall = onConsoleAPICall.bind(null, state); + state.webConsoleFront.on("consoleAPICall", onConsoleAPICall); + doConsoleCalls(state.actor); } let consoleCalls = []; -function onConsoleAPICall(aState, aPacket) +function onConsoleAPICall(state, packet) { - info("received message level: " + aPacket.message.level); + info("received message level: " + packet.message.level); - consoleCalls.push(aPacket.message); + consoleCalls.push(packet.message); if (consoleCalls.length != expectedConsoleCalls.length) { return; } - aState.webConsoleFront.off("consoleAPICall", onConsoleAPICall); + state.webConsoleFront.off("consoleAPICall", onConsoleAPICall); - expectedConsoleCalls.forEach(function(aMessage, aIndex) { - info("checking received console call #" + aIndex); - checkConsoleAPICall(consoleCalls[aIndex], expectedConsoleCalls[aIndex]); + expectedConsoleCalls.forEach(function(message, index) { + info("checking received console call #" + index); + checkConsoleAPICall(consoleCalls[index], expectedConsoleCalls[index]); }); consoleCalls = []; - closeDebugger(aState, function() { + closeDebugger(state, function() { SimpleTest.finish(); }); } diff --git a/devtools/shared/webconsole/test/chrome/test_consoleapi_innerID.html b/devtools/shared/webconsole/test/chrome/test_consoleapi_innerID.html @@ -120,35 +120,35 @@ async function startTest() onAttach(state); } -function onAttach(aState) +function onAttach(state) { - onConsoleAPICall = onConsoleAPICall.bind(null, aState); - aState.webConsoleFront.on("consoleAPICall", onConsoleAPICall); - doConsoleCalls(aState.actor); + onConsoleAPICall = onConsoleAPICall.bind(null, state); + state.webConsoleFront.on("consoleAPICall", onConsoleAPICall); + doConsoleCalls(state.actor); } let consoleCalls = []; -function onConsoleAPICall(aState, aPacket) +function onConsoleAPICall(state, packet) { - info("received message level: " + aPacket.message.level); + info("received message level: " + packet.message.level); - consoleCalls.push(aPacket.message); + consoleCalls.push(packet.message); if (consoleCalls.length != expectedConsoleCalls.length) { return; } - aState.webConsoleFront.off("consoleAPICall", onConsoleAPICall); + state.webConsoleFront.off("consoleAPICall", onConsoleAPICall); - expectedConsoleCalls.forEach(function(aMessage, aIndex) { - info("checking received console call #" + aIndex); - checkConsoleAPICall(consoleCalls[aIndex], expectedConsoleCalls[aIndex]); + expectedConsoleCalls.forEach(function(message, index) { + info("checking received console call #" + index); + checkConsoleAPICall(consoleCalls[index], expectedConsoleCalls[index]); }); consoleCalls = []; - closeDebugger(aState, function() { + closeDebugger(state, function() { SimpleTest.finish(); }); } diff --git a/devtools/shared/webconsole/test/chrome/test_file_uri.html b/devtools/shared/webconsole/test/chrome/test_file_uri.html @@ -45,9 +45,9 @@ function doFileActivity() NetUtil.asyncCopy(stream, fout, addIframe); } -function addIframe(aStatus) +function addIframe(status) { - ok(Components.isSuccessCode(aStatus), + ok(Components.isSuccessCode(status), "the temporary file was saved successfully"); const iframe = document.createElement("iframe"); @@ -63,19 +63,19 @@ async function startTest() onAttach(state); } -function onAttach(aState) +function onAttach(state) { - gState = aState; + gState = state; gState.webConsoleFront.on("fileActivity", onFileActivity); doFileActivity(); } -function onFileActivity(aPacket) +function onFileActivity(packet) { gState.webConsoleFront.off("fileActivity", onFileActivity); - info("aPacket.uri: " + aPacket.uri); - ok(/\bbug798764\b.*\.html$/.test(aPacket.uri), "file URI match"); + info("packet.uri: " + packet.uri); + ok(/\bbug798764\b.*\.html$/.test(packet.uri), "file URI match"); testEnd(); } diff --git a/devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html b/devtools/shared/webconsole/test/chrome/test_nsiconsolemessage.html @@ -24,10 +24,10 @@ async function startTest() onAttach(state); } -function onAttach(aState) +function onAttach(state) { - onLogMessage = onLogMessage.bind(null, aState); - aState.webConsoleFront.on("logMessage", onLogMessage); + onLogMessage = onLogMessage.bind(null, state); + state.webConsoleFront.on("logMessage", onLogMessage); expectedMessages = [{ message: "hello world! bug859756", @@ -41,13 +41,13 @@ function onAttach(aState) const receivedMessages = []; -function onLogMessage(aState, aPacket) +function onLogMessage(state, packet) { - info("received message: " + aPacket.message); + info("received message: " + packet.message); let found = false; for (const expected of expectedMessages) { - if (expected.message == aPacket.message) { + if (expected.message == packet.message) { found = true; break; } @@ -56,16 +56,16 @@ function onLogMessage(aState, aPacket) return; } - receivedMessages.push(aPacket); + receivedMessages.push(packet); if (receivedMessages.length != expectedMessages.length) { return; } - aState.webConsoleFront.off("logMessage", onLogMessage); + state.webConsoleFront.off("logMessage", onLogMessage); checkObject(receivedMessages, expectedMessages); - closeDebugger(aState, () => SimpleTest.finish()); + closeDebugger(state, () => SimpleTest.finish()); } addEventListener("load", startTest);