From 822979637894191a11903d0973e67c59ac2c0b8d Mon Sep 17 00:00:00 2001 From: Michael Brennan Date: Sat, 18 Mar 2017 12:26:05 +0100 Subject: [PATCH] Bug 1325989 - Resolve ESLint issues in devtools/server/tests/unit. r=jryans --HG-- extra : rebase_source : 855f1da9fc88af46e8be78c94762a90df29cb75f --- .eslintignore | 3 +- devtools/server/tests/unit/.eslintrc.js | 5 +- devtools/server/tests/unit/head_dbg.js | 182 +++++++++--------- devtools/server/tests/unit/hello-actor.js | 7 +- .../tests/unit/post_init_global_actors.js | 6 +- .../server/tests/unit/post_init_tab_actors.js | 6 +- .../tests/unit/pre_init_global_actors.js | 6 +- .../server/tests/unit/pre_init_tab_actors.js | 6 +- .../tests/unit/registertestactors-01.js | 2 + .../tests/unit/registertestactors-02.js | 2 + .../tests/unit/registertestactors-03.js | 4 +- .../tests/unit/test_actor-registry-actor.js | 7 +- devtools/server/tests/unit/test_add_actors.js | 51 +++-- .../server/tests/unit/test_addon_reload.js | 6 +- .../server/tests/unit/test_addons_actor.js | 5 +- .../server/tests/unit/test_animation_name.js | 174 ++++++++--------- .../server/tests/unit/test_animation_type.js | 136 ++++++------- devtools/server/tests/unit/test_attach.js | 25 ++- .../server/tests/unit/test_blackboxing-01.js | 50 ++--- .../server/tests/unit/test_blackboxing-02.js | 58 +++--- .../server/tests/unit/test_blackboxing-03.js | 40 ++-- .../server/tests/unit/test_blackboxing-04.js | 43 +++-- .../server/tests/unit/test_blackboxing-05.js | 39 ++-- .../server/tests/unit/test_blackboxing-06.js | 49 +++-- .../server/tests/unit/test_blackboxing-07.js | 14 +- .../server/tests/unit/test_breakpoint-01.js | 52 ++--- .../server/tests/unit/test_breakpoint-02.js | 45 +++-- .../server/tests/unit/test_breakpoint-03.js | 59 +++--- .../server/tests/unit/test_breakpoint-04.js | 54 +++--- .../server/tests/unit/test_breakpoint-05.js | 55 +++--- .../server/tests/unit/test_breakpoint-06.js | 56 +++--- .../server/tests/unit/test_breakpoint-07.js | 55 +++--- .../server/tests/unit/test_breakpoint-08.js | 63 +++--- .../server/tests/unit/test_breakpoint-09.js | 56 +++--- .../server/tests/unit/test_breakpoint-10.js | 61 +++--- .../server/tests/unit/test_breakpoint-11.js | 61 +++--- .../server/tests/unit/test_breakpoint-12.js | 68 +++---- .../server/tests/unit/test_breakpoint-13.js | 93 ++++----- .../server/tests/unit/test_breakpoint-14.js | 91 ++++----- .../server/tests/unit/test_breakpoint-15.js | 30 +-- .../server/tests/unit/test_breakpoint-16.js | 52 ++--- .../server/tests/unit/test_breakpoint-17.js | 52 ++--- .../server/tests/unit/test_breakpoint-18.js | 24 +-- .../server/tests/unit/test_breakpoint-19.js | 24 +-- .../server/tests/unit/test_breakpoint-20.js | 12 +- .../server/tests/unit/test_breakpoint-21.js | 21 +- .../server/tests/unit/test_breakpoint-22.js | 22 +-- .../tests/unit/test_breakpoint-actor-map.js | 11 +- .../server/tests/unit/test_client_close.js | 14 +- .../server/tests/unit/test_client_request.js | 47 +++-- .../unit/test_conditional_breakpoint-01.js | 37 ++-- .../unit/test_conditional_breakpoint-02.js | 35 ++-- .../unit/test_conditional_breakpoint-03.js | 37 ++-- devtools/server/tests/unit/test_dbgactor.js | 92 +++++---- .../unit/test_dbgclient_debuggerstatement.js | 44 ++--- devtools/server/tests/unit/test_dbgglobal.js | 23 +-- devtools/server/tests/unit/test_eval-01.js | 45 ++--- devtools/server/tests/unit/test_eval-02.js | 34 ++-- devtools/server/tests/unit/test_eval-03.js | 36 ++-- devtools/server/tests/unit/test_eval-04.js | 47 ++--- devtools/server/tests/unit/test_eval-05.js | 36 ++-- .../tests/unit/test_eventlooplag_actor.js | 4 +- .../tests/unit/test_forwardingprefix.js | 114 +++++------ .../server/tests/unit/test_frameactor-01.js | 25 +-- .../server/tests/unit/test_frameactor-02.js | 24 +-- .../server/tests/unit/test_frameactor-03.js | 26 +-- .../server/tests/unit/test_frameactor-04.js | 32 +-- .../server/tests/unit/test_frameactor-05.js | 58 ++---- .../tests/unit/test_frameactor_wasm-01.js | 39 ++-- .../tests/unit/test_framearguments-01.js | 23 +-- .../tests/unit/test_framebindings-01.js | 61 +++--- .../tests/unit/test_framebindings-02.js | 32 +-- .../tests/unit/test_framebindings-03.js | 40 ++-- .../tests/unit/test_framebindings-04.js | 52 ++--- .../tests/unit/test_framebindings-05.js | 44 +++-- .../tests/unit/test_framebindings-06.js | 42 ++-- .../tests/unit/test_framebindings-07.js | 53 +++-- .../server/tests/unit/test_frameclient-01.js | 22 ++- .../server/tests/unit/test_frameclient-02.js | 21 +- .../tests/unit/test_functiongrips-01.js | 56 +++--- .../test_get-executable-lines-source-map.js | 6 +- .../tests/unit/test_get-executable-lines.js | 6 +- .../server/tests/unit/test_getRuleText.js | 3 +- .../tests/unit/test_getyoungestframe.js | 16 +- .../unit/test_ignore_caught_exceptions.js | 32 +-- .../test_ignore_no_interface_exceptions.js | 26 +-- devtools/server/tests/unit/test_interrupt.js | 37 ++-- .../unit/test_layout-reflows-observer.js | 2 + .../server/tests/unit/test_listsources-01.js | 33 ++-- .../server/tests/unit/test_listsources-02.js | 36 ++-- .../server/tests/unit/test_listsources-03.js | 25 +-- .../server/tests/unit/test_listsources-04.js | 9 +- .../server/tests/unit/test_longstringactor.js | 23 +-- .../tests/unit/test_longstringgrips-01.js | 28 +-- .../tests/unit/test_longstringgrips-02.js | 18 +- .../server/tests/unit/test_monitor_actor.js | 5 +- .../server/tests/unit/test_nativewrappers.js | 15 +- devtools/server/tests/unit/test_nesting-01.js | 19 +- devtools/server/tests/unit/test_nesting-02.js | 21 +- devtools/server/tests/unit/test_nesting-03.js | 39 ++-- .../server/tests/unit/test_new_source-01.js | 27 +-- .../server/tests/unit/test_nsjsinspector.js | 12 +- .../server/tests/unit/test_objectgrips-01.js | 43 ++--- .../server/tests/unit/test_objectgrips-02.js | 51 ++--- .../server/tests/unit/test_objectgrips-03.js | 66 +++---- .../server/tests/unit/test_objectgrips-04.js | 70 +++---- .../server/tests/unit/test_objectgrips-05.js | 34 ++-- .../server/tests/unit/test_objectgrips-06.js | 34 ++-- .../server/tests/unit/test_objectgrips-07.js | 34 ++-- .../server/tests/unit/test_objectgrips-08.js | 66 +++---- .../server/tests/unit/test_objectgrips-09.js | 75 ++++---- .../server/tests/unit/test_objectgrips-10.js | 51 ++--- .../server/tests/unit/test_objectgrips-11.js | 26 +-- .../server/tests/unit/test_objectgrips-12.js | 22 ++- .../server/tests/unit/test_objectgrips-13.js | 21 +- .../tests/unit/test_pause_exceptions-01.js | 28 +-- .../tests/unit/test_pause_exceptions-02.js | 25 +-- .../tests/unit/test_pauselifetime-01.js | 33 ++-- .../tests/unit/test_pauselifetime-02.js | 32 +-- .../tests/unit/test_pauselifetime-03.js | 32 +-- .../tests/unit/test_pauselifetime-04.js | 27 +-- .../tests/unit/test_profiler_activation-01.js | 63 +++--- .../tests/unit/test_profiler_activation-02.js | 4 +- .../tests/unit/test_profiler_bufferstatus.js | 48 ++--- .../server/tests/unit/test_profiler_close.js | 13 +- .../server/tests/unit/test_profiler_data.js | 27 ++- .../tests/unit/test_profiler_events-01.js | 7 +- .../tests/unit/test_profiler_events-02.js | 9 +- .../tests/unit/test_profiler_getbufferinfo.js | 47 ++--- .../tests/unit/test_profiler_getfeatures.js | 8 +- .../unit/test_profiler_sharedlibraries.js | 6 +- .../tests/unit/test_promise_state-01.js | 29 +-- .../tests/unit/test_promise_state-02.js | 34 ++-- .../tests/unit/test_promise_state-03.js | 34 ++-- .../tests/unit/test_promises_actor_attach.js | 2 + .../tests/unit/test_promises_actor_exist.js | 3 + .../server/tests/unit/test_protocolSpec.js | 2 + .../server/tests/unit/test_protocol_abort.js | 5 +- .../server/tests/unit/test_protocol_async.js | 50 +++-- .../tests/unit/test_protocol_children.js | 146 +++++++++----- .../tests/unit/test_protocol_formtype.js | 5 +- .../tests/unit/test_protocol_longstring.js | 87 ++++++--- .../server/tests/unit/test_protocol_simple.js | 76 +++++--- .../server/tests/unit/test_protocol_stack.js | 3 +- .../tests/unit/test_protocol_unregister.js | 12 +- .../server/tests/unit/test_reattach-thread.js | 39 ++-- .../server/tests/unit/test_registerClient.js | 17 +- .../server/tests/unit/test_register_actor.js | 27 +-- .../server/tests/unit/test_requestTypes.js | 22 +-- .../server/tests/unit/test_safe-getter.js | 7 +- ...n-column-with-no-offsets-at-end-of-line.js | 2 +- devtools/server/tests/unit/test_source-01.js | 42 ++-- .../server/tests/unit/test_sourcemaps-01.js | 29 +-- .../server/tests/unit/test_sourcemaps-02.js | 25 +-- .../server/tests/unit/test_sourcemaps-03.js | 40 ++-- .../server/tests/unit/test_sourcemaps-04.js | 31 +-- .../server/tests/unit/test_sourcemaps-05.js | 31 +-- .../server/tests/unit/test_sourcemaps-06.js | 35 ++-- .../server/tests/unit/test_sourcemaps-07.js | 38 ++-- .../server/tests/unit/test_sourcemaps-08.js | 21 +- .../server/tests/unit/test_sourcemaps-09.js | 50 +++-- .../server/tests/unit/test_sourcemaps-10.js | 36 ++-- .../server/tests/unit/test_sourcemaps-11.js | 40 ++-- .../server/tests/unit/test_sourcemaps-12.js | 21 +- .../server/tests/unit/test_sourcemaps-13.js | 18 +- .../server/tests/unit/test_sourcemaps-16.js | 27 +-- .../server/tests/unit/test_sourcemaps-17.js | 17 +- .../server/tests/unit/test_stepping-01.js | 59 +++--- .../server/tests/unit/test_stepping-02.js | 59 +++--- .../server/tests/unit/test_stepping-03.js | 42 ++-- .../server/tests/unit/test_stepping-04.js | 51 ++--- .../server/tests/unit/test_stepping-05.js | 68 +++---- .../server/tests/unit/test_stepping-06.js | 79 ++++---- .../server/tests/unit/test_stepping-07.js | 17 +- devtools/server/tests/unit/test_symbols-01.js | 13 +- devtools/server/tests/unit/test_symbols-02.js | 13 +- .../tests/unit/test_threadlifetime-01.js | 34 ++-- .../tests/unit/test_threadlifetime-02.js | 43 +++-- .../tests/unit/test_threadlifetime-03.js | 47 ++--- .../tests/unit/test_threadlifetime-04.js | 32 +-- .../tests/unit/test_threadlifetime-05.js | 62 +++--- .../tests/unit/test_threadlifetime-06.js | 44 +++-- .../tests/unit/test_unsafeDereference.js | 19 +- .../tests/unit/test_xpcshell_debugging.js | 7 +- devtools/server/tests/unit/testactors.js | 47 +++-- devtools/server/tests/unit/tracerlocations.js | 8 - 186 files changed, 3475 insertions(+), 3150 deletions(-) delete mode 100644 devtools/server/tests/unit/tracerlocations.js diff --git a/.eslintignore b/.eslintignore index 59576d3e93cf..d915c4f4e62a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -135,7 +135,7 @@ devtools/server/actors/stylesheets.js devtools/server/tests/browser/storage-*.html !devtools/server/tests/browser/storage-unsecured-iframe.html devtools/server/tests/browser/stylesheets-nested-iframes.html -devtools/server/tests/unit/** +devtools/server/tests/unit/xpcshell_debugging_script.js devtools/shared/platform/content/test/test_clipboard.html devtools/shared/qrcode/tests/mochitest/test_decode.html devtools/shared/tests/mochitest/*.html @@ -178,6 +178,7 @@ devtools/client/debugger/test/mochitest/code_worker-source-map.js devtools/client/framework/test/code_ugly* devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js devtools/server/tests/unit/setBreakpoint* +devtools/server/tests/unit/sourcemapped.js # dom/ exclusions dom/animation/** diff --git a/devtools/server/tests/unit/.eslintrc.js b/devtools/server/tests/unit/.eslintrc.js index 0124280192b7..8342de80c309 100644 --- a/devtools/server/tests/unit/.eslintrc.js +++ b/devtools/server/tests/unit/.eslintrc.js @@ -2,5 +2,8 @@ module.exports = { // Extend from the common devtools xpcshell eslintrc config. - "extends": "../../../.eslintrc.xpcshell.js" + "extends": "../../../.eslintrc.xpcshell.js", + "rules": { + "no-debugger": 0, + } }; diff --git a/devtools/server/tests/unit/head_dbg.js b/devtools/server/tests/unit/head_dbg.js index 57d0eb8ffc3e..9d58b1f75756 100644 --- a/devtools/server/tests/unit/head_dbg.js +++ b/devtools/server/tests/unit/head_dbg.js @@ -1,5 +1,7 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint no-unused-vars: ["error", {"vars": "local"}] */ +/* eslint-disable no-shadow */ "use strict"; var Cc = Components.classes; @@ -42,11 +44,11 @@ const { MemoryFront } = require("devtools/shared/fronts/memory"); const { addDebuggerToGlobal } = Cu.import("resource://gre/modules/jsdebugger.jsm", {}); -const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal); +const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"] + .createInstance(Ci.nsIPrincipal); -var loadSubScript = Cc[ - "@mozilla.org/moz/jssubscript-loader;1" -].getService(Ci.mozIJSSubScriptLoader).loadSubScript; +var { loadSubScript } = Cc["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Ci.mozIJSSubScriptLoader); /** * Initializes any test that needs to work with add-ons. @@ -150,9 +152,8 @@ function makeFullRuntimeMemoryActorTest(testGeneratorFunction) { } function createTestGlobal(name) { - let sandbox = Cu.Sandbox( - Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal) - ); + let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"] + .createInstance(Ci.nsIPrincipal)); sandbox.__name = name; return sandbox; } @@ -236,24 +237,27 @@ function dumpn(msg) { function testExceptionHook(ex) { try { do_report_unexpected_exception(ex); - } catch (ex) { - return {throw: ex}; + } catch (e) { + return {throw: e}; } return undefined; } -// Convert an nsIScriptError 'aFlags' value into an appropriate string. -function scriptErrorFlagsToKind(aFlags) { - var kind; - if (aFlags & Ci.nsIScriptError.warningFlag) +// Convert an nsIScriptError 'flags' value into an appropriate string. +function scriptErrorFlagsToKind(flags) { + let kind; + if (flags & Ci.nsIScriptError.warningFlag) { kind = "warning"; - if (aFlags & Ci.nsIScriptError.exceptionFlag) + } + if (flags & Ci.nsIScriptError.exceptionFlag) { kind = "exception"; - else + } else { kind = "error"; + } - if (aFlags & Ci.nsIScriptError.strictFlag) + if (flags & Ci.nsIScriptError.strictFlag) { kind = "strict " + kind; + } return kind; } @@ -262,24 +266,25 @@ function scriptErrorFlagsToKind(aFlags) { // into the ether. var errorCount = 0; var listener = { - observe: function (aMessage) { + observe: function (message) { try { + let string; errorCount++; try { // If we've been given an nsIScriptError, then we can print out // something nicely formatted, for tools like Emacs to pick up. - var scriptError = aMessage.QueryInterface(Ci.nsIScriptError); - dumpn(aMessage.sourceName + ":" + aMessage.lineNumber + ": " + - scriptErrorFlagsToKind(aMessage.flags) + ": " + - aMessage.errorMessage); - var string = aMessage.errorMessage; - } catch (x) { + message.QueryInterface(Ci.nsIScriptError); + dumpn(message.sourceName + ":" + message.lineNumber + ": " + + scriptErrorFlagsToKind(message.flags) + ": " + + message.errorMessage); + string = message.errorMessage; + } catch (e1) { // Be a little paranoid with message, as the whole goal here is to lose // no information. try { - var string = "" + aMessage.message; - } catch (x) { - var string = ""; + string = "" + message.message; + } catch (e2) { + string = ""; } } @@ -310,8 +315,7 @@ var listener = { var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); consoleService.registerListener(listener); -function check_except(func) -{ +function check_except(func) { try { func(); } catch (e) { @@ -322,70 +326,67 @@ function check_except(func) do_check_true(false); } -function testGlobal(aName) { - let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"] - .createInstance(Ci.nsIPrincipal); - - let sandbox = Cu.Sandbox(systemPrincipal); - sandbox.__name = aName; +function testGlobal(name) { + let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"] + .createInstance(Ci.nsIPrincipal)); + sandbox.__name = name; return sandbox; } -function addTestGlobal(aName, aServer = DebuggerServer) -{ - let global = testGlobal(aName); - aServer.addTestGlobal(global); +function addTestGlobal(name, server = DebuggerServer) { + let global = testGlobal(name); + server.addTestGlobal(global); return global; } -// List the DebuggerClient |aClient|'s tabs, look for one whose title is -// |aTitle|, and apply |aCallback| to the packet's entry for that tab. -function getTestTab(aClient, aTitle, aCallback) { - aClient.listTabs(function (aResponse) { - for (let tab of aResponse.tabs) { - if (tab.title === aTitle) { - aCallback(tab, aResponse); +// List the DebuggerClient |client|'s tabs, look for one whose title is +// |title|, and apply |callback| to the packet's entry for that tab. +function getTestTab(client, title, callback) { + client.listTabs(function (response) { + for (let tab of response.tabs) { + if (tab.title === title) { + callback(tab, response); return; } } - aCallback(null); + callback(null); }); } -// Attach to |aClient|'s tab whose title is |aTitle|; pass |aCallback| the +// Attach to |client|'s tab whose title is |title|; pass |callback| the // response packet and a TabClient instance referring to that tab. -function attachTestTab(aClient, aTitle, aCallback) { - getTestTab(aClient, aTitle, function (aTab) { - aClient.attachTab(aTab.actor, aCallback); +function attachTestTab(client, title, callback) { + getTestTab(client, title, function (tab) { + client.attachTab(tab.actor, callback); }); } -// Attach to |aClient|'s tab whose title is |aTitle|, and then attach to -// that tab's thread. Pass |aCallback| the thread attach response packet, a +// Attach to |client|'s tab whose title is |title|, and then attach to +// that tab's thread. Pass |callback| the thread attach response packet, a // TabClient referring to the tab, and a ThreadClient referring to the // thread. -function attachTestThread(aClient, aTitle, aCallback) { - attachTestTab(aClient, aTitle, function (aTabResponse, aTabClient) { - function onAttach(aResponse, aThreadClient) { - aCallback(aResponse, aTabClient, aThreadClient, aTabResponse); +function attachTestThread(client, title, callback) { + attachTestTab(client, title, function (tabResponse, tabClient) { + function onAttach(response, threadClient) { + callback(response, tabClient, threadClient, tabResponse); } - aTabClient.attachThread({ + tabClient.attachThread({ useSourceMaps: true, autoBlackBox: true }, onAttach); }); } -// Attach to |aClient|'s tab whose title is |aTitle|, attach to the tab's -// thread, and then resume it. Pass |aCallback| the thread's response to +// Attach to |client|'s tab whose title is |title|, attach to the tab's +// thread, and then resume it. Pass |callback| the thread's response to // the 'resume' packet, a TabClient for the tab, and a ThreadClient for the // thread. -function attachTestTabAndResume(aClient, aTitle, aCallback = () => {}) { - return new Promise((resolve, reject) => { - attachTestThread(aClient, aTitle, function (aResponse, aTabClient, aThreadClient) { - aThreadClient.resume(function (aResponse) { - aCallback(aResponse, aTabClient, aThreadClient); - resolve([aResponse, aTabClient, aThreadClient]); +function attachTestTabAndResume(client, title, callback = () => {}) { + return new Promise((resolve) => { + attachTestThread(client, title, function (response, tabClient, threadClient) { + threadClient.resume(function (response) { + callback(response, tabClient, threadClient); + resolve([response, tabClient, threadClient]); }); }); }); @@ -394,11 +395,12 @@ function attachTestTabAndResume(aClient, aTitle, aCallback = () => {}) { /** * Initialize the testing debugger server. */ -function initTestDebuggerServer(aServer = DebuggerServer) -{ - aServer.registerModule("xpcshell-test/testactors"); +function initTestDebuggerServer(server = DebuggerServer) { + server.registerModule("xpcshell-test/testactors"); // Allow incoming connections. - aServer.init(function () { return true; }); + server.init(function () { + return true; + }); } /** @@ -415,18 +417,16 @@ function startTestDebuggerServer(title, server = DebuggerServer) { return connect(client).then(() => client); } -function finishClient(aClient) -{ - aClient.close(function () { +function finishClient(client) { + client.close(function () { DebuggerServer.destroy(); do_test_finished(); }); } // Create a server, connect to it and fetch tab actors for the parent process; -// pass |aCallback| the debugger client and tab actor form with all actor IDs. -function get_chrome_actors(callback) -{ +// pass |callback| the debugger client and tab actor form with all actor IDs. +function get_chrome_actors(callback) { if (!DebuggerServer.initialized) { DebuggerServer.init(); DebuggerServer.addBrowserActors(); @@ -449,8 +449,8 @@ function getChromeActors(client, server = DebuggerServer) { /** * Takes a relative file path and returns the absolute file url for it. */ -function getFileUrl(aName, aAllowMissing = false) { - let file = do_get_file(aName, aAllowMissing); +function getFileUrl(name, allowMissing = false) { + let file = do_get_file(name, allowMissing); return Services.io.newFileURI(file).spec; } @@ -458,9 +458,8 @@ function getFileUrl(aName, aAllowMissing = false) { * Returns the full path of the file with the specified name in a * platform-independent and URL-like form. */ -function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = false) -{ - let file = do_get_file(aName, aAllowMissing); +function getFilePath(name, allowMissing = false, usePlatformPathSeparator = false) { + let file = do_get_file(name, allowMissing); let path = Services.io.newFileURI(file).spec; let filePrePath = "file://"; if ("nsILocalFileWin" in Ci && @@ -470,7 +469,7 @@ function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = f path = path.slice(filePrePath.length); - if (aUsePlatformPathSeparator && path.match(/^\w:/)) { + if (usePlatformPathSeparator && path.match(/^\w:/)) { path = path.replace(/\//g, "\\"); } @@ -480,8 +479,8 @@ function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = f /** * Returns the full text contents of the given file. */ -function readFile(aFileName) { - let f = do_get_file(aFileName); +function readFile(fileName) { + let f = do_get_file(fileName); let s = Cc["@mozilla.org/network/file-input-stream;1"] .createInstance(Ci.nsIFileInputStream); s.init(f, -1, -1, false); @@ -492,16 +491,16 @@ function readFile(aFileName) { } } -function writeFile(aFileName, aContent) { - let file = do_get_file(aFileName, true); +function writeFile(fileName, content) { + let file = do_get_file(fileName, true); let stream = Cc["@mozilla.org/network/file-output-stream;1"] .createInstance(Ci.nsIFileOutputStream); stream.init(file, -1, -1, 0); try { do { - let numWritten = stream.write(aContent, aContent.length); - aContent = aContent.slice(numWritten); - } while (aContent.length > 0); + let numWritten = stream.write(content, content.length); + content = content.slice(numWritten); + } while (content.length > 0); } finally { stream.close(); } @@ -585,9 +584,9 @@ StubTransport.prototype.ready = function () {}; StubTransport.prototype.send = function () {}; StubTransport.prototype.close = function () {}; -function executeSoon(aFunc) { +function executeSoon(func) { Services.tm.mainThread.dispatch({ - run: DevToolsUtils.makeInfallible(aFunc) + run: DevToolsUtils.makeInfallible(func) }, Ci.nsIThread.DISPATCH_NORMAL); } @@ -810,8 +809,7 @@ function getSource(threadClient, url) { }); if (source.length) { deferred.resolve(threadClient.source(source[0])); - } - else { + } else { deferred.reject(new Error("source not found")); } }); diff --git a/devtools/server/tests/unit/hello-actor.js b/devtools/server/tests/unit/hello-actor.js index 6d7427f63cc6..f7e4819dc4f2 100644 --- a/devtools/server/tests/unit/hello-actor.js +++ b/devtools/server/tests/unit/hello-actor.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint no-unused-vars: ["error", {"vars": "local"}] */ + +"use strict"; const protocol = require("devtools/shared/protocol"); @@ -12,7 +15,5 @@ const helloSpec = protocol.generateActorSpec({ }); var HelloActor = protocol.ActorClassWithSpec(helloSpec, { - hello: function () { - return; - } + hello: function () {} }); diff --git a/devtools/server/tests/unit/post_init_global_actors.js b/devtools/server/tests/unit/post_init_global_actors.js index 0035e8914f7f..748f93cbf248 100644 --- a/devtools/server/tests/unit/post_init_global_actors.js +++ b/devtools/server/tests/unit/post_init_global_actors.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function PostInitGlobalActor(aConnection) {} +"use strict"; + +function PostInitGlobalActor(connection) {} PostInitGlobalActor.prototype = { actorPrefix: "postInitGlobal", - onPing: function onPing(aRequest) { + onPing(request) { return { message: "pong" }; }, }; diff --git a/devtools/server/tests/unit/post_init_tab_actors.js b/devtools/server/tests/unit/post_init_tab_actors.js index 9b9ddf111d85..b20f2a63457e 100644 --- a/devtools/server/tests/unit/post_init_tab_actors.js +++ b/devtools/server/tests/unit/post_init_tab_actors.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function PostInitTabActor(aConnection) {} +"use strict"; + +function PostInitTabActor(connection) {} PostInitTabActor.prototype = { actorPostfix: "postInitTab", - onPing: function onPing(aRequest) { + onPing(request) { return { message: "pong" }; }, }; diff --git a/devtools/server/tests/unit/pre_init_global_actors.js b/devtools/server/tests/unit/pre_init_global_actors.js index bd4284a70a31..e0c03514b2bd 100644 --- a/devtools/server/tests/unit/pre_init_global_actors.js +++ b/devtools/server/tests/unit/pre_init_global_actors.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function PreInitGlobalActor(aConnection) {} +"use strict"; + +function PreInitGlobalActor(connection) {} PreInitGlobalActor.prototype = { actorPrefix: "preInitGlobal", - onPing: function onPing(aRequest) { + onPing(request) { return { message: "pong" }; }, }; diff --git a/devtools/server/tests/unit/pre_init_tab_actors.js b/devtools/server/tests/unit/pre_init_tab_actors.js index 628f0fb2fe79..b3eda97c2657 100644 --- a/devtools/server/tests/unit/pre_init_tab_actors.js +++ b/devtools/server/tests/unit/pre_init_tab_actors.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function PreInitTabActor(aConnection) {} +"use strict"; + +function PreInitTabActor(connection) {} PreInitTabActor.prototype = { actorPrefix: "preInitTab", - onPing: function onPing(aRequest) { + onPing(request) { return { message: "pong" }; }, }; diff --git a/devtools/server/tests/unit/registertestactors-01.js b/devtools/server/tests/unit/registertestactors-01.js index 92f511225b67..e771314f528b 100644 --- a/devtools/server/tests/unit/registertestactors-01.js +++ b/devtools/server/tests/unit/registertestactors-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + function Actor() {} exports.register = function (handle) { diff --git a/devtools/server/tests/unit/registertestactors-02.js b/devtools/server/tests/unit/registertestactors-02.js index 54f78e508689..35b43236c59f 100644 --- a/devtools/server/tests/unit/registertestactors-02.js +++ b/devtools/server/tests/unit/registertestactors-02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + function Actor() {} exports.register = function (handle) { diff --git a/devtools/server/tests/unit/registertestactors-03.js b/devtools/server/tests/unit/registertestactors-03.js index 8d42fdbd80dd..f3d9bd66af64 100644 --- a/devtools/server/tests/unit/registertestactors-03.js +++ b/devtools/server/tests/unit/registertestactors-03.js @@ -1,7 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -var {method, RetVal, Actor, ActorClassWithSpec, Front, FrontClassWithSpec, +"use strict"; + +var {RetVal, Actor, ActorClassWithSpec, Front, FrontClassWithSpec, generateActorSpec} = require("devtools/shared/protocol"); var Services = require("Services"); diff --git a/devtools/server/tests/unit/test_actor-registry-actor.js b/devtools/server/tests/unit/test_actor-registry-actor.js index 8b0abfbbb886..1d704d0f9aa9 100644 --- a/devtools/server/tests/unit/test_actor-registry-actor.js +++ b/devtools/server/tests/unit/test_actor-registry-actor.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that you can register new actors via the ActorRegistrationActor. */ @@ -12,8 +14,7 @@ var gOldPref; const { ActorRegistryFront } = require("devtools/shared/fronts/actor-registry"); -function run_test() -{ +function run_test() { gOldPref = Services.prefs.getBoolPref("devtools.debugger.forbid-certified-apps"); Services.prefs.setBoolPref("devtools.debugger.forbid-certified-apps", false); initTestDebuggerServer(); @@ -39,7 +40,7 @@ function registerNewActor() { gRegistryFront .registerActor("resource://test/hello-actor.js", options) - .then(actorFront => gActorFront = actorFront) + .then(actorFront => (gActorFront = actorFront)) .then(talkToNewActor) .then(null, e => { DevToolsUtils.reportException("registerNewActor", e); diff --git a/devtools/server/tests/unit/test_add_actors.js b/devtools/server/tests/unit/test_add_actors.js index 9b90da72437c..643b9e2e5ce3 100644 --- a/devtools/server/tests/unit/test_add_actors.js +++ b/devtools/server/tests/unit/test_add_actors.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gClient; var gActors; @@ -11,8 +13,7 @@ var gActors; * in order to add actors after initialization but rather can add actors anytime * regardless of the object's state. */ -function run_test() -{ +function run_test() { DebuggerServer.addActors("resource://test/pre_init_global_actors.js"); DebuggerServer.addActors("resource://test/pre_init_tab_actors.js"); @@ -32,52 +33,47 @@ function run_test() run_next_test(); } -function init() -{ +function init() { gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect() .then(() => gClient.listTabs()) - .then(aResponse => { - gActors = aResponse; + .then(response => { + gActors = response; run_next_test(); }); } -function test_pre_init_global_actor() -{ +function test_pre_init_global_actor() { gClient.request({ to: gActors.preInitGlobalActor, type: "ping" }, - function onResponse(aResponse) { - do_check_eq(aResponse.message, "pong"); + function onResponse(response) { + do_check_eq(response.message, "pong"); run_next_test(); } ); } -function test_pre_init_tab_actor() -{ +function test_pre_init_tab_actor() { gClient.request({ to: gActors.preInitTabActor, type: "ping" }, - function onResponse(aResponse) { - do_check_eq(aResponse.message, "pong"); + function onResponse(response) { + do_check_eq(response.message, "pong"); run_next_test(); } ); } -function test_post_init_global_actor() -{ +function test_post_init_global_actor() { gClient.request({ to: gActors.postInitGlobalActor, type: "ping" }, - function onResponse(aResponse) { - do_check_eq(aResponse.message, "pong"); + function onResponse(response) { + do_check_eq(response.message, "pong"); run_next_test(); } ); } -function test_post_init_tab_actor() -{ +function test_post_init_tab_actor() { gClient.request({ to: gActors.postInitTabActor, type: "ping" }, - function onResponse(aResponse) { - do_check_eq(aResponse.message, "pong"); + function onResponse(response) { + do_check_eq(response.message, "pong"); run_next_test(); } ); @@ -88,16 +84,17 @@ function getActorInstance(connID, actorID) { return DebuggerServer._connections[connID].getActor(actorID); } -function test_stable_global_actor_instances() -{ +function test_stable_global_actor_instances() { // Consider that there is only one connection, // and the first one is ours let connID = Object.keys(DebuggerServer._connections)[0]; let postInitGlobalActor = getActorInstance(connID, gActors.postInitGlobalActor); let preInitGlobalActor = getActorInstance(connID, gActors.preInitGlobalActor); - gClient.listTabs(function onListTabs(aResponse) { - do_check_eq(postInitGlobalActor, getActorInstance(connID, aResponse.postInitGlobalActor)); - do_check_eq(preInitGlobalActor, getActorInstance(connID, aResponse.preInitGlobalActor)); + gClient.listTabs(function onListTabs(response) { + do_check_eq(postInitGlobalActor, + getActorInstance(connID, response.postInitGlobalActor)); + do_check_eq(preInitGlobalActor, + getActorInstance(connID, response.preInitGlobalActor)); run_next_test(); }); } diff --git a/devtools/server/tests/unit/test_addon_reload.js b/devtools/server/tests/unit/test_addon_reload.js index 5fbd75ff8ee1..e72988e6d00a 100644 --- a/devtools/server/tests/unit/test_addon_reload.js +++ b/devtools/server/tests/unit/test_addon_reload.js @@ -1,7 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; -const protocol = require("devtools/shared/protocol"); const {AddonManager} = require("resource://gre/modules/AddonManager.jsm"); startupAddonsManager(); @@ -80,7 +82,7 @@ add_task(function* testReloadExitedAddon() { // Uninstall the decoy add-on, which should cause its actor to exit. const onUninstalled = promiseAddonEvent("onUninstalled"); installedAddon2.uninstall(); - const [uninstalledAddon] = yield onUninstalled; + yield onUninstalled; // Try to re-list all add-ons after a reload. // This was throwing an exception because of the exited actor. diff --git a/devtools/server/tests/unit/test_addons_actor.js b/devtools/server/tests/unit/test_addons_actor.js index 1815d43c6ad5..448b7b7afaae 100644 --- a/devtools/server/tests/unit/test_addons_actor.js +++ b/devtools/server/tests/unit/test_addons_actor.js @@ -1,8 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; -const protocol = require("devtools/shared/protocol"); -const {AddonsActor} = require("devtools/server/actors/addons"); const {AddonsFront} = require("devtools/shared/fronts/addons"); startupAddonsManager(); diff --git a/devtools/server/tests/unit/test_animation_name.js b/devtools/server/tests/unit/test_animation_name.js index 4cd708fc4d89..3b9bc0589c7f 100644 --- a/devtools/server/tests/unit/test_animation_name.js +++ b/devtools/server/tests/unit/test_animation_name.js @@ -1,87 +1,87 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Test that AnimationPlayerActor.getName returns the right name depending on -// the type of an animation and the various properties available on it. - -const { AnimationPlayerActor } = require("devtools/server/actors/animation"); - -function run_test() { - // Mock a window with just the properties the AnimationPlayerActor uses. - let window = { - MutationObserver: function () { - this.observe = () => {}; - }, - Animation: function () { - this.effect = {target: getMockNode()}; - }, - CSSAnimation: function () { - this.effect = {target: getMockNode()}; - }, - CSSTransition: function () { - this.effect = {target: getMockNode()}; - } - }; - - window.CSSAnimation.prototype = Object.create(window.Animation.prototype); - window.CSSTransition.prototype = Object.create(window.Animation.prototype); - - // Helper to get a mock DOM node. - function getMockNode() { - return { - ownerDocument: { - defaultView: window - } - }; - } - - // Objects in this array should contain the following properties: - // - desc {String} For logging - // - animation {Object} An animation object instantiated from one of the mock - // window animation constructors. - // - props {Objet} Properties of this object will be added to the animation - // object. - // - expectedName {String} The expected name returned by - // AnimationPlayerActor.getName. - const TEST_DATA = [{ - desc: "Animation with an id", - animation: new window.Animation(), - props: { id: "animation-id" }, - expectedName: "animation-id" - }, { - desc: "Animation without an id", - animation: new window.Animation(), - props: {}, - expectedName: "" - }, { - desc: "CSSTransition with an id", - animation: new window.CSSTransition(), - props: { id: "transition-with-id", transitionProperty: "width" }, - expectedName: "transition-with-id" - }, { - desc: "CSSAnimation with an id", - animation: new window.CSSAnimation(), - props: { id: "animation-with-id", animationName: "move" }, - expectedName: "animation-with-id" - }, { - desc: "CSSTransition without an id", - animation: new window.CSSTransition(), - props: { transitionProperty: "width" }, - expectedName: "width" - }, { - desc: "CSSAnimation without an id", - animation: new window.CSSAnimation(), - props: { animationName: "move" }, - expectedName: "move" - }]; - - for (let { desc, animation, props, expectedName } of TEST_DATA) { - do_print(desc); - for (let key in props) { - animation[key] = props[key]; - } - let actor = AnimationPlayerActor({}, animation); - do_check_eq(actor.getName(), expectedName); - } -} +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test that AnimationPlayerActor.getName returns the right name depending on +// the type of an animation and the various properties available on it. + +const { AnimationPlayerActor } = require("devtools/server/actors/animation"); + +function run_test() { + // Mock a window with just the properties the AnimationPlayerActor uses. + let window = { + MutationObserver: function () { + this.observe = () => {}; + }, + Animation: function () { + this.effect = {target: getMockNode()}; + }, + CSSAnimation: function () { + this.effect = {target: getMockNode()}; + }, + CSSTransition: function () { + this.effect = {target: getMockNode()}; + } + }; + + window.CSSAnimation.prototype = Object.create(window.Animation.prototype); + window.CSSTransition.prototype = Object.create(window.Animation.prototype); + + // Helper to get a mock DOM node. + function getMockNode() { + return { + ownerDocument: { + defaultView: window + } + }; + } + + // Objects in this array should contain the following properties: + // - desc {String} For logging + // - animation {Object} An animation object instantiated from one of the mock + // window animation constructors. + // - props {Objet} Properties of this object will be added to the animation + // object. + // - expectedName {String} The expected name returned by + // AnimationPlayerActor.getName. + const TEST_DATA = [{ + desc: "Animation with an id", + animation: new window.Animation(), + props: { id: "animation-id" }, + expectedName: "animation-id" + }, { + desc: "Animation without an id", + animation: new window.Animation(), + props: {}, + expectedName: "" + }, { + desc: "CSSTransition with an id", + animation: new window.CSSTransition(), + props: { id: "transition-with-id", transitionProperty: "width" }, + expectedName: "transition-with-id" + }, { + desc: "CSSAnimation with an id", + animation: new window.CSSAnimation(), + props: { id: "animation-with-id", animationName: "move" }, + expectedName: "animation-with-id" + }, { + desc: "CSSTransition without an id", + animation: new window.CSSTransition(), + props: { transitionProperty: "width" }, + expectedName: "width" + }, { + desc: "CSSAnimation without an id", + animation: new window.CSSAnimation(), + props: { animationName: "move" }, + expectedName: "move" + }]; + + for (let { desc, animation, props, expectedName } of TEST_DATA) { + do_print(desc); + for (let key in props) { + animation[key] = props[key]; + } + let actor = AnimationPlayerActor({}, animation); + do_check_eq(actor.getName(), expectedName); + } +} diff --git a/devtools/server/tests/unit/test_animation_type.js b/devtools/server/tests/unit/test_animation_type.js index 0f37755a4ee0..c4e842afe67c 100644 --- a/devtools/server/tests/unit/test_animation_type.js +++ b/devtools/server/tests/unit/test_animation_type.js @@ -1,68 +1,68 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// Test the output of AnimationPlayerActor.getType(). - -const { ANIMATION_TYPES, AnimationPlayerActor } = - require("devtools/server/actors/animation"); - -function run_test() { - // Mock a window with just the properties the AnimationPlayerActor uses. - let window = { - MutationObserver: function () { - this.observe = () => {}; - }, - Animation: function () { - this.effect = {target: getMockNode()}; - }, - CSSAnimation: function () { - this.effect = {target: getMockNode()}; - }, - CSSTransition: function () { - this.effect = {target: getMockNode()}; - } - }; - - window.CSSAnimation.prototype = Object.create(window.Animation.prototype); - window.CSSTransition.prototype = Object.create(window.Animation.prototype); - - // Helper to get a mock DOM node. - function getMockNode() { - return { - ownerDocument: { - defaultView: window - } - }; - } - - // Objects in this array should contain the following properties: - // - desc {String} For logging - // - animation {Object} An animation object instantiated from one of the mock - // window animation constructors. - // - expectedType {String} The expected type returned by - // AnimationPlayerActor.getType. - const TEST_DATA = [{ - desc: "Test CSSAnimation type", - animation: new window.CSSAnimation(), - expectedType: ANIMATION_TYPES.CSS_ANIMATION - }, { - desc: "Test CSSTransition type", - animation: new window.CSSTransition(), - expectedType: ANIMATION_TYPES.CSS_TRANSITION - }, { - desc: "Test ScriptAnimation type", - animation: new window.Animation(), - expectedType: ANIMATION_TYPES.SCRIPT_ANIMATION - }, { - desc: "Test unknown type", - animation: {effect: {target: getMockNode()}}, - expectedType: ANIMATION_TYPES.UNKNOWN - }]; - - for (let { desc, animation, expectedType } of TEST_DATA) { - do_print(desc); - let actor = AnimationPlayerActor({}, animation); - do_check_eq(actor.getType(), expectedType); - } -} +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test the output of AnimationPlayerActor.getType(). + +const { ANIMATION_TYPES, AnimationPlayerActor } = + require("devtools/server/actors/animation"); + +function run_test() { + // Mock a window with just the properties the AnimationPlayerActor uses. + let window = { + MutationObserver: function () { + this.observe = () => {}; + }, + Animation: function () { + this.effect = {target: getMockNode()}; + }, + CSSAnimation: function () { + this.effect = {target: getMockNode()}; + }, + CSSTransition: function () { + this.effect = {target: getMockNode()}; + } + }; + + window.CSSAnimation.prototype = Object.create(window.Animation.prototype); + window.CSSTransition.prototype = Object.create(window.Animation.prototype); + + // Helper to get a mock DOM node. + function getMockNode() { + return { + ownerDocument: { + defaultView: window + } + }; + } + + // Objects in this array should contain the following properties: + // - desc {String} For logging + // - animation {Object} An animation object instantiated from one of the mock + // window animation constructors. + // - expectedType {String} The expected type returned by + // AnimationPlayerActor.getType. + const TEST_DATA = [{ + desc: "Test CSSAnimation type", + animation: new window.CSSAnimation(), + expectedType: ANIMATION_TYPES.CSS_ANIMATION + }, { + desc: "Test CSSTransition type", + animation: new window.CSSTransition(), + expectedType: ANIMATION_TYPES.CSS_TRANSITION + }, { + desc: "Test ScriptAnimation type", + animation: new window.Animation(), + expectedType: ANIMATION_TYPES.SCRIPT_ANIMATION + }, { + desc: "Test unknown type", + animation: {effect: {target: getMockNode()}}, + expectedType: ANIMATION_TYPES.UNKNOWN + }]; + + for (let { desc, animation, expectedType } of TEST_DATA) { + do_print(desc); + let actor = AnimationPlayerActor({}, animation); + do_check_eq(actor.getType(), expectedType); + } +} diff --git a/devtools/server/tests/unit/test_attach.js b/devtools/server/tests/unit/test_attach.js index a69db2c2ba05..3efbb596160a 100644 --- a/devtools/server/tests/unit/test_attach.js +++ b/devtools/server/tests/unit/test_attach.js @@ -1,36 +1,35 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gClient; var gDebuggee; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-1"); DebuggerServer.addTestGlobal(gDebuggee); let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); - gClient.connect().then(function ([aType, aTraits]) { - attachTestTab(gClient, "test-1", function (aReply, aTabClient) { - test_attach(aTabClient); + gClient.connect().then(function ([type, traits]) { + attachTestTab(gClient, "test-1", function (reply, tabClient) { + test_attach(tabClient); }); }); do_test_pending(); } -function test_attach(aTabClient) -{ - aTabClient.attachThread({}, function (aResponse, aThreadClient) { - do_check_eq(aThreadClient.state, "paused"); - aThreadClient.resume(cleanup); +function test_attach(tabClient) { + tabClient.attachThread({}, function (response, threadClient) { + do_check_eq(threadClient.state, "paused"); + threadClient.resume(cleanup); }); } -function cleanup() -{ - gClient.addListener("closed", function (aEvent) { +function cleanup() { + gClient.addListener("closed", function (event) { do_test_finished(); }); gClient.close(); diff --git a/devtools/server/tests/unit/test_blackboxing-01.js b/devtools/server/tests/unit/test_blackboxing-01.js index d5356c39035d..9e9d0a70244c 100644 --- a/devtools/server/tests/unit/test_blackboxing-01.js +++ b/devtools/server/tests/unit/test_blackboxing-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test basic black boxing. */ @@ -9,16 +11,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - testBlackBox(); - }); + attachTestTabAndResume(gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + testBlackBox(); + }); }); do_test_pending(); } @@ -43,27 +45,27 @@ const testBlackBox = Task.async(function* () { // Test that we can step into `doStuff` when we are not black boxed. yield runTest( - function onSteppedLocation(aLocation) { - do_check_eq(aLocation.source.url, BLACK_BOXED_URL); - do_check_eq(aLocation.line, 2); + function onSteppedLocation(location) { + do_check_eq(location.source.url, BLACK_BOXED_URL); + do_check_eq(location.line, 2); }, - function onDebuggerStatementFrames(aFrames) { - do_check_true(!aFrames.some(f => f.where.source.isBlackBoxed)); + function onDebuggerStatementFrames(frames) { + do_check_true(!frames.some(f => f.where.source.isBlackBoxed)); } ); - let blackBoxResponse = yield blackBox(sourceClient); + yield blackBox(sourceClient); do_check_true(sourceClient.isBlackBoxed); // Test that we step through `doStuff` when we are black boxed and its frame // doesn't show up. yield runTest( - function onSteppedLocation(aLocation) { - do_check_eq(aLocation.source.url, SOURCE_URL); - do_check_eq(aLocation.line, 4); + function onSteppedLocation(location) { + do_check_eq(location.source.url, SOURCE_URL); + do_check_eq(location.line, 4); }, - function onDebuggerStatementFrames(aFrames) { - for (let f of aFrames) { + function onDebuggerStatementFrames(frames) { + for (let f of frames) { if (f.where.source.url == BLACK_BOXED_URL) { do_check_true(f.where.source.isBlackBoxed); } else { @@ -73,17 +75,17 @@ const testBlackBox = Task.async(function* () { } ); - let unBlackBoxResponse = yield unBlackBox(sourceClient); + yield unBlackBox(sourceClient); do_check_true(!sourceClient.isBlackBoxed); // Test that we can step into `doStuff` again. yield runTest( - function onSteppedLocation(aLocation) { - do_check_eq(aLocation.source.url, BLACK_BOXED_URL); - do_check_eq(aLocation.line, 2); + function onSteppedLocation(location) { + do_check_eq(location.source.url, BLACK_BOXED_URL); + do_check_eq(location.line, 2); }, - function onDebuggerStatementFrames(aFrames) { - do_check_true(!aFrames.some(f => f.where.source.isBlackBoxed)); + function onDebuggerStatementFrames(frames) { + do_check_true(!frames.some(f => f.where.source.isBlackBoxed)); } ); @@ -91,6 +93,7 @@ const testBlackBox = Task.async(function* () { }); function evalCode() { + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 let arg = 15; // line 2 - Step in here @@ -116,6 +119,7 @@ function evalCode() { SOURCE_URL, 1 ); + /* eslint-enable */ } const runTest = Task.async(function* (onSteppedLocation, onDebuggerStatementFrames) { diff --git a/devtools/server/tests/unit/test_blackboxing-02.js b/devtools/server/tests/unit/test_blackboxing-02.js index 5bfb3641a7b8..66bf08257a5a 100644 --- a/devtools/server/tests/unit/test_blackboxing-02.js +++ b/devtools/server/tests/unit/test_blackboxing-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that we don't hit breakpoints in black boxed sources, and that when we @@ -11,16 +14,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_black_box(); - }); + attachTestTabAndResume(gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_black_box(); + }); }); do_test_pending(); } @@ -28,27 +31,27 @@ function run_test() const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; const SOURCE_URL = "http://example.com/source.js"; -function test_black_box() -{ - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(aPacket.frame.actor, "doStuff", function (aResponse) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return); +function test_black_box() { + gClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(packet.frame.actor, "doStuff", function (response) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return); obj.getDefinitionSite(runWithSource); }); }); - function runWithSource(aPacket) { - let source = gThreadClient.source(aPacket.source); + function runWithSource(packet) { + let source = gThreadClient.source(packet.source); source.setBreakpoint({ line: 2 - }, function (aResponse) { - do_check_true(!aResponse.error, "Should be able to set breakpoint."); + }, function (response) { + do_check_true(!response.error, "Should be able to set breakpoint."); gThreadClient.resume(test_black_box_breakpoint); }); } }); + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 let arg = 15; // line 2 - Break here @@ -74,18 +77,22 @@ function test_black_box() SOURCE_URL, 1 ); + /* eslint-enable */ } function test_black_box_breakpoint() { gThreadClient.getSources(function ({error, sources}) { do_check_true(!error, "Should not get an error: " + error); - let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); + let sourceClient = gThreadClient.source( + sources.filter(s => s.url == BLACK_BOXED_URL)[0] + ); sourceClient.blackBox(function ({error}) { do_check_true(!error, "Should not get an error: " + error); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "debuggerStatement", - "We should pass over the breakpoint since the source is black boxed."); + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq( + packet.why.type, "debuggerStatement", + "We should pass over the breakpoint since the source is black boxed."); gThreadClient.resume(test_unblack_box_breakpoint.bind(null, sourceClient)); }); gDebuggee.runTest(); @@ -93,14 +100,15 @@ function test_black_box_breakpoint() { }); } -function test_unblack_box_breakpoint(aSourceClient) { - aSourceClient.unblackBox(function ({error}) { +function test_unblack_box_breakpoint(sourceClient) { + sourceClient.unblackBox(function ({error}) { do_check_true(!error, "Should not get an error: " + error); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "breakpoint", + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "breakpoint", "We should hit the breakpoint again"); - // We will hit the debugger statement on resume, so do this nastiness to skip over it. + // We will hit the debugger statement on resume, so do this + // nastiness to skip over it. gClient.addOneTimeListener( "paused", gThreadClient.resume.bind( diff --git a/devtools/server/tests/unit/test_blackboxing-03.js b/devtools/server/tests/unit/test_blackboxing-03.js index 48f1787772aa..78e1d85fcbd0 100644 --- a/devtools/server/tests/unit/test_blackboxing-03.js +++ b/devtools/server/tests/unit/test_blackboxing-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Test that we don't stop at debugger statements inside black boxed sources. @@ -10,16 +13,16 @@ var gClient; var gThreadClient; var gBpClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_black_box(); - }); + attachTestTabAndResume(gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_black_box(); + }); }); do_test_pending(); } @@ -27,10 +30,9 @@ function run_test() const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; const SOURCE_URL = "http://example.com/source.js"; -function test_black_box() -{ - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_black_box() { + gClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); source.setBreakpoint({ line: 4 }, function ({error}, bpClient) { @@ -40,6 +42,7 @@ function test_black_box() }); }); + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 debugger; // line 2 - Break here @@ -65,18 +68,21 @@ function test_black_box() SOURCE_URL, 1 ); + /* eslint-enable */ } function test_black_box_dbg_statement() { gThreadClient.getSources(function ({error, sources}) { do_check_true(!error, "Should not get an error: " + error); - let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); + let sourceClient = gThreadClient.source( + sources.filter(s => s.url == BLACK_BOXED_URL)[0] + ); sourceClient.blackBox(function ({error}) { do_check_true(!error, "Should not get an error: " + error); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "breakpoint", + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "breakpoint", "We should pass over the debugger statement."); gBpClient.remove(function ({error}) { do_check_true(!error, "Should not get an error: " + error); @@ -88,12 +94,12 @@ function test_black_box_dbg_statement() { }); } -function test_unblack_box_dbg_statement(aSourceClient) { - aSourceClient.unblackBox(function ({error}) { +function test_unblack_box_dbg_statement(sourceClient) { + sourceClient.unblackBox(function ({error}) { do_check_true(!error, "Should not get an error: " + error); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "debuggerStatement", + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "debuggerStatement", "We should stop at the debugger statement again"); finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_blackboxing-04.js b/devtools/server/tests/unit/test_blackboxing-04.js index fbfaf288177e..9952ff302fcb 100644 --- a/devtools/server/tests/unit/test_blackboxing-04.js +++ b/devtools/server/tests/unit/test_blackboxing-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test behavior of blackboxing sources we are currently paused in. @@ -9,16 +12,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_black_box(); - }); + attachTestTabAndResume(gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_black_box(); + }); }); do_test_pending(); } @@ -26,27 +29,27 @@ function run_test() const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; const SOURCE_URL = "http://example.com/source.js"; -function test_black_box() -{ - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(aPacket.frame.actor, "doStuff", function (aResponse) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return); +function test_black_box() { + gClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(packet.frame.actor, "doStuff", function (response) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return); obj.getDefinitionSite(runWithSource); }); }); - function runWithSource(aPacket) { - let source = gThreadClient.source(aPacket.source); + function runWithSource(packet) { + let source = gThreadClient.source(packet.source); source.setBreakpoint({ line: 2 - }, function (aResponse) { - do_check_true(!aResponse.error, "Should be able to set breakpoint."); + }, function (response) { + do_check_true(!response.error, "Should be able to set breakpoint."); test_black_box_paused(); }); } }); + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 debugger; // line 2 @@ -72,16 +75,20 @@ function test_black_box() SOURCE_URL, 1 ); + /* eslint-enable */ } function test_black_box_paused() { gThreadClient.getSources(function ({error, sources}) { do_check_true(!error, "Should not get an error: " + error); - let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); + let sourceClient = gThreadClient.source( + sources.filter(s => s.url == BLACK_BOXED_URL)[0] + ); sourceClient.blackBox(function ({error, pausedInSource}) { do_check_true(!error, "Should not get an error: " + error); - do_check_true(pausedInSource, "We should be notified that we are currently paused in this source"); + do_check_true(pausedInSource, + "We should be notified that we are currently paused in this source"); finishClient(gClient); }); }); diff --git a/devtools/server/tests/unit/test_blackboxing-05.js b/devtools/server/tests/unit/test_blackboxing-05.js index fa8142e870e3..1835070ac44b 100644 --- a/devtools/server/tests/unit/test_blackboxing-05.js +++ b/devtools/server/tests/unit/test_blackboxing-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test exceptions inside black boxed sources. @@ -9,21 +12,22 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - // XXX: We have to do an executeSoon so that the error isn't caught and - // reported by DebuggerClient.requester (because we are using the local - // transport and share a stack) which causes the test to fail. - Services.tm.mainThread.dispatch({ - run: test_black_box - }, Ci.nsIThread.DISPATCH_NORMAL); - }); + attachTestTabAndResume( + gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + // XXX: We have to do an executeSoon so that the error isn't caught and + // reported by DebuggerClient.requester (because we are using the local + // transport and share a stack) which causes the test to fail. + Services.tm.mainThread.dispatch({ + run: test_black_box + }, Ci.nsIThread.DISPATCH_NORMAL); + }); }); do_test_pending(); } @@ -31,10 +35,10 @@ function run_test() const BLACK_BOXED_URL = "http://example.com/blackboxme.js"; const SOURCE_URL = "http://example.com/source.js"; -function test_black_box() -{ +function test_black_box() { gClient.addOneTimeListener("paused", test_black_box_exception); + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2 @@ -61,19 +65,22 @@ function test_black_box() SOURCE_URL, 1 ); + /* eslint-enable */ } function test_black_box_exception() { gThreadClient.getSources(function ({error, sources}) { do_check_true(!error, "Should not get an error: " + error); - let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]); + let sourceClient = gThreadClient.source( + sources.filter(s => s.url == BLACK_BOXED_URL)[0] + ); sourceClient.blackBox(function ({error}) { do_check_true(!error, "Should not get an error: " + error); gThreadClient.pauseOnExceptions(true); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.frame.where.source.url, SOURCE_URL, + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.frame.where.source.url, SOURCE_URL, "We shouldn't pause while in the black boxed source."); finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_blackboxing-06.js b/devtools/server/tests/unit/test_blackboxing-06.js index 9384f2cc25f1..2f6bfcc4e3a0 100644 --- a/devtools/server/tests/unit/test_blackboxing-06.js +++ b/devtools/server/tests/unit/test_blackboxing-06.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that we can black box source mapped sources. @@ -11,31 +14,33 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + attachTestTabAndResume( + gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; - promise.resolve(setup_code()) - .then(black_box_code) - .then(run_code) - .then(test_correct_location) - .then(null, function (error) { - do_check_true(false, "Should not get an error, got " + error); - }) - .then(function () { - finishClient(gClient); - }); - }); + promise.resolve(setup_code()) + .then(black_box_code) + .then(run_code) + .then(test_correct_location) + .then(null, function (error) { + do_check_true(false, "Should not get an error, got " + error); + }) + .then(function () { + finishClient(gClient); + }); + }); }); do_test_pending(); } function setup_code() { + /* eslint-disable */ let { code, map } = (new SourceNode(null, null, null, [ new SourceNode(1, 0, "a.js", "" + function a() { return b(); @@ -54,6 +59,7 @@ function setup_code() { file: "abc.js", sourceRoot: "http://example.com/" }); + /* eslint-enable */ code += "//# sourceMappingURL=data:text/json," + map.toString(); @@ -85,8 +91,8 @@ function black_box_code() { function run_code() { const d = promise.defer(); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - d.resolve(aPacket); + gClient.addOneTimeListener("paused", function (event, packet) { + d.resolve(packet); gThreadClient.resume(); }); gDebuggee.a(); @@ -94,9 +100,10 @@ function run_code() { return d.promise; } -function test_correct_location(aPacket) { - do_check_eq(aPacket.why.type, "debuggerStatement", +function test_correct_location(packet) { + do_check_eq(packet.why.type, "debuggerStatement", "Should hit a debugger statement."); - do_check_eq(aPacket.frame.where.source.url, "http://example.com/c.js", - "Should have skipped over the debugger statement in the black boxed source"); + do_check_eq(packet.frame.where.source.url, "http://example.com/c.js", + "Should have skipped over the debugger statement in the" + + " black boxed source"); } diff --git a/devtools/server/tests/unit/test_blackboxing-07.js b/devtools/server/tests/unit/test_blackboxing-07.js index da31470210ab..edb65b53b0f0 100644 --- a/devtools/server/tests/unit/test_blackboxing-07.js +++ b/devtools/server/tests/unit/test_blackboxing-07.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that sources whose URL ends with ".min.js" automatically get black * boxed. @@ -10,16 +12,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-black-box"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - testBlackBox(); - }); + attachTestTabAndResume(gClient, "test-black-box", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + testBlackBox(); + }); }); do_test_pending(); } diff --git a/devtools/server/tests/unit/test_breakpoint-01.js b/devtools/server/tests/unit/test_breakpoint-01.js index 9a20257a3ef0..63e678be3c46 100644 --- a/devtools/server/tests/unit/test_breakpoint-01.js +++ b/devtools/server/tests/unit/test_breakpoint-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check basic breakpoint functionality. @@ -9,55 +12,52 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 3 }; - source.setBreakpoint(location, function (aResponse, bpClient) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + source.setBreakpoint(location, function (response, bpClient) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); }); - }); // Continue until the breakpoint is hit. @@ -65,6 +65,7 @@ function test_simple_breakpoint() }); }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 @@ -72,4 +73,5 @@ function test_simple_breakpoint() "var b = 2;\n", // line0 + 3 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-02.js b/devtools/server/tests/unit/test_breakpoint-02.js index d2b220d8303f..185b9fcc1e1c 100644 --- a/devtools/server/tests/unit/test_breakpoint-02.js +++ b/devtools/server/tests/unit/test_breakpoint-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Check that setting breakpoints when the debuggee is running works. @@ -10,46 +13,44 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_breakpoint_running(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_breakpoint_running(); + }); }); } -function test_breakpoint_running() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_breakpoint_running() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { let location = { line: gDebuggee.line0 + 3 }; gThreadClient.resume(); // Setting the breakpoint later should interrupt the debuggee. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "interrupted"); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "interrupted"); }); - let source = gThreadClient.source(aPacket.frame.where.source); - source.setBreakpoint(location, function (aResponse) { + let source = gThreadClient.source(packet.frame.where.source); + source.setBreakpoint(location, function (response) { // Eval scripts don't stick around long enough for the breakpoint to be set, // so just make sure we got the expected response from the actor. - do_check_neq(aResponse.error, "noScript"); + do_check_neq(response.error, "noScript"); do_execute_soon(function () { gClient.close().then(gCallback); @@ -57,6 +58,7 @@ function test_breakpoint_running() }); }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "debugger;\n" + @@ -64,4 +66,5 @@ function test_breakpoint_running() "var b = 2;\n", // line0 + 3 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-03.js b/devtools/server/tests/unit/test_breakpoint-03.js index b1792866b61b..652ecbee67ea 100644 --- a/devtools/server/tests/unit/test_breakpoint-03.js +++ b/devtools/server/tests/unit/test_breakpoint-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint on a line without code will skip @@ -12,68 +15,66 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-stack", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test_skip_breakpoint(); }); }); } -var test_no_skip_breakpoint = Task.async(function*(source, location) { - let [aResponse, bpClient] = yield source.setBreakpoint( +var test_no_skip_breakpoint = Task.async(function* (source, location) { + let [response, bpClient] = yield source.setBreakpoint( Object.assign({}, location, { noSliding: true }) ); - do_check_true(!aResponse.actualLocation); + do_check_true(!response.actualLocation); do_check_eq(bpClient.location.line, gDebuggee.line0 + 3); yield bpClient.remove(); }); -var test_skip_breakpoint = function() { - gThreadClient.addOneTimeListener("paused", Task.async(function *(aEvent, aPacket) { +var test_skip_breakpoint = function () { + gThreadClient.addOneTimeListener("paused", Task.async(function* (event, packet) { let location = { line: gDebuggee.line0 + 3 }; - let source = gThreadClient.source(aPacket.frame.where.source); + let source = gThreadClient.source(packet.frame.where.source); // First, make sure that we can disable sliding with the // `noSliding` option. yield test_no_skip_breakpoint(source, location); // Now make sure that the breakpoint properly slides forward one line. - const [aResponse, bpClient] = yield source.setBreakpoint(location); - do_check_true(!!aResponse.actualLocation); - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + const [response, bpClient] = yield source.setBreakpoint(location); + do_check_true(!!response.actualLocation); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -85,6 +86,7 @@ var test_skip_breakpoint = function() { // Use `evalInSandbox` to make the debugger treat it as normal // globally-scoped code, where breakpoint sliding rules apply. + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 @@ -93,4 +95,5 @@ var test_skip_breakpoint = function() { "var b = 2;", // line0 + 4 gDebuggee ); -} + /* eslint-enable */ +}; diff --git a/devtools/server/tests/unit/test_breakpoint-04.js b/devtools/server/tests/unit/test_breakpoint-04.js index 9004c092b285..896dfd50c631 100644 --- a/devtools/server/tests/unit/test_breakpoint-04.js +++ b/devtools/server/tests/unit/test_breakpoint-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line in a child script works. @@ -10,51 +13,49 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_breakpoint(); + }); }); } -function test_child_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_child_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 3 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // actualLocation is not returned when breakpoints don't skip forward. - do_check_eq(aResponse.actualLocation, undefined); + do_check_eq(response.actualLocation, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -64,9 +65,9 @@ function test_child_breakpoint() // Continue until the breakpoint is hit. gThreadClient.resume(); }); - }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 @@ -77,4 +78,5 @@ function test_child_breakpoint() "foo();\n", // line0 + 6 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-05.js b/devtools/server/tests/unit/test_breakpoint-05.js index 9e04d0271578..3d2183b73dd5 100644 --- a/devtools/server/tests/unit/test_breakpoint-05.js +++ b/devtools/server/tests/unit/test_breakpoint-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line without code in a child script @@ -11,52 +14,50 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_skip_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_skip_breakpoint(); + }); }); } -function test_child_skip_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_child_skip_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 3 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -68,6 +69,7 @@ function test_child_skip_breakpoint() }); }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 @@ -79,4 +81,5 @@ function test_child_skip_breakpoint() "foo();\n", // line0 + 7 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-06.js b/devtools/server/tests/unit/test_breakpoint-06.js index aa92b1a5f38d..80f7ae6c214b 100644 --- a/devtools/server/tests/unit/test_breakpoint-06.js +++ b/devtools/server/tests/unit/test_breakpoint-06.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line without code in a deeply-nested @@ -11,52 +14,50 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_nested_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_nested_breakpoint(); + }); }); } -function test_nested_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_nested_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 5 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -66,9 +67,9 @@ function test_nested_breakpoint() // Continue until the breakpoint is hit. gThreadClient.resume(); }); - }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 @@ -86,4 +87,5 @@ function test_nested_breakpoint() "foo();\n", // line0 + 13 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-07.js b/devtools/server/tests/unit/test_breakpoint-07.js index 008f1424d0f0..84c1c46e86c7 100644 --- a/devtools/server/tests/unit/test_breakpoint-07.js +++ b/devtools/server/tests/unit/test_breakpoint-07.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line without code in the second child @@ -11,52 +14,50 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_second_child_skip_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_second_child_skip_breakpoint(); + }); }); } -function test_second_child_skip_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_second_child_skip_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 6 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -68,6 +69,7 @@ function test_second_child_skip_breakpoint() }); }); + /* eslint-disable */ Cu.evalInSandbox( "var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 @@ -82,4 +84,5 @@ function test_second_child_skip_breakpoint() "foo();\n", // line0 + 10 gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-08.js b/devtools/server/tests/unit/test_breakpoint-08.js index 6215a61ac685..62bc31763597 100644 --- a/devtools/server/tests/unit/test_breakpoint-08.js +++ b/devtools/server/tests/unit/test_breakpoint-08.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line without code in a child script @@ -11,60 +14,58 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_skip_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_skip_breakpoint(); + }); }); } -function test_child_skip_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(aPacket.frame.actor, "foo", function (aResponse) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return); +function test_child_skip_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(packet.frame.actor, "foo", function (response) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return); obj.getDefinitionSite(runWithBreakpoint); }); }); - function runWithBreakpoint(aPacket) { - let source = gThreadClient.source(aPacket.source); + function runWithBreakpoint(packet) { + let source = gThreadClient.source(packet.source); let location = { line: gDebuggee.line0 + 3 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -77,6 +78,7 @@ function test_child_skip_breakpoint() } }); + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 @@ -93,4 +95,5 @@ function test_child_skip_breakpoint() gDebuggee, "1.7", "script2.js"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-09.js b/devtools/server/tests/unit/test_breakpoint-09.js index 8bea375b98e5..888f1105a9f0 100644 --- a/devtools/server/tests/unit/test_breakpoint-09.js +++ b/devtools/server/tests/unit/test_breakpoint-09.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that removing a breakpoint works. @@ -10,51 +13,49 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_remove_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_remove_breakpoint(); + }); }); } -function test_remove_breakpoint() -{ +function test_remove_breakpoint() { let done = false; - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 2 }; - source.setBreakpoint(location, function (aResponse, bpClient) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + source.setBreakpoint(location, function (response, bpClient) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { done = true; gThreadClient.addOneTimeListener("paused", - function (aEvent, aPacket) { + function (event, packet) { // The breakpoint should not be hit again. gThreadClient.resume(function () { do_check_true(false); @@ -62,15 +63,13 @@ function test_remove_breakpoint() }); gThreadClient.resume(); }); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); - }); - }); + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "function foo(stop) {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 @@ -81,6 +80,7 @@ function test_remove_breakpoint() "debugger;\n" + // line1 + 7 "foo();\n", // line1 + 8 gDebuggee); + /* eslint-enable */ if (!done) { do_check_true(false); } diff --git a/devtools/server/tests/unit/test_breakpoint-10.js b/devtools/server/tests/unit/test_breakpoint-10.js index c6957676704a..99106bad3f5b 100644 --- a/devtools/server/tests/unit/test_breakpoint-10.js +++ b/devtools/server/tests/unit/test_breakpoint-10.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that setting a breakpoint in a line with multiple entry points @@ -11,56 +14,54 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_breakpoint(); + }); }); } -function test_child_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_child_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 3 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // actualLocation is not returned when breakpoints don't skip forward. - do_check_eq(aResponse.actualLocation, undefined); + do_check_eq(response.actualLocation, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.i, 0); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.i, 1); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -69,16 +70,13 @@ function test_child_breakpoint() // Continue until the breakpoint is hit again. gThreadClient.resume(); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); - }); - }); - + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a, i = 0;\n" + // line0 + 2 @@ -86,4 +84,5 @@ function test_child_breakpoint() " a = i;\n" + // line0 + 4 "}\n", // line0 + 5 gDebuggee); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-11.js b/devtools/server/tests/unit/test_breakpoint-11.js index 480b95984d24..8b3aba3e4dc0 100644 --- a/devtools/server/tests/unit/test_breakpoint-11.js +++ b/devtools/server/tests/unit/test_breakpoint-11.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Make sure that setting a breakpoint in a line with bytecodes in multiple @@ -11,57 +14,55 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_breakpoint(); + }); }); } -function test_child_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_child_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 2 }; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // actualLocation is not returned when breakpoints don't skip forward. - do_check_eq(aResponse.actualLocation, undefined); + do_check_eq(response.actualLocation, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a.b, 1); do_check_eq(gDebuggee.res, undefined); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { gClient.close().then(gCallback); }); @@ -70,19 +71,17 @@ function test_child_breakpoint() // Continue until the breakpoint is hit again. gThreadClient.resume(); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); - }); - }); - + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a = { b: 1, f: function() { return 2; } };\n" + // line0+2 "var res = a.f();\n", // line0 + 3 gDebuggee); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-12.js b/devtools/server/tests/unit/test_breakpoint-12.js index fb147da9f29f..6e890cff39a6 100644 --- a/devtools/server/tests/unit/test_breakpoint-12.js +++ b/devtools/server/tests/unit/test_breakpoint-12.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Make sure that setting a breakpoint twice in a line without bytecodes works @@ -14,47 +17,45 @@ var gBpActor; var gCount; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; +function run_test_with_server(server, callback) { + gCallback = callback; gCount = 1; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_child_skip_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_child_skip_breakpoint(); + }); }); } -function test_child_skip_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_child_skip_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 3}; - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); - gBpActor = aResponse.actor; + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); + gBpActor = response.actor; // Set more breakpoints at the same location. set_breakpoints(source, location); }); - }); + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 @@ -64,17 +65,18 @@ function test_child_skip_breakpoint() "debugger;\n" + // line0 + 6 "foo();\n", // line0 + 7 gDebuggee); + /* eslint-enable */ } // Set many breakpoints at the same location. function set_breakpoints(source, location) { do_check_neq(gCount, NUM_BREAKPOINTS); - source.setBreakpoint(location, function (aResponse, bpClient) { + source.setBreakpoint(location, function (response, bpClient) { // Check that the breakpoint has properly skipped forward one line. - do_check_eq(aResponse.actualLocation.source.actor, source.actor); - do_check_eq(aResponse.actualLocation.line, location.line + 1); + do_check_eq(response.actualLocation.source.actor, source.actor); + do_check_eq(response.actualLocation.line, location.line + 1); // Check that the same breakpoint actor was returned. - do_check_eq(aResponse.actor, gBpActor); + do_check_eq(response.actor, gBpActor); if (++gCount < NUM_BREAKPOINTS) { set_breakpoints(source, location); @@ -83,18 +85,18 @@ function set_breakpoints(source, location) { // After setting all the breakpoints, check that only one has effectively // remained. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line + 1); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line + 1); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); // Check that the breakpoint worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // We don't expect any more pauses after the breakpoint was hit once. do_check_true(false); }); @@ -104,10 +106,8 @@ function set_breakpoints(source, location) { gClient.close().then(gCallback); }); }); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); }); - } diff --git a/devtools/server/tests/unit/test_breakpoint-13.js b/devtools/server/tests/unit/test_breakpoint-13.js index cdc4c9091e6a..533466da36d0 100644 --- a/devtools/server/tests/unit/test_breakpoint-13.js +++ b/devtools/server/tests/unit/test_breakpoint-13.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Check that execution doesn't pause twice while stepping, when encountering @@ -11,80 +14,78 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 2 }; - source.setBreakpoint(location, Task.async(function* (aResponse, bpClient) { + source.setBreakpoint(location, Task.async(function* (response, bpClient) { const testCallbacks = [ - function (aPacket) { + function (packet) { // Check that the stepping worked. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Entered the foo function call frame. - do_check_eq(aPacket.frame.where.line, location.line); - do_check_neq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, location.line); + do_check_neq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // At the end of the foo function call frame. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_neq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_neq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Check that the breakpoint wasn't the reason for this pause, but // that the frame is about to be popped while stepping. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_neq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.why.frameFinished.return.type, "undefined"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_neq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.why.frameFinished.return.type, "undefined"); }, - function (aPacket) { + function (packet) { // The foo function call frame was just popped from the stack. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.poppedFrames.length, 1); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.poppedFrames.length, 1); }, - function (aPacket) { + function (packet) { // Check that the debugger statement wasn't the reason for this pause. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6); - do_check_neq(aPacket.why.type, "debuggerStatement"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 6); + do_check_neq(packet.why.type, "debuggerStatement"); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Check that the debugger statement wasn't the reason for this pause. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7); - do_check_neq(aPacket.why.type, "debuggerStatement"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 7); + do_check_neq(packet.why.type, "debuggerStatement"); + do_check_eq(packet.why.type, "resumeLimit"); }, ]; @@ -103,6 +104,7 @@ function test_simple_breakpoint() })); }); + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 <-- Breakpoint is set here. @@ -112,4 +114,5 @@ function test_simple_breakpoint() "debugger;\n" + // line0 + 6 "var b = 2;\n", // line0 + 7 gDebuggee); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-14.js b/devtools/server/tests/unit/test_breakpoint-14.js index aa86975b66d6..3846e5778c52 100644 --- a/devtools/server/tests/unit/test_breakpoint-14.js +++ b/devtools/server/tests/unit/test_breakpoint-14.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Check that a breakpoint or a debugger statement cause execution to pause even @@ -11,78 +14,76 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 2 }; - source.setBreakpoint(location, Task.async(function* (aResponse, bpClient) { + source.setBreakpoint(location, Task.async(function* (response, bpClient) { const testCallbacks = [ - function (aPacket) { + function (packet) { // Check that the stepping worked. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Reached the breakpoint. - do_check_eq(aPacket.frame.where.line, location.line); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_neq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, location.line); + do_check_eq(packet.why.type, "breakpoint"); + do_check_neq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Stepped to the closing brace of the function. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // The frame is about to be popped while stepping. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_neq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.why.frameFinished.return.type, "undefined"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_neq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.why.frameFinished.return.type, "undefined"); }, - function (aPacket) { + function (packet) { // The foo function call frame was just popped from the stack. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.poppedFrames.length, 1); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.poppedFrames.length, 1); }, - function (aPacket) { + function (packet) { // Check that the debugger statement wasn't the reason for this pause. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6); - do_check_neq(aPacket.why.type, "debuggerStatement"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 6); + do_check_neq(packet.why.type, "debuggerStatement"); + do_check_eq(packet.why.type, "resumeLimit"); }, - function (aPacket) { + function (packet) { // Check that the debugger statement wasn't the reason for this pause. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7); - do_check_neq(aPacket.why.type, "debuggerStatement"); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 7); + do_check_neq(packet.why.type, "debuggerStatement"); + do_check_eq(packet.why.type, "resumeLimit"); }, ]; @@ -101,6 +102,7 @@ function test_simple_breakpoint() })); }); + /* eslint-disable */ Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + "function foo() {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 <-- Breakpoint is set here. @@ -110,4 +112,5 @@ function test_simple_breakpoint() "debugger;\n" + // line0 + 6 "var b = 2;\n", // line0 + 7 gDebuggee); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-15.js b/devtools/server/tests/unit/test_breakpoint-15.js index 6a3ab7c6f556..57b2d101007b 100644 --- a/devtools/server/tests/unit/test_breakpoint-15.js +++ b/devtools/server/tests/unit/test_breakpoint-15.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that adding a breakpoint in the same place returns the same actor. */ @@ -9,16 +11,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - testSameBreakpoint(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + testSameBreakpoint(); + }); }); do_test_pending(); } @@ -34,10 +36,11 @@ const testSameBreakpoint = Task.async(function* () { line: 2 }; - let [firstResponse, firstBpClient] = yield setBreakpoint(source, wholeLineLocation); - let [secondResponse, secondBpClient] = yield setBreakpoint(source, wholeLineLocation); + let [, firstBpClient] = yield setBreakpoint(source, wholeLineLocation); + let [, secondBpClient] = yield setBreakpoint(source, wholeLineLocation); - do_check_eq(firstBpClient.actor, secondBpClient.actor, "Should get the same actor w/ whole line breakpoints"); + do_check_eq(firstBpClient.actor, secondBpClient.actor, + "Should get the same actor w/ whole line breakpoints"); // Specific column @@ -46,15 +49,17 @@ const testSameBreakpoint = Task.async(function* () { column: 6 }; - [firstResponse, firstBpClient] = yield setBreakpoint(source, columnLocation); - [secondResponse, secondBpClient] = yield setBreakpoint(source, columnLocation); + [, firstBpClient] = yield setBreakpoint(source, columnLocation); + [, secondBpClient] = yield setBreakpoint(source, columnLocation); - do_check_eq(secondBpClient.actor, secondBpClient.actor, "Should get the same actor column breakpoints"); + do_check_eq(secondBpClient.actor, secondBpClient.actor, + "Should get the same actor column breakpoints"); finishClient(gClient); }); function evalCode() { + /* eslint-disable */ Components.utils.evalInSandbox( "" + function doStuff(k) { // line 1 let arg = 15; // line 2 - Step in here @@ -66,4 +71,5 @@ function evalCode() { SOURCE_URL, 1 ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-16.js b/devtools/server/tests/unit/test_breakpoint-16.js index 43a9086ecad1..27befc8468d7 100644 --- a/devtools/server/tests/unit/test_breakpoint-16.js +++ b/devtools/server/tests/unit/test_breakpoint-16.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that we can set breakpoints in columns, not just lines. @@ -10,57 +13,54 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-breakpoints", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test_column_breakpoint(); }); }); } -function test_column_breakpoint() -{ +function test_column_breakpoint() { // Debugger statement - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); + gClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); let location = { line: gDebuggee.line0 + 1, column: 55 }; let timesBreakpointHit = 0; - source.setBreakpoint(location, function (aResponse, bpClient) { - gThreadClient.addListener("paused", function onPaused(aEvent, aPacket) { - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.why.actors[0], bpClient.actor); - do_check_eq(aPacket.frame.where.source.actor, source.actor); - do_check_eq(aPacket.frame.where.line, location.line); - do_check_eq(aPacket.frame.where.column, location.column); + source.setBreakpoint(location, function (response, bpClient) { + gThreadClient.addListener("paused", function onPaused(event, packet) { + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.why.actors[0], bpClient.actor); + do_check_eq(packet.frame.where.source.actor, source.actor); + do_check_eq(packet.frame.where.line, location.line); + do_check_eq(packet.frame.where.column, location.column); do_check_eq(gDebuggee.acc, timesBreakpointHit); - do_check_eq(aPacket.frame.environment.bindings.variables.i.value, + do_check_eq(packet.frame.environment.bindings.variables.i.value, timesBreakpointHit); if (++timesBreakpointHit === 3) { gThreadClient.removeListener("paused", onPaused); - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(() => gClient.close().then(gCallback)); }); } else { @@ -71,13 +71,13 @@ function test_column_breakpoint() // Continue until the breakpoint is hit. gThreadClient.resume(); }); - }); - + /* eslint-disable */ Components.utils.evalInSandbox( "var line0 = Error().lineNumber;\n" + "(function () { debugger; this.acc = 0; for (var i = 0; i < 3; i++) this.acc++; }());", gDebuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_breakpoint-17.js b/devtools/server/tests/unit/test_breakpoint-17.js index 944627e619bc..d5f99a5aed36 100644 --- a/devtools/server/tests/unit/test_breakpoint-17.js +++ b/devtools/server/tests/unit/test_breakpoint-17.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that when we add 2 breakpoints to the same line at different columns and @@ -11,23 +14,22 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, do_test_finished); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-breakpoints", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_breakpoints_columns(); - }); + attachTestTabAndResume(gClient, "test-breakpoints", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_breakpoints_columns(); + }); }); } @@ -56,44 +58,44 @@ function test_breakpoints_columns() { Components.utils.evalInSandbox(code, gDebuggee, "1.8", "http://example.com/", 1); } -function set_breakpoints(aEvent, aPacket) { +function set_breakpoints(event, packet) { let first, second; - let source = gThreadClient.source(aPacket.frame.where.source); + let source = gThreadClient.source(packet.frame.where.source); source.setBreakpoint(firstLocation, function ({ error, actualLocation }, - aBreakpointClient) { + breakpointClient) { do_check_true(!error, "Should not get an error setting the breakpoint"); do_check_true(!actualLocation, "Should not get an actualLocation"); - first = aBreakpointClient; + first = breakpointClient; source.setBreakpoint(secondLocation, function ({ error, actualLocation }, - aBreakpointClient) { + breakpointClient) { do_check_true(!error, "Should not get an error setting the breakpoint"); do_check_true(!actualLocation, "Should not get an actualLocation"); - second = aBreakpointClient; + second = breakpointClient; test_different_actors(first, second); }); }); } -function test_different_actors(aFirst, aSecond) { - do_check_neq(aFirst.actor, aSecond.actor, +function test_different_actors(first, second) { + do_check_neq(first.actor, second.actor, "Each breakpoint should have a different actor"); - test_remove_one(aFirst, aSecond); + test_remove_one(first, second); } -function test_remove_one(aFirst, aSecond) { - aFirst.remove(function ({error}) { +function test_remove_one(first, second) { + first.remove(function ({error}) { do_check_true(!error, "Should not get an error removing a breakpoint"); let hitSecond; - gClient.addListener("paused", function _onPaused(aEvent, {why, frame}) { + gClient.addListener("paused", function _onPaused(event, {why, frame}) { if (why.type == "breakpoint") { hitSecond = true; do_check_eq(why.actors.length, 1, "Should only be paused because of one breakpoint actor"); - do_check_eq(why.actors[0], aSecond.actor, + do_check_eq(why.actors[0], second.actor, "Should be paused because of the correct breakpoint actor"); do_check_eq(frame.where.line, secondLocation.line, "Should be at the right line"); diff --git a/devtools/server/tests/unit/test_breakpoint-18.js b/devtools/server/tests/unit/test_breakpoint-18.js index d153d3eff8f0..1be1676b345b 100644 --- a/devtools/server/tests/unit/test_breakpoint-18.js +++ b/devtools/server/tests/unit/test_breakpoint-18.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we only break on offsets that are entry points for the line we are * breaking on. Bug 907278. @@ -11,26 +13,24 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); gDebuggee.console = { log: x => void x }; - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-breakpoints", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; setUpCode(); }); }); @@ -51,8 +51,8 @@ function setUpCode() { ); } -function setBreakpoint(aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function setBreakpoint(event, packet) { + let source = gThreadClient.source(packet.frame.where.source); gClient.addOneTimeListener("resumed", runCode); source.setBreakpoint({ line: 2 }, ({ error }) => { diff --git a/devtools/server/tests/unit/test_breakpoint-19.js b/devtools/server/tests/unit/test_breakpoint-19.js index da04a52681dc..4de09807bff5 100644 --- a/devtools/server/tests/unit/test_breakpoint-19.js +++ b/devtools/server/tests/unit/test_breakpoint-19.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Make sure that setting a breakpoint in a not-yet-existing script doesn't throw * an error (see bug 897567). Also make sure that this breakpoint works. @@ -9,28 +11,24 @@ var gDebuggee; var gClient; var gThreadClient; -var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); +function run_test_with_server(server, callback) { + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); gDebuggee.console = { log: x => void x }; - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-breakpoints", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; testBreakpoint(); }); }); @@ -39,6 +37,7 @@ function run_test_with_server(aServer, aCallback) const URL = "test.js"; function setUpCode() { + /* eslint-disable */ Cu.evalInSandbox( "" + function test() { // 1 var a = 1; // 2 @@ -49,11 +48,12 @@ function setUpCode() { "1.8", URL ); + /* eslint-enable */ } const testBreakpoint = Task.async(function* () { let source = yield getSource(gThreadClient, URL); - let [response, bpClient] = yield setBreakpoint(source, {line: 2}); + let [response, ] = yield setBreakpoint(source, {line: 2}); ok(!response.error); let actor = response.actor; diff --git a/devtools/server/tests/unit/test_breakpoint-20.js b/devtools/server/tests/unit/test_breakpoint-20.js index b70282dae45b..322fb204e6cb 100644 --- a/devtools/server/tests/unit/test_breakpoint-20.js +++ b/devtools/server/tests/unit/test_breakpoint-20.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Verify that when two of the "same" source are loaded concurrently (like e10s * frame scripts), breakpoints get hit in scripts defined by all sources. @@ -8,11 +10,8 @@ var gDebuggee; var gClient; -var gTraceClient; -var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-breakpoints"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); @@ -22,7 +21,8 @@ function run_test() do_test_pending(); } -const testBreakpoint = Task.async(function* (threadResponse, tabClient, threadClient, tabResponse) { +const testBreakpoint = Task.async(function* (threadResponse, tabClient, + threadClient, tabResponse) { evalSetupCode(); // Load the test source once. @@ -34,7 +34,7 @@ const testBreakpoint = Task.async(function* (threadResponse, tabClient, threadCl // Set a breakpoint in the test source. const source = yield getSource(threadClient, "test.js"); - const [response, bpClient] = yield setBreakpoint(source, { + const [response, ] = yield setBreakpoint(source, { line: 3 }); ok(!response.error, "Shouldn't get an error setting the BP."); diff --git a/devtools/server/tests/unit/test_breakpoint-21.js b/devtools/server/tests/unit/test_breakpoint-21.js index e5f2e9e4a9e5..e59f9f4e827b 100644 --- a/devtools/server/tests/unit/test_breakpoint-21.js +++ b/devtools/server/tests/unit/test_breakpoint-21.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Bug 1122064 - make sure that scripts introduced via onNewScripts * properly populate the `ScriptStore` with all there nested child @@ -10,27 +12,23 @@ var gDebuggee; var gClient; var gThreadClient; -var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-breakpoints", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test(); }); }); @@ -62,6 +60,7 @@ const test = Task.async(function* () { finishClient(gClient); }); +/* eslint-disable */ function evalCode() { // Start a new script Components.utils.evalInSandbox( diff --git a/devtools/server/tests/unit/test_breakpoint-22.js b/devtools/server/tests/unit/test_breakpoint-22.js index 75fe8aa5a20a..f167a4a62276 100644 --- a/devtools/server/tests/unit/test_breakpoint-22.js +++ b/devtools/server/tests/unit/test_breakpoint-22.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Bug 1333219 - make that setBreakpoint fails when script is not found * at the specified line. @@ -9,27 +11,23 @@ var gDebuggee; var gClient; var gThreadClient; -var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-breakpoints", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-breakpoints", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume(gClient, "test-breakpoints", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test(); }); }); @@ -46,7 +44,7 @@ const test = Task.async(function* () { line: gDebuggee.line0 + 2 }; - let [res, bpClient] = yield setBreakpoint(source, location); + let [res, ] = yield setBreakpoint(source, location); ok(!res.error); let location2 = { diff --git a/devtools/server/tests/unit/test_breakpoint-actor-map.js b/devtools/server/tests/unit/test_breakpoint-actor-map.js index d1d149648a23..2c37c9bcc404 100644 --- a/devtools/server/tests/unit/test_breakpoint-actor-map.js +++ b/devtools/server/tests/unit/test_breakpoint-actor-map.js @@ -128,7 +128,9 @@ function test_find_actors() { // Breakpoints by URL - bpSet = new Set(bps.filter(bp => { return bp.originalSourceActor.actorID === "actor1"; })); + bpSet = new Set(bps.filter(bp => { + return bp.originalSourceActor.actorID === "actor1"; + })); for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" } })) { bpSet.delete(bp); } @@ -137,9 +139,12 @@ function test_find_actors() { // Breakpoints by URL and line - bpSet = new Set(bps.filter(bp => { return bp.originalSourceActor.actorID === "actor1" && bp.originalLine === 10; })); + bpSet = new Set(bps.filter(bp => { + return bp.originalSourceActor.actorID === "actor1" && bp.originalLine === 10; + })); let first = true; - for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" }, originalLine: 10 })) { + for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" }, + originalLine: 10 })) { if (first) { do_check_eq(bp.originalColumn, undefined, "Should always get the whole line breakpoint first"); diff --git a/devtools/server/tests/unit/test_client_close.js b/devtools/server/tests/unit/test_client_close.js index 84747e85b8b5..6a6298ec9d3f 100644 --- a/devtools/server/tests/unit/test_client_close.js +++ b/devtools/server/tests/unit/test_client_close.js @@ -1,27 +1,27 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gClient; var gDebuggee; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-1"); DebuggerServer.addTestGlobal(gDebuggee); let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); - gClient.connect().then(function (aType, aTraits) { - attachTestTab(gClient, "test-1", function (aReply, aTabClient) { + gClient.connect().then(function (type, traits) { + attachTestTab(gClient, "test-1", function (reply, tabClient) { test_close(transport); }); }); do_test_pending(); } -function test_close(aTransport) -{ +function test_close(transport) { // Check that, if we fake a transport shutdown // (like if a device is unplugged) // the client is automatically closed, @@ -35,5 +35,5 @@ function test_close(aTransport) }); }; gClient.addListener("closed", onClosed); - aTransport.close(); + transport.close(); } diff --git a/devtools/server/tests/unit/test_client_request.js b/devtools/server/tests/unit/test_client_request.js index c0c2c3a92e29..d01be89cac91 100644 --- a/devtools/server/tests/unit/test_client_request.js +++ b/devtools/server/tests/unit/test_client_request.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test the DebuggerClient.request API. var gClient, gActorId; @@ -24,8 +26,7 @@ TestActor.prototype.requestTypes = { "error": TestActor.prototype.error }; -function run_test() -{ +function run_test() { DebuggerServer.addGlobalActor(TestActor); DebuggerServer.init(); @@ -42,13 +43,12 @@ function run_test() run_next_test(); } -function init() -{ +function init() { gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect() .then(() => gClient.listTabs()) - .then(aResponse => { - gActorId = aResponse.test; + .then(response => { + gActorId = response.test; run_next_test(); }); } @@ -72,8 +72,7 @@ function checkStack(expectedName) { ok(false, "Incomplete stack"); } -function test_client_request_callback() -{ +function test_client_request_callback() { // Test that DebuggerClient.request accepts a `onResponse` callback as 2nd argument gClient.request({ to: gActorId, @@ -86,8 +85,7 @@ function test_client_request_callback() }); } -function test_client_request_promise() -{ +function test_client_request_promise() { // Test that DebuggerClient.request returns a promise that resolves on response let request = gClient.request({ to: gActorId, @@ -102,8 +100,7 @@ function test_client_request_promise() }); } -function test_client_request_promise_error() -{ +function test_client_request_promise_error() { // Test that DebuggerClient.request returns a promise that reject when server // returns an explicit error message let request = gClient.request({ @@ -122,8 +119,7 @@ function test_client_request_promise_error() }); } -function test_client_request_event_emitter() -{ +function test_client_request_event_emitter() { // Test that DebuggerClient.request returns also an EventEmitter object let request = gClient.request({ to: gActorId, @@ -156,7 +152,8 @@ function test_close_client_while_sending_requests() { let expectReply = promise.defer(); gClient.expectReply("root", function (response) { do_check_eq(response.error, "connectionClosed"); - do_check_eq(response.message, "server side packet can't be received as the connection just closed."); + do_check_eq(response.message, + "server side packet can't be received as the connection just closed."); expectReply.resolve(); }); @@ -165,22 +162,23 @@ function test_close_client_while_sending_requests() { ok(false, "First request unexpectedly succeed while closing the connection"); }, response => { do_check_eq(response.error, "connectionClosed"); - do_check_eq(response.message, "'hello' active request packet to '" + gActorId + "' can't be sent as the connection just closed."); + do_check_eq(response.message, "'hello' active request packet to '" + + gActorId + "' can't be sent as the connection just closed."); }) .then(() => pendingRequest) .then(() => { ok(false, "Second request unexpectedly succeed while closing the connection"); }, response => { do_check_eq(response.error, "connectionClosed"); - do_check_eq(response.message, "'hello' pending request packet to '" + gActorId + "' can't be sent as the connection just closed."); + do_check_eq(response.message, "'hello' pending request packet to '" + + gActorId + "' can't be sent as the connection just closed."); }) .then(() => expectReply.promise) .then(run_next_test); }); } -function test_client_request_after_close() -{ +function test_client_request_after_close() { // Test that DebuggerClient.request fails after we called client.close() // (with promise API) let request = gClient.request({ @@ -193,22 +191,23 @@ function test_client_request_after_close() }, response => { ok(true, "Request failed after client.close"); do_check_eq(response.error, "connectionClosed"); - ok(response.message.match(/'hello' request packet to '.*' can't be sent as the connection is closed./)); + ok(response.message.match( + /'hello' request packet to '.*' can't be sent as the connection is closed./)); run_next_test(); }); } -function test_client_request_after_close_callback() -{ +function test_client_request_after_close_callback() { // Test that DebuggerClient.request fails after we called client.close() // (with callback API) - let request = gClient.request({ + gClient.request({ to: gActorId, type: "hello" }, response => { ok(true, "Request failed after client.close"); do_check_eq(response.error, "connectionClosed"); - ok(response.message.match(/'hello' request packet to '.*' can't be sent as the connection is closed./)); + ok(response.message.match( + /'hello' request packet to '.*' can't be sent as the connection is closed./)); run_next_test(); }); } diff --git a/devtools/server/tests/unit/test_conditional_breakpoint-01.js b/devtools/server/tests/unit/test_conditional_breakpoint-01.js index 4661bb0c4c2a..7df85e2a7ff6 100644 --- a/devtools/server/tests/unit/test_conditional_breakpoint-01.js +++ b/devtools/server/tests/unit/test_conditional_breakpoint-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check conditional breakpoint when condition evaluates to true. @@ -9,48 +12,45 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-conditional-breakpoint"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-conditional-breakpoint", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); do_test_pending(); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); source.setBreakpoint({ line: 3, condition: "a === 1" - }, function (aResponse, bpClient) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + }, function (response, bpClient) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.why.type, "breakpoint"); - do_check_eq(aPacket.frame.where.line, 3); + do_check_eq(packet.why.type, "breakpoint"); + do_check_eq(packet.frame.where.line, 3); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { finishClient(gClient); }); }); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); - }); - }); + /* eslint-disable */ Components.utils.evalInSandbox("debugger;\n" + // 1 "var a = 1;\n" + // 2 "var b = 2;\n", // 3 @@ -58,4 +58,5 @@ function test_simple_breakpoint() "1.8", "test.js", 1); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_conditional_breakpoint-02.js b/devtools/server/tests/unit/test_conditional_breakpoint-02.js index 873f761599ba..84c58a836a67 100644 --- a/devtools/server/tests/unit/test_conditional_breakpoint-02.js +++ b/devtools/server/tests/unit/test_conditional_breakpoint-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check conditional breakpoint when condition evaluates to false. @@ -9,46 +12,45 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-conditional-breakpoint"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-conditional-breakpoint", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); do_test_pending(); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); source.setBreakpoint({ line: 3, condition: "a === 2" - }, function (aResponse, bpClient) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + }, function (response, bpClient) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.why.type, "debuggerStatement"); - do_check_eq(aPacket.frame.where.line, 4); + do_check_eq(packet.why.type, "debuggerStatement"); + do_check_eq(packet.frame.where.line, 4); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { finishClient(gClient); }); }); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); }); }); + /* eslint-disable */ Components.utils.evalInSandbox("debugger;\n" + // 1 "var a = 1;\n" + // 2 "var b = 2;\n" + // 3 @@ -57,4 +59,5 @@ function test_simple_breakpoint() "1.8", "test.js", 1); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_conditional_breakpoint-03.js b/devtools/server/tests/unit/test_conditional_breakpoint-03.js index d9cf13e005da..a0d8ea868902 100644 --- a/devtools/server/tests/unit/test_conditional_breakpoint-03.js +++ b/devtools/server/tests/unit/test_conditional_breakpoint-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check conditional breakpoint when condition throws and make sure it pauses @@ -9,48 +12,45 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-conditional-breakpoint"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_breakpoint(); - }); + attachTestTabAndResume(gClient, "test-conditional-breakpoint", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_breakpoint(); + }); }); do_test_pending(); } -function test_simple_breakpoint() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let source = gThreadClient.source(aPacket.frame.where.source); +function test_simple_breakpoint() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let source = gThreadClient.source(packet.frame.where.source); source.setBreakpoint({ line: 3, condition: "throw new Error()" - }, function (aResponse, bpClient) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + }, function (response, bpClient) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.why.type, "breakpointConditionThrown"); - do_check_eq(aPacket.frame.where.line, 3); + do_check_eq(packet.why.type, "breakpointConditionThrown"); + do_check_eq(packet.frame.where.line, 3); // Remove the breakpoint. - bpClient.remove(function (aResponse) { + bpClient.remove(function (response) { gThreadClient.resume(function () { finishClient(gClient); }); }); - }); // Continue until the breakpoint is hit. gThreadClient.resume(); - }); - }); + /* eslint-disable */ Components.utils.evalInSandbox("debugger;\n" + // 1 "var a = 1;\n" + // 2 "var b = 2;\n", // 3 @@ -58,4 +58,5 @@ function test_simple_breakpoint() "1.8", "test.js", 1); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_dbgactor.js b/devtools/server/tests/unit/test_dbgactor.js index b22b8446ba48..77fa20883159 100644 --- a/devtools/server/tests/unit/test_dbgactor.js +++ b/devtools/server/tests/unit/test_dbgactor.js @@ -1,29 +1,31 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gClient; var gDebuggee; const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-1"); DebuggerServer.addTestGlobal(gDebuggee); let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); - gClient.addListener("connected", function (aEvent, aType, aTraits) { - gClient.listTabs((aResponse) => { - do_check_true("tabs" in aResponse); - for (let tab of aResponse.tabs) { + gClient.addListener("connected", function (event, type, traits) { + gClient.listTabs((response) => { + do_check_true("tabs" in response); + for (let tab of response.tabs) { if (tab.title == "test-1") { test_attach_tab(tab.actor); return false; } } - do_check_true(false); // We should have found our tab in the list. + // We should have found our tab in the list. + do_check_true(false); return undefined; }); }); @@ -33,42 +35,39 @@ function run_test() do_test_pending(); } -// Attach to |aTabActor|, and check the response. -function test_attach_tab(aTabActor) -{ - gClient.request({ to: aTabActor, type: "attach" }, function (aResponse) { - do_check_false("error" in aResponse); - do_check_eq(aResponse.from, aTabActor); - do_check_eq(aResponse.type, "tabAttached"); - do_check_true(typeof aResponse.threadActor === "string"); +// Attach to |tabActor|, and check the response. +function test_attach_tab(tabActor) { + gClient.request({ to: tabActor, type: "attach" }, function (response) { + do_check_false("error" in response); + do_check_eq(response.from, tabActor); + do_check_eq(response.type, "tabAttached"); + do_check_true(typeof response.threadActor === "string"); - test_attach_thread(aResponse.threadActor); + test_attach_thread(response.threadActor); }); } -// Attach to |aThreadActor|, check the response, and resume it. -function test_attach_thread(aThreadActor) -{ - gClient.request({ to: aThreadActor, type: "attach" }, function (aResponse) { - do_check_false("error" in aResponse); - do_check_eq(aResponse.from, aThreadActor); - do_check_eq(aResponse.type, "paused"); - do_check_true("why" in aResponse); - do_check_eq(aResponse.why.type, "attached"); +// Attach to |threadActor|, check the response, and resume it. +function test_attach_thread(threadActor) { + gClient.request({ to: threadActor, type: "attach" }, function (response) { + do_check_false("error" in response); + do_check_eq(response.from, threadActor); + do_check_eq(response.type, "paused"); + do_check_true("why" in response); + do_check_eq(response.why.type, "attached"); - test_resume_thread(aThreadActor); + test_resume_thread(threadActor); }); } -// Resume |aThreadActor|, and see that it stops at the 'debugger' +// Resume |threadActor|, and see that it stops at the 'debugger' // statement. -function test_resume_thread(aThreadActor) -{ +function test_resume_thread(threadActor) { // Allow the client to resume execution. - gClient.request({ to: aThreadActor, type: "resume" }, function (aResponse) { - do_check_false("error" in aResponse); - do_check_eq(aResponse.from, aThreadActor); - do_check_eq(aResponse.type, "resumed"); + gClient.request({ to: threadActor, type: "resume" }, function (response) { + do_check_false("error" in response); + do_check_eq(response.from, threadActor); + do_check_eq(response.type, "resumed"); do_check_eq(xpcInspector.eventLoopNestLevel, 0); @@ -78,14 +77,14 @@ function test_resume_thread(aThreadActor) do_check_true(gDebuggee.b); }); - gClient.addListener("paused", function (aName, aPacket) { - do_check_eq(aName, "paused"); - do_check_false("error" in aPacket); - do_check_eq(aPacket.from, aThreadActor); - do_check_eq(aPacket.type, "paused"); - do_check_true("actor" in aPacket); - do_check_true("why" in aPacket); - do_check_eq(aPacket.why.type, "debuggerStatement"); + gClient.addListener("paused", function (name, packet) { + do_check_eq(name, "paused"); + do_check_false("error" in packet); + do_check_eq(packet.from, threadActor); + do_check_eq(packet.type, "paused"); + do_check_true("actor" in packet); + do_check_true("why" in packet); + do_check_eq(packet.why.type, "debuggerStatement"); // Reach around the protocol to check that the debuggee is in the state // we expect. @@ -95,19 +94,18 @@ function test_resume_thread(aThreadActor) do_check_eq(xpcInspector.eventLoopNestLevel, 1); // Let the debuggee continue execution. - gClient.request({ to: aThreadActor, type: "resume" }, cleanup); + gClient.request({ to: threadActor, type: "resume" }, cleanup); }); } -function cleanup() -{ - gClient.addListener("closed", function (aEvent, aResult) { +function cleanup() { + gClient.addListener("closed", function (event, result) { do_test_finished(); }); try { - let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); - do_check_eq(xpcInspector.eventLoopNestLevel, 0); + let inspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); + do_check_eq(inspector.eventLoopNestLevel, 0); } catch (e) { dump(e); } diff --git a/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js b/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js index 40468cb1df49..e3e745031100 100644 --- a/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js +++ b/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js @@ -1,44 +1,43 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gClient; var gTabClient; var gDebuggee; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-1"); DebuggerServer.addTestGlobal(gDebuggee); let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); - gClient.connect().then(function ([aType, aTraits]) { - attachTestTab(gClient, "test-1", function (aReply, aTabClient) { - gTabClient = aTabClient; - test_threadAttach(aReply.threadActor); + gClient.connect().then(function ([type, traits]) { + attachTestTab(gClient, "test-1", function (reply, tabClient) { + gTabClient = tabClient; + test_threadAttach(reply.threadActor); }); }); do_test_pending(); } -function test_threadAttach(aThreadActorID) -{ - do_print("Trying to attach to thread " + aThreadActorID); - gTabClient.attachThread({}, function (aResponse, aThreadClient) { - do_check_eq(aThreadClient.state, "paused"); - do_check_eq(aThreadClient.actor, aThreadActorID); - aThreadClient.resume(function () { - do_check_eq(aThreadClient.state, "attached"); - test_debugger_statement(aThreadClient); +function test_threadAttach(threadActorID) { + do_print("Trying to attach to thread " + threadActorID); + gTabClient.attachThread({}, function (response, threadClient) { + do_check_eq(threadClient.state, "paused"); + do_check_eq(threadClient.actor, threadActorID); + threadClient.resume(function () { + do_check_eq(threadClient.state, "attached"); + test_debugger_statement(threadClient); }); }); } -function test_debugger_statement(aThreadClient) -{ - aThreadClient.addListener("paused", function (aEvent, aPacket) { - do_check_eq(aThreadClient.state, "paused"); +function test_debugger_statement(threadClient) { + threadClient.addListener("paused", function (event, packet) { + do_check_eq(threadClient.state, "paused"); // Reach around the protocol to check that the debuggee is in the state // we expect. do_check_true(gDebuggee.a); @@ -47,7 +46,7 @@ function test_debugger_statement(aThreadClient) let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); do_check_eq(xpcInspector.eventLoopNestLevel, 1); - aThreadClient.resume(cleanup); + threadClient.resume(cleanup); }); Cu.evalInSandbox("var a = true; var b = false; debugger; var b = true;", gDebuggee); @@ -56,9 +55,8 @@ function test_debugger_statement(aThreadClient) do_check_true(gDebuggee.b); } -function cleanup() -{ - gClient.addListener("closed", function (aEvent) { +function cleanup() { + gClient.addListener("closed", function (event) { do_test_finished(); }); diff --git a/devtools/server/tests/unit/test_dbgglobal.js b/devtools/server/tests/unit/test_dbgglobal.js index 09489b9e20b4..d98a09d8c9d0 100644 --- a/devtools/server/tests/unit/test_dbgglobal.js +++ b/devtools/server/tests/unit/test_dbgglobal.js @@ -1,8 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -function run_test() -{ +"use strict"; + +function run_test() { // Should get an exception if we try to interact with DebuggerServer // before we initialize it... check_except(function () { @@ -28,28 +29,28 @@ function run_test() // Make sure we got the test's root actor all set up. let client1 = DebuggerServer.connectPipe(); client1.hooks = { - onPacket: function (aPacket1) { - do_check_eq(aPacket1.from, "root"); - do_check_eq(aPacket1.applicationType, "xpcshell-tests"); + onPacket: function (packet1) { + do_check_eq(packet1.from, "root"); + do_check_eq(packet1.applicationType, "xpcshell-tests"); // Spin up a second connection, make sure it has its own root // actor. let client2 = DebuggerServer.connectPipe(); client2.hooks = { - onPacket: function (aPacket2) { - do_check_eq(aPacket2.from, "root"); - do_check_neq(aPacket1.testConnectionPrefix, - aPacket2.testConnectionPrefix); + onPacket: function (packet2) { + do_check_eq(packet2.from, "root"); + do_check_neq(packet1.testConnectionPrefix, + packet2.testConnectionPrefix); client2.close(); }, - onClosed: function (aResult) { + onClosed: function (result) { client1.close(); }, }; client2.ready(); }, - onClosed: function (aResult) { + onClosed: function (result) { do_test_finished(); }, }; diff --git a/devtools/server/tests/unit/test_eval-01.js b/devtools/server/tests/unit/test_eval-01.js index b11903f8719f..4e0c0668f152 100644 --- a/devtools/server/tests/unit/test_eval-01.js +++ b/devtools/server/tests/unit/test_eval-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check basic eval resume/re-pause @@ -9,50 +12,48 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_eval(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_eval(); + }); }); do_test_pending(); } -function test_simple_eval() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let arg1Actor = aPacket.frame.arguments[0].actor; - gThreadClient.eval(null, "({ obj: true })", function (aResponse) { - do_check_eq(aResponse.type, "resumed"); +function test_simple_eval() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let arg1Actor = packet.frame.arguments[0].actor; + gThreadClient.eval(null, "({ obj: true })", function (response) { + do_check_eq(response.type, "resumed"); // Expect a pause notification immediately. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value... - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "clientEvaluated"); - do_check_eq(aPacket.why.frameFinished.return.type, "object"); - do_check_eq(aPacket.why.frameFinished.return.class, "Object"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "clientEvaluated"); + do_check_eq(packet.why.frameFinished.return.type, "object"); + do_check_eq(packet.why.frameFinished.return.class, "Object"); // Make sure the previous pause lifetime was correctly dropped. - gClient.request({ to: arg1Actor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); + gClient.request({ to: arg1Actor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); gThreadClient.resume(function () { finishClient(gClient); }); }); - }); - }); - }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function stopMe(arg1) { debugger; } stopMe({obj: true}); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_eval-02.js b/devtools/server/tests/unit/test_eval-02.js index 386ea5c98944..b86499e3c59b 100644 --- a/devtools/server/tests/unit/test_eval-02.js +++ b/devtools/server/tests/unit/test_eval-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check eval resume/re-pause with a throw. @@ -9,31 +12,30 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_throw_eval(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_throw_eval(); + }); }); do_test_pending(); } -function test_throw_eval() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(null, "throw 'failure'", function (aResponse) { - do_check_eq(aResponse.type, "resumed"); +function test_throw_eval() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(null, "throw 'failure'", function (response) { + do_check_eq(response.type, "resumed"); // Expect a pause notification immediately. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value... - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "clientEvaluated"); - do_check_eq(aPacket.why.frameFinished.throw, "failure"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "clientEvaluated"); + do_check_eq(packet.why.frameFinished.throw, "failure"); gThreadClient.resume(function () { finishClient(gClient); }); @@ -41,8 +43,10 @@ function test_throw_eval() }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function stopMe(arg1) { debugger; } stopMe({obj: true}); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_eval-03.js b/devtools/server/tests/unit/test_eval-03.js index 2234259aabc1..f75b0f538d21 100644 --- a/devtools/server/tests/unit/test_eval-03.js +++ b/devtools/server/tests/unit/test_eval-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check syntax errors in an eval. @@ -9,32 +12,31 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_syntax_error_eval(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_syntax_error_eval(); + }); }); do_test_pending(); } -function test_syntax_error_eval() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(null, "%$@!@#", function (aResponse) { - do_check_eq(aResponse.type, "resumed"); +function test_syntax_error_eval() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(null, "%$@!@#", function (response) { + do_check_eq(response.type, "resumed"); // Expect a pause notification immediately. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value... - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "clientEvaluated"); - do_check_eq(aPacket.why.frameFinished.throw.type, "object"); - do_check_eq(aPacket.why.frameFinished.throw.class, "Error"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "clientEvaluated"); + do_check_eq(packet.why.frameFinished.throw.type, "object"); + do_check_eq(packet.why.frameFinished.throw.class, "Error"); gThreadClient.resume(function () { finishClient(gClient); @@ -43,8 +45,10 @@ function test_syntax_error_eval() }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function stopMe(arg1) { debugger; } stopMe({obj: true}); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_eval-04.js b/devtools/server/tests/unit/test_eval-04.js index 77cb58d97b9f..2fdf1dc33976 100644 --- a/devtools/server/tests/unit/test_eval-04.js +++ b/devtools/server/tests/unit/test_eval-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check evals against different frames. @@ -9,43 +12,41 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_syntax_error_eval(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_different_frames_eval(); + }); }); do_test_pending(); } -function test_syntax_error_eval() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - - gThreadClient.getFrames(0, 2, function (aResponse) { - let frame0 = aResponse.frames[0]; - let frame1 = aResponse.frames[1]; +function test_different_frames_eval() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getFrames(0, 2, function (response) { + let frame0 = response.frames[0]; + let frame1 = response.frames[1]; // Eval against the top frame... - gThreadClient.eval(frame0.actor, "arg", function (aResponse) { - do_check_eq(aResponse.type, "resumed"); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.eval(frame0.actor, "arg", function (response) { + do_check_eq(response.type, "resumed"); + gThreadClient.addOneTimeListener("paused", function (event, packet) { // 'arg' should have been evaluated in frame0 - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.type, "clientEvaluated"); - do_check_eq(aPacket.why.frameFinished.return, "arg0"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.type, "clientEvaluated"); + do_check_eq(packet.why.frameFinished.return, "arg0"); // Now eval against the second frame. - gThreadClient.eval(frame1.actor, "arg", function (aResponse) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.eval(frame1.actor, "arg", function (response) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // 'arg' should have been evaluated in frame1 - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.why.frameFinished.return, "arg1"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.why.frameFinished.return, "arg1"); gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_eval-05.js b/devtools/server/tests/unit/test_eval-05.js index b199e4afbec5..30b7731f82e5 100644 --- a/devtools/server/tests/unit/test_eval-05.js +++ b/devtools/server/tests/unit/test_eval-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check pauses within evals. @@ -9,34 +12,33 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_syntax_error_eval(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pauses_eval(); + }); }); do_test_pending(); } -function test_syntax_error_eval() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.eval(null, "debugger", function (aResponse) { +function test_pauses_eval() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.eval(null, "debugger", function (response) { // Expect a resume then a debuggerStatement pause. - do_check_eq(aResponse.type, "resumed"); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "debuggerStatement"); + do_check_eq(response.type, "resumed"); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "debuggerStatement"); // Resume from the debugger statement should immediately re-pause // with a clientEvaluated reason. - gThreadClient.resume(function (aPacket) { - do_check_eq(aPacket.type, "resumed"); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "clientEvaluated"); + gThreadClient.resume(function (packet) { + do_check_eq(packet.type, "resumed"); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "clientEvaluated"); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_eventlooplag_actor.js b/devtools/server/tests/unit/test_eventlooplag_actor.js index d2acdd8f8983..5a2fab215bc1 100644 --- a/devtools/server/tests/unit/test_eventlooplag_actor.js +++ b/devtools/server/tests/unit/test_eventlooplag_actor.js @@ -7,8 +7,7 @@ "use strict"; -function run_test() -{ +function run_test() { let {EventLoopLagFront} = require("devtools/shared/fronts/eventlooplag"); DebuggerServer.init(); @@ -18,7 +17,6 @@ function run_test() let threshold = 20; let interval = 10; - let front; let client = new DebuggerClient(DebuggerServer.connectPipe()); diff --git a/devtools/server/tests/unit/test_forwardingprefix.js b/devtools/server/tests/unit/test_forwardingprefix.js index 885a99db897d..d7d15c3f518d 100644 --- a/devtools/server/tests/unit/test_forwardingprefix.js +++ b/devtools/server/tests/unit/test_forwardingprefix.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /* Exercise prefix-based forwarding of packets to other transports. */ const { RootActor } = require("devtools/server/actors/root"); @@ -9,8 +11,7 @@ var gMainConnection, gMainTransport; var gSubconnection1, gSubconnection2; var gClient; -function run_test() -{ +function run_test() { DebuggerServer.init(); add_test(createMainConnection); @@ -31,28 +32,26 @@ function run_test() * (that is, packets sent on |transport| go to the new connection, and * |transport|'s hooks receive replies). * - * |aPrefix| is optional; if present, it's the prefix (minus the '/') for + * |prefix| is optional; if present, it's the prefix (minus the '/') for * actors in the new connection. */ -function newConnection(aPrefix) -{ - var conn; - DebuggerServer.createRootActor = function (aConn) { - conn = aConn; - return new RootActor(aConn, {}); +function newConnection(prefix) { + let conn; + DebuggerServer.createRootActor = function (connection) { + conn = connection; + return new RootActor(connection, {}); }; - var transport = DebuggerServer.connectPipe(aPrefix); + let transport = DebuggerServer.connectPipe(prefix); return { conn: conn, transport: transport }; } /* Create the main connection for these tests. */ -function createMainConnection() -{ +function createMainConnection() { ({ conn: gMainConnection, transport: gMainTransport } = newConnection()); gClient = new DebuggerClient(gMainTransport); - gClient.connect().then(([aType, aTraits]) => run_next_test()); + gClient.connect().then(([type, traits]) => run_next_test()); } /* @@ -63,13 +62,13 @@ function createMainConnection() * - prefix2/root * - prefix2/actor * - * Expect proper echos from those named in |aReachables|, and 'noSuchActor' + * Expect proper echos from those named in |reachables|, and 'noSuchActor' * errors from the others. When we've gotten all our replies (errors or - * otherwise), call |aCompleted|. + * otherwise), call |completed|. * - * To avoid deep stacks, we call aCompleted from the next tick. + * To avoid deep stacks, we call completed from the next tick. */ -function tryActors(aReachables, aCompleted) { +function tryActors(reachables, completed) { let count = 0; let outerActor; @@ -84,16 +83,22 @@ function tryActors(aReachables, aCompleted) { count++; - gClient.request({ to: actor, type: "echo", value: "tango"}, // phone home - (aResponse) => { - if (aReachables.has(actor)) - do_check_matches({ from: actor, to: actor, type: "echo", value: "tango" }, aResponse); - else - do_check_matches({ from: actor, error: "noSuchActor", message: "No such actor for ID: " + actor }, aResponse); + // phone home + gClient.request( + { to: actor, type: "echo", value: "tango"}, + (response) => { + if (reachables.has(actor)) { + do_check_matches({ from: actor, to: actor, + type: "echo", value: "tango" }, response); + } else { + do_check_matches({ from: actor, error: "noSuchActor", + message: "No such actor for ID: " + actor }, response); + } - if (--count == 0) - do_execute_soon(aCompleted, "tryActors callback " + aCompleted.name); - }); + if (--count == 0) { + do_execute_soon(completed, "tryActors callback " + completed.name); + } + }); } } @@ -102,56 +107,50 @@ function tryActors(aReachables, aCompleted) { * but sending messages to prefixed actor names, or anyone else, should get * an error. */ -function TestNoForwardingYet() -{ +function TestNoForwardingYet() { tryActors(new Set(["root"]), run_next_test); } /* * Create a new pipe connection which forwards its reply packets to * gMainConnection's client, and to which gMainConnection forwards packets - * directed to actors whose names begin with |aPrefix + '/'|, and. + * directed to actors whose names begin with |prefix + '/'|, and. * * Return an object { conn, transport }, as for newConnection. */ -function newSubconnection(aPrefix) -{ - let { conn, transport } = newConnection(aPrefix); +function newSubconnection(prefix) { + let { conn, transport } = newConnection(prefix); transport.hooks = { - onPacket: (aPacket) => gMainConnection.send(aPacket), + onPacket: (packet) => gMainConnection.send(packet), onClosed: () => {} }; - gMainConnection.setForwarding(aPrefix, transport); + gMainConnection.setForwarding(prefix, transport); return { conn: conn, transport: transport }; } /* Create a second root actor, to which we can forward things. */ -function createSubconnection1() -{ +function createSubconnection1() { let { conn, transport } = newSubconnection("prefix1"); gSubconnection1 = conn; transport.ready(); - gClient.expectReply("prefix1/root", (aReply) => run_next_test()); + gClient.expectReply("prefix1/root", (reply) => run_next_test()); } // Establish forwarding, but don't put any actors in that server. -function TestForwardPrefix1OnlyRoot() -{ +function TestForwardPrefix1OnlyRoot() { tryActors(new Set(["root", "prefix1/root"]), run_next_test); } /* Create a third root actor, to which we can forward things. */ -function createSubconnection2() -{ +function createSubconnection2() { let { conn, transport } = newSubconnection("prefix2"); gSubconnection2 = conn; transport.ready(); - gClient.expectReply("prefix2/root", (aReply) => run_next_test()); + gClient.expectReply("prefix2/root", (reply) => run_next_test()); } -function TestForwardPrefix12OnlyRoot() -{ +function TestForwardPrefix12OnlyRoot() { tryActors(new Set(["root", "prefix1/root", "prefix2/root"]), run_next_test); } @@ -161,36 +160,39 @@ function TestForwardPrefix12OnlyRoot() // the reply-sending code attaches the replying actor's name to the packet, // so simply matching the 'from' field in the reply ensures that we heard // from the right actor. -function EchoActor(aConnection) -{ - this.conn = aConnection; +function EchoActor(connection) { + this.conn = connection; } EchoActor.prototype.actorPrefix = "EchoActor"; -EchoActor.prototype.onEcho = function (aRequest) { +EchoActor.prototype.onEcho = function (request) { /* - * Request packets are frozen. Copy aRequest, so that + * Request packets are frozen. Copy request, so that * DebuggerServerConnection.onPacket can attach a 'from' property. */ - return JSON.parse(JSON.stringify(aRequest)); + return JSON.parse(JSON.stringify(request)); }; EchoActor.prototype.requestTypes = { "echo": EchoActor.prototype.onEcho }; -function TestForwardPrefix12WithActor1() -{ +function TestForwardPrefix12WithActor1() { let actor = new EchoActor(gSubconnection1); actor.actorID = "prefix1/actor"; gSubconnection1.addActor(actor); - tryActors(new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root"]), run_next_test); + tryActors( + new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root"]), + run_next_test + ); } -function TestForwardPrefix12WithActor12() -{ +function TestForwardPrefix12WithActor12() { let actor = new EchoActor(gSubconnection2); actor.actorID = "prefix2/actor"; gSubconnection2.addActor(actor); - tryActors(new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root", "prefix2/actor"]), run_next_test); + tryActors( + new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root", "prefix2/actor"]), + run_next_test + ); } diff --git a/devtools/server/tests/unit/test_frameactor-01.js b/devtools/server/tests/unit/test_frameactor-01.js index ad37a8ab5962..051d44118302 100644 --- a/devtools/server/tests/unit/test_frameactor-01.js +++ b/devtools/server/tests/unit/test_frameactor-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Verify that we get a frame actor along with a debugger statement. */ @@ -9,26 +11,25 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_true(!!aPacket.frame); - do_check_true(!!aPacket.frame.actor); - do_check_eq(aPacket.frame.callee.name, "stopMe"); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_true(!!packet.frame); + do_check_true(!!packet.frame.actor); + do_check_eq(packet.frame.callee.name, "stopMe"); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_frameactor-02.js b/devtools/server/tests/unit/test_frameactor-02.js index f2890adacf58..e1205020bbec 100644 --- a/devtools/server/tests/unit/test_frameactor-02.js +++ b/devtools/server/tests/unit/test_frameactor-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Verify that two pauses in a row will keep the same frame actor. @@ -9,25 +12,24 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket2) { - do_check_eq(aPacket1.frame.actor, aPacket2.frame.actor); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet1) { + gThreadClient.addOneTimeListener("paused", function (event, packet2) { + do_check_eq(packet1.frame.actor, packet2.frame.actor); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_frameactor-03.js b/devtools/server/tests/unit/test_frameactor-03.js index 0d7739d5ac09..2d81cf474059 100644 --- a/devtools/server/tests/unit/test_frameactor-03.js +++ b/devtools/server/tests/unit/test_frameactor-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Verify that a frame actor is properly expired when the frame goes away. @@ -9,27 +12,26 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket2) { - let poppedFrames = aPacket2.poppedFrames; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet1) { + gThreadClient.addOneTimeListener("paused", function (event, packet2) { + let poppedFrames = packet2.poppedFrames; do_check_eq(typeof (poppedFrames), typeof ([])); - do_check_true(poppedFrames.indexOf(aPacket1.frame.actor) >= 0); + do_check_true(poppedFrames.indexOf(packet1.frame.actor) >= 0); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_frameactor-04.js b/devtools/server/tests/unit/test_frameactor-04.js index b4faa96e039c..6fdb2ab9e177 100644 --- a/devtools/server/tests/unit/test_frameactor-04.js +++ b/devtools/server/tests/unit/test_frameactor-04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Verify the "frames" request on the thread. */ @@ -9,16 +11,16 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } @@ -46,17 +48,18 @@ var gSliceTests = [ function test_frame_slice() { if (gSliceTests.length == 0) { - gThreadClient.resume(function () { finishClient(gClient); }); + gThreadClient.resume(() => finishClient(gClient)); return; } let test = gSliceTests.shift(); - gThreadClient.getFrames(test.start, test.count, function (aResponse) { - var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined); - do_check_eq(testFrames.length, aResponse.frames.length); - for (var i = 0; i < testFrames.length; i++) { + gThreadClient.getFrames(test.start, test.count, function (response) { + let testFrames = gFrames.slice(test.start, + test.count ? test.start + test.count : undefined); + do_check_eq(testFrames.length, response.frames.length); + for (let i = 0; i < testFrames.length; i++) { let expected = testFrames[i]; - let actual = aResponse.frames[i]; + let actual = response.frames[i]; if (test.resetActors) { expected.actor = actual.actor; @@ -70,9 +73,8 @@ function test_frame_slice() { }); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) { +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { test_frame_slice(); }); diff --git a/devtools/server/tests/unit/test_frameactor-05.js b/devtools/server/tests/unit/test_frameactor-05.js index feece598ef2d..ed1bf57efc18 100644 --- a/devtools/server/tests/unit/test_frameactor-05.js +++ b/devtools/server/tests/unit/test_frameactor-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Verify that frame actors retrieved with the frames request @@ -10,64 +13,37 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_frame_slice() { - if (gSliceTests.length == 0) { - gThreadClient.resume(function () { finishClient(gClient); }); - return; - } - - let test = gSliceTests.shift(); - gThreadClient.getFrames(test.start, test.count, function (aResponse) { - var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined); - do_check_eq(testFrames.length, aResponse.frames.length); - for (var i = 0; i < testFrames.length; i++) { - let expected = testFrames[i]; - let actual = aResponse.frames[i]; - - if (test.resetActors) { - expected.actor = actual.actor; - } - - for (var key in expected) { - do_check_eq(expected[key], actual[key]); - } - } - test_frame_slice(); - }); -} - -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) { - gThreadClient.getFrames(0, null, function (aFrameResponse) { - do_check_eq(aFrameResponse.frames.length, 5); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getFrames(0, null, function (frameResponse) { + do_check_eq(frameResponse.frames.length, 5); // Now wait for the next pause, after which the three // youngest actors should be popped.. - let expectPopped = aFrameResponse.frames.slice(0, 3).map(frame => frame.actor); + let expectPopped = frameResponse.frames.slice(0, 3).map(frame => frame.actor); expectPopped.sort(); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPausePacket) { - let popped = aPausePacket.poppedFrames.sort(); + gThreadClient.addOneTimeListener("paused", function (event, pausePacket) { + let popped = pausePacket.poppedFrames.sort(); do_check_eq(popped.length, 3); for (let i = 0; i < 3; i++) { do_check_eq(expectPopped[i], popped[i]); } - gThreadClient.resume(function () { finishClient(gClient); }); + gThreadClient.resume(() => finishClient(gClient)); }); gThreadClient.resume(); }); diff --git a/devtools/server/tests/unit/test_frameactor_wasm-01.js b/devtools/server/tests/unit/test_frameactor_wasm-01.js index bc941b32283a..1e9f7b8326c8 100644 --- a/devtools/server/tests/unit/test_frameactor_wasm-01.js +++ b/devtools/server/tests/unit/test_frameactor_wasm-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Verify that wasm frame(s) can be requested from the client. @@ -9,34 +12,35 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { if (typeof WebAssembly == "undefined") { - return; // wasm is not enabled for this platform + // wasm is not enabled for this platform + return; } initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - gThreadClient.reconfigure({ observeAsmJS: true }, function (aResponse) { - do_check_eq(!!aResponse.error, false); - test_pause_frame(); + attachTestTabAndResume( + gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + gThreadClient.reconfigure({ observeAsmJS: true }, function (response) { + do_check_eq(!!response.error, false); + test_pause_frame(); + }); }); - }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) { - gThreadClient.getFrames(0, null, function (aFrameResponse) { - do_check_eq(aFrameResponse.frames.length, 4); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getFrames(0, null, function (frameResponse) { + do_check_eq(frameResponse.frames.length, 4); - let wasmFrame = aFrameResponse.frames[1]; + let wasmFrame = frameResponse.frames[1]; do_check_eq(wasmFrame.type, "wasmcall"); do_check_eq(wasmFrame.this, undefined); @@ -49,15 +53,16 @@ function test_pause_frame() }); }); + /* eslint-disable comma-spacing, max-len */ gDebuggee.eval("(" + function () { // WebAssembly bytecode was generated by running: // js -e 'print(wasmTextToBinary("(module(import \"a\" \"b\")(func(export \"c\")call 0))"))' - var m = new WebAssembly.Module(new Uint8Array([ + let m = new WebAssembly.Module(new Uint8Array([ 0,97,115,109,1,0,0,0,1,132,128,128,128,0,1,96,0,0,2,135,128,128,128,0,1,1,97,1, 98,0,0,3,130,128,128,128,0,1,0,6,129,128,128,128,0,0,7,133,128,128,128,0,1,1,99, 0,1,10,138,128,128,128,0,1,132,128,128,128,0,0,16,0,11 ])); - var i = new WebAssembly.Instance(m, {a: {b: () => { + let i = new WebAssembly.Instance(m, {a: {b: () => { debugger; }}}); i.exports.c(); diff --git a/devtools/server/tests/unit/test_framearguments-01.js b/devtools/server/tests/unit/test_framearguments-01.js index e075d2c25df2..bae9b52674ee 100644 --- a/devtools/server/tests/unit/test_framearguments-01.js +++ b/devtools/server/tests/unit/test_framearguments-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check a frame actor's arguments property. */ @@ -9,24 +11,23 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame["arguments"]; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args.length, 6); do_check_eq(args[0], 42); do_check_eq(args[1], true); @@ -43,7 +44,7 @@ function test_pause_frame() }); gDebuggee.eval("(" + function () { - function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) { + function stopMe(number, bool, string, null_, undef, object) { debugger; } stopMe(42, true, "nasu", null, undefined, { foo: "bar" }); diff --git a/devtools/server/tests/unit/test_framebindings-01.js b/devtools/server/tests/unit/test_framebindings-01.js index ae62f8ff1007..36a97f4d0d9a 100644 --- a/devtools/server/tests/unit/test_framebindings-01.js +++ b/devtools/server/tests/unit/test_framebindings-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check a frame actor's bindings property. */ @@ -9,36 +11,35 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let bindings = aPacket.frame.environment.bindings; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let bindings = packet.frame.environment.bindings; let args = bindings.arguments; let vars = bindings.variables; do_check_eq(args.length, 6); - do_check_eq(args[0].aNumber.value, 42); - do_check_eq(args[1].aBool.value, true); - do_check_eq(args[2].aString.value, "nasu"); - do_check_eq(args[3].aNull.value.type, "null"); - do_check_eq(args[4].aUndefined.value.type, "undefined"); - do_check_eq(args[5].aObject.value.type, "object"); - do_check_eq(args[5].aObject.value.class, "Object"); - do_check_true(!!args[5].aObject.value.actor); + do_check_eq(args[0].number.value, 42); + do_check_eq(args[1].bool.value, true); + do_check_eq(args[2].string.value, "nasu"); + do_check_eq(args[3].null_.value.type, "null"); + do_check_eq(args[4].undef.value.type, "undefined"); + do_check_eq(args[5].object.value.type, "object"); + do_check_eq(args[5].object.value.class, "Object"); + do_check_true(!!args[5].object.value.actor); do_check_eq(vars.a.value, 1); do_check_eq(vars.b.value, true); @@ -47,17 +48,17 @@ function test_pause_frame() do_check_true(!!vars.c.value.actor); let objClient = gThreadClient.pauseGrip(vars.c.value); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.a.configurable, true); - do_check_eq(aResponse.ownProperties.a.enumerable, true); - do_check_eq(aResponse.ownProperties.a.writable, true); - do_check_eq(aResponse.ownProperties.a.value, "a"); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.a.configurable, true); + do_check_eq(response.ownProperties.a.enumerable, true); + do_check_eq(response.ownProperties.a.writable, true); + do_check_eq(response.ownProperties.a.value, "a"); - do_check_eq(aResponse.ownProperties.b.configurable, true); - do_check_eq(aResponse.ownProperties.b.enumerable, true); - do_check_eq(aResponse.ownProperties.b.writable, true); - do_check_eq(aResponse.ownProperties.b.value.type, "undefined"); - do_check_false("class" in aResponse.ownProperties.b.value); + do_check_eq(response.ownProperties.b.configurable, true); + do_check_eq(response.ownProperties.b.enumerable, true); + do_check_eq(response.ownProperties.b.writable, true); + do_check_eq(response.ownProperties.b.value.type, "undefined"); + do_check_false("class" in response.ownProperties.b.value); gThreadClient.resume(function () { finishClient(gClient); @@ -65,8 +66,9 @@ function test_pause_frame() }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { - function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) { + function stopMe(number, bool, string, null_, undef, object) { var a = 1; var b = true; var c = { a: "a", b: undefined }; @@ -74,4 +76,5 @@ function test_pause_frame() } stopMe(42, true, "nasu", null, undefined, { foo: "bar" }); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_framebindings-02.js b/devtools/server/tests/unit/test_framebindings-02.js index 552670349cbc..606383b30580 100644 --- a/devtools/server/tests/unit/test_framebindings-02.js +++ b/devtools/server/tests/unit/test_framebindings-02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check a frame actor's parent bindings. */ @@ -9,24 +11,23 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let parentEnv = aPacket.frame.environment.parent; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let parentEnv = packet.frame.environment.parent; let bindings = parentEnv.bindings; let args = bindings.arguments; let vars = bindings.variables; @@ -40,10 +41,10 @@ function test_pause_frame() parentEnv = parentEnv.parent.parent; do_check_neq(parentEnv, undefined); let objClient = gThreadClient.pauseGrip(parentEnv.object); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.Object.value.type, "object"); - do_check_eq(aResponse.ownProperties.Object.value.class, "Function"); - do_check_true(!!aResponse.ownProperties.Object.value.actor); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.Object.value.type, "object"); + do_check_eq(response.ownProperties.Object.value.class, "Function"); + do_check_true(!!response.ownProperties.Object.value.actor); gThreadClient.resume(function () { finishClient(gClient); @@ -51,8 +52,9 @@ function test_pause_frame() }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { - function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) { + function stopMe(number, bool, string, null_, undef, object) { var a = 1; var b = true; var c = { a: "a" }; diff --git a/devtools/server/tests/unit/test_framebindings-03.js b/devtools/server/tests/unit/test_framebindings-03.js index 1ec51570d84c..f32bdf39649f 100644 --- a/devtools/server/tests/unit/test_framebindings-03.js +++ b/devtools/server/tests/unit/test_framebindings-03.js @@ -1,6 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* strict mode code may not contain 'with' statements */ +/* eslint-disable strict */ + /** * Check a |with| frame actor's bindings. */ @@ -9,24 +12,23 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let env = aPacket.frame.environment; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let env = packet.frame.environment; do_check_neq(env, undefined); let parentEnv = env.parent; @@ -36,18 +38,18 @@ function test_pause_frame() let args = bindings.arguments; let vars = bindings.variables; do_check_eq(args.length, 1); - do_check_eq(args[0].aNumber.value, 10); + do_check_eq(args[0].number.value, 10); do_check_eq(vars.r.value, 10); do_check_eq(vars.a.value, Math.PI * 100); do_check_eq(vars.arguments.value.class, "Arguments"); do_check_true(!!vars.arguments.value.actor); let objClient = gThreadClient.pauseGrip(env.object); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.PI.value, Math.PI); - do_check_eq(aResponse.ownProperties.cos.value.type, "object"); - do_check_eq(aResponse.ownProperties.cos.value.class, "Function"); - do_check_true(!!aResponse.ownProperties.cos.value.actor); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.PI.value, Math.PI); + do_check_eq(response.ownProperties.cos.value.type, "object"); + do_check_eq(response.ownProperties.cos.value.class, "Function"); + do_check_true(!!response.ownProperties.cos.value.actor); gThreadClient.resume(function () { finishClient(gClient); @@ -55,10 +57,11 @@ function test_pause_frame() }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { - function stopMe(aNumber) { + function stopMe(number) { var a; - var r = aNumber; + var r = number; with (Math) { a = PI * r * r; debugger; @@ -66,4 +69,5 @@ function test_pause_frame() } stopMe(10); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_framebindings-04.js b/devtools/server/tests/unit/test_framebindings-04.js index 963a12055076..311c2b318e45 100644 --- a/devtools/server/tests/unit/test_framebindings-04.js +++ b/devtools/server/tests/unit/test_framebindings-04.js @@ -1,49 +1,52 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +/* strict mode code may not contain 'with' statements */ +/* eslint-disable strict */ /** - * Check the environment bindongs of a |with| within a |with|. + * Check the environment bindings of a |with| within a |with|. */ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let env = aPacket.frame.environment; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let env = packet.frame.environment; do_check_neq(env, undefined); let objClient = gThreadClient.pauseGrip(env.object); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.one.value, 1); - do_check_eq(aResponse.ownProperties.two.value, 2); - do_check_eq(aResponse.ownProperties.foo, undefined); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.one.value, 1); + do_check_eq(response.ownProperties.two.value, 2); + do_check_eq(response.ownProperties.foo, undefined); let parentEnv = env.parent; do_check_neq(parentEnv, undefined); let parentClient = gThreadClient.pauseGrip(parentEnv.object); - parentClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.PI.value, Math.PI); - do_check_eq(aResponse.ownProperties.cos.value.type, "object"); - do_check_eq(aResponse.ownProperties.cos.value.class, "Function"); - do_check_true(!!aResponse.ownProperties.cos.value.actor); + parentClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.PI.value, Math.PI); + do_check_eq(response.ownProperties.cos.value.type, "object"); + do_check_eq(response.ownProperties.cos.value.class, "Function"); + do_check_true(!!response.ownProperties.cos.value.actor); parentEnv = parentEnv.parent; do_check_neq(parentEnv, undefined); @@ -52,7 +55,7 @@ function test_pause_frame() let args = bindings.arguments; let vars = bindings.variables; do_check_eq(args.length, 1); - do_check_eq(args[0].aNumber.value, 10); + do_check_eq(args[0].number.value, 10); do_check_eq(vars.r.value, 10); do_check_eq(vars.a.value, Math.PI * 100); do_check_eq(vars.arguments.value.class, "Arguments"); @@ -64,13 +67,13 @@ function test_pause_frame() }); }); }); - }); + /* eslint-disable */ gDebuggee.eval("(" + function () { - function stopMe(aNumber) { + function stopMe(number) { var a, obj = { one: 1, two: 2 }; - var r = aNumber; + var r = number; with (Math) { a = PI * r * r; with (obj) { @@ -81,4 +84,5 @@ function test_pause_frame() } stopMe(10); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_framebindings-05.js b/devtools/server/tests/unit/test_framebindings-05.js index 9827c617a6b1..7a3eac60d83a 100644 --- a/devtools/server/tests/unit/test_framebindings-05.js +++ b/devtools/server/tests/unit/test_framebindings-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check the environment bindings of a |with| in global scope. @@ -9,44 +12,43 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let env = aPacket.frame.environment; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let env = packet.frame.environment; do_check_neq(env, undefined); let objClient = gThreadClient.pauseGrip(env.object); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.PI.value, Math.PI); - do_check_eq(aResponse.ownProperties.cos.value.type, "object"); - do_check_eq(aResponse.ownProperties.cos.value.class, "Function"); - do_check_true(!!aResponse.ownProperties.cos.value.actor); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.PI.value, Math.PI); + do_check_eq(response.ownProperties.cos.value.type, "object"); + do_check_eq(response.ownProperties.cos.value.class, "Function"); + do_check_true(!!response.ownProperties.cos.value.actor); // Skip the global lexical scope. let parentEnv = env.parent.parent; do_check_neq(parentEnv, undefined); let parentClient = gThreadClient.pauseGrip(parentEnv.object); - parentClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.a.value, Math.PI * 100); - do_check_eq(aResponse.ownProperties.r.value, 10); - do_check_eq(aResponse.ownProperties.Object.value.type, "object"); - do_check_eq(aResponse.ownProperties.Object.value.class, "Function"); - do_check_true(!!aResponse.ownProperties.Object.value.actor); + parentClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.a.value, Math.PI * 100); + do_check_eq(response.ownProperties.r.value, 10); + do_check_eq(response.ownProperties.Object.value.type, "object"); + do_check_eq(response.ownProperties.Object.value.class, "Function"); + do_check_true(!!response.ownProperties.Object.value.actor); gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_framebindings-06.js b/devtools/server/tests/unit/test_framebindings-06.js index 9d8478a299e6..b7d6392c9751 100644 --- a/devtools/server/tests/unit/test_framebindings-06.js +++ b/devtools/server/tests/unit/test_framebindings-06.js @@ -1,32 +1,32 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_banana_environment(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_banana_environment(); + }); }); do_test_pending(); } -function test_banana_environment() -{ - +function test_banana_environment() { gThreadClient.addOneTimeListener("paused", - function (aEvent, aPacket) { - equal(aPacket.type, "paused"); - let env = aPacket.frame.environment; + function (event, packet) { + equal(packet.type, "paused"); + let env = packet.frame.environment; equal(env.type, "function"); equal(env.function.name, "banana3"); let parent = env.parent; @@ -47,14 +47,12 @@ function test_banana_environment() }); }); - gDebuggee.eval("\ - function banana(x) { \n\ - return function banana2(y) { \n\ - return function banana3(z) { \n\ - debugger; \n\ - }; \n\ - }; \n\ - } \n\ - banana('x')('y')('z'); \n\ - "); + gDebuggee.eval("function banana(x) {\n" + + " return function banana2(y) {\n" + + " return function banana3(z) {\n" + + " debugger;\n" + + " };\n" + + " };\n" + + "}\n" + + "banana('x')('y')('z');\n"); } diff --git a/devtools/server/tests/unit/test_framebindings-07.js b/devtools/server/tests/unit/test_framebindings-07.js index bdfc36d97ad7..44c00f58461d 100644 --- a/devtools/server/tests/unit/test_framebindings-07.js +++ b/devtools/server/tests/unit/test_framebindings-07.js @@ -1,31 +1,32 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; var gThreadClient; // Test that the EnvironmentClient's getBindings() method works as expected. -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-bindings"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-bindings", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_banana_environment(); - }); + attachTestTabAndResume(gClient, "test-bindings", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_banana_environment(); + }); }); do_test_pending(); } -function test_banana_environment() -{ - - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let environment = aPacket.frame.environment; +function test_banana_environment() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let environment = packet.frame.environment; do_check_eq(environment.type, "function"); let parent = environment.parent; @@ -35,30 +36,28 @@ function test_banana_environment() do_check_eq(grandpa.type, "function"); let envClient = gThreadClient.environment(environment); - envClient.getBindings(aResponse => { - do_check_eq(aResponse.bindings.arguments[0].z.value, "z"); + envClient.getBindings(response => { + do_check_eq(response.bindings.arguments[0].z.value, "z"); let parentClient = gThreadClient.environment(parent); - parentClient.getBindings(aResponse => { - do_check_eq(aResponse.bindings.variables.banana3.value.class, "Function"); + parentClient.getBindings(response => { + do_check_eq(response.bindings.variables.banana3.value.class, "Function"); let grandpaClient = gThreadClient.environment(grandpa); - grandpaClient.getBindings(aResponse => { - do_check_eq(aResponse.bindings.arguments[0].y.value, "y"); + grandpaClient.getBindings(response => { + do_check_eq(response.bindings.arguments[0].y.value, "y"); gThreadClient.resume(() => finishClient(gClient)); }); }); }); }); - gDebuggee.eval("\ - function banana(x) { \n\ - return function banana2(y) { \n\ - return function banana3(z) { \n\ - debugger; \n\ - }; \n\ - }; \n\ - } \n\ - banana('x')('y')('z'); \n\ - "); + gDebuggee.eval("function banana(x) {\n" + + " return function banana2(y) {\n" + + " return function banana3(z) {\n" + + " debugger;\n" + + " };\n" + + " };\n" + + "}\n" + + "banana('x')('y')('z');\n"); } diff --git a/devtools/server/tests/unit/test_frameclient-01.js b/devtools/server/tests/unit/test_frameclient-01.js index a441c9adeb37..290649252128 100644 --- a/devtools/server/tests/unit/test_frameclient-01.js +++ b/devtools/server/tests/unit/test_frameclient-01.js @@ -1,27 +1,29 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { gThreadClient.addOneTimeListener("framesadded", function () { do_check_eq(gThreadClient.cachedFrames.length, 3); do_check_true(gThreadClient.moreFrames); @@ -39,6 +41,7 @@ function test_pause_frame() do_check_true(gThreadClient.fillFrames(3)); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { var recurseLeft = 5; function recurse() { @@ -50,4 +53,5 @@ function test_pause_frame() } recurse(); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_frameclient-02.js b/devtools/server/tests/unit/test_frameclient-02.js index a257e5960837..323966491ead 100644 --- a/devtools/server/tests/unit/test_frameclient-02.js +++ b/devtools/server/tests/unit/test_frameclient-02.js @@ -1,27 +1,28 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Ask for exactly the number of frames we expect. gThreadClient.addOneTimeListener("framesadded", function () { do_check_false(gThreadClient.moreFrames); @@ -32,6 +33,7 @@ function test_pause_frame() do_check_true(gThreadClient.fillFrames(3)); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { var recurseLeft = 1; function recurse() { @@ -43,4 +45,5 @@ function test_pause_frame() } recurse(); } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_functiongrips-01.js b/devtools/server/tests/unit/test_functiongrips-01.js index 81b1b77670b0..b5adc8ebc8e8 100644 --- a/devtools/server/tests/unit/test_functiongrips-01.js +++ b/devtools/server/tests/unit/test_functiongrips-01.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gDebuggee.eval(function stopMe(arg1) { @@ -15,39 +16,38 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_named_function(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_named_function(); + }); }); do_test_pending(); } -function test_named_function() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_named_function() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Function"); do_check_eq(args[0].name, "stopMe"); do_check_eq(args[0].displayName, "stopMe"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getParameterNames(function (aResponse) { - do_check_eq(aResponse.parameterNames.length, 1); - do_check_eq(aResponse.parameterNames[0], "arg1"); + objClient.getParameterNames(function (response) { + do_check_eq(response.parameterNames.length, 1); + do_check_eq(response.parameterNames[0], "arg1"); gThreadClient.resume(test_inferred_name_function); }); - }); gDebuggee.eval("stopMe(stopMe)"); } function test_inferred_name_function() { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Function"); // No name for an anonymous function, but it should have an inferred name. @@ -55,11 +55,11 @@ function test_inferred_name_function() { do_check_eq(args[0].displayName, "m"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getParameterNames(function (aResponse) { - do_check_eq(aResponse.parameterNames.length, 3); - do_check_eq(aResponse.parameterNames[0], "foo"); - do_check_eq(aResponse.parameterNames[1], "bar"); - do_check_eq(aResponse.parameterNames[2], "baz"); + objClient.getParameterNames(function (response) { + do_check_eq(response.parameterNames.length, 3); + do_check_eq(response.parameterNames[0], "foo"); + do_check_eq(response.parameterNames[1], "bar"); + do_check_eq(response.parameterNames[2], "baz"); gThreadClient.resume(test_anonymous_function); }); @@ -69,8 +69,8 @@ function test_inferred_name_function() { } function test_anonymous_function() { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Function"); // No name for an anonymous function, and no inferred name, either. @@ -78,11 +78,11 @@ function test_anonymous_function() { do_check_eq(args[0].displayName, undefined); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getParameterNames(function (aResponse) { - do_check_eq(aResponse.parameterNames.length, 3); - do_check_eq(aResponse.parameterNames[0], "foo"); - do_check_eq(aResponse.parameterNames[1], "bar"); - do_check_eq(aResponse.parameterNames[2], "baz"); + objClient.getParameterNames(function (response) { + do_check_eq(response.parameterNames.length, 3); + do_check_eq(response.parameterNames[0], "foo"); + do_check_eq(response.parameterNames[1], "bar"); + do_check_eq(response.parameterNames[2], "baz"); gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_get-executable-lines-source-map.js b/devtools/server/tests/unit/test_get-executable-lines-source-map.js index bca8eebee2c0..42794535b784 100644 --- a/devtools/server/tests/unit/test_get-executable-lines-source-map.js +++ b/devtools/server/tests/unit/test_get-executable-lines-source-map.js @@ -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/. */ +"use strict"; + /** * Test if getExecutableLines return correct information */ @@ -20,8 +22,8 @@ function run_test() { attachTestTabAndResume( gClient, "test-get-executable-lines", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test_executable_lines(); } ); diff --git a/devtools/server/tests/unit/test_get-executable-lines.js b/devtools/server/tests/unit/test_get-executable-lines.js index 233fb6ada9df..3660a4db93e4 100644 --- a/devtools/server/tests/unit/test_get-executable-lines.js +++ b/devtools/server/tests/unit/test_get-executable-lines.js @@ -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/. */ +"use strict"; + /** * Test if getExecutableLines return correct information */ @@ -20,8 +22,8 @@ function run_test() { attachTestTabAndResume( gClient, "test-get-executable-lines", - function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + function (response, tabClient, threadClient) { + gThreadClient = threadClient; test_executable_lines(); } ); diff --git a/devtools/server/tests/unit/test_getRuleText.js b/devtools/server/tests/unit/test_getRuleText.js index fe735928daa9..0f8e8d8325c7 100644 --- a/devtools/server/tests/unit/test_getRuleText.js +++ b/devtools/server/tests/unit/test_getRuleText.js @@ -24,7 +24,8 @@ const TEST_DATA = [ }, { desc: "Multiple rules test case", - input: "#id{color:red;background:yellow;}.class-one .class-two { position:absolute; line-height: 45px}", + input: "#id{color:red;background:yellow;}.class-one .class-two " + + "{ position:absolute; line-height: 45px}", line: 1, column: 34, expected: {offset: 56, text: " position:absolute; line-height: 45px"} diff --git a/devtools/server/tests/unit/test_getyoungestframe.js b/devtools/server/tests/unit/test_getyoungestframe.js index 035ab5b0c328..1254f53bf8a6 100644 --- a/devtools/server/tests/unit/test_getyoungestframe.js +++ b/devtools/server/tests/unit/test_getyoungestframe.js @@ -1,22 +1,22 @@ -function run_test() -{ +/* eslint-disable strict */ +function run_test() { Components.utils.import("resource://gre/modules/jsdebugger.jsm"); addDebuggerToGlobal(this); - var xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); - var g = testGlobal("test1"); + let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); + let g = testGlobal("test1"); - var dbg = new Debugger(); + let dbg = new Debugger(); dbg.uncaughtExceptionHook = testExceptionHook; dbg.addDebuggee(g); - dbg.onDebuggerStatement = function (aFrame) { - do_check_true(aFrame === dbg.getNewestFrame()); + dbg.onDebuggerStatement = function (frame) { + do_check_true(frame === dbg.getNewestFrame()); // Execute from the nested event loop, dbg.getNewestFrame() won't // be working anymore. do_execute_soon(function () { try { - do_check_true(aFrame === dbg.getNewestFrame()); + do_check_true(frame === dbg.getNewestFrame()); } finally { xpcInspector.exitNestedEventLoop("test"); } diff --git a/devtools/server/tests/unit/test_ignore_caught_exceptions.js b/devtools/server/tests/unit/test_ignore_caught_exceptions.js index a4b2218238e8..05ba9277a0b5 100644 --- a/devtools/server/tests/unit/test_ignore_caught_exceptions.js +++ b/devtools/server/tests/unit/test_ignore_caught_exceptions.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that setting ignoreCaughtExceptions will cause the debugger to ignore @@ -10,26 +13,25 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "exception"); - do_check_eq(aPacket.why.exception, "bar"); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "exception"); + do_check_eq(packet.why.exception, "bar"); gThreadClient.resume(function () { finishClient(gClient); }); @@ -39,6 +41,7 @@ function test_pause_frame() }); try { + /* eslint-disable */ gDebuggee.eval("(" + function () { debugger; try { @@ -46,5 +49,8 @@ function test_pause_frame() } catch (e) {} throw "bar"; } + ")()"); - } catch (e) {} + /* eslint-enable */ + } catch (e) { + /* Empty */ + } } diff --git a/devtools/server/tests/unit/test_ignore_no_interface_exceptions.js b/devtools/server/tests/unit/test_ignore_no_interface_exceptions.js index 5aaa31de3dc0..37b0bfbfe191 100644 --- a/devtools/server/tests/unit/test_ignore_no_interface_exceptions.js +++ b/devtools/server/tests/unit/test_ignore_no_interface_exceptions.js @@ -1,41 +1,42 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that the debugger automatically ignores NS_ERROR_NO_INTERFACE * exceptions, but not normal ones. */ - var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-no-interface"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-no-interface", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-no-interface", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ +function test_pause_frame() { gThreadClient.pauseOnExceptions(true, false, function () { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "exception"); - do_check_eq(aPacket.why.exception, 42); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "exception"); + do_check_eq(packet.why.exception, 42); gThreadClient.resume(function () { finishClient(gClient); }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function QueryInterface() { throw Components.results.NS_ERROR_NO_INTERFACE; @@ -50,5 +51,6 @@ function test_pause_frame() stopMe(); } catch (e) {} } + ")()"); + /* eslint-enable */ }); } diff --git a/devtools/server/tests/unit/test_interrupt.js b/devtools/server/tests/unit/test_interrupt.js index 34835cc0a0c0..e2190c5d7919 100644 --- a/devtools/server/tests/unit/test_interrupt.js +++ b/devtools/server/tests/unit/test_interrupt.js @@ -1,48 +1,47 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; var gClient; var gDebuggee; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-1"); DebuggerServer.addTestGlobal(gDebuggee); let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); - gClient.connect().then(function (aType, aTraits) { + gClient.connect().then(function (type, traits) { attachTestTab(gClient, "test-1", test_attach); }); do_test_pending(); } -function test_attach(aResponse, aTabClient) -{ - aTabClient.attachThread({}, function (aResponse, aThreadClient) { - do_check_eq(aThreadClient.paused, true); - aThreadClient.resume(function () { - test_interrupt(aThreadClient); +function test_attach(response, tabClient) { + tabClient.attachThread({}, function (response, threadClient) { + do_check_eq(threadClient.paused, true); + threadClient.resume(function () { + test_interrupt(threadClient); }); }); } -function test_interrupt(aThreadClient) -{ - do_check_eq(aThreadClient.paused, false); - aThreadClient.interrupt(function (aResponse) { - do_check_eq(aThreadClient.paused, true); - aThreadClient.resume(function () { - do_check_eq(aThreadClient.paused, false); +function test_interrupt(threadClient) { + do_check_eq(threadClient.paused, false); + threadClient.interrupt(function (response) { + do_check_eq(threadClient.paused, true); + threadClient.resume(function () { + do_check_eq(threadClient.paused, false); cleanup(); }); }); } -function cleanup() -{ - gClient.addListener("closed", function (aEvent) { +function cleanup() { + gClient.addListener("closed", function (event) { do_test_finished(); }); gClient.close(); diff --git a/devtools/server/tests/unit/test_layout-reflows-observer.js b/devtools/server/tests/unit/test_layout-reflows-observer.js index ff6c07b2646f..9fde8688fe6a 100644 --- a/devtools/server/tests/unit/test_layout-reflows-observer.js +++ b/devtools/server/tests/unit/test_layout-reflows-observer.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test the LayoutChangesObserver var { diff --git a/devtools/server/tests/unit/test_listsources-01.js b/devtools/server/tests/unit/test_listsources-01.js index 231e6a1e4fa7..8c9c75ec9ebb 100644 --- a/devtools/server/tests/unit/test_listsources-01.js +++ b/devtools/server/tests/unit/test_listsources-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check basic getSources functionality. */ @@ -11,33 +13,32 @@ var gThreadClient; var gNumTimesSourcesSent = 0; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); - gClient.request = (function (request) { - return function (aRequest, aOnResponse) { - if (aRequest.type === "sources") { + gClient.request = (function (origRequest) { + return function (request, onResponse) { + if (request.type === "sources") { ++gNumTimesSourcesSent; } - return request.call(this, aRequest, aOnResponse); + return origRequest.call(this, request, onResponse); }; }(gClient.request)); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_listsources(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_listsources(); + }); }); do_test_pending(); } -function test_simple_listsources() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.getSources(function (aResponse) { - do_check_true(aResponse.sources.some(function (s) { +function test_simple_listsources() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getSources(function (response) { + do_check_true(response.sources.some(function (s) { return s.url && s.url.match(/test_listsources-01.js/); })); @@ -51,9 +52,11 @@ function test_simple_listsources() }); }); + /* eslint-disable */ Components.utils.evalInSandbox("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a = 1;\n" + // line0 + 2 "var b = 2;\n", // line0 + 3 gDebuggee); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_listsources-02.js b/devtools/server/tests/unit/test_listsources-02.js index 190a5e31bc95..272eb1ec4c85 100644 --- a/devtools/server/tests/unit/test_listsources-02.js +++ b/devtools/server/tests/unit/test_listsources-02.js @@ -1,44 +1,44 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check getting sources before there are any. */ -var gDebuggee; var gClient; var gThreadClient; var gNumTimesSourcesSent = 0; -function run_test() -{ +function run_test() { initTestDebuggerServer(); - gDebuggee = addTestGlobal("test-stack"); + addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); - gClient.request = (function (request) { - return function (aRequest, aOnResponse) { - if (aRequest.type === "sources") { + gClient.request = (function (origRequest) { + return function (request, onResponse) { + if (request.type === "sources") { ++gNumTimesSourcesSent; } - return request.call(this, aRequest, aOnResponse); + return origRequest.call(this, request, onResponse); }; }(gClient.request)); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_listing_zero_sources(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_listing_zero_sources(); + }); }); do_test_pending(); } -function test_listing_zero_sources() -{ - gThreadClient.getSources(function (aPacket) { - do_check_true(!aPacket.error); - do_check_true(!!aPacket.sources); - do_check_eq(aPacket.sources.length, 0); +function test_listing_zero_sources() { + gThreadClient.getSources(function (packet) { + do_check_true(!packet.error); + do_check_true(!!packet.sources); + do_check_eq(packet.sources.length, 0); do_check_true(gNumTimesSourcesSent <= 1, "Should only send one sources request at most, even though we" diff --git a/devtools/server/tests/unit/test_listsources-03.js b/devtools/server/tests/unit/test_listsources-03.js index 72ebb5e1c281..c5f77a298e5f 100644 --- a/devtools/server/tests/unit/test_listsources-03.js +++ b/devtools/server/tests/unit/test_listsources-03.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check getSources functionality when there are lots of sources. */ @@ -9,29 +11,28 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-sources"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-sources", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_listsources(); - }); + attachTestTabAndResume(gClient, "test-sources", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_listsources(); + }); }); do_test_pending(); } -function test_simple_listsources() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.getSources(function (aResponse) { +function test_simple_listsources() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getSources(function (response) { do_check_true( - !aResponse.error, + !response.error, "There shouldn't be an error fetching large amounts of sources."); - do_check_true(aResponse.sources.some(function (s) { + do_check_true(response.sources.some(function (s) { return s.url.match(/foo-999.js$/); })); diff --git a/devtools/server/tests/unit/test_listsources-04.js b/devtools/server/tests/unit/test_listsources-04.js index 8e1a57bf027f..9a1089c7d6b0 100644 --- a/devtools/server/tests/unit/test_listsources-04.js +++ b/devtools/server/tests/unit/test_listsources-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Check getSources functionality with sourcemaps. @@ -18,12 +21,12 @@ function run_test() { } function run_test_with_server(server, cb) { - Task.spawn(function*() { + Task.spawn(function* () { initTestDebuggerServer(server); const debuggee = addTestGlobal("test-sources", server); const client = new DebuggerClient(server.connectPipe()); yield client.connect(); - const [,,threadClient] = yield attachTestTabAndResume(client, "test-sources"); + const [,, threadClient] = yield attachTestTabAndResume(client, "test-sources"); yield threadClient.reconfigure({ useSourceMaps: true }); addSources(debuggee); @@ -33,7 +36,7 @@ function run_test_with_server(server, cb) { yield threadClient.reconfigure({ useSourceMaps: false }); - threadClient.getSources(function(res) { + threadClient.getSources(function (res) { do_check_eq(res.sources.length, 1, "1 source exist"); client.close().then(cb); }); diff --git a/devtools/server/tests/unit/test_longstringactor.js b/devtools/server/tests/unit/test_longstringactor.js index 18f01e363576..3f8aefac2b37 100644 --- a/devtools/server/tests/unit/test_longstringactor.js +++ b/devtools/server/tests/unit/test_longstringactor.js @@ -14,8 +14,7 @@ function run_test() { const TEST_STRING = "This is a very long string!"; -function makeMockLongStringActor() -{ +function makeMockLongStringActor() { let string = TEST_STRING; let actor = new LongStringActor(string); actor.actorID = "longString1"; @@ -27,8 +26,7 @@ function makeMockLongStringActor() return actor; } -function test_LSA_destroy() -{ +function test_LSA_destroy() { let actor = makeMockLongStringActor(); do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], actor); @@ -36,27 +34,18 @@ function test_LSA_destroy() do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], void 0); } -function test_LSA_substring() -{ - let actor = makeMockLongStringActor(); - do_check_eq(actor._substring(0, 4), TEST_STRING.substring(0, 4)); - do_check_eq(actor._substring(6, 9), TEST_STRING.substring(6, 9)); - do_check_eq(actor._substring(0, TEST_STRING.length), TEST_STRING); -} - -function test_LSA_grip() -{ +function test_LSA_grip() { let actor = makeMockLongStringActor(); let grip = actor.grip(); do_check_eq(grip.type, "longString"); - do_check_eq(grip.initial, TEST_STRING.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); + do_check_eq(grip.initial, + TEST_STRING.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); do_check_eq(grip.length, TEST_STRING.length); do_check_eq(grip.actor, actor.actorID); } -function test_LSA_onSubstring() -{ +function test_LSA_onSubstring() { let actor = makeMockLongStringActor(); let response; diff --git a/devtools/server/tests/unit/test_longstringgrips-01.js b/devtools/server/tests/unit/test_longstringgrips-01.js index b8e6789c7e67..551e45fdd228 100644 --- a/devtools/server/tests/unit/test_longstringgrips-01.js +++ b/devtools/server/tests/unit/test_longstringgrips-01.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gDebuggee.eval(function stopMe(arg1) { @@ -15,16 +16,16 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_longstring_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_longstring_grip(); + }); }); do_test_pending(); } -function test_longstring_grip() -{ +function test_longstring_grip() { let longString = "All I want is to be a monkey of moderate intelligence who" + " wears a suit... that's why I'm transferring to business school! Maybe I" + " love you so much, I love you no matter who you are pretending to be." @@ -38,20 +39,21 @@ function test_longstring_grip() DebuggerServer.LONG_STRING_LENGTH = 200; - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args.length, 1); let grip = args[0]; try { do_check_eq(grip.type, "longString"); do_check_eq(grip.length, longString.length); - do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); + do_check_eq(grip.initial, + longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH)); let longStringClient = gThreadClient.pauseLongString(grip); - longStringClient.substring(22, 28, function (aResponse) { + longStringClient.substring(22, 28, function (response) { try { - do_check_eq(aResponse.substring, "monkey"); + do_check_eq(response.substring, "monkey"); } finally { gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_longstringgrips-02.js b/devtools/server/tests/unit/test_longstringgrips-02.js index 01f9c1b8f256..65178f1fe74d 100644 --- a/devtools/server/tests/unit/test_longstringgrips-02.js +++ b/devtools/server/tests/unit/test_longstringgrips-02.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gDebuggee.eval(function stopMe(arg1) { @@ -16,19 +17,18 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { attachTestTabAndResume( - gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; + gClient, "test-grips", function (response, tabClient, threadClient) { + gThreadClient = threadClient; test_longstring_grip(); }); }); do_test_pending(); } -function test_longstring_grip() -{ +function test_longstring_grip() { DebuggerServer.LONG_STRING_LENGTH = 200; - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { try { let fakeLongStringGrip = { type: "longString", @@ -37,9 +37,9 @@ function test_longstring_grip() initial: "" }; let longStringClient = gThreadClient.pauseLongString(fakeLongStringGrip); - longStringClient.substring(22, 28, function (aResponse) { + longStringClient.substring(22, 28, function (response) { try { - do_check_true(!!aResponse.error, + do_check_true(!!response.error, "We should not get a response, but an error."); } finally { gThreadClient.resume(function () { diff --git a/devtools/server/tests/unit/test_monitor_actor.js b/devtools/server/tests/unit/test_monitor_actor.js index 17c272d800a3..f4752dabc27c 100644 --- a/devtools/server/tests/unit/test_monitor_actor.js +++ b/devtools/server/tests/unit/test_monitor_actor.js @@ -7,8 +7,7 @@ "use strict"; -function run_test() -{ +function run_test() { let EventEmitter = require("devtools/shared/event-emitter"); function MonitorClient(client, form) { @@ -64,7 +63,7 @@ function run_test() do_check_eq(event.curve, "test"); do_check_eq(event.value, 42); do_check_eq(event.time, time); - monitor.stop(function (aResponse) { + monitor.stop(function (response) { monitor.destroy(); finishClient(client); }); diff --git a/devtools/server/tests/unit/test_nativewrappers.js b/devtools/server/tests/unit/test_nativewrappers.js index fbadfcdecdd4..8814a117ec83 100644 --- a/devtools/server/tests/unit/test_nativewrappers.js +++ b/devtools/server/tests/unit/test_nativewrappers.js @@ -1,13 +1,13 @@ -function run_test() -{ +/* eslint-disable strict */ +function run_test() { Components.utils.import("resource://gre/modules/jsdebugger.jsm"); addDebuggerToGlobal(this); - var g = testGlobal("test1"); + let g = testGlobal("test1"); - var dbg = new Debugger(); + let dbg = new Debugger(); dbg.addDebuggee(g); - dbg.onDebuggerStatement = function (aFrame) { - let args = aFrame.arguments; + dbg.onDebuggerStatement = function (frame) { + let args = frame.arguments; try { args[0]; do_check_true(true); @@ -21,7 +21,8 @@ function run_test() g2 = testGlobal("test2"); g2.g = g; g2.eval("(" + function createBadEvent() { - let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"].createInstance(Components.interfaces.nsIDOMParser); + let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); let doc = parser.parseFromString("", "text/xml"); g.stopMe(doc.createEvent("MouseEvent")); } + ")()"); diff --git a/devtools/server/tests/unit/test_nesting-01.js b/devtools/server/tests/unit/test_nesting-01.js index e515f051ee82..0dcea0dc0434 100644 --- a/devtools/server/tests/unit/test_nesting-01.js +++ b/devtools/server/tests/unit/test_nesting-01.js @@ -2,6 +2,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can nest event loops when needed in // ThreadActor.prototype.unsafeSynchronize. @@ -10,22 +12,25 @@ var gThreadActor; function run_test() { initTestDebuggerServer(); - let gDebuggee = addTestGlobal("test-nesting"); + addTestGlobal("test-nesting"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-nesting", function (aResponse, aTabClient, aThreadClient) { - // Reach over the protocol connection and get a reference to the thread actor. - gThreadActor = aThreadClient._transport._serverConnection.getActor(aThreadClient._actor); + attachTestTabAndResume( + gClient, "test-nesting", + function (response, tabClient, threadClient) { + // Reach over the protocol connection and get a reference to the thread actor. + gThreadActor = + threadClient._transport._serverConnection.getActor(threadClient._actor); - test_nesting(); - }); + test_nesting(); + }); }); do_test_pending(); } function test_nesting() { const thread = gThreadActor; - const { resolve, reject, promise: p } = promise.defer(); + const { resolve, promise: p } = promise.defer(); let currentStep = 0; diff --git a/devtools/server/tests/unit/test_nesting-02.js b/devtools/server/tests/unit/test_nesting-02.js index 928331be5697..b12c5fc9a0ec 100644 --- a/devtools/server/tests/unit/test_nesting-02.js +++ b/devtools/server/tests/unit/test_nesting-02.js @@ -2,6 +2,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can nest event loops and then automatically exit nested event // loops when requested. @@ -10,23 +12,26 @@ var gThreadActor; function run_test() { initTestDebuggerServer(); - let gDebuggee = addTestGlobal("test-nesting"); + addTestGlobal("test-nesting"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-nesting", function (aResponse, aTabClient, aThreadClient) { - // Reach over the protocol connection and get a reference to the thread - // actor. - gThreadActor = aThreadClient._transport._serverConnection.getActor(aThreadClient._actor); + attachTestTabAndResume( + gClient, "test-nesting", + function (response, tabClient, threadClient) { + // Reach over the protocol connection and get a reference to the thread + // actor. + gThreadActor = + threadClient._transport._serverConnection.getActor(threadClient._actor); - test_nesting(); - }); + test_nesting(); + }); }); do_test_pending(); } function test_nesting() { const thread = gThreadActor; - const { resolve, reject, promise: p } = promise.defer(); + const { resolve, promise: p } = promise.defer(); // The following things should happen (in order): // 1. In the new event loop (created by unsafeSynchronize) diff --git a/devtools/server/tests/unit/test_nesting-03.js b/devtools/server/tests/unit/test_nesting-03.js index 6a0e5a66b274..d63b247538e6 100644 --- a/devtools/server/tests/unit/test_nesting-03.js +++ b/devtools/server/tests/unit/test_nesting-03.js @@ -1,6 +1,9 @@ /* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; // Test that we can detect nested event loops in tabs with the same URL. @@ -13,10 +16,11 @@ function run_test() { // Conect the first client to the first debuggee. gClient1 = new DebuggerClient(DebuggerServer.connectPipe()); gClient1.connect(function () { - attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) { - gThreadClient1 = aThreadClient; - start_second_connection(); - }); + attachTestThread(gClient1, "test-nesting1", + function (response, tabClient, threadClient) { + gThreadClient1 = threadClient; + start_second_connection(); + }); }); do_test_pending(); } @@ -24,25 +28,24 @@ function run_test() { function start_second_connection() { gClient2 = new DebuggerClient(DebuggerServer.connectPipe()); gClient2.connect(function () { - attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) { - gThreadClient2 = aThreadClient; - test_nesting(); - }); + attachTestThread(gClient2, "test-nesting1", + function (response, tabClient, threadClient) { + gThreadClient2 = threadClient; + test_nesting(); + }); }); } function test_nesting() { - const { resolve, reject, promise: p } = promise.defer(); + gThreadClient1.resume(response => { + do_check_eq(response.error, "wrongOrder"); + gThreadClient2.resume(response => { + do_check_true(!response.error); + do_check_eq(response.from, gThreadClient2.actor); - gThreadClient1.resume(aResponse => { - do_check_eq(aResponse.error, "wrongOrder"); - gThreadClient2.resume(aResponse => { - do_check_true(!aResponse.error); - do_check_eq(aResponse.from, gThreadClient2.actor); - - gThreadClient1.resume(aResponse => { - do_check_true(!aResponse.error); - do_check_eq(aResponse.from, gThreadClient1.actor); + gThreadClient1.resume(response => { + do_check_true(!response.error); + do_check_eq(response.from, gThreadClient1.actor); gClient1.close(() => finishClient(gClient2)); }); diff --git a/devtools/server/tests/unit/test_new_source-01.js b/devtools/server/tests/unit/test_new_source-01.js index aa249837123a..56827ec48e90 100644 --- a/devtools/server/tests/unit/test_new_source-01.js +++ b/devtools/server/tests/unit/test_new_source-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check basic newSource packet sent from server. */ @@ -9,27 +11,26 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_new_source(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_new_source(); + }); }); do_test_pending(); } -function test_simple_new_source() -{ - gThreadClient.addOneTimeListener("newSource", function (aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); - do_check_true(!!aPacket.source.url.match(/test_new_source-01.js$/)); +function test_simple_new_source() { + gThreadClient.addOneTimeListener("newSource", function (event, packet) { + do_check_eq(event, "newSource"); + do_check_eq(packet.type, "newSource"); + do_check_true(!!packet.source); + do_check_true(!!packet.source.url.match(/test_new_source-01.js$/)); finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_nsjsinspector.js b/devtools/server/tests/unit/test_nsjsinspector.js index 14a99a308483..7cef47b940f7 100644 --- a/devtools/server/tests/unit/test_nsjsinspector.js +++ b/devtools/server/tests/unit/test_nsjsinspector.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test the basic functionality of the nsIJSInspector component. var gCount = 0; const MAX = 10; @@ -9,17 +11,15 @@ var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); // Emulate 10 simultaneously-debugged windows from 3 separate client connections. var requestor = (count) => ({ - url:"http://foo/bar/" + count, + url: "http://foo/bar/" + count, connection: "conn" + (count % 3) }); -function run_test() -{ +function run_test() { test_nesting(); } -function test_nesting() -{ +function test_nesting() { do_check_eq(inspector.eventLoopNestLevel, 0); tm.currentThread.dispatch({ run: enterEventLoop}, 0); @@ -33,7 +33,7 @@ function enterEventLoop() { if (gCount++ < MAX) { tm.currentThread.dispatch({ run: enterEventLoop}, 0); - let r = Object.create(requestor(gCount)); + Object.create(requestor(gCount)); do_check_eq(inspector.eventLoopNestLevel, gCount); do_check_eq(inspector.lastNestRequestor.url, requestor(gCount - 1).url); diff --git a/devtools/server/tests/unit/test_objectgrips-01.js b/devtools/server/tests/unit/test_objectgrips-01.js index e1857e5b8667..4199dd7cc283 100644 --- a/devtools/server/tests/unit/test_objectgrips-01.js +++ b/devtools/server/tests/unit/test_objectgrips-01.js @@ -1,56 +1,55 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Object"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getOwnPropertyNames(function (aResponse) { - do_check_eq(aResponse.ownPropertyNames.length, 3); - do_check_eq(aResponse.ownPropertyNames[0], "a"); - do_check_eq(aResponse.ownPropertyNames[1], "b"); - do_check_eq(aResponse.ownPropertyNames[2], "c"); + objClient.getOwnPropertyNames(function (response) { + do_check_eq(response.ownPropertyNames.length, 3); + do_check_eq(response.ownPropertyNames[0], "a"); + do_check_eq(response.ownPropertyNames[1], "b"); + do_check_eq(response.ownPropertyNames[2], "c"); gThreadClient.resume(function () { gClient.close().then(gCallback); }); }); - }); gDebuggee.eval("stopMe({ a: 1, b: true, c: 'foo' })"); diff --git a/devtools/server/tests/unit/test_objectgrips-02.js b/devtools/server/tests/unit/test_objectgrips-02.js index 649d52c64c34..d2705c8b9df5 100644 --- a/devtools/server/tests/unit/test_objectgrips-02.js +++ b/devtools/server/tests/unit/test_objectgrips-02.js @@ -1,65 +1,66 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Object"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getPrototype(function (aResponse) { - do_check_true(aResponse.prototype != undefined); + objClient.getPrototype(function (response) { + do_check_true(response.prototype != undefined); - let protoClient = gThreadClient.pauseGrip(aResponse.prototype); - protoClient.getOwnPropertyNames(function (aResponse) { - do_check_eq(aResponse.ownPropertyNames.length, 2); - do_check_eq(aResponse.ownPropertyNames[0], "b"); - do_check_eq(aResponse.ownPropertyNames[1], "c"); + let protoClient = gThreadClient.pauseGrip(response.prototype); + protoClient.getOwnPropertyNames(function (response) { + do_check_eq(response.ownPropertyNames.length, 2); + do_check_eq(response.ownPropertyNames[0], "b"); + do_check_eq(response.ownPropertyNames[1], "c"); gThreadClient.resume(function () { gClient.close().then(gCallback); }); }); }); - }); gDebuggee.eval(function Constr() { this.a = 1; }.toString()); - gDebuggee.eval("Constr.prototype = { b: true, c: 'foo' }; var o = new Constr(); stopMe(o)"); + gDebuggee.eval( + "Constr.prototype = { b: true, c: 'foo' }; var o = new Constr(); stopMe(o)"); } diff --git a/devtools/server/tests/unit/test_objectgrips-03.js b/devtools/server/tests/unit/test_objectgrips-03.js index 8b19db713abf..280597549bd4 100644 --- a/devtools/server/tests/unit/test_objectgrips-03.js +++ b/devtools/server/tests/unit/test_objectgrips-03.js @@ -1,63 +1,64 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Object"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getProperty("x", function (aResponse) { - do_check_eq(aResponse.descriptor.configurable, true); - do_check_eq(aResponse.descriptor.enumerable, true); - do_check_eq(aResponse.descriptor.writable, true); - do_check_eq(aResponse.descriptor.value, 10); + objClient.getProperty("x", function (response) { + do_check_eq(response.descriptor.configurable, true); + do_check_eq(response.descriptor.enumerable, true); + do_check_eq(response.descriptor.writable, true); + do_check_eq(response.descriptor.value, 10); - objClient.getProperty("y", function (aResponse) { - do_check_eq(aResponse.descriptor.configurable, true); - do_check_eq(aResponse.descriptor.enumerable, true); - do_check_eq(aResponse.descriptor.writable, true); - do_check_eq(aResponse.descriptor.value, "kaiju"); + objClient.getProperty("y", function (response) { + do_check_eq(response.descriptor.configurable, true); + do_check_eq(response.descriptor.enumerable, true); + do_check_eq(response.descriptor.writable, true); + do_check_eq(response.descriptor.value, "kaiju"); - objClient.getProperty("a", function (aResponse) { - do_check_eq(aResponse.descriptor.configurable, true); - do_check_eq(aResponse.descriptor.enumerable, true); - do_check_eq(aResponse.descriptor.get.type, "object"); - do_check_eq(aResponse.descriptor.get.class, "Function"); - do_check_eq(aResponse.descriptor.set.type, "undefined"); + objClient.getProperty("a", function (response) { + do_check_eq(response.descriptor.configurable, true); + do_check_eq(response.descriptor.enumerable, true); + do_check_eq(response.descriptor.get.type, "object"); + do_check_eq(response.descriptor.get.class, "Function"); + do_check_eq(response.descriptor.set.type, "undefined"); gThreadClient.resume(function () { gClient.close().then(gCallback); @@ -65,7 +66,6 @@ function test_object_grip() }); }); }); - }); gDebuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })"); diff --git a/devtools/server/tests/unit/test_objectgrips-04.js b/devtools/server/tests/unit/test_objectgrips-04.js index 1662358e0215..b12159ec6cce 100644 --- a/devtools/server/tests/unit/test_objectgrips-04.js +++ b/devtools/server/tests/unit/test_objectgrips-04.js @@ -1,74 +1,74 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Object"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.x.configurable, true); - do_check_eq(aResponse.ownProperties.x.enumerable, true); - do_check_eq(aResponse.ownProperties.x.writable, true); - do_check_eq(aResponse.ownProperties.x.value, 10); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.x.configurable, true); + do_check_eq(response.ownProperties.x.enumerable, true); + do_check_eq(response.ownProperties.x.writable, true); + do_check_eq(response.ownProperties.x.value, 10); - do_check_eq(aResponse.ownProperties.y.configurable, true); - do_check_eq(aResponse.ownProperties.y.enumerable, true); - do_check_eq(aResponse.ownProperties.y.writable, true); - do_check_eq(aResponse.ownProperties.y.value, "kaiju"); + do_check_eq(response.ownProperties.y.configurable, true); + do_check_eq(response.ownProperties.y.enumerable, true); + do_check_eq(response.ownProperties.y.writable, true); + do_check_eq(response.ownProperties.y.value, "kaiju"); - do_check_eq(aResponse.ownProperties.a.configurable, true); - do_check_eq(aResponse.ownProperties.a.enumerable, true); - do_check_eq(aResponse.ownProperties.a.get.type, "object"); - do_check_eq(aResponse.ownProperties.a.get.class, "Function"); - do_check_eq(aResponse.ownProperties.a.set.type, "undefined"); + do_check_eq(response.ownProperties.a.configurable, true); + do_check_eq(response.ownProperties.a.enumerable, true); + do_check_eq(response.ownProperties.a.get.type, "object"); + do_check_eq(response.ownProperties.a.get.class, "Function"); + do_check_eq(response.ownProperties.a.set.type, "undefined"); - do_check_true(aResponse.prototype != undefined); + do_check_true(response.prototype != undefined); - let protoClient = gThreadClient.pauseGrip(aResponse.prototype); - protoClient.getOwnPropertyNames(function (aResponse) { - do_check_true(aResponse.ownPropertyNames.toString != undefined); + let protoClient = gThreadClient.pauseGrip(response.prototype); + protoClient.getOwnPropertyNames(function (response) { + do_check_true(response.ownPropertyNames.toString != undefined); gThreadClient.resume(function () { gClient.close().then(gCallback); }); }); }); - }); gDebuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })"); diff --git a/devtools/server/tests/unit/test_objectgrips-05.js b/devtools/server/tests/unit/test_objectgrips-05.js index 5bbb37d8864d..0e6b6f28ea4d 100644 --- a/devtools/server/tests/unit/test_objectgrips-05.js +++ b/devtools/server/tests/unit/test_objectgrips-05.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * This test checks that frozen objects report themselves as frozen in their * grip. @@ -11,42 +13,40 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1, arg2) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let obj1 = aPacket.frame.arguments[0]; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let obj1 = packet.frame.arguments[0]; do_check_true(obj1.frozen); let obj1Client = gThreadClient.pauseGrip(obj1); do_check_true(obj1Client.isFrozen); - let obj2 = aPacket.frame.arguments[1]; + let obj2 = packet.frame.arguments[1]; do_check_false(obj2.frozen); let obj2Client = gThreadClient.pauseGrip(obj2); diff --git a/devtools/server/tests/unit/test_objectgrips-06.js b/devtools/server/tests/unit/test_objectgrips-06.js index bb9888ab8309..dd4a36c878d0 100644 --- a/devtools/server/tests/unit/test_objectgrips-06.js +++ b/devtools/server/tests/unit/test_objectgrips-06.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * This test checks that sealed objects report themselves as sealed in their * grip. @@ -11,42 +13,40 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1, arg2) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let obj1 = aPacket.frame.arguments[0]; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let obj1 = packet.frame.arguments[0]; do_check_true(obj1.sealed); let obj1Client = gThreadClient.pauseGrip(obj1); do_check_true(obj1Client.isSealed); - let obj2 = aPacket.frame.arguments[1]; + let obj2 = packet.frame.arguments[1]; do_check_false(obj2.sealed); let obj2Client = gThreadClient.pauseGrip(obj2); diff --git a/devtools/server/tests/unit/test_objectgrips-07.js b/devtools/server/tests/unit/test_objectgrips-07.js index 6d9ac11fb3db..c562872a732f 100644 --- a/devtools/server/tests/unit/test_objectgrips-07.js +++ b/devtools/server/tests/unit/test_objectgrips-07.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * This test checks that objects which are not extensible report themselves as * such. @@ -11,37 +13,35 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1, arg2, arg3, arg4) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let [f, s, ne, e] = aPacket.frame.arguments; - let [fClient, sClient, neClient, eClient] = aPacket.frame.arguments.map( +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let [f, s, ne, e] = packet.frame.arguments; + let [fClient, sClient, neClient, eClient] = packet.frame.arguments.map( a => gThreadClient.pauseGrip(a)); do_check_false(f.extensible); diff --git a/devtools/server/tests/unit/test_objectgrips-08.js b/devtools/server/tests/unit/test_objectgrips-08.js index ecaa7146dbd1..71a7039c0c3a 100644 --- a/devtools/server/tests/unit/test_objectgrips-08.js +++ b/devtools/server/tests/unit/test_objectgrips-08.js @@ -1,65 +1,65 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + var gDebuggee; var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; do_check_eq(args[0].class, "Object"); let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getPrototypeAndProperties(function (aResponse) { - do_check_eq(aResponse.ownProperties.a.configurable, true); - do_check_eq(aResponse.ownProperties.a.enumerable, true); - do_check_eq(aResponse.ownProperties.a.writable, true); - do_check_eq(aResponse.ownProperties.a.value.type, "Infinity"); + objClient.getPrototypeAndProperties(function (response) { + do_check_eq(response.ownProperties.a.configurable, true); + do_check_eq(response.ownProperties.a.enumerable, true); + do_check_eq(response.ownProperties.a.writable, true); + do_check_eq(response.ownProperties.a.value.type, "Infinity"); - do_check_eq(aResponse.ownProperties.b.configurable, true); - do_check_eq(aResponse.ownProperties.b.enumerable, true); - do_check_eq(aResponse.ownProperties.b.writable, true); - do_check_eq(aResponse.ownProperties.b.value.type, "-Infinity"); + do_check_eq(response.ownProperties.b.configurable, true); + do_check_eq(response.ownProperties.b.enumerable, true); + do_check_eq(response.ownProperties.b.writable, true); + do_check_eq(response.ownProperties.b.value.type, "-Infinity"); - do_check_eq(aResponse.ownProperties.c.configurable, true); - do_check_eq(aResponse.ownProperties.c.enumerable, true); - do_check_eq(aResponse.ownProperties.c.writable, true); - do_check_eq(aResponse.ownProperties.c.value.type, "NaN"); + do_check_eq(response.ownProperties.c.configurable, true); + do_check_eq(response.ownProperties.c.enumerable, true); + do_check_eq(response.ownProperties.c.writable, true); + do_check_eq(response.ownProperties.c.value.type, "NaN"); - do_check_eq(aResponse.ownProperties.d.configurable, true); - do_check_eq(aResponse.ownProperties.d.enumerable, true); - do_check_eq(aResponse.ownProperties.d.writable, true); - do_check_eq(aResponse.ownProperties.d.value.type, "-0"); + do_check_eq(response.ownProperties.d.configurable, true); + do_check_eq(response.ownProperties.d.enumerable, true); + do_check_eq(response.ownProperties.d.writable, true); + do_check_eq(response.ownProperties.d.value.type, "-0"); gThreadClient.resume(function () { gClient.close().then(gCallback); diff --git a/devtools/server/tests/unit/test_objectgrips-09.js b/devtools/server/tests/unit/test_objectgrips-09.js index 498154b1ed1a..7f521e9cd0be 100644 --- a/devtools/server/tests/unit/test_objectgrips-09.js +++ b/devtools/server/tests/unit/test_objectgrips-09.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + /** * This tests exercises getProtypesAndProperties message accepted * by a thread actor. @@ -10,63 +13,61 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-grips", aServer); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-grips", server); gDebuggee.eval(function stopMe(arg1, arg2) { debugger; }.toString()); - gClient = new DebuggerClient(aServer.connectPipe()); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; - gThreadClient.getPrototypesAndProperties([args[0].actor, args[1].actor], function (aResponse) { - let obj1 = aResponse.actors[args[0].actor]; - let obj2 = aResponse.actors[args[1].actor]; - do_check_eq(obj1.ownProperties.x.configurable, true); - do_check_eq(obj1.ownProperties.x.enumerable, true); - do_check_eq(obj1.ownProperties.x.writable, true); - do_check_eq(obj1.ownProperties.x.value, 10); + gThreadClient.getPrototypesAndProperties( + [args[0].actor, args[1].actor], function (response) { + let obj1 = response.actors[args[0].actor]; + let obj2 = response.actors[args[1].actor]; + do_check_eq(obj1.ownProperties.x.configurable, true); + do_check_eq(obj1.ownProperties.x.enumerable, true); + do_check_eq(obj1.ownProperties.x.writable, true); + do_check_eq(obj1.ownProperties.x.value, 10); - do_check_eq(obj1.ownProperties.y.configurable, true); - do_check_eq(obj1.ownProperties.y.enumerable, true); - do_check_eq(obj1.ownProperties.y.writable, true); - do_check_eq(obj1.ownProperties.y.value, "kaiju"); + do_check_eq(obj1.ownProperties.y.configurable, true); + do_check_eq(obj1.ownProperties.y.enumerable, true); + do_check_eq(obj1.ownProperties.y.writable, true); + do_check_eq(obj1.ownProperties.y.value, "kaiju"); - do_check_eq(obj2.ownProperties.z.configurable, true); - do_check_eq(obj2.ownProperties.z.enumerable, true); - do_check_eq(obj2.ownProperties.z.writable, true); - do_check_eq(obj2.ownProperties.z.value, 123); + do_check_eq(obj2.ownProperties.z.configurable, true); + do_check_eq(obj2.ownProperties.z.enumerable, true); + do_check_eq(obj2.ownProperties.z.writable, true); + do_check_eq(obj2.ownProperties.z.value, 123); - do_check_true(obj1.prototype != undefined); - do_check_true(obj2.prototype != undefined); + do_check_true(obj1.prototype != undefined); + do_check_true(obj2.prototype != undefined); - gThreadClient.resume(function () { - gClient.close().then(gCallback); + gThreadClient.resume(function () { + gClient.close().then(gCallback); + }); }); - }); - }); gDebuggee.eval("stopMe({ x: 10, y: 'kaiju'}, { z: 123 })"); diff --git a/devtools/server/tests/unit/test_objectgrips-10.js b/devtools/server/tests/unit/test_objectgrips-10.js index a5d1b18c6076..7b3eed94d934 100644 --- a/devtools/server/tests/unit/test_objectgrips-10.js +++ b/devtools/server/tests/unit/test_objectgrips-10.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; @@ -7,56 +10,55 @@ var gThreadClient; // Test that closures can be inspected. -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-closures"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-closures", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-closures", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); do_test_pending(); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let person = aPacket.frame.environment.bindings.variables.person; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let person = packet.frame.environment.bindings.variables.person; do_check_eq(person.value.class, "Object"); let personClient = gThreadClient.pauseGrip(person.value); - personClient.getPrototypeAndProperties(aResponse => { - do_check_eq(aResponse.ownProperties.getName.value.class, "Function"); + personClient.getPrototypeAndProperties(response => { + do_check_eq(response.ownProperties.getName.value.class, "Function"); - do_check_eq(aResponse.ownProperties.getAge.value.class, "Function"); + do_check_eq(response.ownProperties.getAge.value.class, "Function"); - do_check_eq(aResponse.ownProperties.getFoo.value.class, "Function"); + do_check_eq(response.ownProperties.getFoo.value.class, "Function"); - let getNameClient = gThreadClient.pauseGrip(aResponse.ownProperties.getName.value); - let getAgeClient = gThreadClient.pauseGrip(aResponse.ownProperties.getAge.value); - let getFooClient = gThreadClient.pauseGrip(aResponse.ownProperties.getFoo.value); - getNameClient.getScope(aResponse => { - do_check_eq(aResponse.scope.bindings.arguments[0].name.value, "Bob"); + let getNameClient = gThreadClient.pauseGrip(response.ownProperties.getName.value); + let getAgeClient = gThreadClient.pauseGrip(response.ownProperties.getAge.value); + let getFooClient = gThreadClient.pauseGrip(response.ownProperties.getFoo.value); + getNameClient.getScope(response => { + do_check_eq(response.scope.bindings.arguments[0].name.value, "Bob"); - getAgeClient.getScope(aResponse => { - do_check_eq(aResponse.scope.bindings.arguments[1].age.value, 58); + getAgeClient.getScope(response => { + do_check_eq(response.scope.bindings.arguments[1].age.value, 58); - getFooClient.getScope(aResponse => { - do_check_eq(aResponse.scope.bindings.variables.foo.value, 10); + getFooClient.getScope(response => { + do_check_eq(response.scope.bindings.variables.foo.value, 10); gThreadClient.resume(() => finishClient(gClient)); }); }); }); }); - }); + /* eslint-disable */ gDebuggee.eval("(" + function () { var PersonFactory = function (name, age) { var foo = 10; @@ -69,4 +71,5 @@ function test_object_grip() var person = new PersonFactory("Bob", 58); debugger; } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_objectgrips-11.js b/devtools/server/tests/unit/test_objectgrips-11.js index 1ad5c353a7be..dea3fb6d9bc4 100644 --- a/devtools/server/tests/unit/test_objectgrips-11.js +++ b/devtools/server/tests/unit/test_objectgrips-11.js @@ -1,14 +1,15 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we get the magic properties on Error objects. var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gDebuggee.eval(function stopMe(arg1) { @@ -17,22 +18,22 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_object_grip(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_object_grip(); + }); }); do_test_pending(); } -function test_object_grip() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_object_grip() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; let objClient = gThreadClient.pauseGrip(args[0]); - objClient.getOwnPropertyNames(function (aResponse) { - var opn = aResponse.ownPropertyNames; + objClient.getOwnPropertyNames(function (response) { + let opn = response.ownPropertyNames; do_check_eq(opn.length, 4); opn.sort(); do_check_eq(opn[0], "columnNumber"); @@ -44,7 +45,6 @@ function test_object_grip() finishClient(gClient); }); }); - }); gDebuggee.eval("stopMe(new TypeError('error message text'))"); diff --git a/devtools/server/tests/unit/test_objectgrips-12.js b/devtools/server/tests/unit/test_objectgrips-12.js index 32d4d47e01f8..419a4fe2ec90 100644 --- a/devtools/server/tests/unit/test_objectgrips-12.js +++ b/devtools/server/tests/unit/test_objectgrips-12.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; // Test getDisplayString. @@ -9,8 +12,7 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gDebuggee.eval(function stopMe(arg1) { @@ -19,16 +21,16 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_display_string(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_display_string(); + }); }); do_test_pending(); } -function test_display_string() -{ +function test_display_string() { const testCases = [ { input: "new Boolean(true)", @@ -139,8 +141,8 @@ function test_display_string() PromiseTestUtils.expectUncaughtRejection(/Error/); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - const args = aPacket.frame.arguments; + gThreadClient.addOneTimeListener("paused", function (event, packet) { + const args = packet.frame.arguments; (function loop() { const objClient = gThreadClient.pauseGrip(args.pop()); diff --git a/devtools/server/tests/unit/test_objectgrips-13.js b/devtools/server/tests/unit/test_objectgrips-13.js index 166e8a0d543b..29b3faa699ac 100644 --- a/devtools/server/tests/unit/test_objectgrips-13.js +++ b/devtools/server/tests/unit/test_objectgrips-13.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that ObjectClient.prototype.getDefinitionSite and the "definitionSite" // request work properly. @@ -8,8 +10,7 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); Components.utils.evalInSandbox(function stopMe() { @@ -18,18 +19,18 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - add_pause_listener(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + add_pause_listener(); + }); }); do_test_pending(); } -function add_pause_listener() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - const [funcGrip, objGrip] = aPacket.frame.arguments; +function add_pause_listener() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + const [funcGrip, objGrip] = packet.frame.arguments; const func = gThreadClient.pauseGrip(funcGrip); const obj = gThreadClient.pauseGrip(objGrip); test_definition_site(func, obj); diff --git a/devtools/server/tests/unit/test_pause_exceptions-01.js b/devtools/server/tests/unit/test_pause_exceptions-01.js index 56ee6816d6da..f2a20dfca4f5 100644 --- a/devtools/server/tests/unit/test_pause_exceptions-01.js +++ b/devtools/server/tests/unit/test_pause_exceptions-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that setting pauseOnExceptions to true will cause the debuggee to pause @@ -10,26 +13,25 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "exception"); - do_check_eq(aPacket.why.exception, 42); +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "exception"); + do_check_eq(packet.why.exception, 42); gThreadClient.resume(function () { finishClient(gClient); }); @@ -38,6 +40,7 @@ function test_pause_frame() gThreadClient.resume(); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function stopMe() { debugger; @@ -47,4 +50,5 @@ function test_pause_frame() stopMe(); } catch (e) {} } + ")()"); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_pause_exceptions-02.js b/devtools/server/tests/unit/test_pause_exceptions-02.js index fa9b419f0350..74cc816de739 100644 --- a/devtools/server/tests/unit/test_pause_exceptions-02.js +++ b/devtools/server/tests/unit/test_pause_exceptions-02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that setting pauseOnExceptions to true when the debugger isn't in a * paused state will cause the debuggee to pause when an exceptions is thrown. @@ -10,31 +12,31 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ +function test_pause_frame() { gThreadClient.pauseOnExceptions(true, false, function () { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "exception"); - do_check_eq(aPacket.why.exception, 42); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "exception"); + do_check_eq(packet.why.exception, 42); gThreadClient.resume(function () { finishClient(gClient); }); }); + /* eslint-disable */ gDebuggee.eval("(" + function () { function stopMe() { throw 42; @@ -43,5 +45,6 @@ function test_pause_frame() stopMe(); } catch (e) {} } + ")()"); + /* eslint-enable */ }); } diff --git a/devtools/server/tests/unit/test_pauselifetime-01.js b/devtools/server/tests/unit/test_pauselifetime-01.js index 71c2ddae7ac6..3ad2d56c6e8f 100644 --- a/devtools/server/tests/unit/test_pauselifetime-01.js +++ b/devtools/server/tests/unit/test_pauselifetime-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that pause-lifetime grips go away correctly after a resume. @@ -9,39 +12,37 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let pauseActor = aPacket.actor; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let pauseActor = packet.actor; - // Make a bogus request to the pause-liftime actor. Should get + // Make a bogus request to the pause-lifetime actor. Should get // unrecognized-packet-type (and not no-such-actor). - gClient.request({ to: pauseActor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "unrecognizedPacketType"); + gClient.request({ to: pauseActor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "unrecognizedPacketType"); gThreadClient.resume(function () { // Now that we've resumed, should get no-such-actor for the // same request. - gClient.request({ to: pauseActor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); + gClient.request({ to: pauseActor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); finishClient(gClient); }); }); - }); }); diff --git a/devtools/server/tests/unit/test_pauselifetime-02.js b/devtools/server/tests/unit/test_pauselifetime-02.js index 6c90725bbe67..c3d4b9254858 100644 --- a/devtools/server/tests/unit/test_pauselifetime-02.js +++ b/devtools/server/tests/unit/test_pauselifetime-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that pause-lifetime grips go away correctly after a resume. @@ -9,38 +12,37 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; let objActor = args[0].actor; do_check_eq(args[0].class, "Object"); do_check_true(!!objActor); // Make a bogus request to the grip actor. Should get // unrecognized-packet-type (and not no-such-actor). - gClient.request({ to: objActor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "unrecognizedPacketType"); + gClient.request({ to: objActor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "unrecognizedPacketType"); gThreadClient.resume(function () { // Now that we've resumed, should get no-such-actor for the // same request. - gClient.request({ to: objActor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); + gClient.request({ to: objActor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); finishClient(gClient); }); }); @@ -48,7 +50,7 @@ function test_pause_frame() }); gDebuggee.eval("(" + function () { - function stopMe(aObject) { + function stopMe(obj) { debugger; } stopMe({ foo: "bar" }); diff --git a/devtools/server/tests/unit/test_pauselifetime-03.js b/devtools/server/tests/unit/test_pauselifetime-03.js index 9fca887b70c0..eaa5477f55d1 100644 --- a/devtools/server/tests/unit/test_pauselifetime-03.js +++ b/devtools/server/tests/unit/test_pauselifetime-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that pause-lifetime grip clients are marked invalid after a resume. @@ -9,24 +12,23 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; let objActor = args[0].actor; do_check_eq(args[0].class, "Object"); do_check_true(!!objActor); @@ -36,16 +38,16 @@ function test_pause_frame() // Make a bogus request to the grip actor. Should get // unrecognized-packet-type (and not no-such-actor). - gClient.request({ to: objActor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "unrecognizedPacketType"); + gClient.request({ to: objActor, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "unrecognizedPacketType"); do_check_true(objClient.valid); gThreadClient.resume(function () { // Now that we've resumed, should get no-such-actor for the // same request. - gClient.request({ to: objActor, type: "bogusRequest" }, function (aResponse) { + gClient.request({ to: objActor, type: "bogusRequest" }, function (response) { do_check_false(objClient.valid); - do_check_eq(aResponse.error, "noSuchActor"); + do_check_eq(response.error, "noSuchActor"); finishClient(gClient); }); }); @@ -53,7 +55,7 @@ function test_pause_frame() }); gDebuggee.eval("(" + function () { - function stopMe(aObject) { + function stopMe(obj) { debugger; } stopMe({ foo: "bar" }); diff --git a/devtools/server/tests/unit/test_pauselifetime-04.js b/devtools/server/tests/unit/test_pauselifetime-04.js index c863da92155e..27ca291a6a07 100644 --- a/devtools/server/tests/unit/test_pauselifetime-04.js +++ b/devtools/server/tests/unit/test_pauselifetime-04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that requesting a pause actor for the same value multiple * times returns the same actor. @@ -10,28 +12,27 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-stack"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_pause_frame(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_pause_frame(); + }); }); do_test_pending(); } -function test_pause_frame() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let args = aPacket.frame.arguments; +function test_pause_frame() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let args = packet.frame.arguments; let objActor1 = args[0].actor; - gThreadClient.getFrames(0, 1, function (aResponse) { - let frame = aResponse.frames[0]; + gThreadClient.getFrames(0, 1, function (response) { + let frame = response.frames[0]; do_check_eq(objActor1, frame.arguments[0].actor); gThreadClient.resume(function () { finishClient(gClient); @@ -40,7 +41,7 @@ function test_pause_frame() }); gDebuggee.eval("(" + function () { - function stopMe(aObject) { + function stopMe(obj) { debugger; } stopMe({ foo: "bar" }); diff --git a/devtools/server/tests/unit/test_profiler_activation-01.js b/devtools/server/tests/unit/test_profiler_activation-01.js index 31efbb5e3a77..0fd417585557 100644 --- a/devtools/server/tests/unit/test_profiler_activation-01.js +++ b/devtools/server/tests/unit/test_profiler_activation-01.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ "use strict"; @@ -11,8 +12,7 @@ const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); const MAX_PROFILER_ENTRIES = 10000000; -function run_test() -{ +function run_test() { // Ensure the profiler is not running when the test starts (it could // happen if the MOZ_PROFILER_STARTUP environment variable is set). Profiler.StopProfiler(); @@ -41,49 +41,50 @@ function test_activate(client1, actor1, client2, actor2, callback) { do_check_true(typeof response.generation === "number"); // Start the profiler on the first connection.... - client1.request({ to: actor1, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { - do_check_true(Profiler.IsActive()); - do_check_true(response.started); - do_check_true(typeof response.position === "number"); - do_check_true(typeof response.totalSize === "number"); - do_check_true(typeof response.generation === "number"); - do_check_true(response.position >= 0 && response.position < response.totalSize); - do_check_true(response.totalSize === MAX_PROFILER_ENTRIES); - - // On the next connection just make sure the actor has been instantiated. - client2.request({ to: actor2, type: "isActive" }, response => { + client1.request( + { to: actor1, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { do_check_true(Profiler.IsActive()); - do_check_true(response.isActive); - do_check_true(response.currentTime > 0); + do_check_true(response.started); do_check_true(typeof response.position === "number"); do_check_true(typeof response.totalSize === "number"); do_check_true(typeof response.generation === "number"); do_check_true(response.position >= 0 && response.position < response.totalSize); do_check_true(response.totalSize === MAX_PROFILER_ENTRIES); - let origConnectionClosed = DebuggerServer._connectionClosed; - - DebuggerServer._connectionClosed = function (conn) { - origConnectionClosed.call(this, conn); - - // The first client is the only actor that started the profiler, - // however the second client can request the accumulated profile data - // at any moment, so the profiler module shouldn't have deactivated. + // On the next connection just make sure the actor has been instantiated. + client2.request({ to: actor2, type: "isActive" }, response => { do_check_true(Profiler.IsActive()); + do_check_true(response.isActive); + do_check_true(response.currentTime > 0); + do_check_true(typeof response.position === "number"); + do_check_true(typeof response.totalSize === "number"); + do_check_true(typeof response.generation === "number"); + do_check_true(response.position >= 0 && response.position < response.totalSize); + do_check_true(response.totalSize === MAX_PROFILER_ENTRIES); + + let origConnectionClosed = DebuggerServer._connectionClosed; DebuggerServer._connectionClosed = function (conn) { origConnectionClosed.call(this, conn); - // Now there are no open clients at all, it should *definitely* - // be deactivated by now. - do_check_false(Profiler.IsActive()); + // The first client is the only actor that started the profiler, + // however the second client can request the accumulated profile data + // at any moment, so the profiler module shouldn't have deactivated. + do_check_true(Profiler.IsActive()); - callback(); + DebuggerServer._connectionClosed = function (conn) { + origConnectionClosed.call(this, conn); + + // Now there are no open clients at all, it should *definitely* + // be deactivated by now. + do_check_false(Profiler.IsActive()); + + callback(); + }; + client2.close(); }; - client2.close(); - }; - client1.close(); + client1.close(); + }); }); - }); }); } diff --git a/devtools/server/tests/unit/test_profiler_activation-02.js b/devtools/server/tests/unit/test_profiler_activation-02.js index cf06b1e06613..69415d112780 100644 --- a/devtools/server/tests/unit/test_profiler_activation-02.js +++ b/devtools/server/tests/unit/test_profiler_activation-02.js @@ -11,13 +11,11 @@ const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); const WAIT_TIME = 1000; // ms -function run_test() -{ +function run_test() { // Ensure the profiler is already running when the test starts. Profiler.StartProfiler(1000000, 1, ["js"], 1); DevToolsUtils.waitForTime(WAIT_TIME).then(() => { - get_chrome_actors((client, form) => { let actor = form.profilerActor; test_start_time(client, actor, () => { diff --git a/devtools/server/tests/unit/test_profiler_bufferstatus.js b/devtools/server/tests/unit/test_profiler_bufferstatus.js index 9c86bf817ed6..df1eda2af330 100644 --- a/devtools/server/tests/unit/test_profiler_bufferstatus.js +++ b/devtools/server/tests/unit/test_profiler_bufferstatus.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ "use strict"; @@ -12,8 +13,7 @@ const INITIAL_WAIT_TIME = 100; // ms const MAX_WAIT_TIME = 20000; // ms const MAX_PROFILER_ENTRIES = 10000000; -function run_test() -{ +function run_test() { // Ensure the profiler is not running when the test starts (it could // happen if the MOZ_PROFILER_STARTUP environment variable is set). Profiler.StopProfiler(); @@ -36,8 +36,7 @@ function run_test() do_test_pending(); } -function check_buffer(client, actor, callback) -{ +function check_buffer(client, actor, callback) { client.request({ to: actor, type: "isActive" }, response => { do_check_true(typeof response.position === "number"); do_check_true(typeof response.totalSize === "number"); @@ -51,8 +50,7 @@ function check_buffer(client, actor, callback) }); } -function check_empty_buffer(client, actor, callback) -{ +function check_empty_buffer(client, actor, callback) { client.request({ to: actor, type: "isActive" }, response => { do_check_false(Profiler.IsActive()); do_check_false(response.isActive); @@ -65,19 +63,18 @@ function check_empty_buffer(client, actor, callback) }); } -function activate_profiler(client, actor, callback) -{ - client.request({ to: actor, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { - do_check_true(response.started); - client.request({ to: actor, type: "isActive" }, response => { - do_check_true(response.isActive); - callback(response.currentTime); +function activate_profiler(client, actor, callback) { + client.request( + { to: actor, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { + do_check_true(response.started); + client.request({ to: actor, type: "isActive" }, response => { + do_check_true(response.isActive); + callback(response.currentTime); + }); }); - }); } -function deactivate_profiler(client, actor, callback) -{ +function deactivate_profiler(client, actor, callback) { client.request({ to: actor, type: "stopProfiler" }, response => { do_check_false(response.started); client.request({ to: actor, type: "isActive" }, response => { @@ -87,18 +84,15 @@ function deactivate_profiler(client, actor, callback) }); } -function wait_for_samples(client, actor, callback) -{ - function attempt(delay) - { - // No idea why, but Components.stack.sourceLine returns null. - let funcLine = Components.stack.lineNumber - 3; - +function wait_for_samples(client, actor, callback) { + function attempt(delay) { // Spin for the requested time, then take a sample. let start = Date.now(); - let stack; + do_print("Attempt: delay = " + delay); - while (Date.now() - start < delay) { stack = Components.stack; } + while (Date.now() - start < delay) { + /* Empty */ + } do_print("Attempt: finished waiting."); client.request({ to: actor, type: "getProfile" }, response => { @@ -109,14 +103,14 @@ function wait_for_samples(client, actor, callback) if (delay < MAX_WAIT_TIME) { // Double the spin-wait time and try again. do_print("Attempt: no samples, going around again."); - return attempt(delay * 2); + attempt(delay * 2); } else { // We've waited long enough, so just fail. do_print("Attempt: waited a long time, but no samples were collected."); do_print("Giving up."); do_check_true(false); - return; } + return; } callback(); }); diff --git a/devtools/server/tests/unit/test_profiler_close.js b/devtools/server/tests/unit/test_profiler_close.js index a8b3040fdf2d..f7ebec68e99c 100644 --- a/devtools/server/tests/unit/test_profiler_close.js +++ b/devtools/server/tests/unit/test_profiler_close.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ "use strict"; @@ -10,8 +11,7 @@ const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); -function run_test() -{ +function run_test() { get_chrome_actors((client1, form1) => { let actor1 = form1.profilerActor; get_chrome_actors((client2, form2) => { @@ -29,8 +29,7 @@ function run_test() do_test_pending(); } -function activate_profiler(client, actor, callback) -{ +function activate_profiler(client, actor, callback) { client.request({ to: actor, type: "startProfiler" }, response => { do_check_true(response.started); do_check_true(Profiler.IsActive()); @@ -42,8 +41,7 @@ function activate_profiler(client, actor, callback) }); } -function deactivate_profiler(client, actor, callback) -{ +function deactivate_profiler(client, actor, callback) { client.request({ to: actor, type: "stopProfiler" }, response => { do_check_false(response.started); do_check_true(Profiler.IsActive()); @@ -55,8 +53,7 @@ function deactivate_profiler(client, actor, callback) }); } -function test_close(client1, actor1, client2, actor2, callback) -{ +function test_close(client1, actor1, client2, actor2, callback) { activate_profiler(client1, actor1, () => { activate_profiler(client2, actor2, () => { deactivate_profiler(client1, actor1, () => { diff --git a/devtools/server/tests/unit/test_profiler_data.js b/devtools/server/tests/unit/test_profiler_data.js index 2a79eed1f1de..65bdd5ffde11 100644 --- a/devtools/server/tests/unit/test_profiler_data.js +++ b/devtools/server/tests/unit/test_profiler_data.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ "use strict"; @@ -8,12 +9,10 @@ * it is activated. */ -const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); const INITIAL_WAIT_TIME = 100; // ms const MAX_WAIT_TIME = 20000; // ms -function run_test() -{ +function run_test() { get_chrome_actors((client, form) => { let actor = form.profilerActor; activate_profiler(client, actor, startTime => { @@ -28,8 +27,7 @@ function run_test() do_test_pending(); } -function activate_profiler(client, actor, callback) -{ +function activate_profiler(client, actor, callback) { client.request({ to: actor, type: "startProfiler" }, response => { do_check_true(response.started); client.request({ to: actor, type: "isActive" }, response => { @@ -39,8 +37,7 @@ function activate_profiler(client, actor, callback) }); } -function deactivate_profiler(client, actor, callback) -{ +function deactivate_profiler(client, actor, callback) { client.request({ to: actor, type: "stopProfiler" }, response => { do_check_false(response.started); client.request({ to: actor, type: "isActive" }, response => { @@ -50,18 +47,18 @@ function deactivate_profiler(client, actor, callback) }); } -function test_data(client, actor, startTime, callback) -{ - function attempt(delay) - { +function test_data(client, actor, startTime, callback) { + function attempt(delay) { // No idea why, but Components.stack.sourceLine returns null. - let funcLine = Components.stack.lineNumber - 3; + let funcLine = Components.stack.lineNumber - 2; // Spin for the requested time, then take a sample. let start = Date.now(); let stack; do_print("Attempt: delay = " + delay); - while (Date.now() - start < delay) { stack = Components.stack; } + while (Date.now() - start < delay) { + stack = Components.stack; + } do_print("Attempt: finished waiting."); client.request({ to: actor, type: "getProfile", startTime }, response => { @@ -81,14 +78,14 @@ function test_data(client, actor, startTime, callback) if (delay < MAX_WAIT_TIME) { // Double the spin-wait time and try again. do_print("Attempt: no samples, going around again."); - return attempt(delay * 2); + attempt(delay * 2); } else { // We've waited long enough, so just fail. do_print("Attempt: waited a long time, but no samples were collected."); do_print("Giving up."); do_check_true(false); - return; } + return; } // Now check the samples. At least one sample is expected to diff --git a/devtools/server/tests/unit/test_profiler_events-01.js b/devtools/server/tests/unit/test_profiler_events-01.js index b8ca592b9dd4..484928558116 100644 --- a/devtools/server/tests/unit/test_profiler_events-01.js +++ b/devtools/server/tests/unit/test_profiler_events-01.js @@ -7,7 +7,6 @@ * Tests the event notification service for the profiler actor. */ -const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); const { ProfilerFront } = require("devtools/shared/fronts/profiler"); function run_test() { @@ -36,7 +35,8 @@ add_task(function* () { do_check_true(events[2] === 0); do_check_true(events[3] === 0); - let ret = yield front.registerEventNotifications({ events: ["console-api-profiler", "profiler-started", "profiler-stopped"] }); + let ret = yield front.registerEventNotifications( + { events: ["console-api-profiler", "profiler-started", "profiler-stopped"] }); do_check_true(ret.registered.length === 3); yield front.startProfiler(); @@ -51,7 +51,8 @@ add_task(function* () { do_check_true(events[2] === 1); do_check_true(events[3] === 2, "compatibility events supported for eventNotifications"); - ret = yield front.unregisterEventNotifications({ events: ["console-api-profiler", "profiler-started", "profiler-stopped"] }); + ret = yield front.unregisterEventNotifications( + { events: ["console-api-profiler", "profiler-started", "profiler-stopped"] }); do_check_true(ret.registered.length === 3); }); diff --git a/devtools/server/tests/unit/test_profiler_events-02.js b/devtools/server/tests/unit/test_profiler_events-02.js index fed702043cfc..90a277da266b 100644 --- a/devtools/server/tests/unit/test_profiler_events-02.js +++ b/devtools/server/tests/unit/test_profiler_events-02.js @@ -48,7 +48,8 @@ add_task(function* () { yield waitForTime(500); yield front.stopProfiler(); - do_check_true(eventsCalled === 0, "No 'profiler-status' events should be fired before registering."); + do_check_true(eventsCalled === 0, + "No 'profiler-status' events should be fired before registering."); let ret = yield front.registerEventNotifications({ events: ["profiler-status"] }); do_check_true(ret.registered.length === 1); @@ -56,11 +57,13 @@ add_task(function* () { yield front.startProfiler(); yield handledThreeTimes.promise; yield front.stopProfiler(); - do_check_true(eventsCalled >= 3, "profiler-status fired atleast three times while recording"); + do_check_true(eventsCalled >= 3, + "profiler-status fired atleast three times while recording"); let totalEvents = eventsCalled; yield waitForTime(50); - do_check_true(totalEvents === eventsCalled, "No more profiler-status events after recording."); + do_check_true(totalEvents === eventsCalled, + "No more profiler-status events after recording."); }); function getChromeActors() { diff --git a/devtools/server/tests/unit/test_profiler_getbufferinfo.js b/devtools/server/tests/unit/test_profiler_getbufferinfo.js index 1ec536738179..1214a0d0a9be 100644 --- a/devtools/server/tests/unit/test_profiler_getbufferinfo.js +++ b/devtools/server/tests/unit/test_profiler_getbufferinfo.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ "use strict"; @@ -12,8 +13,7 @@ const INITIAL_WAIT_TIME = 100; // ms const MAX_WAIT_TIME = 20000; // ms const MAX_PROFILER_ENTRIES = 10000000; -function run_test() -{ +function run_test() { // Ensure the profiler is not running when the test starts (it could // happen if the MOZ_PROFILER_STARTUP environment variable is set). Profiler.StopProfiler(); @@ -36,8 +36,7 @@ function run_test() do_test_pending(); } -function check_empty_buffer(client, actor, callback) -{ +function check_empty_buffer(client, actor, callback) { client.request({ to: actor, type: "getBufferInfo" }, response => { do_check_true(response.position === 0); do_check_true(response.totalSize === 0); @@ -46,8 +45,7 @@ function check_empty_buffer(client, actor, callback) }); } -function check_buffer(client, actor, callback) -{ +function check_buffer(client, actor, callback) { client.request({ to: actor, type: "getBufferInfo" }, response => { do_check_true(typeof response.position === "number"); do_check_true(typeof response.totalSize === "number"); @@ -61,19 +59,18 @@ function check_buffer(client, actor, callback) }); } -function activate_profiler(client, actor, callback) -{ - client.request({ to: actor, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { - do_check_true(response.started); - client.request({ to: actor, type: "isActive" }, response => { - do_check_true(response.isActive); - callback(response.currentTime); +function activate_profiler(client, actor, callback) { + client.request( + { to: actor, type: "startProfiler", entries: MAX_PROFILER_ENTRIES }, response => { + do_check_true(response.started); + client.request({ to: actor, type: "isActive" }, response => { + do_check_true(response.isActive); + callback(response.currentTime); + }); }); - }); } -function deactivate_profiler(client, actor, callback) -{ +function deactivate_profiler(client, actor, callback) { client.request({ to: actor, type: "stopProfiler" }, response => { do_check_false(response.started); client.request({ to: actor, type: "isActive" }, response => { @@ -83,18 +80,14 @@ function deactivate_profiler(client, actor, callback) }); } -function wait_for_samples(client, actor, callback) -{ - function attempt(delay) - { - // No idea why, but Components.stack.sourceLine returns null. - let funcLine = Components.stack.lineNumber - 3; - +function wait_for_samples(client, actor, callback) { + function attempt(delay) { // Spin for the requested time, then take a sample. let start = Date.now(); - let stack; + do_print("Attempt: delay = " + delay); - while (Date.now() - start < delay) { stack = Components.stack; } + /* eslint-disable no-empty */ + while (Date.now() - start < delay) {} do_print("Attempt: finished waiting."); client.request({ to: actor, type: "getProfile" }, response => { @@ -105,14 +98,14 @@ function wait_for_samples(client, actor, callback) if (delay < MAX_WAIT_TIME) { // Double the spin-wait time and try again. do_print("Attempt: no samples, going around again."); - return attempt(delay * 2); + attempt(delay * 2); } else { // We've waited long enough, so just fail. do_print("Attempt: waited a long time, but no samples were collected."); do_print("Giving up."); do_check_true(false); - return; } + return; } callback(); }); diff --git a/devtools/server/tests/unit/test_profiler_getfeatures.js b/devtools/server/tests/unit/test_profiler_getfeatures.js index 5b37e7d55bfd..426b625c4b66 100644 --- a/devtools/server/tests/unit/test_profiler_getfeatures.js +++ b/devtools/server/tests/unit/test_profiler_getfeatures.js @@ -7,10 +7,7 @@ * Tests whether the profiler responds to "getFeatures" adequately. */ -const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); - -function run_test() -{ +function run_test() { get_chrome_actors((client, form) => { let actor = form.profilerActor; test_getfeatures(client, actor, () => { @@ -23,8 +20,7 @@ function run_test() do_test_pending(); } -function test_getfeatures(client, actor, callback) -{ +function test_getfeatures(client, actor, callback) { client.request({ to: actor, type: "getFeatures" }, response => { do_check_eq(typeof response.features, "object"); do_check_true(response.features.length >= 1); diff --git a/devtools/server/tests/unit/test_profiler_sharedlibraries.js b/devtools/server/tests/unit/test_profiler_sharedlibraries.js index eac8e6fd4713..2b1cff3f99fd 100644 --- a/devtools/server/tests/unit/test_profiler_sharedlibraries.js +++ b/devtools/server/tests/unit/test_profiler_sharedlibraries.js @@ -7,8 +7,7 @@ * Tests whether the profiler responds to "sharedLibraries" adequately. */ -function run_test() -{ +function run_test() { get_chrome_actors((client, form) => { let actor = form.profilerActor; test_sharedlibraries(client, actor, () => { @@ -21,8 +20,7 @@ function run_test() do_test_pending(); } -function test_sharedlibraries(client, actor, callback) -{ +function test_sharedlibraries(client, actor, callback) { client.request({ to: actor, type: "sharedLibraries" }, libs => { do_check_eq(typeof libs, "object"); do_check_true(Array.isArray(libs)); diff --git a/devtools/server/tests/unit/test_promise_state-01.js b/devtools/server/tests/unit/test_promise_state-01.js index a525560ab267..7f0dbd40a466 100644 --- a/devtools/server/tests/unit/test_promise_state-01.js +++ b/devtools/server/tests/unit/test_promise_state-01.js @@ -1,34 +1,40 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; /** * Test that the preview in a Promise's grip is correct when the Promise is * pending. */ -function run_test() -{ +function run_test() { initTestDebuggerServer(); const debuggee = addTestGlobal("test-promise-state"); const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { - attachTestTabAndResume(client, "test-promise-state", function (response, tabClient, threadClient) { - Task.spawn(function* () { - const packet = yield executeOnNextTickAndWaitForPause(() => evalCode(debuggee), client); + attachTestTabAndResume( + client, "test-promise-state", + function (response, tabClient, threadClient) { + Task.spawn(function* () { + const packet = yield executeOnNextTickAndWaitForPause( + () => evalCode(debuggee), client); - const grip = packet.frame.environment.bindings.variables.p; - ok(grip.value.preview); - equal(grip.value.class, "Promise"); - equal(grip.value.promiseState.state, "pending"); + const grip = packet.frame.environment.bindings.variables.p; + ok(grip.value.preview); + equal(grip.value.class, "Promise"); + equal(grip.value.promiseState.state, "pending"); - finishClient(client); + finishClient(client); + }); }); - }); }); do_test_pending(); } function evalCode(debuggee) { + /* eslint-disable */ Components.utils.evalInSandbox( "doTest();\n" + function doTest() { @@ -37,4 +43,5 @@ function evalCode(debuggee) { }, debuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_promise_state-02.js b/devtools/server/tests/unit/test_promise_state-02.js index cf44f1946b97..f3b1b724525e 100644 --- a/devtools/server/tests/unit/test_promise_state-02.js +++ b/devtools/server/tests/unit/test_promise_state-02.js @@ -1,36 +1,43 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; /** * Test that the preview in a Promise's grip is correct when the Promise is * fulfilled. */ -function run_test() -{ +function run_test() { initTestDebuggerServer(); const debuggee = addTestGlobal("test-promise-state"); const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { - attachTestTabAndResume(client, "test-promise-state", function (response, tabClient, threadClient) { - Task.spawn(function* () { - const packet = yield executeOnNextTickAndWaitForPause(() => evalCode(debuggee), client); + attachTestTabAndResume( + client, "test-promise-state", + function (response, tabClient, threadClient) { + Task.spawn(function* () { + const packet = yield executeOnNextTickAndWaitForPause( + () => evalCode(debuggee), client); - const grip = packet.frame.environment.bindings.variables.p; - ok(grip.value.preview); - equal(grip.value.class, "Promise"); - equal(grip.value.promiseState.state, "fulfilled"); - equal(grip.value.promiseState.value.actorID, packet.frame.arguments[0].actorID, - "The promise's fulfilled state value should be the same value passed to the then function"); + const grip = packet.frame.environment.bindings.variables.p; + ok(grip.value.preview); + equal(grip.value.class, "Promise"); + equal(grip.value.promiseState.state, "fulfilled"); + equal(grip.value.promiseState.value.actorID, packet.frame.arguments[0].actorID, + "The promise's fulfilled state value should be the same value passed " + + "to the then function"); - finishClient(client); + finishClient(client); + }); }); - }); }); do_test_pending(); } function evalCode(debuggee) { + /* eslint-disable */ Components.utils.evalInSandbox( "doTest();\n" + function doTest() { @@ -42,4 +49,5 @@ function evalCode(debuggee) { }, debuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_promise_state-03.js b/devtools/server/tests/unit/test_promise_state-03.js index cf64e3e277c5..6b8a993dbd91 100644 --- a/devtools/server/tests/unit/test_promise_state-03.js +++ b/devtools/server/tests/unit/test_promise_state-03.js @@ -1,36 +1,43 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; /** * Test that the preview in a Promise's grip is correct when the Promise is * rejected. */ -function run_test() -{ +function run_test() { initTestDebuggerServer(); const debuggee = addTestGlobal("test-promise-state"); const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { - attachTestTabAndResume(client, "test-promise-state", function (response, tabClient, threadClient) { - Task.spawn(function* () { - const packet = yield executeOnNextTickAndWaitForPause(() => evalCode(debuggee), client); + attachTestTabAndResume( + client, "test-promise-state", + function (response, tabClient, threadClient) { + Task.spawn(function* () { + const packet = yield executeOnNextTickAndWaitForPause( + () => evalCode(debuggee), client); - const grip = packet.frame.environment.bindings.variables.p; - ok(grip.value.preview); - equal(grip.value.class, "Promise"); - equal(grip.value.promiseState.state, "rejected"); - equal(grip.value.promiseState.reason.actorID, packet.frame.arguments[0].actorID, - "The promise's rejected state reason should be the same value passed to the then function"); + const grip = packet.frame.environment.bindings.variables.p; + ok(grip.value.preview); + equal(grip.value.class, "Promise"); + equal(grip.value.promiseState.state, "rejected"); + equal(grip.value.promiseState.reason.actorID, packet.frame.arguments[0].actorID, + "The promise's rejected state reason should be the same value passed " + + "to the then function"); - finishClient(client); + finishClient(client); + }); }); - }); }); do_test_pending(); } function evalCode(debuggee) { + /* eslint-disable */ Components.utils.evalInSandbox( "doTest();\n" + function doTest() { @@ -42,4 +49,5 @@ function evalCode(debuggee) { }, debuggee ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_promises_actor_attach.js b/devtools/server/tests/unit/test_promises_actor_attach.js index 17c2a1f41620..5d11fb26ef2b 100644 --- a/devtools/server/tests/unit/test_promises_actor_attach.js +++ b/devtools/server/tests/unit/test_promises_actor_attach.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that we can attach and detach to the PromisesActor under the correct * states. diff --git a/devtools/server/tests/unit/test_promises_actor_exist.js b/devtools/server/tests/unit/test_promises_actor_exist.js index 13eef3e9936a..3a8405eed324 100644 --- a/devtools/server/tests/unit/test_promises_actor_exist.js +++ b/devtools/server/tests/unit/test_promises_actor_exist.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that the PromisesActor exists in the TabActors and ChromeActors. diff --git a/devtools/server/tests/unit/test_protocolSpec.js b/devtools/server/tests/unit/test_protocolSpec.js index cc0746387a3f..833daf0f4ff9 100644 --- a/devtools/server/tests/unit/test_protocolSpec.js +++ b/devtools/server/tests/unit/test_protocolSpec.js @@ -1,3 +1,5 @@ +"use strict"; + const run_test = Test(function* () { initTestDebuggerServer(); const connection = DebuggerServer.connectPipe(); diff --git a/devtools/server/tests/unit/test_protocol_abort.js b/devtools/server/tests/unit/test_protocol_abort.js index bb25d1b2ceaa..7136717e6b26 100644 --- a/devtools/server/tests/unit/test_protocol_abort.js +++ b/devtools/server/tests/unit/test_protocol_abort.js @@ -1,14 +1,15 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Outstanding requests should be rejected when the connection aborts * unexpectedly. */ var protocol = require("devtools/shared/protocol"); -var {Arg, Option, RetVal} = protocol; -var events = require("sdk/event/core"); +var {RetVal} = protocol; function simpleHello() { return { diff --git a/devtools/server/tests/unit/test_protocol_async.js b/devtools/server/tests/unit/test_protocol_async.js index 75f0538632ee..736649282bf4 100644 --- a/devtools/server/tests/unit/test_protocol_async.js +++ b/devtools/server/tests/unit/test_protocol_async.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Make sure we get replies in the same order that we sent their * requests even when earlier requests take several event ticks to @@ -8,8 +10,7 @@ */ var protocol = require("devtools/shared/protocol"); -var {Arg, Option, RetVal} = protocol; -var events = require("sdk/event/core"); +var {Arg, RetVal} = protocol; function simpleHello() { return { @@ -98,8 +99,7 @@ var RootFront = protocol.FrontClassWithSpec(rootSpec, { } }); -function run_test() -{ +function run_test() { DebuggerServer.createRootActor = RootActor; DebuggerServer.init(); @@ -116,26 +116,33 @@ function run_test() // Execute a call that won't finish processing until 2 // more calls have happened calls.push(rootClient.promiseReturn(2).then(ret => { - do_check_eq(sequence, 0); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 0); + // Check request handling order + do_check_eq(ret, sequence++); })); // Put a few requests into the backlog calls.push(rootClient.simpleReturn().then(ret => { - do_check_eq(sequence, 1); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 1); + // Check request handling order + do_check_eq(ret, sequence++); })); calls.push(rootClient.simpleReturn().then(ret => { - do_check_eq(sequence, 2); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 2); + // Check request handling order + do_check_eq(ret, sequence++); })); calls.push(rootClient.simpleThrow().then(() => { do_check_true(false, "simpleThrow shouldn't succeed!"); }, error => { - do_check_eq(sequence++, 3); // Check right return order + // Check right return order + do_check_eq(sequence++, 3); })); // While packets are sent in the correct order, rejection handlers @@ -146,15 +153,18 @@ function run_test() calls.push(rootClient.promiseThrow().then(() => { do_check_true(false, "promiseThrow shouldn't succeed!"); }, error => { - do_check_eq(sequence++, 4); // Check right return order + // Check right return order + do_check_eq(sequence++, 4); do_check_true(true, "simple throw should throw"); deferAfterRejection.resolve(); })); calls.push(rootClient.simpleReturn().then(ret => { return deferAfterRejection.promise.then(function () { - do_check_eq(sequence, 5); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 5); + // Check request handling order + do_check_eq(ret, sequence++); }); })); @@ -162,15 +172,19 @@ function run_test() // for another simpleReturn before completing calls.push(rootClient.promiseReturn(1).then(ret => { return deferAfterRejection.promise.then(function () { - do_check_eq(sequence, 6); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 6); + // Check request handling order + do_check_eq(ret, sequence++); }); })); calls.push(rootClient.simpleReturn().then(ret => { return deferAfterRejection.promise.then(function () { - do_check_eq(sequence, 7); // Check right return order - do_check_eq(ret, sequence++); // Check request handling order + // Check right return order + do_check_eq(sequence, 7); + // Check request handling order + do_check_eq(ret, sequence++); }); })); diff --git a/devtools/server/tests/unit/test_protocol_children.js b/devtools/server/tests/unit/test_protocol_children.js index 67773ebefa8b..caee5492b584 100644 --- a/devtools/server/tests/unit/test_protocol_children.js +++ b/devtools/server/tests/unit/test_protocol_children.js @@ -1,11 +1,14 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; /** * Test simple requests using the protocol helpers. */ var protocol = require("devtools/shared/protocol"); -var {preEvent, types, Arg, Option, RetVal} = protocol; +var {preEvent, types, Arg, RetVal} = protocol; var events = require("sdk/event/core"); @@ -17,8 +20,6 @@ function simpleHello() { }; } -var testTypes = {}; - // Predeclaring the actor type so that it can be used in the // implementation of the child actor. types.addActorType("childActor"); @@ -27,12 +28,12 @@ const childSpec = protocol.generateActorSpec({ typeName: "childActor", events: { - "event1" : { + "event1": { a: Arg(0), b: Arg(1), c: Arg(2) }, - "event2" : { + "event2": { a: Arg(0), b: Arg(1), c: Arg(2) @@ -90,9 +91,13 @@ const childSpec = protocol.generateActorSpec({ var ChildActor = protocol.ActorClassWithSpec(childSpec, { // Actors returned by this actor should be owned by the root actor. - marshallPool: function () { return this.parent(); }, + marshallPool: function () { + return this.parent(); + }, - toString: function () { return "[ChildActor " + this.childID + "]"; }, + toString: function () { + return "[ChildActor " + this.childID + "]"; + }, initialize: function (conn, id) { protocol.Actor.prototype.initialize.call(this, conn); @@ -166,9 +171,13 @@ var ChildFront = protocol.FrontClassWithSpec(childSpec, { protocol.Front.prototype.destroy.call(this); }, - marshallPool: function () { return this.parent(); }, + marshallPool: function () { + return this.parent(); + }, - toString: function () { return "[child front " + this.childID + "]"; }, + toString: function () { + return "[child front " + this.childID + "]"; + }, form: function (form, detail) { if (detail === "actorid") { @@ -183,7 +192,9 @@ var ChildFront = protocol.FrontClassWithSpec(childSpec, { }), onEvent2a: preEvent("event2", function (a, b, c) { - return promise.resolve().then(() => this.event2arg3 = c); + return promise.resolve().then(() => { + this.event2arg3 = c; + }); }), onEvent2b: preEvent("event2", function (a, b, c) { @@ -227,7 +238,9 @@ const rootSpec = protocol.generateActorSpec({ var rootActor = null; var RootActor = protocol.ActorClassWithSpec(rootSpec, { - toString: function () { return "[root actor]"; }, + toString: function () { + return "[root actor]"; + }, initialize: function (conn) { rootActor = this; @@ -264,7 +277,8 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, { getManyChildren: function () { return { - foo: "bar", // note that this isn't in the specialization array. + // note that this isn't in the specialization array. + foo: "bar", child5: this.getChild("child5"), more: [ this.getChild("child6"), this.getChild("child7") ] }; @@ -288,7 +302,9 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, { }); var RootFront = protocol.FrontClassWithSpec(rootSpec, { - toString: function () { return "[root front]"; }, + toString: function () { + return "[root front]"; + }, initialize: function (client) { this.actorID = "root"; protocol.Front.prototype.initialize.call(this, client); @@ -319,8 +335,7 @@ var RootFront = protocol.FrontClassWithSpec(rootSpec, { }) }); -function run_test() -{ +function run_test() { DebuggerServer.createRootActor = (conn => { return RootActor(conn); }); @@ -329,7 +344,9 @@ function run_test() let trace = connectPipeTracing(); let client = new DebuggerClient(trace); client.connect().then(([applicationType, traits]) => { - trace.expectReceive({"from":"", "applicationType":"xpcshell-tests", "traits":[]}); + trace.expectReceive({"from": "", + "applicationType": "xpcshell-tests", + "traits": []}); do_check_eq(applicationType, "xpcshell-tests"); let rootFront = RootFront(client); @@ -344,8 +361,8 @@ function run_test() }; rootFront.getChild("child1").then(ret => { - trace.expectSend({"type":"getChild", "str":"child1", "to":""}); - trace.expectReceive({"actor":"", "from":""}); + trace.expectSend({"type": "getChild", "str": "child1", "to": ""}); + trace.expectReceive({"actor": "", "from": ""}); childFront = ret; do_check_true(childFront instanceof ChildFront); @@ -355,49 +372,57 @@ function run_test() // Request the child again, make sure the same is returned. return rootFront.getChild("child1"); }).then(ret => { - trace.expectSend({"type":"getChild", "str":"child1", "to":""}); - trace.expectReceive({"actor":"", "from":""}); + trace.expectSend({"type": "getChild", "str": "child1", "to": ""}); + trace.expectReceive({"actor": "", "from": ""}); expectRootChildren(1); do_check_true(ret === childFront); }).then(() => { return childFront.echo("hello"); }).then(ret => { - trace.expectSend({"type":"echo", "str":"hello", "to":""}); - trace.expectReceive({"str":"hello", "from":""}); + trace.expectSend({"type": "echo", "str": "hello", "to": ""}); + trace.expectReceive({"str": "hello", "from": ""}); do_check_eq(ret, "hello"); }).then(() => { return childFront.getDetail1(); }).then(ret => { - trace.expectSend({"type":"getDetail1", "to":""}); - trace.expectReceive({"actor":"", "childID":"child1", "detail":"detail1", "from":""}); + trace.expectSend({"type": "getDetail1", "to": ""}); + trace.expectReceive({"actor": "", + "childID": "child1", + "detail": "detail1", + "from": ""}); do_check_true(ret === childFront); do_check_eq(childFront.detail, "detail1"); }).then(() => { return childFront.getDetail2(); }).then(ret => { - trace.expectSend({"type":"getDetail2", "to":""}); - trace.expectReceive({"actor":"", "childID":"child1", "detail":"detail2", "from":""}); + trace.expectSend({"type": "getDetail2", "to": ""}); + trace.expectReceive({"actor": "", + "childID": "child1", + "detail": "detail2", + "from": ""}); do_check_true(ret === childFront); do_check_eq(childFront.detail, "detail2"); }).then(() => { return childFront.getIDDetail(); }).then(ret => { - trace.expectSend({"type":"getIDDetail", "to":""}); - trace.expectReceive({"idDetail": childFront.actorID, "from":""}); + trace.expectSend({"type": "getIDDetail", "to": ""}); + trace.expectReceive({"idDetail": childFront.actorID, "from": ""}); do_check_true(ret === childFront); }).then(() => { return childFront.getSibling("siblingID"); }).then(ret => { - trace.expectSend({"type":"getSibling", "id":"siblingID", "to":""}); - trace.expectReceive({"sibling":{"actor":"", "childID":"siblingID"}, "from":""}); + trace.expectSend({"type": "getSibling", "id": "siblingID", "to": ""}); + trace.expectReceive({"sibling": {"actor": "", "childID": "siblingID"}, + "from": ""}); expectRootChildren(2); }).then(ret => { return rootFront.getTemporaryChild("temp1").then(temp1 => { - trace.expectSend({"type":"getTemporaryChild", "id":"temp1", "to":""}); - trace.expectReceive({"child":{"actor":"", "childID":"temp1"}, "from":""}); + trace.expectSend({"type": "getTemporaryChild", "id": "temp1", "to": ""}); + trace.expectReceive({"child": {"actor": "", "childID": "temp1"}, + "from": ""}); // At this point we expect two direct children, plus the temporary holder // which should hold 1 itself. @@ -406,8 +431,11 @@ function run_test() expectRootChildren(3); return rootFront.getTemporaryChild("temp2").then(temp2 => { - trace.expectSend({"type":"getTemporaryChild", "id":"temp2", "to":""}); - trace.expectReceive({"child":{"actor":"", "childID":"temp2"}, "from":""}); + trace.expectSend({"type": "getTemporaryChild", + "id": "temp2", + "to": ""}); + trace.expectReceive({"child": {"actor": "", "childID": "temp2"}, + "from": ""}); // Same amount of direct children, and an extra in the temporary holder. expectRootChildren(3); @@ -416,12 +444,11 @@ function run_test() // Get the children of the temporary holder... let checkActors = rootActor._temporaryHolder.__poolMap.values(); - let checkFronts = rootFront._temporaryHolder.__poolMap.values(); // Now release the temporary holders and expect them to drop again. return rootFront.clearTemporaryChildren().then(() => { - trace.expectSend({"type":"clearTemporaryChildren", "to":""}); - trace.expectReceive({"from":""}); + trace.expectSend({"type": "clearTemporaryChildren", "to": ""}); + trace.expectReceive({"from": ""}); expectRootChildren(2); do_check_false(!!rootActor._temporaryHolder); @@ -436,8 +463,12 @@ function run_test() }).then(ret => { return rootFront.getChildren(["child1", "child2"]); }).then(ret => { - trace.expectSend({"type":"getChildren", "ids":["child1", "child2"], "to":""}); - trace.expectReceive({"children":[{"actor":"", "childID":"child1"}, {"actor":"", "childID":"child2"}], "from":""}); + trace.expectSend({"type": "getChildren", + "ids": ["child1", "child2"], + "to": ""}); + trace.expectReceive({"children": [{"actor": "", "childID": "child1"}, + {"actor": "", "childID": "child2"}], + "from": ""}); expectRootChildren(3); do_check_true(ret[0] === childFront); @@ -448,7 +479,8 @@ function run_test() // going to trigger events on the first child, so an event // triggered on the second should cause immediate failures. - let set = new Set(["event1", "event2", "named-event", "object-event", "array-object-event"]); + let set = new Set(["event1", "event2", "named-event", + "object-event", "array-object-event"]); childFront.on("event1", (a, b, c) => { do_check_eq(a, 1); @@ -497,22 +529,36 @@ function run_test() ret[1].on("array-object-event", fail); return childFront.emitEvents().then(() => { - trace.expectSend({"type":"emitEvents", "to":""}); - trace.expectReceive({"type":"event1", "a":1, "b":2, "c":3, "from":""}); - trace.expectReceive({"type":"event2", "a":4, "b":5, "c":6, "from":""}); - trace.expectReceive({"type":"namedEvent", "a":1, "b":2, "c":3, "from":""}); - trace.expectReceive({"type":"objectEvent", "detail":{"actor":"", "childID":"child1", "detail":"detail1"}, "from":""}); - trace.expectReceive({"type":"arrayObjectEvent", "detail":[{"actor":"", "childID":"child1", "detail":"detail2"}], "from":""}); - trace.expectReceive({"value":"correct response", "from":""}); - + trace.expectSend({"type": "emitEvents", "to": ""}); + trace.expectReceive({"type": "event1", "a": 1, "b": 2, "c": 3, + "from": ""}); + trace.expectReceive({"type": "event2", "a": 4, "b": 5, "c": 6, + "from": ""}); + trace.expectReceive({"type": "namedEvent", "a": 1, "b": 2, "c": 3, + "from": ""}); + trace.expectReceive({"type": "objectEvent", + "detail": {"actor": "", + "childID": "child1", + "detail": "detail1"}, + "from": ""}); + trace.expectReceive({"type": "arrayObjectEvent", + "detail": [{"actor": "", + "childID": "child1", + "detail": "detail2"}], + "from": ""}); + trace.expectReceive({"value": "correct response", "from": ""}); do_check_eq(set.size, 0); }); }).then(ret => { return rootFront.getManyChildren(); }).then(ret => { - trace.expectSend({"type":"getManyChildren", "to":""}); - trace.expectReceive({"foo":"bar", "child5":{"actor":"", "childID":"child5"}, "more":[{"actor":"", "childID":"child6"}, {"actor":"", "childID":"child7"}], "from":""}); + trace.expectSend({"type": "getManyChildren", "to": ""}); + trace.expectReceive({"foo": "bar", + "child5": {"actor": "", "childID": "child5"}, + "more": [{"actor": "", "childID": "child6"}, + {"actor": "", "childID": "child7"}], + "from": ""}); // Check all the crazy stuff we did in getManyChildren do_check_eq(ret.foo, "bar"); diff --git a/devtools/server/tests/unit/test_protocol_formtype.js b/devtools/server/tests/unit/test_protocol_formtype.js index 27ac0bee9456..5fa0bd5f67b9 100644 --- a/devtools/server/tests/unit/test_protocol_formtype.js +++ b/devtools/server/tests/unit/test_protocol_formtype.js @@ -1,5 +1,7 @@ +"use strict"; + var protocol = require("devtools/shared/protocol"); -var {Arg, Option, RetVal} = protocol; +var {RetVal} = protocol; protocol.types.addActorType("child"); protocol.types.addActorType("root"); @@ -171,6 +173,7 @@ const run_test = Test(function* () { yield rootFront.getUnknownDetail(); do_check_true(false); } catch (ex) { + // empty } yield client.close(); diff --git a/devtools/server/tests/unit/test_protocol_longstring.js b/devtools/server/tests/unit/test_protocol_longstring.js index c37f4251ec99..2cfd5025e14c 100644 --- a/devtools/server/tests/unit/test_protocol_longstring.js +++ b/devtools/server/tests/unit/test_protocol_longstring.js @@ -1,11 +1,14 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable max-nested-callbacks */ + +"use strict"; /** * Test simple requests using the protocol helpers. */ var protocol = require("devtools/shared/protocol"); -var {RetVal, Arg, Option} = protocol; +var {RetVal, Arg} = protocol; var events = require("sdk/event/core"); var {LongStringActor} = require("devtools/server/actors/string"); @@ -20,7 +23,9 @@ function simpleHello() { }; } -DebuggerServer.LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_READ_LENGTH = 5; +DebuggerServer.LONG_STRING_LENGTH = + DebuggerServer.LONG_STRING_INITIAL_LENGTH = + DebuggerServer.LONG_STRING_READ_LENGTH = 5; var SHORT_STR = "abc"; var LONG_STR = "abcdefghijklmnop"; @@ -89,8 +94,7 @@ var RootFront = protocol.FrontClassWithSpec(rootSpec, { } }); -function run_test() -{ +function run_test() { DebuggerServer.createRootActor = (conn => { return RootActor(conn); }); @@ -107,18 +111,19 @@ function run_test() do_check_eq(rootClient.__poolMap.size, size + 1); }; - client.connect().then(([applicationType, traits]) => { rootClient = RootFront(client); // Root actor has no children yet. expectRootChildren(0); - trace.expectReceive({"from":"", "applicationType":"xpcshell-tests", "traits":[]}); + trace.expectReceive({"from": "", + "applicationType": "xpcshell-tests", + "traits": []}); do_check_eq(applicationType, "xpcshell-tests"); rootClient.shortString().then(ret => { - trace.expectSend({"type":"shortString", "to":""}); - trace.expectReceive({"value":"abc", "from":""}); + trace.expectSend({"type": "shortString", "to": ""}); + trace.expectReceive({"value": "abc", "from": ""}); // Should only own the one reference (itself) at this point. expectRootChildren(0); @@ -130,8 +135,12 @@ function run_test() }).then(() => { return rootClient.longString(); }).then(ret => { - trace.expectSend({"type":"longString", "to":""}); - trace.expectReceive({"value":{"type":"longString", "actor":"", "length":16, "initial":"abcde"}, "from":""}); + trace.expectSend({"type": "longString", "to": ""}); + trace.expectReceive({"value": {"type": "longString", + "actor": "", + "length": 16, + "initial": "abcde"}, + "from": ""}); strfront = ret; // Should own a reference to itself and an extra string now. @@ -139,34 +148,36 @@ function run_test() }).then(() => { return strfront.string(); }).then(ret => { - trace.expectSend({"type":"substring", "start":5, "end":10, "to":""}); - trace.expectReceive({"substring":"fghij", "from":""}); - trace.expectSend({"type":"substring", "start":10, "end":15, "to":""}); - trace.expectReceive({"substring":"klmno", "from":""}); - trace.expectSend({"type":"substring", "start":15, "end":20, "to":""}); - trace.expectReceive({"substring":"p", "from":""}); + trace.expectSend({"type": "substring", "start": 5, "end": 10, "to": ""}); + trace.expectReceive({"substring": "fghij", "from": ""}); + trace.expectSend({"type": "substring", "start": 10, "end": 15, "to": ""}); + trace.expectReceive({"substring": "klmno", "from": ""}); + trace.expectSend({"type": "substring", "start": 15, "end": 20, "to": ""}); + trace.expectReceive({"substring": "p", "from": ""}); do_check_eq(ret, LONG_STR); }).then(() => { return strfront.release(); }).then(() => { - trace.expectSend({"type":"release", "to":""}); - trace.expectReceive({"from":""}); + trace.expectSend({"type": "release", "to": ""}); + trace.expectReceive({"from": ""}); // That reference should be removed now. expectRootChildren(0); }).then(() => { let deferred = promise.defer(); rootClient.once("string-event", (str) => { - trace.expectSend({"type":"emitShortString", "to":""}); - trace.expectReceive({"type":"string-event", "str":"abc", "from":""}); + trace.expectSend({"type": "emitShortString", "to": ""}); + trace.expectReceive({"type": "string-event", "str": "abc", "from": ""}); do_check_true(!!str); strfront = str; // Shouldn't generate any new references expectRootChildren(0); // will generate no packets. - strfront.string().then((value) => { deferred.resolve(value); }); + strfront.string().then((value) => { + deferred.resolve(value); + }); }); rootClient.emitShortString(); return deferred.promise; @@ -178,20 +189,34 @@ function run_test() }).then(() => { let deferred = promise.defer(); rootClient.once("string-event", (str) => { - trace.expectSend({"type":"emitLongString", "to":""}); - trace.expectReceive({"type":"string-event", "str":{"type":"longString", "actor":"", "length":16, "initial":"abcde"}, "from":""}); + trace.expectSend({"type": "emitLongString", "to": ""}); + trace.expectReceive({"type": "string-event", + "str": {"type": "longString", + "actor": "", + "length": 16, + "initial": "abcde"}, + "from": ""}); do_check_true(!!str); // Should generate one new reference expectRootChildren(1); strfront = str; strfront.string().then((value) => { - trace.expectSend({"type":"substring", "start":5, "end":10, "to":""}); - trace.expectReceive({"substring":"fghij", "from":""}); - trace.expectSend({"type":"substring", "start":10, "end":15, "to":""}); - trace.expectReceive({"substring":"klmno", "from":""}); - trace.expectSend({"type":"substring", "start":15, "end":20, "to":""}); - trace.expectReceive({"substring":"p", "from":""}); + trace.expectSend({"type": "substring", + "start": 5, + "end": 10, + "to": ""}); + trace.expectReceive({"substring": "fghij", "from": ""}); + trace.expectSend({"type": "substring", + "start": 10, + "end": 15, + "to": ""}); + trace.expectReceive({"substring": "klmno", "from": ""}); + trace.expectSend({"type": "substring", + "start": 15, + "end": 20, + "to": ""}); + trace.expectReceive({"substring": "p", "from": ""}); deferred.resolve(value); }); @@ -203,8 +228,8 @@ function run_test() }).then(() => { return strfront.release(); }).then(() => { - trace.expectSend({"type":"release", "to":""}); - trace.expectReceive({"from":""}); + trace.expectSend({"type": "release", "to": ""}); + trace.expectReceive({"from": ""}); expectRootChildren(0); }).then(() => { client.close().then(() => { diff --git a/devtools/server/tests/unit/test_protocol_simple.js b/devtools/server/tests/unit/test_protocol_simple.js index c85003954923..c19550afc381 100644 --- a/devtools/server/tests/unit/test_protocol_simple.js +++ b/devtools/server/tests/unit/test_protocol_simple.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test simple requests using the protocol helpers. */ @@ -173,8 +175,7 @@ var RootFront = protocol.FrontClassWithSpec(rootSpec, { } }); -function run_test() -{ +function run_test() { DebuggerServer.createRootActor = (conn => { return RootActor(conn); }); @@ -185,6 +186,7 @@ function run_test() missing: preEvent("missing-event", function () { }) }); + void badActor; }); protocol.types.getType("array:array:array:number"); @@ -198,20 +200,22 @@ function run_test() let rootClient; client.connect().then(([applicationType, traits]) => { - trace.expectReceive({"from":"", "applicationType":"xpcshell-tests", "traits":[]}); + trace.expectReceive({"from": "", + "applicationType": "xpcshell-tests", + "traits": []}); do_check_eq(applicationType, "xpcshell-tests"); rootClient = RootFront(client); rootClient.simpleReturn().then(ret => { - trace.expectSend({"type":"simpleReturn", "to":""}); - trace.expectReceive({"value":1, "from":""}); + trace.expectSend({"type": "simpleReturn", "to": ""}); + trace.expectReceive({"value": 1, "from": ""}); do_check_eq(ret, 1); }).then(() => { return rootClient.promiseReturn(); }).then(ret => { - trace.expectSend({"type":"promiseReturn", "to":""}); - trace.expectReceive({"value":1, "from":""}); + trace.expectSend({"type": "promiseReturn", "to": ""}); + trace.expectReceive({"value": 1, "from": ""}); do_check_eq(ret, 1); }).then(() => { // Missing argument should throw an exception @@ -221,15 +225,23 @@ function run_test() return rootClient.simpleArgs(5, 10); }).then(ret => { - trace.expectSend({"type":"simpleArgs", "firstArg":5, "secondArg":10, "to":""}); - trace.expectReceive({"firstResponse":6, "secondResponse":11, "from":""}); + trace.expectSend({"type": "simpleArgs", + "firstArg": 5, + "secondArg": 10, + "to": ""}); + trace.expectReceive({"firstResponse": 6, + "secondResponse": 11, + "from": ""}); do_check_eq(ret.firstResponse, 6); do_check_eq(ret.secondResponse, 11); }).then(() => { return rootClient.nestedArgs(1, 2, 3); }).then(ret => { - trace.expectSend({"type":"nestedArgs", "firstArg":1, "nest":{"secondArg":2, "nest":{"thirdArg":3}}, "to":""}); - trace.expectReceive({"a":1, "b":2, "c":3, "from":""}); + trace.expectSend({"type": "nestedArgs", + "firstArg": 1, + "nest": {"secondArg": 2, "nest": {"thirdArg": 3}}, + "to": ""}); + trace.expectReceive({"a": 1, "b": 2, "c": 3, "from": ""}); do_check_eq(ret.a, 1); do_check_eq(ret.b, 2); do_check_eq(ret.c, 3); @@ -239,56 +251,59 @@ function run_test() "option2": 10 }); }).then(ret => { - trace.expectSend({"type":"optionArgs", "option1":5, "option2":10, "to":""}); - trace.expectReceive({"option1":5, "option2":10, "from":""}); + trace.expectSend({"type": "optionArgs", + "option1": 5, + "option2": 10, + "to": ""}); + trace.expectReceive({"option1": 5, "option2": 10, "from": ""}); do_check_eq(ret.option1, 5); do_check_eq(ret.option2, 10); }).then(() => { return rootClient.optionArgs({}); }).then(ret => { - trace.expectSend({"type":"optionArgs", "to":""}); - trace.expectReceive({"from":""}); + trace.expectSend({"type": "optionArgs", "to": ""}); + trace.expectReceive({"from": ""}); do_check_true(typeof (ret.option1) === "undefined"); do_check_true(typeof (ret.option2) === "undefined"); }).then(() => { // Explicitly call an optional argument... return rootClient.optionalArgs(5, 10); }).then(ret => { - trace.expectSend({"type":"optionalArgs", "a":5, "b":10, "to":""}); - trace.expectReceive({"value":10, "from":""}); + trace.expectSend({"type": "optionalArgs", "a": 5, "b": 10, "to": ""}); + trace.expectReceive({"value": 10, "from": ""}); do_check_eq(ret, 10); }).then(() => { // Now don't pass the optional argument, expect the default. return rootClient.optionalArgs(5); }).then(ret => { - trace.expectSend({"type":"optionalArgs", "a":5, "to":""}); - trace.expectReceive({"value":200, "from":""}); + trace.expectSend({"type": "optionalArgs", "a": 5, "to": ""}); + trace.expectReceive({"value": 200, "from": ""}); do_check_eq(ret, 200); }).then(ret => { return rootClient.arrayArgs([0, 1, 2, 3, 4, 5]); }).then(ret => { - trace.expectSend({"type":"arrayArgs", "a":[0, 1, 2, 3, 4, 5], "to":""}); - trace.expectReceive({"arrayReturn":[0, 1, 2, 3, 4, 5], "from":""}); + trace.expectSend({"type": "arrayArgs", "a": [0, 1, 2, 3, 4, 5], "to": ""}); + trace.expectReceive({"arrayReturn": [0, 1, 2, 3, 4, 5], "from": ""}); do_check_eq(ret[0], 0); do_check_eq(ret[5], 5); }).then(() => { return rootClient.arrayArgs([[5]]); }).then(ret => { - trace.expectSend({"type":"arrayArgs", "a":[[5]], "to":""}); - trace.expectReceive({"arrayReturn":[[5]], "from":""}); + trace.expectSend({"type": "arrayArgs", "a": [[5]], "to": ""}); + trace.expectReceive({"arrayReturn": [[5]], "from": ""}); do_check_eq(ret[0][0], 5); }).then(() => { return rootClient.renamedEcho("hello"); }).then(str => { - trace.expectSend({"type":"echo", "a":"hello", "to":""}); - trace.expectReceive({"value":"hello", "from":""}); + trace.expectSend({"type": "echo", "a": "hello", "to": ""}); + trace.expectReceive({"value": "hello", "from": ""}); do_check_eq(str, "hello"); let deferred = promise.defer(); rootClient.on("oneway", (response) => { - trace.expectSend({"type":"testOneWay", "a":"hello", "to":""}); - trace.expectReceive({"type":"oneway", "a":"hello", "from":""}); + trace.expectSend({"type": "testOneWay", "a": "hello", "to": ""}); + trace.expectReceive({"type": "oneway", "a": "hello", "from": ""}); do_check_eq(response, "hello"); deferred.resolve(); @@ -298,8 +313,11 @@ function run_test() }).then(() => { let deferred = promise.defer(); rootClient.on("falsyOptions", res => { - trace.expectSend({"type":"emitFalsyOptions", "to":""}); - trace.expectReceive({"type":"falsyOptions", "farce":false, "zero": 0, "from":""}); + trace.expectSend({"type": "emitFalsyOptions", "to": ""}); + trace.expectReceive({"type": "falsyOptions", + "farce": false, + "zero": 0, + "from": ""}); do_check_true(res.zero === 0); do_check_true(res.farce === false); diff --git a/devtools/server/tests/unit/test_protocol_stack.js b/devtools/server/tests/unit/test_protocol_stack.js index a81f99a8ea3c..123a64da7bce 100644 --- a/devtools/server/tests/unit/test_protocol_stack.js +++ b/devtools/server/tests/unit/test_protocol_stack.js @@ -11,8 +11,7 @@ */ var protocol = require("devtools/shared/protocol"); -var {Arg, Option, RetVal} = protocol; -var events = require("sdk/event/core"); +var {RetVal} = protocol; function simpleHello() { return { diff --git a/devtools/server/tests/unit/test_protocol_unregister.js b/devtools/server/tests/unit/test_protocol_unregister.js index 5b32dd0a3920..8f3d76e6c1f1 100644 --- a/devtools/server/tests/unit/test_protocol_unregister.js +++ b/devtools/server/tests/unit/test_protocol_unregister.js @@ -1,11 +1,11 @@ +"use strict"; + const {types} = require("devtools/shared/protocol"); - -function run_test() -{ +function run_test() { types.addType("test", { - read: (v) => { return "successful read: " + v; }, - write: (v) => { return "successful write: " + v; } + read: (v) => "successful read: " + v, + write: (v) => "successful write: " + v }); // Verify the type registered correctly. @@ -38,7 +38,5 @@ function run_test() } catch (ex) { do_check_eq(ex.toString(), "Error: Using defunct type: test"); } - } - diff --git a/devtools/server/tests/unit/test_reattach-thread.js b/devtools/server/tests/unit/test_reattach-thread.js index 6d089e896fbe..d78db1ee4ab2 100644 --- a/devtools/server/tests/unit/test_reattach-thread.js +++ b/devtools/server/tests/unit/test_reattach-thread.js @@ -1,14 +1,15 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that reattaching to a previously detached thread works. */ var gClient, gDebuggee, gThreadClient, gTabClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = testGlobal("test-reattach"); DebuggerServer.addTestGlobal(gDebuggee); @@ -16,25 +17,23 @@ function run_test() let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); gClient.connect().then(() => { - attachTestTab(gClient, "test-reattach", (aReply, aTabClient) => { - gTabClient = aTabClient; + attachTestTab(gClient, "test-reattach", (reply, tabClient) => { + gTabClient = tabClient; test_attach(); }); }); do_test_pending(); } -function test_attach() -{ - gTabClient.attachThread({}, (aResponse, aThreadClient) => { - do_check_eq(aThreadClient.state, "paused"); - gThreadClient = aThreadClient; - aThreadClient.resume(test_detach); +function test_attach() { + gTabClient.attachThread({}, (response, threadClient) => { + do_check_eq(threadClient.state, "paused"); + gThreadClient = threadClient; + threadClient.resume(test_detach); }); } -function test_detach() -{ +function test_detach() { gThreadClient.detach(() => { do_check_eq(gThreadClient.state, "detached"); do_check_eq(gTabClient.thread, null); @@ -42,17 +41,15 @@ function test_detach() }); } -function test_reattach() -{ - gTabClient.attachThread({}, (aResponse, aThreadClient) => { - do_check_neq(gThreadClient, aThreadClient); - do_check_eq(aThreadClient.state, "paused"); - do_check_eq(gTabClient.thread, aThreadClient); - aThreadClient.resume(cleanup); +function test_reattach() { + gTabClient.attachThread({}, (response, threadClient) => { + do_check_neq(gThreadClient, threadClient); + do_check_eq(threadClient.state, "paused"); + do_check_eq(gTabClient.thread, threadClient); + threadClient.resume(cleanup); }); } -function cleanup() -{ +function cleanup() { gClient.close().then(do_test_finished); } diff --git a/devtools/server/tests/unit/test_registerClient.js b/devtools/server/tests/unit/test_registerClient.js index c018e4454c1a..3fdb746918d3 100644 --- a/devtools/server/tests/unit/test_registerClient.js +++ b/devtools/server/tests/unit/test_registerClient.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test the DebuggerClient.registerClient API var EventEmitter = require("devtools/shared/event-emitter"); var gClient; -var gActors; var gTestClient; function TestActor(conn) { @@ -49,8 +50,7 @@ TestClient.prototype = { } }; -function run_test() -{ +function run_test() { DebuggerServer.addGlobalActor(TestActor); DebuggerServer.init(); @@ -62,20 +62,17 @@ function run_test() run_next_test(); } -function init() -{ +function init() { gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect() .then(() => gClient.listTabs()) - .then(aResponse => { - gActors = aResponse; - gTestClient = new TestClient(gClient, aResponse); + .then(response => { + gTestClient = new TestClient(gClient, response); run_next_test(); }); } -function test_client_events() -{ +function test_client_events() { // Test DebuggerClient.registerClient and DebuggerServerConnection.sendActorEvent gTestClient.on("foo", function (type, data) { do_check_eq(type, "foo"); diff --git a/devtools/server/tests/unit/test_register_actor.js b/devtools/server/tests/unit/test_register_actor.js index c67e43986aba..818757d11e0e 100644 --- a/devtools/server/tests/unit/test_register_actor.js +++ b/devtools/server/tests/unit/test_register_actor.js @@ -3,18 +3,19 @@ "use strict"; -const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); - function check_actors(expect) { - do_check_eq(expect, DebuggerServer.tabActorFactories.hasOwnProperty("registeredActor1")); - do_check_eq(expect, DebuggerServer.tabActorFactories.hasOwnProperty("registeredActor2")); + do_check_eq(expect, + DebuggerServer.tabActorFactories.hasOwnProperty("registeredActor1")); + do_check_eq(expect, + DebuggerServer.tabActorFactories.hasOwnProperty("registeredActor2")); - do_check_eq(expect, DebuggerServer.globalActorFactories.hasOwnProperty("registeredActor2")); - do_check_eq(expect, DebuggerServer.globalActorFactories.hasOwnProperty("registeredActor1")); + do_check_eq(expect, + DebuggerServer.globalActorFactories.hasOwnProperty("registeredActor2")); + do_check_eq(expect, + DebuggerServer.globalActorFactories.hasOwnProperty("registeredActor1")); } -function run_test() -{ +function run_test() { // Allow incoming connections. DebuggerServer.init(); DebuggerServer.addBrowserActors(); @@ -74,19 +75,19 @@ function test_lazy_api() { client.connect().then(function onConnect() { client.listTabs(onListTabs); }); - function onListTabs(aResponse) { + function onListTabs(response) { // On listTabs, the actor is still not loaded, // but we can see its name in the list of available actors do_check_false(isActorLoaded); do_check_false(isActorInstanciated); - do_check_true("lazyActor" in aResponse); + do_check_true("lazyActor" in response); let {LazyFront} = require("xpcshell-test/registertestactors-03"); - let front = LazyFront(client, aResponse); + let front = LazyFront(client, response); front.hello().then(onRequest); } - function onRequest(aResponse) { - do_check_eq(aResponse, "world"); + function onRequest(response) { + do_check_eq(response, "world"); // Finally, the actor is loaded on the first request being made to it do_check_true(isActorLoaded); diff --git a/devtools/server/tests/unit/test_requestTypes.js b/devtools/server/tests/unit/test_requestTypes.js index 694e276bcada..7bafaa33e897 100644 --- a/devtools/server/tests/unit/test_requestTypes.js +++ b/devtools/server/tests/unit/test_requestTypes.js @@ -5,29 +5,27 @@ const { RootActor } = require("devtools/server/actors/root"); -function test_requestTypes_request(aClient, anActor) -{ - aClient.request({ to: "root", type: "requestTypes" }, function (aResponse) { - var expectedRequestTypes = Object.keys(RootActor. - prototype. - requestTypes); +function test_requestTypes_request(client, anActor) { + client.request({ to: "root", type: "requestTypes" }, function (response) { + let expectedRequestTypes = Object.keys(RootActor + .prototype + .requestTypes); - do_check_true(Array.isArray(aResponse.requestTypes)); - do_check_eq(JSON.stringify(aResponse.requestTypes), + do_check_true(Array.isArray(response.requestTypes)); + do_check_eq(JSON.stringify(response.requestTypes), JSON.stringify(expectedRequestTypes)); - aClient.close().then(() => { + client.close().then(() => { do_test_finished(); }); }); } -function run_test() -{ +function run_test() { DebuggerServer.init(); DebuggerServer.addBrowserActors(); - var client = new DebuggerClient(DebuggerServer.connectPipe()); + let client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { test_requestTypes_request(client); }); diff --git a/devtools/server/tests/unit/test_safe-getter.js b/devtools/server/tests/unit/test_safe-getter.js index 08949154d06c..3517f89ccb0f 100644 --- a/devtools/server/tests/unit/test_safe-getter.js +++ b/devtools/server/tests/unit/test_safe-getter.js @@ -1,9 +1,10 @@ +/* eslint-disable strict */ function run_test() { Components.utils.import("resource://gre/modules/jsdebugger.jsm"); addDebuggerToGlobal(this); - var g = testGlobal("test"); - var dbg = new Debugger(); - var gw = dbg.addDebuggee(g); + let g = testGlobal("test"); + let dbg = new Debugger(); + let gw = dbg.addDebuggee(g); g.eval(` // This is not a CCW. diff --git a/devtools/server/tests/unit/test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js b/devtools/server/tests/unit/test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js index 6185cf589bc0..d6691f616174 100644 --- a/devtools/server/tests/unit/test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js +++ b/devtools/server/tests/unit/test_setBreakpoint-on-column-with-no-offsets-at-end-of-line.js @@ -27,7 +27,7 @@ function run_test() { let sourceClient = threadClient.source(source); let location = { line: 4, column: 23 }; - let [packet, breakpointClient] = yield setBreakpoint(sourceClient, location); + let [packet, ] = yield setBreakpoint(sourceClient, location); do_check_true(packet.isPending); do_check_false("actualLocation" in packet); diff --git a/devtools/server/tests/unit/test_source-01.js b/devtools/server/tests/unit/test_source-01.js index 3401cc660613..595c5dbd879b 100644 --- a/devtools/server/tests/unit/test_source-01.js +++ b/devtools/server/tests/unit/test_source-01.js @@ -1,6 +1,9 @@ /* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; var gDebuggee; var gClient; @@ -10,8 +13,7 @@ var gThreadClient; // and that they can communicate over the protocol to fetch the source text for // a given script. -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); Cu.evalInSandbox( @@ -25,10 +27,11 @@ function run_test() gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_source(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_source(); + }); }); do_test_pending(); } @@ -36,31 +39,30 @@ function run_test() const SOURCE_URL = "http://example.com/foobar.js"; const SOURCE_CONTENT = "stopMe()"; -function test_source() -{ +function test_source() { DebuggerServer.LONG_STRING_LENGTH = 200; - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.getSources(function (aResponse) { - do_check_true(!!aResponse); - do_check_true(!!aResponse.sources); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getSources(function (response) { + do_check_true(!!response); + do_check_true(!!response.sources); - let source = aResponse.sources.filter(function (s) { + let source = response.sources.filter(function (s) { return s.url === SOURCE_URL; })[0]; do_check_true(!!source); let sourceClient = gThreadClient.source(source); - sourceClient.source(function (aResponse) { - do_check_true(!!aResponse); - do_check_true(!aResponse.error); - do_check_true(!!aResponse.contentType); - do_check_true(aResponse.contentType.includes("javascript")); + sourceClient.source(function (response) { + do_check_true(!!response); + do_check_true(!response.error); + do_check_true(!!response.contentType); + do_check_true(response.contentType.includes("javascript")); - do_check_true(!!aResponse.source); + do_check_true(!!response.source); do_check_eq(SOURCE_CONTENT, - aResponse.source); + response.source); gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_sourcemaps-01.js b/devtools/server/tests/unit/test_sourcemaps-01.js index 4d92bf9ccf9c..1fdc8b609977 100644 --- a/devtools/server/tests/unit/test_sourcemaps-01.js +++ b/devtools/server/tests/unit/test_sourcemaps-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check basic source map integration with the "newSource" packet in the RDP. */ @@ -11,36 +13,35 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_source_map(); + }); }); do_test_pending(); } -function test_simple_source_map() -{ +function test_simple_source_map() { // Because we are source mapping, we should be notified of a.js, b.js, and // c.js as sources, and shouldn't receive abc.js or test_sourcemaps-01.js. let expectedSources = new Set(["http://example.com/www/js/a.js", "http://example.com/www/js/b.js", "http://example.com/www/js/c.js"]); - gThreadClient.addListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); + gThreadClient.addListener("newSource", function _onNewSource(event, packet) { + do_check_eq(event, "newSource"); + do_check_eq(packet.type, "newSource"); + do_check_true(!!packet.source); - do_check_true(expectedSources.has(aPacket.source.url), + do_check_true(expectedSources.has(packet.source.url), "The source url should be one of our original sources."); - expectedSources.delete(aPacket.source.url); + expectedSources.delete(packet.source.url); if (expectedSources.size === 0) { gClient.removeListener("newSource", _onNewSource); diff --git a/devtools/server/tests/unit/test_sourcemaps-02.js b/devtools/server/tests/unit/test_sourcemaps-02.js index 2a343afaad8a..80d665382a4b 100644 --- a/devtools/server/tests/unit/test_sourcemaps-02.js +++ b/devtools/server/tests/unit/test_sourcemaps-02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check basic source map integration with the "sources" packet in the RDP. */ @@ -11,33 +13,32 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_source_map(); + }); }); do_test_pending(); } -function test_simple_source_map() -{ +function test_simple_source_map() { // Because we are source mapping, we should be notified of a.js, b.js, and // c.js as sources, and shouldn"t receive abc.js or test_sourcemaps-01.js. let expectedSources = new Set(["http://example.com/www/js/a.js", "http://example.com/www/js/b.js", "http://example.com/www/js/c.js"]); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.getSources(function (aResponse) { - do_check_true(!aResponse.error, "Should not get an error"); + gClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.getSources(function (response) { + do_check_true(!response.error, "Should not get an error"); - for (let s of aResponse.sources) { + for (let s of response.sources) { do_check_neq(s.url, "http://example.com/www/js/abc.js", "Shouldn't get the generated source's url."); expectedSources.delete(s.url); diff --git a/devtools/server/tests/unit/test_sourcemaps-03.js b/devtools/server/tests/unit/test_sourcemaps-03.js index 2fbd99aad538..58f229e9a38e 100644 --- a/devtools/server/tests/unit/test_sourcemaps-03.js +++ b/devtools/server/tests/unit/test_sourcemaps-03.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check setting breakpoints in source mapped sources. */ @@ -11,27 +13,26 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_source_map(); + }); }); do_test_pending(); } -function testBreakpointMapping(aName, aCallback) -{ +function testBreakpointMapping(name, callback) { Task.spawn(function* () { let response = yield waitForPause(gThreadClient); do_check_eq(response.why.type, "debuggerStatement"); - const source = yield getSource(gThreadClient, "http://example.com/www/js/" + aName + ".js"); + const source = yield getSource(gThreadClient, "http://example.com/www/js/" + name + ".js"); response = yield setBreakpoint(source, { // Setting the breakpoint on an empty line so that it is pushed down one // line and we can check the source mapped actualLocation later. @@ -47,7 +48,7 @@ function testBreakpointMapping(aName, aCallback) // because of our breakpoint, we resume again to finish the eval, and // finally receive our last pause which has the result of the client // evaluation. - response = yield gThreadClient.eval(null, aName + "()"); + response = yield gThreadClient.eval(null, name + "()"); do_check_eq(response.type, "resumed"); response = yield waitForPause(gThreadClient); @@ -62,11 +63,11 @@ function testBreakpointMapping(aName, aCallback) response = yield waitForPause(gThreadClient); do_check_eq(response.why.type, "clientEvaluated"); - do_check_eq(response.why.frameFinished.return, aName); + do_check_eq(response.why.frameFinished.return, name); response = yield resume(gThreadClient); - aCallback(); + callback(); }); gDebuggee.eval("(" + function () { @@ -74,26 +75,27 @@ function testBreakpointMapping(aName, aCallback) } + "());"); } -function test_simple_source_map() -{ +function test_simple_source_map() { let expectedSources = new Set([ "http://example.com/www/js/a.js", "http://example.com/www/js/b.js", "http://example.com/www/js/c.js" ]); - gThreadClient.addListener("newSource", function _onNewSource(aEvent, aPacket) { - expectedSources.delete(aPacket.source.url); + gThreadClient.addListener("newSource", function _onNewSource(event, packet) { + expectedSources.delete(packet.source.url); if (expectedSources.size > 0) { return; } gThreadClient.removeListener("newSource", _onNewSource); + function finish() { + finishClient(gClient); + } + testBreakpointMapping("a", function () { testBreakpointMapping("b", function () { - testBreakpointMapping("c", function () { - finishClient(gClient); - }); + testBreakpointMapping("c", finish); }); }); }); diff --git a/devtools/server/tests/unit/test_sourcemaps-04.js b/devtools/server/tests/unit/test_sourcemaps-04.js index 5fecb44c856a..cd9f25c9331f 100644 --- a/devtools/server/tests/unit/test_sourcemaps-04.js +++ b/devtools/server/tests/unit/test_sourcemaps-04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that absolute source map urls work. */ @@ -9,36 +11,35 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_absolute_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_absolute_source_map(); + }); }); do_test_pending(); } -function test_absolute_source_map() -{ - gThreadClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); +function test_absolute_source_map() { + gThreadClient.addOneTimeListener("newSource", function _onNewSource(event, packet) { + do_check_eq(event, "newSource"); + do_check_eq(packet.type, "newSource"); + do_check_true(!!packet.source); - do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1, + do_check_true(packet.source.url.indexOf("sourcemapped.coffee") !== -1, "The new source should be a coffee file."); - do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1, + do_check_eq(packet.source.url.indexOf("sourcemapped.js"), -1, "The new source should not be a js file."); finishClient(gClient); }); - code = readFile("sourcemapped.js") + let code = readFile("sourcemapped.js") + "\n//# sourceMappingURL=" + getFileUrl("source-map-data/sourcemapped.map"); Components.utils.evalInSandbox(code, gDebuggee, "1.8", diff --git a/devtools/server/tests/unit/test_sourcemaps-05.js b/devtools/server/tests/unit/test_sourcemaps-05.js index edc9178dbb19..4e4e54db2ba4 100644 --- a/devtools/server/tests/unit/test_sourcemaps-05.js +++ b/devtools/server/tests/unit/test_sourcemaps-05.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that relative source map urls work. */ @@ -9,36 +11,35 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_relative_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_relative_source_map(); + }); }); do_test_pending(); } -function test_relative_source_map() -{ - gThreadClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); +function test_relative_source_map() { + gThreadClient.addOneTimeListener("newSource", function _onNewSource(event, packet) { + do_check_eq(event, "newSource"); + do_check_eq(packet.type, "newSource"); + do_check_true(!!packet.source); - do_check_true(aPacket.source.url.indexOf("sourcemapped.coffee") !== -1, + do_check_true(packet.source.url.indexOf("sourcemapped.coffee") !== -1, "The new source should be a coffee file."); - do_check_eq(aPacket.source.url.indexOf("sourcemapped.js"), -1, + do_check_eq(packet.source.url.indexOf("sourcemapped.js"), -1, "The new source should not be a js file."); finishClient(gClient); }); - code = readFile("sourcemapped.js") + let code = readFile("sourcemapped.js") + "\n//# sourceMappingURL=source-map-data/sourcemapped.map"; Components.utils.evalInSandbox(code, gDebuggee, "1.8", diff --git a/devtools/server/tests/unit/test_sourcemaps-06.js b/devtools/server/tests/unit/test_sourcemaps-06.js index 41b518753bc9..3f0b3eb01bab 100644 --- a/devtools/server/tests/unit/test_sourcemaps-06.js +++ b/devtools/server/tests/unit/test_sourcemaps-06.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we can load sources whose content is embedded in the * "sourcesContent" field of a source map. @@ -12,34 +14,33 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_source_content(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_source_content(); + }); }); do_test_pending(); } -function test_source_content() -{ +function test_source_content() { let numNewSources = 0; - gThreadClient.addListener("newSource", function _onNewSource(aEvent, aPacket) { + gThreadClient.addListener("newSource", function _onNewSource(event, packet) { if (++numNewSources !== 3) { return; } gThreadClient.removeListener("newSource", _onNewSource); - gThreadClient.getSources(function (aResponse) { - do_check_true(!aResponse.error, "Should not get an error"); + gThreadClient.getSources(function (response) { + do_check_true(!response.error, "Should not get an error"); - testContents(aResponse.sources, 0, (timesCalled) => { + testContents(response.sources, 0, (timesCalled) => { do_check_eq(timesCalled, 3); finishClient(gClient); }); @@ -72,23 +73,21 @@ function testContents(sources, timesCalled, callback) { return; } - let source = sources[0]; let sourceClient = gThreadClient.source(sources[0]); if (sourceClient.url) { - sourceClient.source((aResponse) => { - do_check_true(!aResponse.error, + sourceClient.source((response) => { + do_check_true(!response.error, "Should not get an error loading the source from sourcesContent"); let expectedContent = "content for " + source.url; - do_check_eq(aResponse.source, expectedContent, + do_check_eq(response.source, expectedContent, "Should have the expected source content"); testContents(sources.slice(1), timesCalled + 1, callback); }); - } - else { + } else { testContents(sources.slice(1), timesCalled, callback); } } diff --git a/devtools/server/tests/unit/test_sourcemaps-07.js b/devtools/server/tests/unit/test_sourcemaps-07.js index b8a9462c0902..90cd38ee2e31 100644 --- a/devtools/server/tests/unit/test_sourcemaps-07.js +++ b/devtools/server/tests/unit/test_sourcemaps-07.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Test that we don't permanently cache sources from source maps. @@ -11,22 +14,21 @@ var gThreadClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_cached_original_sources(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_cached_original_sources(); + }); }); do_test_pending(); } -function test_cached_original_sources() -{ +function test_cached_original_sources() { writeFile("temp.js", "initial content"); gThreadClient.addOneTimeListener("newSource", onNewSource); @@ -39,26 +41,26 @@ function test_cached_original_sources() }); code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString()); - Components.utils.evalInSandbox(code, gDebuggee, "1.8", "http://example.com/www/js/abc.js", 1); } -function onNewSource(aEvent, aPacket) { - let sourceClient = gThreadClient.source(aPacket.source); - sourceClient.source(function (aResponse) { - do_check_true(!aResponse.error, +function onNewSource(event, packet) { + let sourceClient = gThreadClient.source(packet.source); + sourceClient.source(function (response) { + do_check_true(!response.error, "Should not be an error grabbing the source"); - do_check_eq(aResponse.source, "initial content", + do_check_eq(response.source, "initial content", "The correct source content should be sent"); writeFile("temp.js", "new content"); - sourceClient.source(function (aResponse) { - do_check_true(!aResponse.error, + sourceClient.source(function (response) { + do_check_true(!response.error, "Should not be an error grabbing the source"); - do_check_eq(aResponse.source, "new content", - "The correct source content should not be cached, so we should get the new content"); + do_check_eq(response.source, "new content", + "The correct source content should not be cached, " + + "so we should get the new content"); do_get_file("temp.js").remove(false); finishClient(gClient); diff --git a/devtools/server/tests/unit/test_sourcemaps-08.js b/devtools/server/tests/unit/test_sourcemaps-08.js index b23665e43979..b0c5f84b80bf 100644 --- a/devtools/server/tests/unit/test_sourcemaps-08.js +++ b/devtools/server/tests/unit/test_sourcemaps-08.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Regression test for bug 882986 regarding sourcesContent and absolute source * URLs. @@ -10,24 +12,23 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_source_maps(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_source_maps(); + }); }); do_test_pending(); } -function test_source_maps() -{ - gThreadClient.addOneTimeListener("newSource", function (aEvent, aPacket) { - let sourceClient = gThreadClient.source(aPacket.source); +function test_source_maps() { + gThreadClient.addOneTimeListener("newSource", function (event, packet) { + let sourceClient = gThreadClient.source(packet.source); sourceClient.source(function ({error, source}) { do_check_true(!error, "should be able to grab the source"); do_check_eq(source, "foo", diff --git a/devtools/server/tests/unit/test_sourcemaps-09.js b/devtools/server/tests/unit/test_sourcemaps-09.js index c317cf72370b..012d83b9343d 100644 --- a/devtools/server/tests/unit/test_sourcemaps-09.js +++ b/devtools/server/tests/unit/test_sourcemaps-09.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that source maps and breakpoints work with minified javascript. */ @@ -9,48 +11,43 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_minified(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_minified(); + }); }); do_test_pending(); } -function test_minified() -{ - let newSourceFired = false; +function test_minified() { + gThreadClient.addOneTimeListener("newSource", function _onNewSource(event, packet) { + do_check_eq(event, "newSource"); + do_check_eq(packet.type, "newSource"); + do_check_true(!!packet.source); - gThreadClient.addOneTimeListener("newSource", function _onNewSource(aEvent, aPacket) { - do_check_eq(aEvent, "newSource"); - do_check_eq(aPacket.type, "newSource"); - do_check_true(!!aPacket.source); - - do_check_eq(aPacket.source.url, "http://example.com/foo.js", + do_check_eq(packet.source.url, "http://example.com/foo.js", "The new source should be foo.js"); - do_check_eq(aPacket.source.url.indexOf("foo.min.js"), -1, + do_check_eq(packet.source.url.indexOf("foo.min.js"), -1, "The new source should not be the minified file"); - - newSourceFired = true; }); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aEvent, "paused"); - do_check_eq(aPacket.why.type, "debuggerStatement"); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(event, "paused"); + do_check_eq(packet.why.type, "debuggerStatement"); let location = { line: 5 }; getSource(gThreadClient, "http://example.com/foo.js").then(source => { - source.setBreakpoint(location, function (aResponse, bpClient) { - do_check_true(!aResponse.error); + source.setBreakpoint(location, function (response, bpClient) { + do_check_true(!response.error); testHitBreakpoint(); }); }); @@ -71,6 +68,7 @@ function test_minified() // } // }()); + // eslint-disable-next-line max-len let code = '(function(){debugger;function r(r){var n=r+r;var u=null;return n}for(var n=0;n<10;n++){r(n)}})();\n//# sourceMappingURL=data:text/json,{"file":"foo.min.js","version":3,"sources":["foo.js"],"names":["foo","n","bar","unused","i"],"mappings":"CAAC,WACC,QACA,SAASA,GAAIC,GACX,GAAIC,GAAMD,EAAIA,CACd,IAAIE,GAAS,IACb,OAAOD,GAET,IAAK,GAAIE,GAAI,EAAGA,EAAI,GAAIA,IAAK,CAC3BJ,EAAII"}'; Components.utils.evalInSandbox(code, gDebuggee, "1.8", @@ -78,11 +76,11 @@ function test_minified() } function testHitBreakpoint(timesHit = 0) { - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gClient.addOneTimeListener("paused", function (event, packet) { ++timesHit; - do_check_eq(aEvent, "paused"); - do_check_eq(aPacket.why.type, "breakpoint"); + do_check_eq(event, "paused"); + do_check_eq(packet.why.type, "breakpoint"); if (timesHit === 10) { gThreadClient.resume(() => finishClient(gClient)); diff --git a/devtools/server/tests/unit/test_sourcemaps-10.js b/devtools/server/tests/unit/test_sourcemaps-10.js index e955dc8fb525..bc66fdbd7dd2 100644 --- a/devtools/server/tests/unit/test_sourcemaps-10.js +++ b/devtools/server/tests/unit/test_sourcemaps-10.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we source map frame locations for the frame we are paused at. */ @@ -16,20 +18,22 @@ function run_test() { gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - promise.resolve(define_code()) - .then(run_code) - .then(test_frame_location) - .then(null, error => { - dump(error + "\n"); - dump(error.stack); - do_check_true(false); - }) - .then(() => { - finishClient(gClient); - }); - }); + attachTestTabAndResume( + gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + promise.resolve(define_code()) + .then(run_code) + .then(test_frame_location) + .then(null, error => { + dump(error + "\n"); + dump(error.stack); + do_check_true(false); + }) + .then(() => { + finishClient(gClient); + }); + }); }); do_test_pending(); } @@ -58,8 +62,8 @@ function define_code() { function run_code() { const d = promise.defer(); - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - d.resolve(aPacket); + gClient.addOneTimeListener("paused", function (event, packet) { + d.resolve(packet); gThreadClient.resume(); }); gDebuggee.a(); diff --git a/devtools/server/tests/unit/test_sourcemaps-11.js b/devtools/server/tests/unit/test_sourcemaps-11.js index e598c4c0975d..8993a32d0176 100644 --- a/devtools/server/tests/unit/test_sourcemaps-11.js +++ b/devtools/server/tests/unit/test_sourcemaps-11.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we source map frame locations returned by "frames" requests. */ @@ -16,20 +18,22 @@ function run_test() { gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - promise.resolve(define_code()) - .then(run_code) - .then(test_frames) - .then(null, error => { - dump(error + "\n"); - dump(error.stack); - do_check_true(false); - }) - .then(() => { - finishClient(gClient); - }); - }); + attachTestTabAndResume( + gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + promise.resolve(define_code()) + .then(run_code) + .then(test_frames) + .then(null, error => { + dump(error + "\n"); + dump(error.stack); + do_check_true(false); + }) + .then(() => { + finishClient(gClient); + }); + }); }); do_test_pending(); } @@ -59,8 +63,8 @@ function define_code() { function run_code() { const d = promise.defer(); gClient.addOneTimeListener("paused", function () { - gThreadClient.getFrames(0, 3, function (aResponse) { - d.resolve(aResponse); + gThreadClient.getFrames(0, 3, function (response) { + d.resolve(response); gThreadClient.resume(); }); }); @@ -76,8 +80,8 @@ function test_frames({ error, frames }) { check_frame(frames[2], "http://example.com/www/js/a.js"); } -function check_frame({ where: { source, line, column } }, aExpectedUrl) { - do_check_eq(source.url, aExpectedUrl); +function check_frame({ where: { source, line, column } }, expectedUrl) { + do_check_eq(source.url, expectedUrl); do_check_eq(line, 2); do_check_eq(column, 0); } diff --git a/devtools/server/tests/unit/test_sourcemaps-12.js b/devtools/server/tests/unit/test_sourcemaps-12.js index cb7f29920514..1148e3711c38 100644 --- a/devtools/server/tests/unit/test_sourcemaps-12.js +++ b/devtools/server/tests/unit/test_sourcemaps-12.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we continue stepping when a single original source's line * corresponds to multiple generated js lines. @@ -17,10 +19,11 @@ function run_test() { gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - define_code(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + define_code(); + }); }); do_test_pending(); } @@ -51,17 +54,17 @@ function define_code() { } function run_code() { - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "debuggerStatement"); + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "debuggerStatement"); step_in(); }); gDebuggee.runTest(); } function step_in() { - gClient.addOneTimeListener("paused", function (aEvent, aPacket) { - do_check_eq(aPacket.why.type, "resumeLimit"); - let { frame: { environment, where: { source, line } } } = aPacket; + gClient.addOneTimeListener("paused", function (event, packet) { + do_check_eq(packet.why.type, "resumeLimit"); + let { frame: { environment, where: { source, line } } } = packet; // Stepping should have moved us to the next source mapped line. do_check_eq(source.url, "http://example.com/a.js"); do_check_eq(line, 3); diff --git a/devtools/server/tests/unit/test_sourcemaps-13.js b/devtools/server/tests/unit/test_sourcemaps-13.js index 203731fda5a9..ac00a9d247e9 100644 --- a/devtools/server/tests/unit/test_sourcemaps-13.js +++ b/devtools/server/tests/unit/test_sourcemaps-13.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that we don't permanently cache source maps across reloads. */ @@ -12,17 +14,17 @@ var gTabClient; const {SourceNode} = require("source-map"); -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - gTabClient = aTabClient; - setup_code(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + gTabClient = tabClient; + setup_code(); + }); }); do_test_pending(); } @@ -92,7 +94,7 @@ function test_new_sources() { // Should now have TEMP_FILE_2 as a source. do_check_eq(sources.length, 1); - let s = sources.filter(s => s.url === getFileUrl(TEMP_FILE_2, true))[0]; + let s = sources.filter(source => source.url === getFileUrl(TEMP_FILE_2, true))[0]; do_check_true(!!s); finish_test(); diff --git a/devtools/server/tests/unit/test_sourcemaps-16.js b/devtools/server/tests/unit/test_sourcemaps-16.js index 4df9ece23cb7..e3defc02713f 100644 --- a/devtools/server/tests/unit/test_sourcemaps-16.js +++ b/devtools/server/tests/unit/test_sourcemaps-16.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Verify that we can load the contents of every source in a source map produced * by babel and browserify. @@ -9,8 +11,7 @@ var gDebuggee; var gClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-sourcemaps"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); @@ -20,19 +21,21 @@ function run_test() do_test_pending(); } -const testSourcemap = Task.async(function* (threadResponse, tabClient, threadClient, tabResponse) { - evalTestCode(); +const testSourcemap = Task.async( + function* (threadResponse, tabClient, threadClient, tabResponse) { + evalTestCode(); - const { sources } = yield getSources(threadClient); + const { sources } = yield getSources(threadClient); - for (let form of sources) { - let sourceResponse = yield getSourceContent(threadClient.source(form)); - ok(sourceResponse, "Should be able to get the source response"); - ok(sourceResponse.source, "Should have the source text as well"); + for (let form of sources) { + let sourceResponse = yield getSourceContent(threadClient.source(form)); + ok(sourceResponse, "Should be able to get the source response"); + ok(sourceResponse.source, "Should have the source text as well"); + } + + finishClient(gClient); } - - finishClient(gClient); -}); +); const TEST_FILE = "babel_and_browserify_script_with_source_map.js"; diff --git a/devtools/server/tests/unit/test_sourcemaps-17.js b/devtools/server/tests/unit/test_sourcemaps-17.js index 85da959722ce..e7953acf11c3 100644 --- a/devtools/server/tests/unit/test_sourcemaps-17.js +++ b/devtools/server/tests/unit/test_sourcemaps-17.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that we properly handle frames that cannot be sourcemapped * when using sourcemaps. @@ -17,10 +19,11 @@ function run_test() { gDebuggee = addTestGlobal("test-source-map"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-source-map", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_source_map(); - }); + attachTestTabAndResume(gClient, "test-source-map", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_source_map(); + }); }); do_test_pending(); } @@ -32,7 +35,9 @@ function test_source_map() { const c = new SourceNode(1, 1, "c.js", "function c() { d(); }"); const d = new SourceNode(null, null, null, "function d() { e(); }"); const e = new SourceNode(1, 1, "e.js", "function e() { debugger; }"); - const { map, code } = (new SourceNode(null, null, null, [a, b, c, d, e])).toStringWithSourceMap({ + const { map, code } = (new SourceNode( + null, null, null, [a, b, c, d, e] + )).toStringWithSourceMap({ file: "root.js", sourceRoot: "root", }); @@ -44,7 +49,7 @@ function test_source_map() { 1 ); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { gThreadClient.getFrames(0, 50, function ({ error, frames }) { do_check_true(!error); do_check_eq(frames.length, 4); diff --git a/devtools/server/tests/unit/test_stepping-01.js b/devtools/server/tests/unit/test_stepping-01.js index 593a485a161e..d31244f84967 100644 --- a/devtools/server/tests/unit/test_stepping-01.js +++ b/devtools/server/tests/unit/test_stepping-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check basic step-over functionality. @@ -10,55 +13,53 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_stepping(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_stepping(); + }); }); } -function test_simple_stepping() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_simple_stepping() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 2); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 2); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, undefined); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); + do_check_eq(packet.type, "paused"); // When leaving a stack frame the line number doesn't change. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, 2); @@ -70,14 +71,14 @@ function test_simple_stepping() gThreadClient.stepOver(); }); gThreadClient.stepOver(); - }); gThreadClient.stepOver(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a = 1;\n" + // line0 + 2 "var b = 2;\n"); // line0 + 3 + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_stepping-02.js b/devtools/server/tests/unit/test_stepping-02.js index eaee099b99b6..f1824d064594 100644 --- a/devtools/server/tests/unit/test_stepping-02.js +++ b/devtools/server/tests/unit/test_stepping-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check basic step-in functionality. @@ -10,55 +13,53 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_stepping(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_stepping(); + }); }); } -function test_simple_stepping() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_simple_stepping() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 2); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 2); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, undefined); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); + do_check_eq(packet.type, "paused"); // When leaving a stack frame the line number doesn't change. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, 2); @@ -70,14 +71,14 @@ function test_simple_stepping() gThreadClient.stepIn(); }); gThreadClient.stepIn(); - }); gThreadClient.stepIn(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a = 1;\n" + // line0 + 2 "var b = 2;\n"); // line0 + 3 + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_stepping-03.js b/devtools/server/tests/unit/test_stepping-03.js index 6123928d7678..5ea74dac0d47 100644 --- a/devtools/server/tests/unit/test_stepping-03.js +++ b/devtools/server/tests/unit/test_stepping-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; /** * Check basic step-out functionality. @@ -10,36 +13,34 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_stepping(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_stepping(); + }); }); } -function test_simple_stepping() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_simple_stepping() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, 2); @@ -49,9 +50,9 @@ function test_simple_stepping() }); }); gThreadClient.stepOut(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "function f() {\n" + // line0 + 1 " debugger;\n" + // line0 + 2 @@ -59,4 +60,5 @@ function test_simple_stepping() " this.b = 2;\n" + // line0 + 4 "}\n" + // line0 + 5 "f();\n"); // line0 + 6 + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_stepping-04.js b/devtools/server/tests/unit/test_stepping-04.js index efe52200dc9e..b74869737708 100644 --- a/devtools/server/tests/unit/test_stepping-04.js +++ b/devtools/server/tests/unit/test_stepping-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that stepping over a function call does not pause inside the function. @@ -10,45 +13,43 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_simple_stepping(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_simple_stepping(); + }); }); } -function test_simple_stepping() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_simple_stepping() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, undefined); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 6); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); @@ -58,12 +59,11 @@ function test_simple_stepping() }); }); gThreadClient.stepOver(); - }); gThreadClient.stepOver(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "function f() {\n" + // line0 + 1 " this.a = 1;\n" + // line0 + 2 @@ -71,4 +71,5 @@ function test_simple_stepping() "debugger;\n" + // line0 + 4 "f();\n" + // line0 + 5 "let b = 2;\n"); // line0 + 6 + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_stepping-05.js b/devtools/server/tests/unit/test_stepping-05.js index 2ab4570afde8..1018943b07b5 100644 --- a/devtools/server/tests/unit/test_stepping-05.js +++ b/devtools/server/tests/unit/test_stepping-05.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Make sure that stepping in the last statement of the last frame doesn't @@ -12,55 +15,53 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_stepping_last(); - }); + attachTestTabAndResume(gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_stepping_last(); + }); }); } -function test_stepping_last() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_stepping_last() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 2); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 2); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, undefined); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); + do_check_eq(packet.type, "paused"); // When leaving a stack frame the line number doesn't change. - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3); - do_check_eq(aPacket.why.type, "resumeLimit"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3); + do_check_eq(packet.why.type, "resumeLimit"); // Check that stepping worked. do_check_eq(gDebuggee.a, 1); do_check_eq(gDebuggee.b, 2); @@ -72,25 +73,24 @@ function test_stepping_last() gThreadClient.stepIn(); }); gThreadClient.stepIn(); - }); gThreadClient.stepIn(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "debugger;\n" + // line0 + 1 "var a = 1;\n" + // line0 + 2 "var b = 2;\n"); // line0 + 3 + /* eslint-enable */ } -function test_next_pause() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_next_pause() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check the return value. - do_check_eq(aPacket.type, "paused"); + do_check_eq(packet.type, "paused"); // Before fixing bug 785689, the type was resumeLimit. - do_check_eq(aPacket.why.type, "debuggerStatement"); + do_check_eq(packet.why.type, "debuggerStatement"); gThreadClient.resume(function () { gClient.close().then(gCallback); diff --git a/devtools/server/tests/unit/test_stepping-06.js b/devtools/server/tests/unit/test_stepping-06.js index 49689f830452..9842b01057e1 100644 --- a/devtools/server/tests/unit/test_stepping-06.js +++ b/devtools/server/tests/unit/test_stepping-06.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that stepping out of a function returns the right return value. @@ -10,58 +13,57 @@ var gClient; var gThreadClient; var gCallback; -function run_test() -{ +function run_test() { run_test_with_server(DebuggerServer, function () { run_test_with_server(WorkerDebuggerServer, do_test_finished); }); do_test_pending(); } -function run_test_with_server(aServer, aCallback) -{ - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stack", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stack", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - // XXX: We have to do an executeSoon so that the error isn't caught and - // reported by DebuggerClient.requester (because we are using the local - // transport and share a stack) which causes the test to fail. - Services.tm.mainThread.dispatch({ - run: test_simple_stepping - }, Ci.nsIThread.DISPATCH_NORMAL); - }); + attachTestTabAndResume( + gClient, "test-stack", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + // XXX: We have to do an executeSoon so that the error isn't caught and + // reported by DebuggerClient.requester (because we are using the local + // transport and share a stack) which causes the test to fail. + Services.tm.mainThread.dispatch({ + run: test_simple_stepping + }, Ci.nsIThread.DISPATCH_NORMAL); + }); }); } -function test_simple_stepping() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_simple_stepping() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check that the return value is 10. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.why.frameFinished.return, 10); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.why.frameFinished.return, 10); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check that the return value is undefined. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 8); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.why.frameFinished.return.type, "undefined"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 8); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.why.frameFinished.return.type, "undefined"); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Check that the exception was thrown. - do_check_eq(aPacket.type, "paused"); - do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 11); - do_check_eq(aPacket.why.type, "resumeLimit"); - do_check_eq(aPacket.why.frameFinished.throw, "ah"); + do_check_eq(packet.type, "paused"); + do_check_eq(packet.frame.where.line, gDebuggee.line0 + 11); + do_check_eq(packet.why.type, "resumeLimit"); + do_check_eq(packet.why.frameFinished.throw, "ah"); gThreadClient.resume(function () { gClient.close().then(gCallback); @@ -76,9 +78,9 @@ function test_simple_stepping() gThreadClient.resume(); }); gThreadClient.stepOut(); - }); + /* eslint-disable */ gDebuggee.eval("var line0 = Error().lineNumber;\n" + "function f() {\n" + // line0 + 1 " debugger;\n" + // line0 + 2 @@ -96,4 +98,5 @@ function test_simple_stepping() "f();\n" + // line0 + 14 "g();\n" + // line0 + 15 "try { h() } catch (ex) { };\n"); // line0 + 16 + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_stepping-07.js b/devtools/server/tests/unit/test_stepping-07.js index 9ad0d79ffc8d..37c0fc72f95a 100644 --- a/devtools/server/tests/unit/test_stepping-07.js +++ b/devtools/server/tests/unit/test_stepping-07.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Check that stepping over an implicit return makes sense. Bug 1155966. */ @@ -16,16 +18,17 @@ function run_test() { }); } -function run_test_with_server(aServer, aCallback) { - gCallback = aCallback; - initTestDebuggerServer(aServer); - gDebuggee = addTestGlobal("test-stepping", aServer); - gClient = new DebuggerClient(aServer.connectPipe()); +function run_test_with_server(server, callback) { + gCallback = callback; + initTestDebuggerServer(server); + gDebuggee = addTestGlobal("test-stepping", server); + gClient = new DebuggerClient(server.connectPipe()); gClient.connect(testSteppingAndReturns); } const testSteppingAndReturns = Task.async(function* () { - const [attachResponse, tabClient, threadClient] = yield attachTestTabAndResume(gClient, "test-stepping"); + const [attachResponse,, threadClient] = yield attachTestTabAndResume(gClient, + "test-stepping"); ok(!attachResponse.error, "Should not get an error attaching"); dumpn("Evaluating test code and waiting for first debugger statement"); @@ -64,6 +67,7 @@ const testSteppingAndReturns = Task.async(function* () { }); function evaluateTestCode() { + /* eslint-disable */ Cu.evalInSandbox( ` // 1 function implicitReturn() { // 2 @@ -89,4 +93,5 @@ function evaluateTestCode() { "test_stepping-07-test-code.js", 1 ); + /* eslint-enable */ } diff --git a/devtools/server/tests/unit/test_symbols-01.js b/devtools/server/tests/unit/test_symbols-01.js index 8ea26086adfc..e0afe113c170 100644 --- a/devtools/server/tests/unit/test_symbols-01.js +++ b/devtools/server/tests/unit/test_symbols-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that we can represent ES6 Symbols over the RDP. */ @@ -13,10 +15,11 @@ function run_test() { const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { - attachTestTabAndResume(client, "test-symbols", function (response, tabClient, threadClient) { - add_task(testSymbols.bind(null, client, debuggee)); - run_next_test(); - }); + attachTestTabAndResume(client, "test-symbols", + function (response, tabClient, threadClient) { + add_task(testSymbols.bind(null, client, debuggee)); + run_next_test(); + }); }); do_test_pending(); @@ -24,6 +27,7 @@ function run_test() { function* testSymbols(client, debuggee) { const evalCode = () => { + /* eslint-disable */ Components.utils.evalInSandbox( "(" + function () { var symbolWithName = Symbol("Chris"); @@ -36,6 +40,7 @@ function* testSymbols(client, debuggee) { URL, 1 ); + /* eslint-enable */ }; const packet = yield executeOnNextTickAndWaitForPause(evalCode, client); diff --git a/devtools/server/tests/unit/test_symbols-02.js b/devtools/server/tests/unit/test_symbols-02.js index f80dc332236f..73df6585c32c 100644 --- a/devtools/server/tests/unit/test_symbols-02.js +++ b/devtools/server/tests/unit/test_symbols-02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Test that we don't run debuggee code when getting symbol names. */ @@ -13,10 +15,11 @@ function run_test() { const client = new DebuggerClient(DebuggerServer.connectPipe()); client.connect().then(function () { - attachTestTabAndResume(client, "test-symbols", function (response, tabClient, threadClient) { - add_task(testSymbols.bind(null, client, debuggee)); - run_next_test(); - }); + attachTestTabAndResume(client, "test-symbols", + function (response, tabClient, threadClient) { + add_task(testSymbols.bind(null, client, debuggee)); + run_next_test(); + }); }); do_test_pending(); @@ -24,6 +27,7 @@ function run_test() { function* testSymbols(client, debuggee) { const evalCode = () => { + /* eslint-disable */ Components.utils.evalInSandbox( "(" + function () { Symbol.prototype.toString = () => { @@ -37,6 +41,7 @@ function* testSymbols(client, debuggee) { URL, 1 ); + /* eslint-enable */ }; const packet = yield executeOnNextTickAndWaitForPause(evalCode, client); diff --git a/devtools/server/tests/unit/test_threadlifetime-01.js b/devtools/server/tests/unit/test_threadlifetime-01.js index 1325a45fa475..7dad64558a69 100644 --- a/devtools/server/tests/unit/test_threadlifetime-01.js +++ b/devtools/server/tests/unit/test_threadlifetime-01.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that thread-lifetime grips last past a resume. @@ -9,36 +12,35 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function test_thread_lifetime() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let pauseGrip = aPacket.frame.arguments[0]; +function test_thread_lifetime() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let pauseGrip = packet.frame.arguments[0]; // Create a thread-lifetime actor for this object. - gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (aResponse) { + gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (response) { // Successful promotion won't return an error. - do_check_eq(aResponse.error, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + do_check_eq(response.error, undefined); + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Verify that the promoted actor is returned again. - do_check_eq(pauseGrip.actor, aPacket.frame.arguments[0].actor); + do_check_eq(pauseGrip.actor, packet.frame.arguments[0].actor); // Now that we've resumed, should get unrecognizePacketType for the // promoted grip. - gClient.request({ to: pauseGrip.actor, type: "bogusRequest"}, function (aResponse) { - do_check_eq(aResponse.error, "unrecognizedPacketType"); + gClient.request({to: pauseGrip.actor, type: "bogusRequest"}, function (response) { + do_check_eq(response.error, "unrecognizedPacketType"); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_threadlifetime-02.js b/devtools/server/tests/unit/test_threadlifetime-02.js index a7d21a7f9bd6..cb98ac2b933b 100644 --- a/devtools/server/tests/unit/test_threadlifetime-02.js +++ b/devtools/server/tests/unit/test_threadlifetime-02.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that thread-lifetime grips last past a resume. @@ -9,40 +12,40 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function test_thread_lifetime() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let pauseGrip = aPacket.frame.arguments[0]; +function test_thread_lifetime() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let pauseGrip = packet.frame.arguments[0]; // Create a thread-lifetime actor for this object. - gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (aResponse) { + gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (response) { // Successful promotion won't return an error. - do_check_eq(aResponse.error, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + do_check_eq(response.error, undefined); + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Verify that the promoted actor is returned again. - do_check_eq(pauseGrip.actor, aPacket.frame.arguments[0].actor); + do_check_eq(pauseGrip.actor, packet.frame.arguments[0].actor); // Now that we've resumed, release the thread-lifetime grip. - gClient.release(pauseGrip.actor, function (aResponse) { - gClient.request({ to: pauseGrip.actor, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); - gThreadClient.resume(function (aResponse) { - finishClient(gClient); + gClient.release(pauseGrip.actor, function (response) { + gClient.request( + {to: pauseGrip.actor, type: "bogusRequest"}, function (response) { + do_check_eq(response.error, "noSuchActor"); + gThreadClient.resume(function (response) { + finishClient(gClient); + }); }); - }); }); }); gThreadClient.resume(); diff --git a/devtools/server/tests/unit/test_threadlifetime-03.js b/devtools/server/tests/unit/test_threadlifetime-03.js index 22b707ff89c2..608d7418dec2 100644 --- a/devtools/server/tests/unit/test_threadlifetime-03.js +++ b/devtools/server/tests/unit/test_threadlifetime-03.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that thread-lifetime grips last past a resume. @@ -9,38 +12,37 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function test_thread_lifetime() -{ +function test_thread_lifetime() { // Get three thread-lifetime grips. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { let grips = []; - let handler = function (aResponse) { - if (aResponse.error) { - do_check_eq(aResponse.error, ""); + let handler = function (response) { + if (response.error) { + do_check_eq(response.error, ""); finishClient(gClient); } - grips.push(aResponse.from); + grips.push(response.from); if (grips.length == 3) { test_release_many(grips); } }; for (let i = 0; i < 3; i++) { - gClient.request({ to: aPacket.frame.arguments[i].actor, type: "threadGrip" }, + gClient.request({ to: packet.frame.arguments[i].actor, type: "threadGrip" }, handler); } }); @@ -53,24 +55,23 @@ function test_thread_lifetime() } + ")()"); } -function test_release_many(grips) -{ +function test_release_many(grips) { // Release the first two grips, leave the third alive. let release = [grips[0], grips[1]]; - gThreadClient.releaseMany(release, function (aResponse) { + gThreadClient.releaseMany(release, function (response) { // First two actors should return a noSuchActor error, because // they're gone now. - gClient.request({ to: grips[0], type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); - gClient.request({ to: grips[1], type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); + gClient.request({ to: grips[0], type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); + gClient.request({ to: grips[1], type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); // Last actor should return unrecognizedPacketType, because it's still // alive. - gClient.request({ to: grips[2], type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "unrecognizedPacketType"); + gClient.request({ to: grips[2], type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "unrecognizedPacketType"); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_threadlifetime-04.js b/devtools/server/tests/unit/test_threadlifetime-04.js index aff8b525ce6f..da3a12723118 100644 --- a/devtools/server/tests/unit/test_threadlifetime-04.js +++ b/devtools/server/tests/unit/test_threadlifetime-04.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that requesting a thread-lifetime actor twice for the same @@ -10,33 +13,32 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function test_thread_lifetime() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - let pauseGrip = aPacket.frame.arguments[0]; +function test_thread_lifetime() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let pauseGrip = packet.frame.arguments[0]; - gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (aResponse) { + gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (response) { // Successful promotion won't return an error. - do_check_eq(aResponse.error, undefined); + do_check_eq(response.error, undefined); - let threadGrip1 = aResponse.from; + let threadGrip1 = response.from; - gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (aResponse) { - do_check_eq(threadGrip1, aResponse.from); + gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (response) { + do_check_eq(threadGrip1, response.from); gThreadClient.resume(function () { finishClient(gClient); }); diff --git a/devtools/server/tests/unit/test_threadlifetime-05.js b/devtools/server/tests/unit/test_threadlifetime-05.js index 6697947c16ed..71f88cd7e5a0 100644 --- a/devtools/server/tests/unit/test_threadlifetime-05.js +++ b/devtools/server/tests/unit/test_threadlifetime-05.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Make sure that releasing a pause-lifetime actorin a releaseMany returns an * error, but releases all the thread-lifetime actors. @@ -11,47 +13,45 @@ var gClient; var gThreadClient; var gPauseGrip; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function arg_grips(aFrameArgs, aOnResponse) { +function arg_grips(frameArgs, onResponse) { let grips = []; - let handler = function (aResponse) { - if (aResponse.error) { - grips.push(aResponse.error); + let handler = function (response) { + if (response.error) { + grips.push(response.error); } else { - grips.push(aResponse.from); + grips.push(response.from); } - if (grips.length == aFrameArgs.length) { - aOnResponse(grips); + if (grips.length == frameArgs.length) { + onResponse(grips); } }; - for (let i = 0; i < aFrameArgs.length; i++) { - gClient.request({ to: aFrameArgs[i].actor, type: "threadGrip" }, + for (let i = 0; i < frameArgs.length; i++) { + gClient.request({ to: frameArgs[i].actor, type: "threadGrip" }, handler); } } -function test_thread_lifetime() -{ +function test_thread_lifetime() { // Get two thread-lifetime grips. - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { - - let frameArgs = [ aPacket.frame.arguments[0], aPacket.frame.arguments[1] ]; - gPauseGrip = aPacket.frame.arguments[2]; - arg_grips(frameArgs, function (aGrips) { - release_grips(frameArgs, aGrips); + gThreadClient.addOneTimeListener("paused", function (event, packet) { + let frameArgs = [ packet.frame.arguments[0], packet.frame.arguments[1] ]; + gPauseGrip = packet.frame.arguments[2]; + arg_grips(frameArgs, function (grips) { + release_grips(frameArgs, grips); }); }); @@ -63,17 +63,15 @@ function test_thread_lifetime() } + ")()"); } - -function release_grips(aFrameArgs, aThreadGrips) -{ +function release_grips(frameArgs, threadGrips) { // Release all actors with releaseMany... - let release = [aThreadGrips[0], aThreadGrips[1], gPauseGrip.actor]; - gThreadClient.releaseMany(release, function (aResponse) { - do_check_eq(aResponse.error, "notReleasable"); + let release = [threadGrips[0], threadGrips[1], gPauseGrip.actor]; + gThreadClient.releaseMany(release, function (response) { + do_check_eq(response.error, "notReleasable"); // Now ask for thread grips again, they should not exist. - arg_grips(aFrameArgs, function (aNewGrips) { - for (let i = 0; i < aNewGrips.length; i++) { - do_check_eq(aNewGrips[i], "noSuchActor"); + arg_grips(frameArgs, function (newGrips) { + for (let i = 0; i < newGrips.length; i++) { + do_check_eq(newGrips[i], "noSuchActor"); } gThreadClient.resume(function () { finishClient(gClient); diff --git a/devtools/server/tests/unit/test_threadlifetime-06.js b/devtools/server/tests/unit/test_threadlifetime-06.js index dba0156f93fa..42fd02a82ca5 100644 --- a/devtools/server/tests/unit/test_threadlifetime-06.js +++ b/devtools/server/tests/unit/test_threadlifetime-06.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; /** * Check that promoting multiple pause-lifetime actors to thread-lifetime actors @@ -10,48 +13,47 @@ var gDebuggee; var gClient; var gThreadClient; -function run_test() -{ +function run_test() { initTestDebuggerServer(); gDebuggee = addTestGlobal("test-grips"); gClient = new DebuggerClient(DebuggerServer.connectPipe()); gClient.connect().then(function () { - attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) { - gThreadClient = aThreadClient; - test_thread_lifetime(); - }); + attachTestTabAndResume(gClient, "test-grips", + function (response, tabClient, threadClient) { + gThreadClient = threadClient; + test_thread_lifetime(); + }); }); do_test_pending(); } -function test_thread_lifetime() -{ - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { +function test_thread_lifetime() { + gThreadClient.addOneTimeListener("paused", function (event, packet) { let actors = []; let last; - for (let aGrip of aPacket.frame.arguments) { - actors.push(aGrip.actor); - last = aGrip.actor; + for (let grip of packet.frame.arguments) { + actors.push(grip.actor); + last = grip.actor; } // Create thread-lifetime actors for these objects. - gThreadClient.threadGrips(actors, function (aResponse) { + gThreadClient.threadGrips(actors, function (response) { // Successful promotion won't return an error. - do_check_eq(aResponse.error, undefined); + do_check_eq(response.error, undefined); - gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { + gThreadClient.addOneTimeListener("paused", function (event, packet) { // Verify that the promoted actors are returned again. actors.forEach(function (actor, i) { - do_check_eq(actor, aPacket.frame.arguments[i].actor); + do_check_eq(actor, packet.frame.arguments[i].actor); }); // Now that we've resumed, release the thread-lifetime grips. - gThreadClient.releaseMany(actors, function (aResponse) { + gThreadClient.releaseMany(actors, function (response) { // Successful release won't return an error. - do_check_eq(aResponse.error, undefined); + do_check_eq(response.error, undefined); - gClient.request({ to: last, type: "bogusRequest" }, function (aResponse) { - do_check_eq(aResponse.error, "noSuchActor"); - gThreadClient.resume(function (aResponse) { + gClient.request({ to: last, type: "bogusRequest" }, function (response) { + do_check_eq(response.error, "noSuchActor"); + gThreadClient.resume(function (response) { finishClient(gClient); }); }); diff --git a/devtools/server/tests/unit/test_unsafeDereference.js b/devtools/server/tests/unit/test_unsafeDereference.js index d7afe645f076..baddf06f1216 100644 --- a/devtools/server/tests/unit/test_unsafeDereference.js +++ b/devtools/server/tests/unit/test_unsafeDereference.js @@ -1,6 +1,8 @@ // Any copyright is dedicated to the Public Domain. // http://creativecommons.org/publicdomain/zero/1.0/ +/* eslint-disable strict */ + // Test Debugger.Object.prototype.unsafeDereference in the presence of // interesting cross-compartment wrappers. // @@ -14,13 +16,14 @@ addDebuggerToGlobal(this); // Add a method to Debugger.Object for fetching value properties // conveniently. -Debugger.Object.prototype.getProperty = function (aName) { - let desc = this.getOwnPropertyDescriptor(aName); - if (!desc) +Debugger.Object.prototype.getProperty = function (name) { + let desc = this.getOwnPropertyDescriptor(name); + if (!desc) { return undefined; + } if (!desc.value) { throw Error("Debugger.Object.prototype.getProperty: " + - "not a value property: " + aName); + "not a value property: " + name); } return desc.value; }; @@ -33,7 +36,7 @@ function run_test() { // Create an objects in this compartment, and one in each sandbox. We'll // refer to the objects as "mainObj", "contentObj", and "chromeObj", in // variable and property names. - var mainObj = { name: "mainObj" }; + let mainObj = { name: "mainObj" }; Components.utils.evalInSandbox('var contentObj = { name: "contentObj" };', contentBox); Components.utils.evalInSandbox('var chromeObj = { name: "chromeObj" };', @@ -41,8 +44,8 @@ function run_test() { // Give each global a pointer to all the other globals' objects. contentBox.mainObj = chromeBox.mainObj = mainObj; - var contentObj = chromeBox.contentObj = contentBox.contentObj; - var chromeObj = contentBox.chromeObj = chromeBox.chromeObj; + let contentObj = chromeBox.contentObj = contentBox.contentObj; + let chromeObj = contentBox.chromeObj = chromeBox.chromeObj; // First, a whole bunch of basic sanity checks, to ensure that JavaScript // evaluated in various scopes really does see the world the way this @@ -91,7 +94,7 @@ function run_test() { // would. // Create a debugger, debugging our two sandboxes. - let dbg = new Debugger; + let dbg = new Debugger(); // Create Debugger.Object instances referring to the two sandboxes, as // seen from their own compartments. diff --git a/devtools/server/tests/unit/test_xpcshell_debugging.js b/devtools/server/tests/unit/test_xpcshell_debugging.js index 7026a02b344c..f620c97c7046 100644 --- a/devtools/server/tests/unit/test_xpcshell_debugging.js +++ b/devtools/server/tests/unit/test_xpcshell_debugging.js @@ -1,5 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow, max-nested-callbacks */ + +"use strict"; // Test the xpcshell-test debug support. Ideally we should have this test // next to the xpcshell support code, but that's tricky... @@ -9,7 +12,9 @@ function run_test() { // _setupDebuggerServer is from xpcshell-test's head.js let testResumed = false; - let DebuggerServer = _setupDebuggerServer([testFile.path], () => testResumed = true); + let DebuggerServer = _setupDebuggerServer([testFile.path], () => { + testResumed = true; + }); let transport = DebuggerServer.connectPipe(); let client = new DebuggerClient(transport); client.connect().then(() => { diff --git a/devtools/server/tests/unit/testactors.js b/devtools/server/tests/unit/testactors.js index 39564eeef7e7..b8d9ce391126 100644 --- a/devtools/server/tests/unit/testactors.js +++ b/devtools/server/tests/unit/testactors.js @@ -1,17 +1,18 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common"); const { RootActor } = require("devtools/server/actors/root"); const { ThreadActor } = require("devtools/server/actors/script"); const { DebuggerServer } = require("devtools/server/main"); const { TabSources } = require("devtools/server/actors/utils/TabSources"); -const promise = require("promise"); const makeDebugger = require("devtools/server/actors/utils/make-debugger"); var gTestGlobals = []; -DebuggerServer.addTestGlobal = function (aGlobal) { - gTestGlobals.push(aGlobal); +DebuggerServer.addTestGlobal = function (global) { + gTestGlobals.push(global); }; DebuggerServer.getTestGlobal = function (name) { @@ -31,18 +32,18 @@ DebuggerServer.getTestGlobal = function (name) { // As implemented now, we consult gTestGlobals when we're constructed, not // when we're iterated over, so tests have to add their globals before the // root actor is created. -function TestTabList(aConnection) { - this.conn = aConnection; +function TestTabList(connection) { + this.conn = connection; // An array of actors for each global added with // DebuggerServer.addTestGlobal. this._tabActors = []; // A pool mapping those actors' names to the actors. - this._tabActorPool = new ActorPool(aConnection); + this._tabActorPool = new ActorPool(connection); for (let global of gTestGlobals) { - let actor = new TestTabActor(aConnection, global); + let actor = new TestTabActor(connection, global); actor.selected = false; this._tabActors.push(actor); this._tabActorPool.addActor(actor); @@ -51,7 +52,7 @@ function TestTabList(aConnection) { this._tabActors[0].selected = true; } - aConnection.addActorPool(this._tabActorPool); + connection.addActorPool(this._tabActorPool); } TestTabList.prototype = { @@ -61,10 +62,9 @@ TestTabList.prototype = { } }; -function createRootActor(aConnection) -{ - let root = new RootActor(aConnection, { - tabList: new TestTabList(aConnection), +function createRootActor(connection) { + let root = new RootActor(connection, { + tabList: new TestTabList(connection), globalActorFactories: DebuggerServer.globalActorFactories, }); @@ -72,11 +72,10 @@ function createRootActor(aConnection) return root; } -function TestTabActor(aConnection, aGlobal) -{ - this.conn = aConnection; - this._global = aGlobal; - this._global.wrappedJSObject = aGlobal; +function TestTabActor(connection, global) { + this.conn = connection; + this._global = global; + this._global.wrappedJSObject = global; this.threadActor = new ThreadActor(this, this._global); this.conn.addActor(this.threadActor); this._attached = false; @@ -125,7 +124,7 @@ TestTabActor.prototype = { return response; }, - onAttach: function (aRequest) { + onAttach: function (request) { this._attached = true; let response = { type: "tabAttached", threadActor: this.threadActor.actorID }; @@ -134,26 +133,26 @@ TestTabActor.prototype = { return response; }, - onDetach: function (aRequest) { + onDetach: function (request) { if (!this._attached) { - return { "error":"wrongState" }; + return { "error": "wrongState" }; } return { type: "detached" }; }, - onReload: function (aRequest) { + onReload: function (request) { this.sources.reset({ sourceMaps: true }); this.threadActor.clearDebuggees(); this.threadActor.dbg.addDebuggees(); return {}; }, - removeActorByName: function (aName) { - const actor = this._extraActors[aName]; + removeActorByName: function (name) { + const actor = this._extraActors[name]; if (this._tabActorPool) { this._tabActorPool.removeActor(actor); } - delete this._extraActors[aName]; + delete this._extraActors[name]; }, /* Support for DebuggerServer.addTabActor. */ diff --git a/devtools/server/tests/unit/tracerlocations.js b/devtools/server/tests/unit/tracerlocations.js deleted file mode 100644 index aa4677c0f70a..000000000000 --- a/devtools/server/tests/unit/tracerlocations.js +++ /dev/null @@ -1,8 +0,0 @@ -// For JS Tracer tests dealing with source locations. - -function foo(x) { - x += 6; - return "bar"; -} - -foo(42);