diff --git a/.eslintignore b/.eslintignore index c678180d573a..a676a160e1c7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -117,10 +117,20 @@ devtools/server/tests/browser/** devtools/server/tests/mochitest/** devtools/server/tests/unit/** devtools/shared/apps/** +devtools/shared/client/** +devtools/shared/discovery/** devtools/shared/gcli/** !devtools/shared/gcli/templater.js devtools/shared/heapsnapshot/** devtools/shared/layout/** +devtools/shared/performance/** +!devtools/shared/platform/** +devtools/shared/qrcode/** +devtools/shared/security/** +devtools/shared/shims/** +devtools/shared/tests/** +!devtools/shared/tests/unit/test_csslexer.js +devtools/shared/touch/** devtools/shared/transport/** !devtools/shared/transport/transport.js !devtools/shared/transport/websocket-transport.js diff --git a/devtools/shared/client/connection-manager.js b/devtools/shared/client/connection-manager.js index 6b6a1e5e85c9..ef242db85302 100644 --- a/devtools/shared/client/connection-manager.js +++ b/devtools/shared/client/connection-manager.js @@ -6,8 +6,9 @@ "use strict"; -const {Cc, Ci, Cr} = require("chrome"); +const {Cc, Ci, Cu, Cr} = require("chrome"); const EventEmitter = require("devtools/shared/event-emitter"); +const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const { DebuggerServer } = require("devtools/server/main"); const { DebuggerClient } = require("devtools/shared/client/main"); const Services = require("Services"); @@ -69,10 +70,8 @@ const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout"; * . Connection.Events.CONNECTING Trying to connect to host:port * . Connection.Events.CONNECTED Connection is successful * . Connection.Events.DISCONNECTING Trying to disconnect from server - * . Connection.Events.DISCONNECTED Disconnected (at client request, - * or because of a timeout or connection error) - * . Connection.Events.STATUS_CHANGED The connection status (connection.status) - * has changed + * . Connection.Events.DISCONNECTED Disconnected (at client request, or because of a timeout or connection error) + * . Connection.Events.STATUS_CHANGED The connection status (connection.status) has changed * . Connection.Events.TIMEOUT Connection timeout * . Connection.Events.HOST_CHANGED Host has changed * . Connection.Events.PORT_CHANGED Port has changed @@ -169,9 +168,8 @@ Connection.prototype = { }, set host(value) { - if (this._host && this._host == value) { + if (this._host && this._host == value) return; - } this._host = value; this.emit(Connection.Events.HOST_CHANGED); }, @@ -181,9 +179,8 @@ Connection.prototype = { }, set port(value) { - if (this._port && this._port == value) { + if (this._port && this._port == value) return; - } this._port = value; this.emit(Connection.Events.PORT_CHANGED); }, @@ -337,9 +334,8 @@ Connection.prototype = { }, _setStatus: function (value) { - if (this._status && this._status == value) { + if (this._status && this._status == value) return; - } this._status = value; this.emit(value); this.emit(Connection.Events.STATUS_CHANGED, value); @@ -361,9 +357,7 @@ Connection.prototype = { this.log("disconnected (unexpected)"); break; case Connection.Status.CONNECTING: - this.log("connection error. Possible causes: USB port not connected, port not " + - "forwarded (adb forward), wrong host or port, remote debugging not " + - "enabled on the device."); + this.log("connection error. Possible causes: USB port not connected, port not forwarded (adb forward), wrong host or port, remote debugging not enabled on the device."); break; default: this.log("disconnected"); diff --git a/devtools/shared/client/main.js b/devtools/shared/client/main.js index b1e3295aff64..408c0b277edc 100644 --- a/devtools/shared/client/main.js +++ b/devtools/shared/client/main.js @@ -7,6 +7,7 @@ "use strict"; const { Ci, Cu } = require("chrome"); +const Services = require("Services"); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const { getStack, callFunctionWithAsyncStack } = require("devtools/shared/platform/stack"); @@ -27,22 +28,22 @@ const noop = () => {}; * augmented with the necessary facilities by passing its prototype to this * function. * - * @param proto object + * @param aProto object * The prototype object that will be modified. */ -function eventSource(proto) { +function eventSource(aProto) { /** * Add a listener to the event source for a given event. * - * @param name string + * @param aName string * The event to listen for. - * @param listener function + * @param aListener function * Called when the event is fired. If the same listener * is added more than once, it will be called once per * addListener call. */ - proto.addListener = function (name, listener) { - if (typeof listener != "function") { + aProto.addListener = function (aName, aListener) { + if (typeof aListener != "function") { throw TypeError("Listeners must be functions."); } @@ -50,46 +51,47 @@ function eventSource(proto) { this._listeners = {}; } - this._getListeners(name).push(listener); + this._getListeners(aName).push(aListener); }; /** * Add a listener to the event source for a given event. The * listener will be removed after it is called for the first time. * - * @param name string + * @param aName string * The event to listen for. - * @param listener function + * @param aListener function * Called when the event is fired. */ - proto.addOneTimeListener = function (name, listener) { + aProto.addOneTimeListener = function (aName, aListener) { let l = (...args) => { - this.removeListener(name, l); - listener.apply(null, args); + this.removeListener(aName, l); + aListener.apply(null, args); }; - this.addListener(name, l); + this.addListener(aName, l); }; /** * Remove a listener from the event source previously added with * addListener(). * - * @param name string + * @param aName string * The event name used during addListener to add the listener. - * @param listener function + * @param aListener function * The callback to remove. If addListener was called multiple * times, all instances will be removed. */ - proto.removeListener = function (name, listener) { - if (!this._listeners || (listener && !this._listeners[name])) { + aProto.removeListener = function (aName, aListener) { + if (!this._listeners || (aListener && !this._listeners[aName])) { return; } - if (!listener) { - this._listeners[name] = []; - } else { - this._listeners[name] = - this._listeners[name].filter(l => l != listener); + if (!aListener) { + this._listeners[aName] = []; + } + else { + this._listeners[aName] = + this._listeners[aName].filter(function (l) { return l != aListener; }); } }; @@ -97,27 +99,27 @@ function eventSource(proto) { * Returns the listeners for the specified event name. If none are defined it * initializes an empty list and returns that. * - * @param name string + * @param aName string * The event name. */ - proto._getListeners = function (name) { - if (name in this._listeners) { - return this._listeners[name]; + aProto._getListeners = function (aName) { + if (aName in this._listeners) { + return this._listeners[aName]; } - this._listeners[name] = []; - return this._listeners[name]; + this._listeners[aName] = []; + return this._listeners[aName]; }; /** * Notify listeners of an event. * - * @param name string + * @param aName string * The event to fire. * @param arguments * All arguments will be passed along to the listeners, * including the name argument. */ - proto.emit = function () { + aProto.emit = function () { if (!this._listeners) { return; } @@ -200,8 +202,9 @@ const UnsolicitedPauses = { * provides the means to communicate with the server and exchange the messages * required by the protocol in a traditional JavaScript API. */ -const DebuggerClient = exports.DebuggerClient = function (transport) { - this._transport = transport; +const DebuggerClient = exports.DebuggerClient = function (aTransport) +{ + this._transport = aTransport; this._transport.hooks = this; // Map actor ID to client instance for each actor type. @@ -221,18 +224,18 @@ const DebuggerClient = exports.DebuggerClient = function (transport) { * the connection's root actor. */ this.mainRoot = null; - this.expectReply("root", (packet) => { - this.mainRoot = new RootClient(this, packet); - this.emit("connected", packet.applicationType, packet.traits); + this.expectReply("root", (aPacket) => { + this.mainRoot = new RootClient(this, aPacket); + this.emit("connected", aPacket.applicationType, aPacket.traits); }); }; /** * A declarative helper for defining methods that send requests to the server. * - * @param packetSkeleton + * @param aPacketSkeleton * The form of the packet to send. Can specify fields to be filled from - * the parameters by using the |arg| function. + * the parameters by using the |args| function. * @param before * The function to call before sending the packet. Is passed the packet, * and the return value is used as the new packet. The |this| context is @@ -246,21 +249,21 @@ const DebuggerClient = exports.DebuggerClient = function (transport) { * The `Request` object that is a Promise object and resolves once * we receive the response. (See request method for more details) */ -DebuggerClient.requester = function (packetSkeleton, config = {}) { +DebuggerClient.requester = function (aPacketSkeleton, config = {}) { let { before, after } = config; return DevToolsUtils.makeInfallible(function (...args) { let outgoingPacket = { - to: packetSkeleton.to || this.actor + to: aPacketSkeleton.to || this.actor }; let maxPosition = -1; - for (let k of Object.keys(packetSkeleton)) { - if (packetSkeleton[k] instanceof DebuggerClient.Argument) { - let { position } = packetSkeleton[k]; - outgoingPacket[k] = packetSkeleton[k].getArgument(args); + for (let k of Object.keys(aPacketSkeleton)) { + if (aPacketSkeleton[k] instanceof DebuggerClient.Argument) { + let { position } = aPacketSkeleton[k]; + outgoingPacket[k] = aPacketSkeleton[k].getArgument(args); maxPosition = Math.max(position, maxPosition); } else { - outgoingPacket[k] = packetSkeleton[k]; + outgoingPacket[k] = aPacketSkeleton[k]; } } @@ -268,37 +271,37 @@ DebuggerClient.requester = function (packetSkeleton, config = {}) { outgoingPacket = before.call(this, outgoingPacket); } - return this.request(outgoingPacket, DevToolsUtils.makeInfallible((response) => { + return this.request(outgoingPacket, DevToolsUtils.makeInfallible((aResponse) => { if (after) { - let { from } = response; - response = after.call(this, response); - if (!response.from) { - response.from = from; + let { from } = aResponse; + aResponse = after.call(this, aResponse); + if (!aResponse.from) { + aResponse.from = from; } } // The callback is always the last parameter. let thisCallback = args[maxPosition + 1]; if (thisCallback) { - thisCallback(response); + thisCallback(aResponse); } }, "DebuggerClient.requester request callback")); }, "DebuggerClient.requester"); }; -function arg(pos) { - return new DebuggerClient.Argument(pos); +function args(aPos) { + return new DebuggerClient.Argument(aPos); } -DebuggerClient.Argument = function (position) { - this.position = position; +DebuggerClient.Argument = function (aPosition) { + this.position = aPosition; }; -DebuggerClient.Argument.prototype.getArgument = function (params) { - if (!(this.position in params)) { +DebuggerClient.Argument.prototype.getArgument = function (aParams) { + if (!(this.position in aParams)) { throw new Error("Bad index into params: " + this.position); } - return params[this.position]; + return aParams[this.position]; }; // Expose these to save callers the trouble of importing DebuggerSocket @@ -317,7 +320,7 @@ DebuggerClient.prototype = { /** * Connect to the server and start exchanging protocol messages. * - * @param onConnected function + * @param aOnConnected function * If specified, will be called when the greeting packet is * received from the debugging server. * @@ -327,7 +330,7 @@ DebuggerClient.prototype = { * element is the traits object (help figure out the features * and behaviors of the server we connect to. See RootActor). */ - connect: function (onConnected) { + connect: function (aOnConnected) { let deferred = promise.defer(); this.emit("connect"); @@ -335,12 +338,12 @@ DebuggerClient.prototype = { // so it's possible to track all instances. events.emit(DebuggerClient, "connect", this); - this.addOneTimeListener("connected", (name, applicationType, traits) => { - this.traits = traits; - if (onConnected) { - onConnected(applicationType, traits); + this.addOneTimeListener("connected", (aName, aApplicationType, aTraits) => { + this.traits = aTraits; + if (aOnConnected) { + aOnConnected(aApplicationType, aTraits); } - deferred.resolve([applicationType, traits]); + deferred.resolve([aApplicationType, aTraits]); }); this._transport.ready(); @@ -350,17 +353,17 @@ DebuggerClient.prototype = { /** * Shut down communication with the debugging server. * - * @param onClosed function + * @param aOnClosed function * If specified, will be called when the debugging connection * has been closed. This parameter is deprecated - please use * the returned Promise. * @return Promise * Resolves after the underlying transport is closed. */ - close: function (onClosed) { + close: function (aOnClosed) { let deferred = promise.defer(); - if (onClosed) { - deferred.promise.then(onClosed); + if (aOnClosed) { + deferred.promise.then(aOnClosed); } // Disable detach event notifications, because event handlers will be in a @@ -410,206 +413,198 @@ DebuggerClient.prototype = { * This function exists only to preserve DebuggerClient's interface; * new code should say 'client.mainRoot.listTabs()'. */ - listTabs: function (onResponse) { - return this.mainRoot.listTabs(onResponse); - }, + listTabs: function (aOnResponse) { return this.mainRoot.listTabs(aOnResponse); }, /* * This function exists only to preserve DebuggerClient's interface; * new code should say 'client.mainRoot.listAddons()'. */ - listAddons: function (onResponse) { - return this.mainRoot.listAddons(onResponse); - }, + listAddons: function (aOnResponse) { return this.mainRoot.listAddons(aOnResponse); }, - getTab: function (filter) { - return this.mainRoot.getTab(filter); - }, + getTab: function (aFilter) { return this.mainRoot.getTab(aFilter); }, /** * Attach to a tab actor. * - * @param string tabActor + * @param string aTabActor * The actor ID for the tab to attach. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a TabClient * (which will be undefined on error). */ - attachTab: function (tabActor, onResponse = noop) { - if (this._clients.has(tabActor)) { - let cachedTab = this._clients.get(tabActor); + attachTab: function (aTabActor, aOnResponse = noop) { + if (this._clients.has(aTabActor)) { + let cachedTab = this._clients.get(aTabActor); let cachedResponse = { cacheDisabled: cachedTab.cacheDisabled, javascriptEnabled: cachedTab.javascriptEnabled, traits: cachedTab.traits, }; - DevToolsUtils.executeSoon(() => onResponse(cachedResponse, cachedTab)); + DevToolsUtils.executeSoon(() => aOnResponse(cachedResponse, cachedTab)); return promise.resolve([cachedResponse, cachedTab]); } let packet = { - to: tabActor, + to: aTabActor, type: "attach" }; - return this.request(packet).then(response => { + return this.request(packet).then(aResponse => { let tabClient; - if (!response.error) { - tabClient = new TabClient(this, response); + if (!aResponse.error) { + tabClient = new TabClient(this, aResponse); this.registerClient(tabClient); } - onResponse(response, tabClient); - return [response, tabClient]; + aOnResponse(aResponse, tabClient); + return [aResponse, tabClient]; }); }, - attachWorker: function (workerActor, onResponse = noop) { - let workerClient = this._clients.get(workerActor); + attachWorker: function DC_attachWorker(aWorkerActor, aOnResponse = noop) { + let workerClient = this._clients.get(aWorkerActor); if (workerClient !== undefined) { let response = { from: workerClient.actor, type: "attached", url: workerClient.url }; - DevToolsUtils.executeSoon(() => onResponse(response, workerClient)); + DevToolsUtils.executeSoon(() => aOnResponse(response, workerClient)); return promise.resolve([response, workerClient]); } - return this.request({ to: workerActor, type: "attach" }).then(response => { - if (response.error) { - onResponse(response, null); - return [response, null]; + return this.request({ to: aWorkerActor, type: "attach" }).then(aResponse => { + if (aResponse.error) { + aOnResponse(aResponse, null); + return [aResponse, null]; } - workerClient = new WorkerClient(this, response); + let workerClient = new WorkerClient(this, aResponse); this.registerClient(workerClient); - onResponse(response, workerClient); - return [response, workerClient]; + aOnResponse(aResponse, workerClient); + return [aResponse, workerClient]; }); }, /** * Attach to an addon actor. * - * @param string addonActor + * @param string aAddonActor * The actor ID for the addon to attach. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a AddonClient * (which will be undefined on error). */ - attachAddon: function (addonActor, onResponse = noop) { + attachAddon: function DC_attachAddon(aAddonActor, aOnResponse = noop) { let packet = { - to: addonActor, + to: aAddonActor, type: "attach" }; - return this.request(packet).then(response => { + return this.request(packet).then(aResponse => { let addonClient; - if (!response.error) { - addonClient = new AddonClient(this, addonActor); + if (!aResponse.error) { + addonClient = new AddonClient(this, aAddonActor); this.registerClient(addonClient); this.activeAddon = addonClient; } - onResponse(response, addonClient); - return [response, addonClient]; + aOnResponse(aResponse, addonClient); + return [aResponse, addonClient]; }); }, /** * Attach to a Web Console actor. * - * @param string consoleActor + * @param string aConsoleActor * The ID for the console actor to attach to. - * @param array listeners + * @param array aListeners * The console listeners you want to start. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a WebConsoleClient * instance (which will be undefined on error). */ attachConsole: - function (consoleActor, listeners, onResponse = noop) { + function (aConsoleActor, aListeners, aOnResponse = noop) { let packet = { - to: consoleActor, + to: aConsoleActor, type: "startListeners", - listeners: listeners, + listeners: aListeners, }; - return this.request(packet).then(response => { + return this.request(packet).then(aResponse => { let consoleClient; - if (!response.error) { - if (this._clients.has(consoleActor)) { - consoleClient = this._clients.get(consoleActor); + if (!aResponse.error) { + if (this._clients.has(aConsoleActor)) { + consoleClient = this._clients.get(aConsoleActor); } else { - consoleClient = new WebConsoleClient(this, response); + consoleClient = new WebConsoleClient(this, aResponse); this.registerClient(consoleClient); } } - onResponse(response, consoleClient); - return [response, consoleClient]; + aOnResponse(aResponse, consoleClient); + return [aResponse, consoleClient]; }); }, /** * Attach to a global-scoped thread actor for chrome debugging. * - * @param string threadActor + * @param string aThreadActor * The actor ID for the thread to attach. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a ThreadClient * (which will be undefined on error). - * @param object options + * @param object aOptions * Configuration options. * - useSourceMaps: whether to use source maps or not. */ - attachThread: function (threadActor, onResponse = noop, options = {}) { - if (this._clients.has(threadActor)) { - let client = this._clients.get(threadActor); - DevToolsUtils.executeSoon(() => onResponse({}, client)); + attachThread: function (aThreadActor, aOnResponse = noop, aOptions = {}) { + if (this._clients.has(aThreadActor)) { + let client = this._clients.get(aThreadActor); + DevToolsUtils.executeSoon(() => aOnResponse({}, client)); return promise.resolve([{}, client]); } let packet = { - to: threadActor, + to: aThreadActor, type: "attach", - options, + options: aOptions }; - return this.request(packet).then(response => { - let threadClient; - if (!response.error) { - threadClient = new ThreadClient(this, threadActor); + return this.request(packet).then(aResponse => { + if (!aResponse.error) { + var threadClient = new ThreadClient(this, aThreadActor); this.registerClient(threadClient); } - onResponse(response, threadClient); - return [response, threadClient]; + aOnResponse(aResponse, threadClient); + return [aResponse, threadClient]; }); }, /** * Attach to a trace actor. * - * @param string traceActor + * @param string aTraceActor * The actor ID for the tracer to attach. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a TraceClient * (which will be undefined on error). */ - attachTracer: function (traceActor, onResponse = noop) { - if (this._clients.has(traceActor)) { - let client = this._clients.get(traceActor); - DevToolsUtils.executeSoon(() => onResponse({}, client)); + attachTracer: function (aTraceActor, aOnResponse = noop) { + if (this._clients.has(aTraceActor)) { + let client = this._clients.get(aTraceActor); + DevToolsUtils.executeSoon(() => aOnResponse({}, client)); return promise.resolve([{}, client]); } let packet = { - to: traceActor, + to: aTraceActor, type: "attach" }; - return this.request(packet).then(response => { - let traceClient; - if (!response.error) { - traceClient = new TraceClient(this, traceActor); + return this.request(packet).then(aResponse => { + if (!aResponse.error) { + var traceClient = new TraceClient(this, aTraceActor); this.registerClient(traceClient); } - onResponse(response, traceClient); - return [response, traceClient]; + aOnResponse(aResponse, traceClient); + return [aResponse, traceClient]; }); }, @@ -617,17 +612,17 @@ DebuggerClient.prototype = { * Fetch the ChromeActor for the main process or ChildProcessActor for a * a given child process ID. * - * @param number id + * @param number aId * The ID for the process to attach (returned by `listProcesses`). * Connected to the main process if omitted, or is 0. */ - getProcess: function (id) { + getProcess: function (aId) { let packet = { to: "root", type: "getProcess" }; - if (typeof (id) == "number") { - packet.id = id; + if (typeof (aId) == "number") { + packet.id = aId; } return this.request(packet); }, @@ -635,23 +630,23 @@ DebuggerClient.prototype = { /** * Release an object actor. * - * @param string actor + * @param string aActor * The actor ID to send the request to. - * @param onResponse function + * @param aOnResponse function * If specified, will be called with the response packet when * debugging server responds. */ release: DebuggerClient.requester({ - to: arg(0), + to: args(0), type: "release" }), /** * Send a request to the debugging server. * - * @param packet object + * @param aRequest object * A JSON packet to send to the debugging server. - * @param onResponse function + * @param aOnResponse function * If specified, will be called with the JSON response packet when * debugging server responds. * @return Request @@ -661,7 +656,7 @@ DebuggerClient.prototype = { * whenever a JSON or a Bulk response is received; and is rejected * if the response is an error. * Note: This return value can be ignored if you are using JSON alone, - * because the callback provided in |onResponse| will be bound to the + * because the callback provided in |aOnResponse| will be bound to the * "json-reply" event automatically. * * Events emitted: @@ -693,30 +688,30 @@ DebuggerClient.prototype = { * This object also emits "progress" events for each chunk * that is copied. See stream-utils.js. */ - request: function (packet, onResponse) { + request: function (aRequest, aOnResponse) { if (!this.mainRoot) { throw Error("Have not yet received a hello packet from the server."); } - let type = packet.type || ""; - if (!packet.to) { + let type = aRequest.type || ""; + if (!aRequest.to) { throw Error("'" + type + "' request packet has no destination."); } if (this._closed) { let msg = "'" + type + "' request packet to " + - "'" + packet.to + "' " + + "'" + aRequest.to + "' " + "can't be sent as the connection is closed."; let resp = { error: "connectionClosed", message: msg }; - if (onResponse) { - onResponse(resp); + if (aOnResponse) { + aOnResponse(resp); } return promise.reject(resp); } - let request = new Request(packet); + let request = new Request(aRequest); request.format = "json"; request.stack = getStack(); - if (onResponse) { - request.on("json-reply", onResponse); + if (aOnResponse) { + request.on("json-reply", aOnResponse); } this._sendOrQueueRequest(request); @@ -866,7 +861,7 @@ DebuggerClient.prototype = { if (request.format === "json") { this._transport.send(request.request); - return; + return false; } this._transport.startBulkSend(request.request).then((...args) => { @@ -904,28 +899,28 @@ DebuggerClient.prototype = { }, /** - * Arrange to hand the next reply from |actor| to the handler bound to - * |request|. + * Arrange to hand the next reply from |aActor| to the handler bound to + * |aRequest|. * * DebuggerClient.prototype.request / startBulkRequest usually takes care of * establishing the handler for a given request, but in rare cases (well, * greetings from new root actors, is the only case at the moment) we must be * prepared for a "reply" that doesn't correspond to any request we sent. */ - expectReply: function (actor, request) { - if (this._activeRequests.has(actor)) { - throw Error("clashing handlers for next reply from " + actor); + expectReply: function (aActor, aRequest) { + if (this._activeRequests.has(aActor)) { + throw Error("clashing handlers for next reply from " + uneval(aActor)); } // If a handler is passed directly (as it is with the handler for the root // actor greeting), create a dummy request to bind this to. - if (typeof request === "function") { - let handler = request; - request = new Request(); - request.on("json-reply", handler); + if (typeof aRequest === "function") { + let handler = aRequest; + aRequest = new Request(); + aRequest.on("json-reply", handler); } - this._activeRequests.set(actor, request); + this._activeRequests.set(aActor, aRequest); }, // Transport hooks. @@ -933,23 +928,23 @@ DebuggerClient.prototype = { /** * Called by DebuggerTransport to dispatch incoming packets as appropriate. * - * @param packet object + * @param aPacket object * The incoming packet. */ - onPacket: function (packet) { - if (!packet.from) { + onPacket: function (aPacket) { + if (!aPacket.from) { DevToolsUtils.reportException( "onPacket", new Error("Server did not specify an actor, dropping packet: " + - JSON.stringify(packet))); + JSON.stringify(aPacket))); return; } // If we have a registered Front for this actor, let it handle the packet // and skip all the rest of this unpleasantness. - let front = this.getActor(packet.from); + let front = this.getActor(aPacket.from); if (front) { - front.onPacket(packet); + front.onPacket(aPacket); return; } @@ -957,17 +952,17 @@ DebuggerClient.prototype = { // This is necessary because we might receive this event while the client is closing, // and the clients have already been removed by that point. if (this.mainRoot && - packet.from == this.mainRoot.actor && - packet.type == "forwardingCancelled") { - this.purgeRequests(packet.prefix); + aPacket.from == this.mainRoot.actor && + aPacket.type == "forwardingCancelled") { + this.purgeRequests(aPacket.prefix); return; } - if (this._clients.has(packet.from) && packet.type) { - let client = this._clients.get(packet.from); - let type = packet.type; + if (this._clients.has(aPacket.from) && aPacket.type) { + let client = this._clients.get(aPacket.from); + let type = aPacket.type; if (client.events.indexOf(type) != -1) { - client.emit(type, packet); + client.emit(type, aPacket); // we ignore the rest, as the client is expected to handle this packet. return; } @@ -977,24 +972,24 @@ DebuggerClient.prototype = { // See if we have a handler function waiting for a reply from this // actor. (Don't count unsolicited notifications or pauses as // replies.) - if (this._activeRequests.has(packet.from) && - !(packet.type in UnsolicitedNotifications) && - !(packet.type == ThreadStateTypes.paused && - packet.why.type in UnsolicitedPauses)) { - activeRequest = this._activeRequests.get(packet.from); - this._activeRequests.delete(packet.from); + if (this._activeRequests.has(aPacket.from) && + !(aPacket.type in UnsolicitedNotifications) && + !(aPacket.type == ThreadStateTypes.paused && + aPacket.why.type in UnsolicitedPauses)) { + activeRequest = this._activeRequests.get(aPacket.from); + this._activeRequests.delete(aPacket.from); } // If there is a subsequent request for the same actor, hand it off to the // transport. Delivery of packets on the other end is always async, even // in the local transport case. - this._attemptNextRequest(packet.from); + this._attemptNextRequest(aPacket.from); // Packets that indicate thread state changes get special treatment. - if (packet.type in ThreadStateTypes && - this._clients.has(packet.from) && - typeof this._clients.get(packet.from)._onThreadState == "function") { - this._clients.get(packet.from)._onThreadState(packet); + if (aPacket.type in ThreadStateTypes && + this._clients.has(aPacket.from) && + typeof this._clients.get(aPacket.from)._onThreadState == "function") { + this._clients.get(aPacket.from)._onThreadState(aPacket); } // TODO: Bug 1151156 - Remove once Gecko 40 is on b2g-stable. @@ -1002,10 +997,10 @@ DebuggerClient.prototype = { // On navigation the server resumes, so the client must resume as well. // We achieve that by generating a fake resumption packet that triggers // the client's thread state change listeners. - if (packet.type == UnsolicitedNotifications.tabNavigated && - this._clients.has(packet.from) && - this._clients.get(packet.from).thread) { - let thread = this._clients.get(packet.from).thread; + if (aPacket.type == UnsolicitedNotifications.tabNavigated && + this._clients.has(aPacket.from) && + this._clients.get(aPacket.from).thread) { + let thread = this._clients.get(aPacket.from).thread; let resumption = { from: thread._actor, type: "resumed" }; thread._onThreadState(resumption); } @@ -1013,12 +1008,12 @@ DebuggerClient.prototype = { // Only try to notify listeners on events, not responses to requests // that lack a packet type. - if (packet.type) { - this.emit(packet.type, packet); + if (aPacket.type) { + this.emit(aPacket.type, aPacket); } if (activeRequest) { - let emitReply = () => activeRequest.emit("json-reply", packet); + let emitReply = () => activeRequest.emit("json-reply", aPacket); if (activeRequest.stack) { callFunctionWithAsyncStack(emitReply, activeRequest.stack, "DevTools RDP"); @@ -1059,7 +1054,7 @@ DebuggerClient.prototype = { * that is copied. See stream-utils.js. */ onBulkPacket: function (packet) { - let { actor } = packet; + let { actor, type, length } = packet; if (!actor) { DevToolsUtils.reportException( @@ -1089,7 +1084,7 @@ DebuggerClient.prototype = { /** * Called by DebuggerTransport when the underlying stream is closed. * - * @param status nsresult + * @param aStatus nsresult * The status code that corresponds to the reason for closing * the stream. */ @@ -1285,9 +1280,7 @@ DebuggerClient.prototype = { poolFor: function (actorID) { for (let pool of this._pools) { - if (pool.has(actorID)) { - return pool; - } + if (pool.has(actorID)) return pool; } return null; }, @@ -1322,9 +1315,7 @@ Request.prototype = { events.emit(this, type, ...args); }, - get actor() { - return this.request.to || this.request.actor; - } + get actor() { return this.request.to || this.request.actor; } }; @@ -1333,80 +1324,76 @@ Request.prototype = { * is a front to the tab actor created in the server side, hiding the protocol * details in a traditional JavaScript API. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param form object + * @param aForm object * The protocol form for this tab. */ -function TabClient(client, form) { - this.client = client; - this._actor = form.from; - this._threadActor = form.threadActor; - this.javascriptEnabled = form.javascriptEnabled; - this.cacheDisabled = form.cacheDisabled; +function TabClient(aClient, aForm) { + this.client = aClient; + this._actor = aForm.from; + this._threadActor = aForm.threadActor; + this.javascriptEnabled = aForm.javascriptEnabled; + this.cacheDisabled = aForm.cacheDisabled; this.thread = null; this.request = this.client.request; - this.traits = form.traits || {}; + this.traits = aForm.traits || {}; this.events = ["workerListChanged"]; } TabClient.prototype = { - get actor() { - return this._actor; - }, - get _transport() { - return this.client._transport; - }, + get actor() { return this._actor; }, + get _transport() { return this.client._transport; }, /** * Attach to a thread actor. * - * @param object options + * @param object aOptions * Configuration options. * - useSourceMaps: whether to use source maps or not. - * @param function onResponse + * @param function aOnResponse * Called with the response packet and a ThreadClient * (which will be undefined on error). */ - attachThread: function (options = {}, onResponse = noop) { + attachThread: function (aOptions = {}, aOnResponse = noop) { if (this.thread) { - DevToolsUtils.executeSoon(() => onResponse({}, this.thread)); + DevToolsUtils.executeSoon(() => aOnResponse({}, this.thread)); return promise.resolve([{}, this.thread]); } let packet = { to: this._threadActor, type: "attach", - options, + options: aOptions }; - return this.request(packet).then(response => { - if (!response.error) { + return this.request(packet).then(aResponse => { + if (!aResponse.error) { this.thread = new ThreadClient(this, this._threadActor); this.client.registerClient(this.thread); } - onResponse(response, this.thread); - return [response, this.thread]; + aOnResponse(aResponse, this.thread); + return [aResponse, this.thread]; }); }, /** * Detach the client from the tab actor. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ detach: DebuggerClient.requester({ type: "detach" }, { - before: function (packet) { + before: function (aPacket) { if (this.thread) { this.thread.detach(); } - return packet; + return aPacket; }, - after: function (response) { + after: function (aResponse) { this.client.unregisterClient(this); - return response; + return aResponse; }, }), @@ -1429,7 +1416,7 @@ TabClient.prototype = { }, _reload: DebuggerClient.requester({ type: "reload", - options: arg(0) + options: args(0) }), /** @@ -1440,28 +1427,28 @@ TabClient.prototype = { */ navigateTo: DebuggerClient.requester({ type: "navigateTo", - url: arg(0) + url: args(0) }), /** * Reconfigure the tab actor. * - * @param object options + * @param object aOptions * A dictionary object of the new options to use in the tab actor. - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ reconfigure: DebuggerClient.requester({ type: "reconfigure", - options: arg(0) + options: args(0) }), listWorkers: DebuggerClient.requester({ type: "listWorkers" }), - attachWorker: function (workerActor, onResponse) { - this.client.attachWorker(workerActor, onResponse); + attachWorker: function (aWorkerActor, aOnResponse) { + this.client.attachWorker(aWorkerActor, aOnResponse); }, /** @@ -1474,17 +1461,17 @@ TabClient.prototype = { */ resolveLocation: DebuggerClient.requester({ type: "resolveLocation", - location: arg(0) + location: args(0) }), }; eventSource(TabClient.prototype); -function WorkerClient(client, form) { - this.client = client; - this._actor = form.from; +function WorkerClient(aClient, aForm) { + this.client = aClient; + this._actor = aForm.from; this._isClosed = false; - this._url = form.url; + this._url = aForm.url; this._onClose = this._onClose.bind(this); @@ -1515,23 +1502,23 @@ WorkerClient.prototype = { }, detach: DebuggerClient.requester({ type: "detach" }, { - after: function (response) { + after: function (aResponse) { if (this.thread) { this.client.unregisterClient(this.thread); } this.client.unregisterClient(this); - return response; + return aResponse; }, }), - attachThread: function (options = {}, onResponse = noop) { + attachThread: function (aOptions = {}, aOnResponse = noop) { if (this.thread) { let response = [{ type: "connected", threadActor: this.thread._actor, consoleActor: this.consoleActor, }, this.thread]; - DevToolsUtils.executeSoon(() => onResponse(response)); + DevToolsUtils.executeSoon(() => aOnResponse(response)); return response; } @@ -1539,31 +1526,31 @@ WorkerClient.prototype = { return this.request({ to: this._actor, type: "connect", - options, - }).then(connectResponse => { - if (connectResponse.error) { - onResponse(connectResponse, null); + options: aOptions, + }).then(connectReponse => { + if (connectReponse.error) { + aOnResponse(connectReponse, null); return [connectResponse, null]; } return this.request({ - to: connectResponse.threadActor, + to: connectReponse.threadActor, type: "attach", - options, + options: aOptions }).then(attachResponse => { if (attachResponse.error) { - onResponse(attachResponse, null); + aOnResponse(attachResponse, null); } - this.thread = new ThreadClient(this, connectResponse.threadActor); - this.consoleActor = connectResponse.consoleActor; + this.thread = new ThreadClient(this, connectReponse.threadActor); + this.consoleActor = connectReponse.consoleActor; this.client.registerClient(this.thread); - onResponse(connectResponse, this.thread); + aOnResponse(connectReponse, this.thread); return [connectResponse, this.thread]; }); }, error => { - onResponse(error, null); + aOnResponse(error, null); }); }, @@ -1586,36 +1573,32 @@ WorkerClient.prototype = { eventSource(WorkerClient.prototype); -function AddonClient(client, actor) { - this._client = client; - this._actor = actor; +function AddonClient(aClient, aActor) { + this._client = aClient; + this._actor = aActor; this.request = this._client.request; this.events = []; } AddonClient.prototype = { - get actor() { - return this._actor; - }, - get _transport() { - return this._client._transport; - }, + get actor() { return this._actor; }, + get _transport() { return this._client._transport; }, /** * Detach the client from the addon actor. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ detach: DebuggerClient.requester({ type: "detach" }, { - after: function (response) { + after: function (aResponse) { if (this._client.activeAddon === this) { this._client.activeAddon = null; } this._client.unregisterClient(this); - return response; + return aResponse; }, }) }; @@ -1626,9 +1609,9 @@ AddonClient.prototype = { * for the initial connection; DebuggerClient's 'listTabs' and * 'listChildProcesses' methods forward to that root actor. * - * @param client object + * @param aClient object * The client connection to which this actor belongs. - * @param greeting string + * @param aGreeting string * The greeting packet from the root actor we're to represent. * * Properties of a RootClient instance: @@ -1640,11 +1623,11 @@ AddonClient.prototype = { * @property traits object * The traits object, as given in the root actor's greeting packet. */ -function RootClient(client, greeting) { - this._client = client; - this.actor = greeting.from; - this.applicationType = greeting.applicationType; - this.traits = greeting.traits; +function RootClient(aClient, aGreeting) { + this._client = aClient; + this.actor = aGreeting.from; + this.applicationType = aGreeting.applicationType; + this.traits = aGreeting.traits; } exports.RootClient = RootClient; @@ -1654,7 +1637,7 @@ RootClient.prototype = { /** * List the open tabs. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ listTabs: DebuggerClient.requester({ type: "listTabs" }), @@ -1662,7 +1645,7 @@ RootClient.prototype = { /** * List the installed addons. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ listAddons: DebuggerClient.requester({ type: "listAddons" }), @@ -1670,7 +1653,7 @@ RootClient.prototype = { /** * List the registered workers. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ listWorkers: DebuggerClient.requester({ type: "listWorkers" }), @@ -1678,7 +1661,7 @@ RootClient.prototype = { /** * List the registered service workers. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ listServiceWorkerRegistrations: DebuggerClient.requester({ @@ -1688,7 +1671,7 @@ RootClient.prototype = { /** * List the running processes. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ listProcesses: DebuggerClient.requester({ type: "listProcesses" }), @@ -1697,7 +1680,7 @@ RootClient.prototype = { * Fetch the TabActor for the currently selected tab, or for a specific * tab given as first parameter. * - * @param [optional] object filter + * @param [optional] object aFilter * A dictionary object with following optional attributes: * - outerWindowID: used to match tabs in parent process * - tabId: used to match tabs in child processes @@ -1705,19 +1688,19 @@ RootClient.prototype = { * If nothing is specified, returns the actor for the currently * selected tab. */ - getTab: function (filter) { + getTab: function (aFilter) { let packet = { to: this.actor, type: "getTab" }; - if (filter) { - if (typeof (filter.outerWindowID) == "number") { - packet.outerWindowID = filter.outerWindowID; - } else if (typeof (filter.tabId) == "number") { - packet.tabId = filter.tabId; - } else if ("tab" in filter) { - let browser = filter.tab.linkedBrowser; + if (aFilter) { + if (typeof (aFilter.outerWindowID) == "number") { + packet.outerWindowID = aFilter.outerWindowID; + } else if (typeof (aFilter.tabId) == "number") { + packet.tabId = aFilter.tabId; + } else if ("tab" in aFilter) { + let browser = aFilter.tab.linkedBrowser; if (browser.frameLoader.tabParent) { // Tabs in child process packet.tabId = browser.frameLoader.tabParent.tabId; @@ -1744,7 +1727,7 @@ RootClient.prototype = { /** * Description of protocol's actors and methods. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ protocolDescription: DebuggerClient.requester({ type: "protocolDescription" }), @@ -1753,12 +1736,8 @@ RootClient.prototype = { * Methods constructed by DebuggerClient.requester require these forwards * on their 'this'. */ - get _transport() { - return this._client._transport; - }, - get request() { - return this._client.request; - } + get _transport() { return this._client._transport; }, + get request() { return this._client.request; } }; /** @@ -1766,16 +1745,16 @@ RootClient.prototype = { * is a front to the thread actor created in the server side, hiding the * protocol details in a traditional JavaScript API. * - * @param client DebuggerClient|TabClient + * @param aClient DebuggerClient|TabClient * The parent of the thread (tab for tab-scoped debuggers, DebuggerClient * for chrome debuggers). - * @param actor string + * @param aActor string * The actor ID for this thread. */ -function ThreadClient(client, actor) { - this._parent = client; - this.client = client instanceof DebuggerClient ? client : client.client; - this._actor = actor; +function ThreadClient(aClient, aActor) { + this._parent = aClient; + this.client = aClient instanceof DebuggerClient ? aClient : aClient.client; + this._actor = aActor; this._frameCache = []; this._scriptCache = {}; this._pauseGrips = {}; @@ -1785,48 +1764,40 @@ function ThreadClient(client, actor) { ThreadClient.prototype = { _state: "paused", - get state() { - return this._state; - }, - get paused() { - return this._state === "paused"; - }, + get state() { return this._state; }, + get paused() { return this._state === "paused"; }, _pauseOnExceptions: false, _ignoreCaughtExceptions: false, _pauseOnDOMEvents: null, _actor: null, - get actor() { - return this._actor; - }, + get actor() { return this._actor; }, - get _transport() { - return this.client._transport; - }, + get _transport() { return this.client._transport; }, - _assertPaused: function (command) { + _assertPaused: function (aCommand) { if (!this.paused) { - throw Error(command + " command sent while not paused. Currently " + this._state); + throw Error(aCommand + " command sent while not paused. Currently " + this._state); } }, /** - * Resume a paused thread. If the optional limit parameter is present, then + * Resume a paused thread. If the optional aLimit parameter is present, then * the thread will also pause when that limit is reached. * - * @param [optional] object limit + * @param [optional] object aLimit * An object with a type property set to the appropriate limit (next, * step, or finish) per the remote debugging protocol specification. * Use null to specify no limit. - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ _doResume: DebuggerClient.requester({ type: "resume", - resumeLimit: arg(0) + resumeLimit: args(0) }, { - before: function (packet) { + before: function (aPacket) { this._assertPaused("resume"); // Put the client in a tentative "resuming" state so we can prevent @@ -1835,152 +1806,150 @@ ThreadClient.prototype = { this._state = "resuming"; if (this._pauseOnExceptions) { - packet.pauseOnExceptions = this._pauseOnExceptions; + aPacket.pauseOnExceptions = this._pauseOnExceptions; } if (this._ignoreCaughtExceptions) { - packet.ignoreCaughtExceptions = this._ignoreCaughtExceptions; + aPacket.ignoreCaughtExceptions = this._ignoreCaughtExceptions; } if (this._pauseOnDOMEvents) { - packet.pauseOnDOMEvents = this._pauseOnDOMEvents; + aPacket.pauseOnDOMEvents = this._pauseOnDOMEvents; } - return packet; + return aPacket; }, - after: function (response) { - if (response.error && this._state == "resuming") { + after: function (aResponse) { + if (aResponse.error && this._state == "resuming") { // There was an error resuming, update the state to the new one // reported by the server, if given (only on wrongState), otherwise // reset back to the previous state. - if (response.state) { - this._state = ThreadStateTypes[response.state]; + if (aResponse.state) { + this._state = ThreadStateTypes[aResponse.state]; } else { this._state = this._previousState; } } delete this._previousState; - return response; + return aResponse; }, }), /** * Reconfigure the thread actor. * - * @param object options + * @param object aOptions * A dictionary object of the new options to use in the thread actor. - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ reconfigure: DebuggerClient.requester({ type: "reconfigure", - options: arg(0) + options: args(0) }), /** * Resume a paused thread. */ - resume: function (onResponse) { - return this._doResume(null, onResponse); + resume: function (aOnResponse) { + return this._doResume(null, aOnResponse); }, /** * Resume then pause without stepping. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - resumeThenPause: function (onResponse) { - return this._doResume({ type: "break" }, onResponse); + resumeThenPause: function (aOnResponse) { + return this._doResume({ type: "break" }, aOnResponse); }, /** * Step over a function call. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - stepOver: function (onResponse) { - return this._doResume({ type: "next" }, onResponse); + stepOver: function (aOnResponse) { + return this._doResume({ type: "next" }, aOnResponse); }, /** * Step into a function call. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - stepIn: function (onResponse) { - return this._doResume({ type: "step" }, onResponse); + stepIn: function (aOnResponse) { + return this._doResume({ type: "step" }, aOnResponse); }, /** * Step out of a function call. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - stepOut: function (onResponse) { - return this._doResume({ type: "finish" }, onResponse); + stepOut: function (aOnResponse) { + return this._doResume({ type: "finish" }, aOnResponse); }, /** * Immediately interrupt a running thread. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - interrupt: function (onResponse) { - return this._doInterrupt(null, onResponse); + interrupt: function (aOnResponse) { + return this._doInterrupt(null, aOnResponse); }, /** * Pause execution right before the next JavaScript bytecode is executed. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - breakOnNext: function (onResponse) { - return this._doInterrupt("onNext", onResponse); + breakOnNext: function (aOnResponse) { + return this._doInterrupt("onNext", aOnResponse); }, /** * Interrupt a running thread. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ _doInterrupt: DebuggerClient.requester({ type: "interrupt", - when: arg(0) + when: args(0) }), /** * Enable or disable pausing when an exception is thrown. * - * @param boolean pauseOnExceptions + * @param boolean aFlag * Enables pausing if true, disables otherwise. - * @param boolean ignoreCaughtExceptions - * Whether to ignore caught exceptions - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ - pauseOnExceptions: function (pauseOnExceptions, - ignoreCaughtExceptions, - onResponse = noop) { - this._pauseOnExceptions = pauseOnExceptions; - this._ignoreCaughtExceptions = ignoreCaughtExceptions; + pauseOnExceptions: function (aPauseOnExceptions, + aIgnoreCaughtExceptions, + aOnResponse = noop) { + this._pauseOnExceptions = aPauseOnExceptions; + this._ignoreCaughtExceptions = aIgnoreCaughtExceptions; // Otherwise send the flag using a standard resume request. if (!this.paused) { - return this.interrupt(response => { - if (response.error) { + return this.interrupt(aResponse => { + if (aResponse.error) { // Can't continue if pausing failed. - onResponse(response); - return response; + aOnResponse(aResponse); + return aResponse; } - return this.resume(onResponse); + return this.resume(aOnResponse); }); } - onResponse(); + aOnResponse(); return promise.resolve(); }, @@ -2019,48 +1988,48 @@ ThreadClient.prototype = { * Send a clientEvaluate packet to the debuggee. Response * will be a resume packet. * - * @param string frame + * @param string aFrame * The actor ID of the frame where the evaluation should take place. - * @param string expression + * @param string aExpression * The expression that will be evaluated in the scope of the frame * above. - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ eval: DebuggerClient.requester({ type: "clientEvaluate", - frame: arg(0), - expression: arg(1) + frame: args(0), + expression: args(1) }, { - before: function (packet) { + before: function (aPacket) { this._assertPaused("eval"); // Put the client in a tentative "resuming" state so we can prevent // further requests that should only be sent in the paused state. this._state = "resuming"; - return packet; + return aPacket; }, - after: function (response) { - if (response.error) { + after: function (aResponse) { + if (aResponse.error) { // There was an error resuming, back to paused state. this._state = "paused"; } - return response; + return aResponse; }, }), /** * Detach from the thread actor. * - * @param function onResponse + * @param function aOnResponse * Called with the response packet. */ detach: DebuggerClient.requester({ type: "detach" }, { - after: function (response) { + after: function (aResponse) { this.client.unregisterClient(this); this._parent.thread = null; - return response; + return aResponse; }, }), @@ -2074,7 +2043,7 @@ ThreadClient.prototype = { */ releaseMany: DebuggerClient.requester({ type: "releaseMany", - actors: arg(0), + actors: args(0), }), /** @@ -2085,13 +2054,13 @@ ThreadClient.prototype = { */ threadGrips: DebuggerClient.requester({ type: "threadGrips", - actors: arg(0) + actors: args(0) }), /** * Return the event listeners defined on the page. * - * @param onResponse Function + * @param aOnResponse Function * Called with the thread's response. */ eventListeners: DebuggerClient.requester({ @@ -2101,7 +2070,7 @@ ThreadClient.prototype = { /** * Request the loaded sources for the current thread. * - * @param onResponse Function + * @param aOnResponse Function * Called with the thread's response. */ getSources: DebuggerClient.requester({ @@ -2122,19 +2091,19 @@ ThreadClient.prototype = { /** * Request frames from the callstack for the current thread. * - * @param start integer + * @param aStart integer * The number of the youngest stack frame to return (the youngest * frame is 0). - * @param count integer + * @param aCount integer * The maximum number of frames to return, or null to return all * frames. - * @param onResponse function + * @param aOnResponse function * Called with the thread's response. */ getFrames: DebuggerClient.requester({ type: "frames", - start: arg(0), - count: arg(1) + start: args(0), + count: args(1) }), /** @@ -2142,9 +2111,7 @@ ThreadClient.prototype = { * framescleared event to keep up to date on changes to this cache, * and can fill it using the fillFrames method. */ - get cachedFrames() { - return this._frameCache; - }, + get cachedFrames() { return this._frameCache; }, /** * true if there are more stack frames available on the server. @@ -2155,34 +2122,34 @@ ThreadClient.prototype = { }, /** - * Ensure that at least total stack frames have been loaded in the + * Ensure that at least aTotal stack frames have been loaded in the * ThreadClient's stack frame cache. A framesadded event will be * sent when the stack frame cache is updated. * - * @param total number + * @param aTotal number * The minimum number of stack frames to be included. - * @param callback function + * @param aCallback function * Optional callback function called when frames have been loaded * @returns true if a framesadded notification should be expected. */ - fillFrames: function (total, callback = noop) { + fillFrames: function (aTotal, aCallback = noop) { this._assertPaused("fillFrames"); - if (this._frameCache.length >= total) { + if (this._frameCache.length >= aTotal) { return false; } let numFrames = this._frameCache.length; - this.getFrames(numFrames, total - numFrames, (response) => { - if (response.error) { - callback(response); + this.getFrames(numFrames, aTotal - numFrames, (aResponse) => { + if (aResponse.error) { + aCallback(aResponse); return; } let threadGrips = DevToolsUtils.values(this._threadGrips); - for (let i in response.frames) { - let frame = response.frames[i]; + for (let i in aResponse.frames) { + let frame = aResponse.frames[i]; if (!frame.where.source) { // Older servers use urls instead, so we need to resolve // them to source actors @@ -2200,7 +2167,7 @@ ThreadClient.prototype = { // frames available. this.emit("framesadded"); - callback(response); + aCallback(aResponse); }); return true; @@ -2220,16 +2187,16 @@ ThreadClient.prototype = { /** * Return a ObjectClient object for the given object grip. * - * @param grip object + * @param aGrip object * A pause-lifetime object grip returned by the protocol. */ - pauseGrip: function (grip) { - if (grip.actor in this._pauseGrips) { - return this._pauseGrips[grip.actor]; + pauseGrip: function (aGrip) { + if (aGrip.actor in this._pauseGrips) { + return this._pauseGrips[aGrip.actor]; } - let client = new ObjectClient(this.client, grip); - this._pauseGrips[grip.actor] = client; + let client = new ObjectClient(this.client, aGrip); + this._pauseGrips[aGrip.actor] = client; return client; }, @@ -2237,19 +2204,19 @@ ThreadClient.prototype = { * Get or create a long string client, checking the grip client cache if it * already exists. * - * @param grip Object + * @param aGrip Object * The long string grip returned by the protocol. - * @param gripCacheName String + * @param aGripCacheName String * The property name of the grip client cache to check for existing * clients in. */ - _longString: function (grip, gripCacheName) { - if (grip.actor in this[gripCacheName]) { - return this[gripCacheName][grip.actor]; + _longString: function (aGrip, aGripCacheName) { + if (aGrip.actor in this[aGripCacheName]) { + return this[aGripCacheName][aGrip.actor]; } - let client = new LongStringClient(this.client, grip); - this[gripCacheName][grip.actor] = client; + let client = new LongStringClient(this.client, aGrip); + this[aGripCacheName][aGrip.actor] = client; return client; }, @@ -2257,35 +2224,35 @@ ThreadClient.prototype = { * Return an instance of LongStringClient for the given long string grip that * is scoped to the current pause. * - * @param grip Object + * @param aGrip Object * The long string grip returned by the protocol. */ - pauseLongString: function (grip) { - return this._longString(grip, "_pauseGrips"); + pauseLongString: function (aGrip) { + return this._longString(aGrip, "_pauseGrips"); }, /** * Return an instance of LongStringClient for the given long string grip that * is scoped to the thread lifetime. * - * @param grip Object + * @param aGrip Object * The long string grip returned by the protocol. */ - threadLongString: function (grip) { - return this._longString(grip, "_threadGrips"); + threadLongString: function (aGrip) { + return this._longString(aGrip, "_threadGrips"); }, /** * Clear and invalidate all the grip clients from the given cache. * - * @param gripCacheName + * @param aGripCacheName * The property name of the grip cache we want to clear. */ - _clearObjectClients: function (gripCacheName) { - for (let id in this[gripCacheName]) { - this[gripCacheName][id].valid = false; + _clearObjectClients: function (aGripCacheName) { + for (let id in this[aGripCacheName]) { + this[aGripCacheName][id].valid = false; } - this[gripCacheName] = {}; + this[aGripCacheName] = {}; }, /** @@ -2308,16 +2275,16 @@ ThreadClient.prototype = { * Handle thread state change by doing necessary cleanup and notifying all * registered listeners. */ - _onThreadState: function (packet) { - this._state = ThreadStateTypes[packet.type]; + _onThreadState: function (aPacket) { + this._state = ThreadStateTypes[aPacket.type]; // The debugger UI may not be initialized yet so we want to keep // the packet around so it knows what to pause state to display // when it's initialized - this._lastPausePacket = packet.type === "resumed" ? null : packet; + this._lastPausePacket = aPacket.type === "resumed" ? null : aPacket; this._clearFrames(); this._clearPauseGrips(); - packet.type === ThreadStateTypes.detached && this._clearThreadGrips(); - this.client._eventsEnabled && this.emit(packet.type, packet); + aPacket.type === ThreadStateTypes.detached && this._clearThreadGrips(); + this.client._eventsEnabled && this.emit(aPacket.type, aPacket); }, getLastPausePacket: function () { @@ -2327,33 +2294,32 @@ ThreadClient.prototype = { /** * Return an EnvironmentClient instance for the given environment actor form. */ - environment: function (form) { - return new EnvironmentClient(this.client, form); + environment: function (aForm) { + return new EnvironmentClient(this.client, aForm); }, /** * Return an instance of SourceClient for the given source actor form. */ - source: function (form) { - if (form.actor in this._threadGrips) { - return this._threadGrips[form.actor]; + source: function (aForm) { + if (aForm.actor in this._threadGrips) { + return this._threadGrips[aForm.actor]; } - this._threadGrips[form.actor] = new SourceClient(this, form); - return this._threadGrips[form.actor]; + return this._threadGrips[aForm.actor] = new SourceClient(this, aForm); }, /** * Request the prototype and own properties of mutlipleObjects. * - * @param onResponse function + * @param aOnResponse function * Called with the request's response. * @param actors [string] * List of actor ID of the queried objects. */ getPrototypesAndProperties: DebuggerClient.requester({ type: "prototypesAndProperties", - actors: arg(0) + actors: args(0) }), events: ["newSource"] @@ -2367,14 +2333,14 @@ eventSource(ThreadClient.prototype); * server side, hiding the protocol details in a traditional * JavaScript API. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param actor string + * @param aActor string * The actor ID for this thread. */ -function TraceClient(client, actor) { - this._client = client; - this._actor = actor; +function TraceClient(aClient, aActor) { + this._client = aClient; + this._actor = aActor; this._activeTraces = new Set(); this._waitingPackets = new Map(); this._expectedPacket = 0; @@ -2383,16 +2349,10 @@ function TraceClient(client, actor) { } TraceClient.prototype = { - get actor() { - return this._actor; - }, - get tracing() { - return this._activeTraces.size > 0; - }, + get actor() { return this._actor; }, + get tracing() { return this._activeTraces.size > 0; }, - get _transport() { - return this._client._transport; - }, + get _transport() { return this._client._transport; }, /** * Detach from the trace actor. @@ -2400,41 +2360,41 @@ TraceClient.prototype = { detach: DebuggerClient.requester({ type: "detach" }, { - after: function (response) { + after: function (aResponse) { this._client.unregisterClient(this); - return response; + return aResponse; }, }), /** * Start a new trace. * - * @param trace [string] + * @param aTrace [string] * An array of trace types to be recorded by the new trace. * - * @param name string + * @param aName string * The name of the new trace. * - * @param onResponse function + * @param aOnResponse function * Called with the request's response. */ startTrace: DebuggerClient.requester({ type: "startTrace", - name: arg(1), - trace: arg(0) + name: args(1), + trace: args(0) }, { - after: function (response) { - if (response.error) { - return response; + after: function (aResponse) { + if (aResponse.error) { + return aResponse; } if (!this.tracing) { this._waitingPackets.clear(); this._expectedPacket = 0; } - this._activeTraces.add(response.name); + this._activeTraces.add(aResponse.name); - return response; + return aResponse; }, }), @@ -2442,24 +2402,24 @@ TraceClient.prototype = { * End a trace. If a name is provided, stop the named * trace. Otherwise, stop the most recently started trace. * - * @param name string + * @param aName string * The name of the trace to stop. * - * @param onResponse function + * @param aOnResponse function * Called with the request's response. */ stopTrace: DebuggerClient.requester({ type: "stopTrace", - name: arg(0) + name: args(0) }, { - after: function (response) { - if (response.error) { - return response; + after: function (aResponse) { + if (aResponse.error) { + return aResponse; } - this._activeTraces.delete(response.name); + this._activeTraces.delete(aResponse.name); - return response; + return aResponse; }, }) }; @@ -2467,25 +2427,22 @@ TraceClient.prototype = { /** * Grip clients are used to retrieve information about the relevant object. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param grip object + * @param aGrip object * A pause-lifetime object grip returned by the protocol. */ -function ObjectClient(client, grip) { - this._grip = grip; - this._client = client; +function ObjectClient(aClient, aGrip) +{ + this._grip = aGrip; + this._client = aClient; this.request = this._client.request; } exports.ObjectClient = ObjectClient; ObjectClient.prototype = { - get actor() { - return this._grip.actor; - }, - get _transport() { - return this._client._transport; - }, + get actor() { return this._grip.actor; }, + get _transport() { return this._client._transport; }, valid: true, @@ -2502,18 +2459,18 @@ ObjectClient.prototype = { getDefinitionSite: DebuggerClient.requester({ type: "definitionSite" }, { - before: function (packet) { + before: function (aPacket) { if (this._grip.class != "Function") { throw new Error("getDefinitionSite is only valid for function grips."); } - return packet; + return aPacket; } }), /** * Request the names of a function's formal parameters. * - * @param onResponse function + * @param aOnResponse function * Called with an object of the form: * { parameterNames:[, ...] } * where each is the name of a parameter. @@ -2521,11 +2478,11 @@ ObjectClient.prototype = { getParameterNames: DebuggerClient.requester({ type: "parameterNames" }, { - before: function (packet) { - if (this._grip.class !== "Function") { + before: function (aPacket) { + if (this._grip["class"] !== "Function") { throw new Error("getParameterNames is only valid for function grips."); } - return packet; + return aPacket; }, }), @@ -2533,7 +2490,7 @@ ObjectClient.prototype = { * Request the names of the properties defined on the object and not its * prototype. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ getOwnPropertyNames: DebuggerClient.requester({ type: "ownPropertyNames" @@ -2542,7 +2499,7 @@ ObjectClient.prototype = { /** * Request the prototype and own properties of the object. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ getPrototypeAndProperties: DebuggerClient.requester({ type: "prototypeAndProperties" @@ -2564,17 +2521,17 @@ ObjectClient.prototype = { * - sort Boolean * If true, the iterator will sort the properties by name * before dispatching them. - * @param onResponse function Called with the client instance. + * @param aOnResponse function Called with the client instance. */ enumProperties: DebuggerClient.requester({ type: "enumProperties", - options: arg(0) + options: args(0) }, { - after: function (response) { - if (response.iterator) { - return { iterator: new PropertyIteratorClient(this._client, response.iterator) }; + after: function (aResponse) { + if (aResponse.iterator) { + return { iterator: new PropertyIteratorClient(this._client, aResponse.iterator) }; } - return response; + return aResponse; }, }), @@ -2582,7 +2539,7 @@ ObjectClient.prototype = { * Request a PropertyIteratorClient instance to enumerate entries in a * Map/Set-like object. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ enumEntries: DebuggerClient.requester({ type: "enumEntries" @@ -2606,18 +2563,18 @@ ObjectClient.prototype = { /** * Request the property descriptor of the object's specified property. * - * @param name string The name of the requested property. - * @param onResponse function Called with the request's response. + * @param aName string The name of the requested property. + * @param aOnResponse function Called with the request's response. */ getProperty: DebuggerClient.requester({ type: "property", - name: arg(0) + name: args(0) }), /** * Request the prototype of the object. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ getPrototype: DebuggerClient.requester({ type: "prototype" @@ -2626,7 +2583,7 @@ ObjectClient.prototype = { /** * Request the display string of the object. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ getDisplayString: DebuggerClient.requester({ type: "displayString" @@ -2635,16 +2592,16 @@ ObjectClient.prototype = { /** * Request the scope of the object. * - * @param onResponse function Called with the request's response. + * @param aOnResponse function Called with the request's response. */ getScope: DebuggerClient.requester({ type: "scope" }, { - before: function (packet) { + before: function (aPacket) { if (this._grip.class !== "Function") { throw new Error("scope is only valid for function grips."); } - return packet; + return aPacket; }, }), @@ -2654,12 +2611,12 @@ ObjectClient.prototype = { getDependentPromises: DebuggerClient.requester({ type: "dependentPromises" }, { - before: function (packet) { + before: function (aPacket) { if (this._grip.class !== "Promise") { throw new Error("getDependentPromises is only valid for promise " + "grips."); } - return packet; + return aPacket; } }), @@ -2669,11 +2626,11 @@ ObjectClient.prototype = { getPromiseAllocationStack: DebuggerClient.requester({ type: "allocationStack" }, { - before: function (packet) { + before: function (aPacket) { if (this._grip.class !== "Promise") { throw new Error("getAllocationStack is only valid for promise grips."); } - return packet; + return aPacket; } }), @@ -2715,29 +2672,25 @@ ObjectClient.prototype = { * this is controled while creating the PropertyIteratorClient * from ObjectClient.enumProperties. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param grip Object + * @param aGrip Object * A PropertyIteratorActor grip returned by the protocol via * TabActor.enumProperties request. */ -function PropertyIteratorClient(client, grip) { - this._grip = grip; - this._client = client; +function PropertyIteratorClient(aClient, aGrip) { + this._grip = aGrip; + this._client = aClient; this.request = this._client.request; } PropertyIteratorClient.prototype = { - get actor() { - return this._grip.actor; - }, + get actor() { return this._grip.actor; }, /** * Get the total number of properties available in the iterator. */ - get count() { - return this._grip.count; - }, + get count() { return this._grip.count; }, /** * Get one or more property names that correspond to the positions in the @@ -2745,12 +2698,12 @@ PropertyIteratorClient.prototype = { * * @param indexes Array * An array of property indexes. - * @param callback Function + * @param aCallback Function * The function called when we receive the property names. */ names: DebuggerClient.requester({ type: "names", - indexes: arg(0) + indexes: args(0) }, {}), /** @@ -2760,19 +2713,19 @@ PropertyIteratorClient.prototype = { * The index of the first property to fetch. * @param count Number * The number of properties to fetch. - * @param callback Function + * @param aCallback Function * The function called when we receive the property values. */ slice: DebuggerClient.requester({ type: "slice", - start: arg(0), - count: arg(1) + start: args(0), + count: args(1) }, {}), /** * Get all the property values. * - * @param callback Function + * @param aCallback Function * The function called when we receive the property values. */ all: DebuggerClient.requester({ @@ -2784,65 +2737,57 @@ PropertyIteratorClient.prototype = { * A LongStringClient provides a way to access "very long" strings from the * debugger server. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param grip Object + * @param aGrip Object * A pause-lifetime long string grip returned by the protocol. */ -function LongStringClient(client, grip) { - this._grip = grip; - this._client = client; +function LongStringClient(aClient, aGrip) { + this._grip = aGrip; + this._client = aClient; this.request = this._client.request; } exports.LongStringClient = LongStringClient; LongStringClient.prototype = { - get actor() { - return this._grip.actor; - }, - get length() { - return this._grip.length; - }, - get initial() { - return this._grip.initial; - }, - get _transport() { - return this._client._transport; - }, + get actor() { return this._grip.actor; }, + get length() { return this._grip.length; }, + get initial() { return this._grip.initial; }, + get _transport() { return this._client._transport; }, valid: true, /** - * Get the substring of this LongString from start to end. + * Get the substring of this LongString from aStart to aEnd. * - * @param start Number + * @param aStart Number * The starting index. - * @param end Number + * @param aEnd Number * The ending index. - * @param callback Function + * @param aCallback Function * The function called when we receive the substring. */ substring: DebuggerClient.requester({ type: "substring", - start: arg(0), - end: arg(1) + start: args(0), + end: args(1) }), }; /** * A SourceClient provides a way to access the source text of a script. * - * @param client ThreadClient + * @param aClient ThreadClient * The thread client parent. - * @param form Object + * @param aForm Object * The form sent across the remote debugging protocol. */ -function SourceClient(client, form) { - this._form = form; - this._isBlackBoxed = form.isBlackBoxed; - this._isPrettyPrinted = form.isPrettyPrinted; - this._activeThread = client; - this._client = client.client; +function SourceClient(aClient, aForm) { + this._form = aForm; + this._isBlackBoxed = aForm.isBlackBoxed; + this._isPrettyPrinted = aForm.isPrettyPrinted; + this._activeThread = aClient; + this._client = aClient.client; } SourceClient.prototype = { @@ -2868,47 +2813,47 @@ SourceClient.prototype = { /** * Black box this SourceClient's source. * - * @param callback Function + * @param aCallback Function * The callback function called when we receive the response from the server. */ blackBox: DebuggerClient.requester({ type: "blackbox" }, { - after: function (response) { - if (!response.error) { + after: function (aResponse) { + if (!aResponse.error) { this._isBlackBoxed = true; if (this._activeThread) { this._activeThread.emit("blackboxchange", this); } } - return response; + return aResponse; } }), /** * Un-black box this SourceClient's source. * - * @param callback Function + * @param aCallback Function * The callback function called when we receive the response from the server. */ unblackBox: DebuggerClient.requester({ type: "unblackbox" }, { - after: function (response) { - if (!response.error) { + after: function (aResponse) { + if (!aResponse.error) { this._isBlackBoxed = false; if (this._activeThread) { this._activeThread.emit("blackboxchange", this); } } - return response; + return aResponse; } }), /** * Get Executable Lines from a source * - * @param callback Function + * @param aCallback Function * The callback function called when we receive the response from the server. */ getExecutableLines: function (cb = noop) { @@ -2926,105 +2871,105 @@ SourceClient.prototype = { /** * Get a long string grip for this SourceClient's source. */ - source: function (callback = noop) { + source: function (aCallback = noop) { let packet = { to: this._form.actor, type: "source" }; - return this._client.request(packet).then(response => { - return this._onSourceResponse(response, callback); + return this._client.request(packet).then(aResponse => { + return this._onSourceResponse(aResponse, aCallback); }); }, /** * Pretty print this source's text. */ - prettyPrint: function (indent, callback = noop) { + prettyPrint: function (aIndent, aCallback = noop) { const packet = { to: this._form.actor, type: "prettyPrint", - indent + indent: aIndent }; - return this._client.request(packet).then(response => { - if (!response.error) { + return this._client.request(packet).then(aResponse => { + if (!aResponse.error) { this._isPrettyPrinted = true; this._activeThread._clearFrames(); this._activeThread.emit("prettyprintchange", this); } - return this._onSourceResponse(response, callback); + return this._onSourceResponse(aResponse, aCallback); }); }, /** * Stop pretty printing this source's text. */ - disablePrettyPrint: function (callback = noop) { + disablePrettyPrint: function (aCallback = noop) { const packet = { to: this._form.actor, type: "disablePrettyPrint" }; - return this._client.request(packet).then(response => { - if (!response.error) { + return this._client.request(packet).then(aResponse => { + if (!aResponse.error) { this._isPrettyPrinted = false; this._activeThread._clearFrames(); this._activeThread.emit("prettyprintchange", this); } - return this._onSourceResponse(response, callback); + return this._onSourceResponse(aResponse, aCallback); }); }, - _onSourceResponse: function (response, callback) { - if (response.error) { - callback(response); - return response; + _onSourceResponse: function (aResponse, aCallback) { + if (aResponse.error) { + aCallback(aResponse); + return aResponse; } - if (typeof response.source === "string") { - callback(response); - return response; + if (typeof aResponse.source === "string") { + aCallback(aResponse); + return aResponse; } - let { contentType, source } = response; + let { contentType, source } = aResponse; let longString = this._activeThread.threadLongString(source); - return longString.substring(0, longString.length).then(function (resp) { - if (resp.error) { - callback(resp); - return resp; + return longString.substring(0, longString.length).then(function (aResponse) { + if (aResponse.error) { + aCallback(aResponse); + return aReponse; } - let newResponse = { - source: resp.substring, + let response = { + source: aResponse.substring, contentType: contentType }; - callback(newResponse); - return newResponse; + aCallback(response); + return response; }); }, /** * Request to set a breakpoint in the specified location. * - * @param object location + * @param object aLocation * The location and condition of the breakpoint in * the form of { line[, column, condition] }. - * @param function onResponse + * @param function aOnResponse * Called with the thread's response. */ - setBreakpoint: function ({ line, column, condition, noSliding }, onResponse = noop) { + setBreakpoint: function ({ line, column, condition, noSliding }, aOnResponse = noop) { // A helper function that sets the breakpoint. - let doSetBreakpoint = callback => { + let doSetBreakpoint = aCallback => { let root = this._client.mainRoot; let location = { - line, - column, + line: line, + column: column }; let packet = { to: this.actor, type: "setBreakpoint", - location, - condition, - noSliding, + location: location, + condition: condition, + noSliding: noSliding }; // Backwards compatibility: send the breakpoint request to the @@ -3034,24 +2979,24 @@ SourceClient.prototype = { packet.location.url = this.url; } - return this._client.request(packet).then(response => { + return this._client.request(packet).then(aResponse => { // Ignoring errors, since the user may be setting a breakpoint in a // dead script that will reappear on a page reload. let bpClient; - if (response.actor) { + if (aResponse.actor) { bpClient = new BreakpointClient( this._client, this, - response.actor, + aResponse.actor, location, root.traits.conditionalBreakpoints ? condition : undefined ); } - onResponse(response, bpClient); - if (callback) { - callback(); + aOnResponse(aResponse, bpClient); + if (aCallback) { + aCallback(); } - return [response, bpClient]; + return [aResponse, bpClient]; }); }; @@ -3060,14 +3005,14 @@ SourceClient.prototype = { return doSetBreakpoint(); } // Otherwise, force a pause in order to set the breakpoint. - return this._activeThread.interrupt().then(response => { - if (response.error) { + return this._activeThread.interrupt().then(aResponse => { + if (aResponse.error) { // Can't set the breakpoint if pausing failed. - onResponse(response); - return response; + aOnResponse(aResponse); + return aResponse; } - const { type, why } = response; + const { type, why } = aResponse; const cleanUp = type == "paused" && why.type == "interrupted" ? () => this._activeThread.resume() : noop; @@ -3080,42 +3025,38 @@ SourceClient.prototype = { /** * Breakpoint clients are used to remove breakpoints that are no longer used. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param sourceClient SourceClient + * @param aSourceClient SourceClient * The source where this breakpoint exists - * @param actor string + * @param aActor string * The actor ID for this breakpoint. - * @param location object + * @param aLocation object * The location of the breakpoint. This is an object with two properties: * url and line. - * @param condition string + * @param aCondition string * The conditional expression of the breakpoint */ -function BreakpointClient(client, sourceClient, actor, location, condition) { - this._client = client; - this._actor = actor; - this.location = location; - this.location.actor = sourceClient.actor; - this.location.url = sourceClient.url; - this.source = sourceClient; +function BreakpointClient(aClient, aSourceClient, aActor, aLocation, aCondition) { + this._client = aClient; + this._actor = aActor; + this.location = aLocation; + this.location.actor = aSourceClient.actor; + this.location.url = aSourceClient.url; + this.source = aSourceClient; this.request = this._client.request; // The condition property should only exist if it's a truthy value - if (condition) { - this.condition = condition; + if (aCondition) { + this.condition = aCondition; } } BreakpointClient.prototype = { _actor: null, - get actor() { - return this._actor; - }, - get _transport() { - return this._client._transport; - }, + get actor() { return this._actor; }, + get _transport() { return this._client._transport; }, /** * Remove the breakpoint from the server. @@ -3133,8 +3074,9 @@ BreakpointClient.prototype = { // conditional breakpoints if (root.traits.conditionalBreakpoints) { return "condition" in this; + } else { + return "conditionalExpression" in this; } - return "conditionalExpression" in this; }, /** @@ -3148,14 +3090,15 @@ BreakpointClient.prototype = { let root = this._client.mainRoot; if (root.traits.conditionalBreakpoints) { return this.condition; + } else { + return this.conditionalExpression; } - return this.conditionalExpression; }, /** * Set the condition of this breakpoint */ - setCondition: function (gThreadClient, condition) { + setCondition: function (gThreadClient, aCondition) { let root = this._client.mainRoot; let deferred = promise.defer(); @@ -3163,31 +3106,32 @@ BreakpointClient.prototype = { let info = { line: this.location.line, column: this.location.column, - condition: condition + condition: aCondition }; // Remove the current breakpoint and add a new one with the // condition. - this.remove(response => { - if (response && response.error) { - deferred.reject(response); + this.remove(aResponse => { + if (aResponse && aResponse.error) { + deferred.reject(aResponse); return; } - this.source.setBreakpoint(info, (resp, newBreakpoint) => { - if (resp && resp.error) { - deferred.reject(resp); + this.source.setBreakpoint(info, (aResponse, aNewBreakpoint) => { + if (aResponse && aResponse.error) { + deferred.reject(aResponse); } else { - deferred.resolve(newBreakpoint); + deferred.resolve(aNewBreakpoint); } }); }); } else { // The property shouldn't even exist if the condition is blank - if (condition === "") { + if (aCondition === "") { delete this.conditionalExpression; - } else { - this.conditionalExpression = condition; + } + else { + this.conditionalExpression = aCondition; } deferred.resolve(this); } @@ -3201,14 +3145,14 @@ eventSource(BreakpointClient.prototype); /** * Environment clients are used to manipulate the lexical environment actors. * - * @param client DebuggerClient + * @param aClient DebuggerClient * The debugger client parent. - * @param form Object + * @param aForm Object * The form sent across the remote debugging protocol. */ -function EnvironmentClient(client, form) { - this._client = client; - this._form = form; +function EnvironmentClient(aClient, aForm) { + this._client = aClient; + this._form = aForm; this.request = this._client.request; } exports.EnvironmentClient = EnvironmentClient; @@ -3218,9 +3162,7 @@ EnvironmentClient.prototype = { get actor() { return this._form.actor; }, - get _transport() { - return this._client._transport; - }, + get _transport() { return this._client._transport; }, /** * Fetches the bindings introduced by this lexical environment. @@ -3235,8 +3177,8 @@ EnvironmentClient.prototype = { */ assign: DebuggerClient.requester({ type: "assign", - name: arg(0), - value: arg(1) + name: args(0), + value: args(1) }) }; diff --git a/devtools/shared/discovery/discovery.js b/devtools/shared/discovery/discovery.js index a07f21d445e7..d0b49f1290cd 100644 --- a/devtools/shared/discovery/discovery.js +++ b/devtools/shared/discovery/discovery.js @@ -47,8 +47,8 @@ const REPLY_TIMEOUT = 5000; const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); XPCOMUtils.defineLazyGetter(this, "converter", () => { - let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"] - .createInstance(Ci.nsIScriptableUnicodeConverter); + let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]. + createInstance(Ci.nsIScriptableUnicodeConverter); conv.charset = "utf8"; return conv; }); @@ -77,8 +77,7 @@ function log(msg) { function Transport(port) { EventEmitter.decorate(this); try { - this.socket = new UDPSocket(port, false, - Services.scriptSecurityManager.getSystemPrincipal()); + this.socket = new UDPSocket(port, false, Services.scriptSecurityManager.getSystemPrincipal()); this.socket.joinMulticast(ADDRESS); this.socket.asyncListen(this); } catch (e) { @@ -147,8 +146,7 @@ function LocalDevice() { Cc["@mozilla.org/settingsService;1"].getService(Ci.nsISettingsService); Services.obs.addObserver(this, "mozsettings-changed", false); } - // Trigger |_get| to load name eagerly - this._get(); + this._get(); // Trigger |_get| to load name eagerly } LocalDevice.SETTING = "devtools.discovery.device"; @@ -346,8 +344,7 @@ Discovery.prototype = { _startListeningForScan: function () { if (this._transports.scan) { - // Already listening - return; + return; // Already listening } log("LISTEN FOR SCAN"); this._transports.scan = new this.Transport(SCAN_PORT); @@ -356,8 +353,7 @@ Discovery.prototype = { _stopListeningForScan: function () { if (!this._transports.scan) { - // Not listening - return; + return; // Not listening } this._transports.scan.off("message", this._onRemoteScan); this._transports.scan.destroy(); @@ -366,8 +362,7 @@ Discovery.prototype = { _startListeningForUpdate: function () { if (this._transports.update) { - // Already listening - return; + return; // Already listening } log("LISTEN FOR UPDATE"); this._transports.update = new this.Transport(UPDATE_PORT); @@ -376,8 +371,7 @@ Discovery.prototype = { _stopListeningForUpdate: function () { if (!this._transports.update) { - // Not listening - return; + return; // Not listening } this._transports.update.off("message", this._onRemoteUpdate); this._transports.update.destroy(); diff --git a/devtools/shared/discovery/tests/unit/.eslintrc.js b/devtools/shared/discovery/tests/unit/.eslintrc.js deleted file mode 100644 index f21b71f67ad0..000000000000 --- a/devtools/shared/discovery/tests/unit/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -module.exports = { - // Extend from the shared list of defined globals for mochitests. - "extends": "../../../../.eslintrc.xpcshell.js" -}; \ No newline at end of file diff --git a/devtools/shared/discovery/tests/unit/test_discovery.js b/devtools/shared/discovery/tests/unit/test_discovery.js index 56b0bc1e7c94..c31340b08966 100644 --- a/devtools/shared/discovery/tests/unit/test_discovery.js +++ b/devtools/shared/discovery/tests/unit/test_discovery.js @@ -8,6 +8,7 @@ var Cu = Components.utils; const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const Services = require("Services"); +const promise = require("promise"); const defer = require("devtools/shared/defer"); const EventEmitter = require("devtools/shared/event-emitter"); const discovery = require("devtools/shared/discovery/discovery"); diff --git a/devtools/shared/performance/recording-common.js b/devtools/shared/performance/recording-common.js index 8aa6440e4ee1..d0826bd1881e 100644 --- a/devtools/shared/performance/recording-common.js +++ b/devtools/shared/performance/recording-common.js @@ -9,7 +9,7 @@ * and LegacyPerformanceRecording for helper methods to access data. */ -exports.PerformanceRecordingCommon = { +const PerformanceRecordingCommon = exports.PerformanceRecordingCommon = { // Private fields, only needed when a recording is started or stopped. _console: false, _imported: false, @@ -35,32 +35,18 @@ exports.PerformanceRecordingCommon = { * Helper methods for returning the status of the recording. * These methods should be consistent on both the front and actor. */ - isRecording: function () { - return this._recording; - }, - isCompleted: function () { - return this._completed || this.isImported(); - }, - isFinalizing: function () { - return !this.isRecording() && !this.isCompleted(); - }, - isConsole: function () { - return this._console; - }, - isImported: function () { - return this._imported; - }, + isRecording: function () { return this._recording; }, + isCompleted: function () { return this._completed || this.isImported(); }, + isFinalizing: function () { return !this.isRecording() && !this.isCompleted(); }, + isConsole: function () { return this._console; }, + isImported: function () { return this._imported; }, /** * Helper methods for returning configuration for the recording. * These methods should be consistent on both the front and actor. */ - getConfiguration: function () { - return this._configuration; - }, - getLabel: function () { - return this._label; - }, + getConfiguration: function () { return this._configuration; }, + getLabel: function () { return this._label; }, /** * Gets duration of this recording, in milliseconds. @@ -73,43 +59,25 @@ exports.PerformanceRecordingCommon = { // the duration from the profiler; if between recording and being finalized, // use the last estimated duration. if (this.isRecording()) { - this._estimatedDuration = Date.now() - this._localStartTime; - return this._estimatedDuration; + return this._estimatedDuration = Date.now() - this._localStartTime; + } else { + return this._duration || this._estimatedDuration || 0; } - return this._duration || this._estimatedDuration || 0; }, /** * Helper methods for returning recording data. * These methods should be consistent on both the front and actor. */ - getMarkers: function () { - return this._markers; - }, - getFrames: function () { - return this._frames; - }, - getMemory: function () { - return this._memory; - }, - getTicks: function () { - return this._ticks; - }, - getAllocations: function () { - return this._allocations; - }, - getProfile: function () { - return this._profile; - }, - getHostSystemInfo: function () { - return this._systemHost; - }, - getClientSystemInfo: function () { - return this._systemClient; - }, - getStartingBufferStatus: function () { - return this._startingBufferStatus; - }, + getMarkers: function () { return this._markers; }, + getFrames: function () { return this._frames; }, + getMemory: function () { return this._memory; }, + getTicks: function () { return this._ticks; }, + getAllocations: function () { return this._allocations; }, + getProfile: function () { return this._profile; }, + getHostSystemInfo: function () { return this._systemHost; }, + getClientSystemInfo: function () { return this._systemClient; }, + getStartingBufferStatus: function () { return this._startingBufferStatus; }, getAllData: function () { let label = this.getLabel(); @@ -124,18 +92,6 @@ exports.PerformanceRecordingCommon = { let systemHost = this.getHostSystemInfo(); let systemClient = this.getClientSystemInfo(); - return { - label, - duration, - markers, - frames, - memory, - ticks, - allocations, - profile, - configuration, - systemHost, - systemClient - }; + return { label, duration, markers, frames, memory, ticks, allocations, profile, configuration, systemHost, systemClient }; }, }; diff --git a/devtools/shared/performance/recording-utils.js b/devtools/shared/performance/recording-utils.js index 3b9c4cbca0fd..64ed12c71f1c 100644 --- a/devtools/shared/performance/recording-utils.js +++ b/devtools/shared/performance/recording-utils.js @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +const { Cc, Ci, Cu, Cr } = require("chrome"); loader.lazyRequireGetter(this, "extend", "sdk/util/object", true); @@ -15,8 +16,7 @@ function mapRecordingOptions(type, options) { if (type === "profiler") { return { entries: options.bufferSize, - interval: options.sampleFrequency ? (1000 / (options.sampleFrequency * 1000)) - : void 0 + interval: options.sampleFrequency ? (1000 / (options.sampleFrequency * 1000)) : void 0 }; } @@ -568,8 +568,7 @@ UniqueStacks.prototype.getOrAddFrameIndex = function (frame) { let implementationIndex = this.getOrAddStringIndex(frame.implementation); // Super dumb. - let hash = `${locationIndex} ${implementationIndex || ""} ` + - `${frame.line || ""} ${frame.category || ""}`; + let hash = `${locationIndex} ${implementationIndex || ""} ${frame.line || ""} ${frame.category || ""}`; let index = frameHash[hash]; if (index !== undefined) { diff --git a/devtools/shared/performance/test/.eslintrc.js b/devtools/shared/performance/test/.eslintrc.js deleted file mode 100644 index 90ed7706421b..000000000000 --- a/devtools/shared/performance/test/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -module.exports = { - // Extend from the shared list of defined globals for mochitests. - "extends": "../../../.eslintrc.xpcshell.js" -}; \ No newline at end of file diff --git a/devtools/shared/performance/test/head.js b/devtools/shared/performance/test/head.js index 414831c96443..9e7748055723 100644 --- a/devtools/shared/performance/test/head.js +++ b/devtools/shared/performance/test/head.js @@ -1,10 +1,7 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* exported require */ - "use strict"; -var { utils: Cu } = Components; +var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); diff --git a/devtools/shared/performance/test/test_perf-utils-allocations-to-samples.js b/devtools/shared/performance/test/test_perf-utils-allocations-to-samples.js index 141395652275..6429eff2d434 100644 --- a/devtools/shared/performance/test/test_perf-utils-allocations-to-samples.js +++ b/devtools/shared/performance/test/test_perf-utils-allocations-to-samples.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - /** * Tests if allocations data received from the performance actor is properly * converted to something that follows the same structure as the samples data @@ -67,15 +65,9 @@ var EXPECTED_OUTPUT = { }, "data": [ null, - - // x (A:1:2) - [ null, 1 ], - - // x (A:1:2) > y (B:3:4) - [ 1, 2 ], - - // x (A:1:2) > y (B:3:4) > C:5:6 - [ 2, 3 ] + [ null, 1 ], // x (A:1:2) + [ 1, 2 ], // x (A:1:2) > y (B:3:4) + [ 2, 3 ] // x (A:1:2) > y (B:3:4) > C:5:6 ] }, frameTable: { diff --git a/devtools/shared/qrcode/index.js b/devtools/shared/qrcode/index.js index 7bf97e1babc0..ec3442426402 100644 --- a/devtools/shared/qrcode/index.js +++ b/devtools/shared/qrcode/index.js @@ -4,6 +4,7 @@ "use strict"; +const { Cu } = require("chrome"); const promise = require("promise"); const defer = require("devtools/shared/defer"); diff --git a/devtools/shared/qrcode/tests/unit/.eslintrc.js b/devtools/shared/qrcode/tests/unit/.eslintrc.js deleted file mode 100644 index f21b71f67ad0..000000000000 --- a/devtools/shared/qrcode/tests/unit/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -module.exports = { - // Extend from the shared list of defined globals for mochitests. - "extends": "../../../../.eslintrc.xpcshell.js" -}; \ No newline at end of file diff --git a/devtools/shared/security/auth.js b/devtools/shared/security/auth.js index 52c9070b77bc..9272f602ebdc 100644 --- a/devtools/shared/security/auth.js +++ b/devtools/shared/security/auth.js @@ -8,6 +8,7 @@ var { Ci, Cc } = require("chrome"); var Services = require("Services"); +var promise = require("promise"); var defer = require("devtools/shared/defer"); var DevToolsUtils = require("devtools/shared/DevToolsUtils"); var { dumpn, dumpv } = DevToolsUtils; @@ -407,8 +408,7 @@ OOBCert.Client.prototype = { }), _createRandom() { - // 16 bytes / 128 bits - const length = 16; + const length = 16; // 16 bytes / 128 bits let rng = Cc["@mozilla.org/security/random-generator;1"] .createInstance(Ci.nsIRandomGenerator); let bytes = rng.generateRandomBytes(length); @@ -545,11 +545,9 @@ OOBCert.Server.prototype = { switch (authResult) { case AuthenticationResult.ALLOW_PERSIST: case AuthenticationResult.ALLOW: - // Further processing - break; + break; // Further processing default: - // Abort for any negative results - return authResult; + return authResult; // Abort for any negative results } // Examine additional data for authentication diff --git a/devtools/shared/security/cert.js b/devtools/shared/security/cert.js index 7c101f3dbf0e..7dbeded63116 100644 --- a/devtools/shared/security/cert.js +++ b/devtools/shared/security/cert.js @@ -7,6 +7,7 @@ "use strict"; var { Ci, Cc } = require("chrome"); +var promise = require("promise"); var defer = require("devtools/shared/defer"); var DevToolsUtils = require("devtools/shared/DevToolsUtils"); DevToolsUtils.defineLazyGetter(this, "localCertService", () => { diff --git a/devtools/shared/security/socket.js b/devtools/shared/security/socket.js index 64d882c01b5d..068a8ea81f0a 100644 --- a/devtools/shared/security/socket.js +++ b/devtools/shared/security/socket.js @@ -6,7 +6,7 @@ "use strict"; -var { Ci, Cc, CC, Cr } = require("chrome"); +var { Ci, Cc, CC, Cr, Cu } = require("chrome"); // Ensure PSM is initialized to support TLS sockets Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports); @@ -143,8 +143,7 @@ var _getTransport = Task.async(function* (settings) { let attempt = yield _attemptTransport(settings); if (attempt.transport) { - // Success - return attempt.transport; + return attempt.transport; // Success } // If the server cert failed validation, store a temporary override and make @@ -157,8 +156,7 @@ var _getTransport = Task.async(function* (settings) { attempt = yield _attemptTransport(settings); if (attempt.transport) { - // Success - return attempt.transport; + return attempt.transport; // Success } throw new Error("Connection failed even after cert override"); @@ -358,7 +356,7 @@ function _storeCertOverride(s, host, port) { let overrideBits = Ci.nsICertOverrideService.ERROR_UNTRUSTED | Ci.nsICertOverrideService.ERROR_MISMATCH; certOverrideService.rememberValidityOverride(host, port, cert, overrideBits, - true /* temporary */); // eslint-disable-line + true /* temporary */); } /** diff --git a/devtools/shared/security/tests/chrome/.eslintrc.js b/devtools/shared/security/tests/chrome/.eslintrc.js deleted file mode 100644 index 6dc0ab32b6e9..000000000000 --- a/devtools/shared/security/tests/chrome/.eslintrc.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -module.exports = { - // Extend from the shared list of defined globals for mochitests. - "extends": "../../../../../testing/mochitest/chrome.eslintrc.js" -}; diff --git a/devtools/shared/security/tests/chrome/test_websocket-transport.html b/devtools/shared/security/tests/chrome/test_websocket-transport.html index edcb5b2ffad7..542206ecfbfe 100644 --- a/devtools/shared/security/tests/chrome/test_websocket-transport.html +++ b/devtools/shared/security/tests/chrome/test_websocket-transport.html @@ -9,9 +9,7 @@ diff --git a/devtools/shared/security/tests/unit/head_dbg.js b/devtools/shared/security/tests/unit/head_dbg.js index 790675c56dc7..f3b2a9a9744d 100644 --- a/devtools/shared/security/tests/unit/head_dbg.js +++ b/devtools/shared/security/tests/unit/head_dbg.js @@ -2,14 +2,20 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; +var Cr = Components.results; +var CC = Components.Constructor; -/* exported defer, DebuggerClient, initTestDebuggerServer */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); +const promise = require("promise"); const defer = require("devtools/shared/defer"); +const { Task } = require("devtools/shared/task"); + const Services = require("Services"); +const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const xpcInspector = require("xpcInspector"); const { DebuggerServer } = require("devtools/server/main"); const { DebuggerClient } = require("devtools/shared/client/main"); @@ -25,43 +31,43 @@ Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true); // Fast timeout for TLS tests Services.prefs.setIntPref("devtools.remote.tls-handshake-timeout", 1000); -// Convert an nsIScriptError 'flags' value into an appropriate string. -function scriptErrorFlagsToKind(flags) { - let kind; - if (flags & Ci.nsIScriptError.warningFlag) { +// Convert an nsIScriptError 'aFlags' value into an appropriate string. +function scriptErrorFlagsToKind(aFlags) { + var kind; + if (aFlags & Ci.nsIScriptError.warningFlag) kind = "warning"; - } - if (flags & Ci.nsIScriptError.exceptionFlag) { + if (aFlags & Ci.nsIScriptError.exceptionFlag) kind = "exception"; - } else { + else kind = "error"; - } - if (flags & Ci.nsIScriptError.strictFlag) { + if (aFlags & Ci.nsIScriptError.strictFlag) kind = "strict " + kind; - } return kind; } // Register a console listener, so console messages don't just disappear // into the ether. +var errorCount = 0; var listener = { - observe: function (message) { - let string; + observe: function (aMessage) { + errorCount++; try { - message.QueryInterface(Ci.nsIScriptError); - dump(message.sourceName + ":" + message.lineNumber + ": " + - scriptErrorFlagsToKind(message.flags) + ": " + - message.errorMessage + "\n"); - string = message.errorMessage; - } catch (ex) { + // 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); + dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " + + scriptErrorFlagsToKind(aMessage.flags) + ": " + + aMessage.errorMessage + "\n"); + var string = aMessage.errorMessage; + } catch (x) { // Be a little paranoid with message, as the whole goal here is to lose // no information. try { - string = "" + message.message; - } catch (e) { - string = ""; + var string = "" + aMessage.message; + } catch (x) { + var string = ""; } } @@ -71,7 +77,7 @@ var listener = { } // Print in most cases, but ignore the "strict" messages - if (!(message.flags & Ci.nsIScriptError.strictFlag)) { + if (!(aMessage.flags & Ci.nsIScriptError.strictFlag)) { do_print("head_dbg.js got console message: " + string + "\n"); } } diff --git a/devtools/shared/security/tests/unit/test_oob_cert_auth.js b/devtools/shared/security/tests/unit/test_oob_cert_auth.js index e37a0f589d80..1e820af52b2e 100644 --- a/devtools/shared/security/tests/unit/test_oob_cert_auth.js +++ b/devtools/shared/security/tests/unit/test_oob_cert_auth.js @@ -38,8 +38,7 @@ add_task(function* () { serverAuth.allowConnection = () => { return DebuggerServer.AuthenticationResult.ALLOW; }; - // Skip prompt for tests - serverAuth.receiveOOB = () => oobData.promise; + serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests let listener = DebuggerServer.createListener(); ok(listener, "Socket listener created"); @@ -99,8 +98,7 @@ add_task(function* () { serverAuth.allowConnection = () => { return DebuggerServer.AuthenticationResult.ALLOW; }; - // Skip prompt for tests - serverAuth.receiveOOB = () => oobData.promise; + serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests let listener = DebuggerServer.createListener(); ok(listener, "Socket listener created"); @@ -163,8 +161,7 @@ add_task(function* () { serverAuth.allowConnection = () => { return DebuggerServer.AuthenticationResult.ALLOW; }; - // Skip prompt for tests - serverAuth.receiveOOB = () => oobData.promise; + serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests let clientAuth = new AuthenticatorType.Client(); clientAuth.sendOOB = ({ oob }) => { @@ -218,8 +215,7 @@ add_task(function* () { serverAuth.allowConnection = () => { return DebuggerServer.AuthenticationResult.ALLOW; }; - // Skip prompt for tests - serverAuth.receiveOOB = () => oobData.promise; + serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests let clientAuth = new AuthenticatorType.Client(); clientAuth.sendOOB = ({ oob }) => { diff --git a/devtools/shared/security/tests/unit/testactors.js b/devtools/shared/security/tests/unit/testactors.js index 1a170cba78e9..80d5d4e18abe 100644 --- a/devtools/shared/security/tests/unit/testactors.js +++ b/devtools/shared/security/tests/unit/testactors.js @@ -1,8 +1,6 @@ /* 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"); @@ -11,8 +9,8 @@ const { DebuggerServer } = require("devtools/server/main"); const promise = require("promise"); var gTestGlobals = []; -DebuggerServer.addTestGlobal = function (global) { - gTestGlobals.push(global); +DebuggerServer.addTestGlobal = function (aGlobal) { + gTestGlobals.push(aGlobal); }; // A mock tab list, for use by tests. This simply presents each global in @@ -22,18 +20,18 @@ DebuggerServer.addTestGlobal = function (global) { // 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(connection) { - this.conn = connection; +function TestTabList(aConnection) { + this.conn = aConnection; // 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(connection); + this._tabActorPool = new ActorPool(aConnection); for (let global of gTestGlobals) { - let actor = new TestTabActor(connection, global); + let actor = new TestTabActor(aConnection, global); actor.selected = false; this._tabActors.push(actor); this._tabActorPool.addActor(actor); @@ -42,7 +40,7 @@ function TestTabList(connection) { this._tabActors[0].selected = true; } - connection.addActorPool(this._tabActorPool); + aConnection.addActorPool(this._tabActorPool); } TestTabList.prototype = { @@ -52,18 +50,18 @@ TestTabList.prototype = { } }; -function createRootActor(connection) { - let root = new RootActor(connection, { - tabList: new TestTabList(connection), +function createRootActor(aConnection) { + let root = new RootActor(aConnection, { + tabList: new TestTabList(aConnection), globalActorFactories: DebuggerServer.globalActorFactories }); root.applicationType = "xpcshell-tests"; return root; } -function TestTabActor(connection, global) { - this.conn = connection; - this._global = global; +function TestTabActor(aConnection, aGlobal) { + this.conn = aConnection; + this._global = aGlobal; this._threadActor = new ThreadActor(this, this._global); this.conn.addActor(this._threadActor); this._attached = false; @@ -98,7 +96,7 @@ TestTabActor.prototype = { return response; }, - onAttach: function (request) { + onAttach: function (aRequest) { this._attached = true; let response = { type: "tabAttached", threadActor: this._threadActor.actorID }; @@ -107,9 +105,9 @@ TestTabActor.prototype = { return response; }, - onDetach: function (request) { + onDetach: function (aRequest) { if (!this._attached) { - return { "error": "wrongState" }; + return { "error":"wrongState" }; } return { type: "detached" }; }, diff --git a/devtools/shared/shims/event-emitter.js b/devtools/shared/shims/event-emitter.js index bf648e373ad4..6b3672162917 100644 --- a/devtools/shared/shims/event-emitter.js +++ b/devtools/shared/shims/event-emitter.js @@ -9,13 +9,10 @@ * specific path. */ -(function (factory) { - // Module boilerplate - if (this.module && module.id.indexOf("event-emitter") >= 0) { - // require +(function (factory) { // Module boilerplate + if (this.module && module.id.indexOf("event-emitter") >= 0) { // require factory.call(this, require, exports, module); - } else { - // Cu.import + } else { // Cu.import const Cu = Components.utils; const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); diff --git a/devtools/shared/tests/browser/browser_async_storage.js b/devtools/shared/tests/browser/browser_async_storage.js index 141965cf00b4..4329d639aee2 100644 --- a/devtools/shared/tests/browser/browser_async_storage.js +++ b/devtools/shared/tests/browser/browser_async_storage.js @@ -30,7 +30,7 @@ add_task(function* () { }); add_task(function* () { - let object = { + var object = { x: 1, y: "foo", z: true diff --git a/devtools/shared/tests/unit/exposeLoader.js b/devtools/shared/tests/unit/exposeLoader.js index 7c8acdd75945..949640a03e4e 100644 --- a/devtools/shared/tests/unit/exposeLoader.js +++ b/devtools/shared/tests/unit/exposeLoader.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - exports.exerciseLazyRequire = (name, path) => { const o = {}; loader.lazyRequireGetter(o, name, path); diff --git a/devtools/shared/tests/unit/head_devtools.js b/devtools/shared/tests/unit/head_devtools.js index 2854d9389758..f0f47c93ac15 100644 --- a/devtools/shared/tests/unit/head_devtools.js +++ b/devtools/shared/tests/unit/head_devtools.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -/* exported DevToolsUtils, DevToolsLoader */ - "use strict"; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; +var Cr = Components.results; -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; -const { require, DevToolsLoader } = Cu.import("resource://devtools/shared/Loader.jsm", {}); +const {require, DevToolsLoader, devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {}); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const flags = require("devtools/shared/flags"); @@ -22,22 +23,25 @@ do_register_cleanup(() => { // failures, set this to true. var ALLOW_CONSOLE_ERRORS = false; +var errorCount = 0; var listener = { - observe: function (message) { - let string; + observe: function (aMessage) { + errorCount++; try { - message.QueryInterface(Ci.nsIScriptError); - dump(message.sourceName + ":" + message.lineNumber + ": " + - scriptErrorFlagsToKind(message.flags) + ": " + - message.errorMessage + "\n"); - string = message.errorMessage; - } catch (ex) { + // 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); + dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " + + scriptErrorFlagsToKind(aMessage.flags) + ": " + + aMessage.errorMessage + "\n"); + var string = aMessage.errorMessage; + } catch (x) { // Be a little paranoid with message, as the whole goal here is to lose // no information. try { - string = "" + message.message; - } catch (e) { - string = ""; + var string = "" + aMessage.message; + } catch (x) { + var string = ""; } } diff --git a/devtools/shared/tests/unit/test_assert.js b/devtools/shared/tests/unit/test_assert.js index e5fe01974139..b871717511a4 100644 --- a/devtools/shared/tests/unit/test_assert.js +++ b/devtools/shared/tests/unit/test_assert.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test DevToolsUtils.assert ALLOW_CONSOLE_ERRORS = true; @@ -34,6 +32,5 @@ function run_test() { } ok(assertionFailed, - "The assertion should have failed, which should throw an error when assertions " + - "are enabled."); + "The assertion should have failed, which should throw an error when assertions are enabled."); } diff --git a/devtools/shared/tests/unit/test_async-utils.js b/devtools/shared/tests/unit/test_async-utils.js index 8c640c473bca..2b09b82608ca 100644 --- a/devtools/shared/tests/unit/test_async-utils.js +++ b/devtools/shared/tests/unit/test_async-utils.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test async-utils.js const {Task} = require("devtools/shared/task"); @@ -62,13 +60,12 @@ function test_async_return(async) { function test_async_throw(async) { let obj = { method: async(function* () { - throw new Error("boom"); + throw "boom"; }) }; return obj.method().then(null, error => { - do_check_true(error instanceof Error); - do_check_eq(error.message, "boom"); + do_check_eq(error, "boom"); }); } @@ -119,6 +116,7 @@ function test_async_once() { function test_async_invoke() { return Task.spawn(function* () { function func(a, b, expectedThis, callback) { + "use strict"; do_check_eq(a, "foo"); do_check_eq(b, "bar"); do_check_eq(this, expectedThis); @@ -129,11 +127,13 @@ function test_async_invoke() { let callResult = yield promiseCall(func, "foo", "bar", undefined); do_check_eq(callResult, "foobar"); + // Test invoke. let obj = { method: func }; let invokeResult = yield promiseInvoke(obj, obj.method, "foo", "bar", obj); do_check_eq(invokeResult, "foobar"); + // Test passing multiple values to the callback. function multipleResults(callback) { callback("foo", "bar"); @@ -144,14 +144,14 @@ function test_async_invoke() { do_check_eq(results[0], "foo"); do_check_eq(results[1], "bar"); + // Test throwing from the function. function thrower() { - throw new Error("boom"); + throw "boom"; } yield promiseCall(thrower).then(null, error => { - do_check_true(error instanceof Error); - do_check_eq(error.message, "boom"); + do_check_eq(error, "boom"); }); }); } diff --git a/devtools/shared/tests/unit/test_console_filtering.js b/devtools/shared/tests/unit/test_console_filtering.js index e126981d0cfa..6ee620ebbe6f 100644 --- a/devtools/shared/tests/unit/test_console_filtering.js +++ b/devtools/shared/tests/unit/test_console_filtering.js @@ -11,19 +11,19 @@ var seenMessages = 0; var seenTypes = 0; var callback = { - onConsoleAPICall: function (message) { - if (message.consoleID && message.consoleID == "addon/foo") { - do_check_eq(message.level, "warn"); - do_check_eq(message.arguments[0], "Warning from foo"); + onConsoleAPICall: function (aMessage) { + if (aMessage.consoleID && aMessage.consoleID == "addon/foo") { + do_check_eq(aMessage.level, "warn"); + do_check_eq(aMessage.arguments[0], "Warning from foo"); seenTypes |= 1; - } else if (message.originAttributes && - message.originAttributes.addonId == "bar") { - do_check_eq(message.level, "error"); - do_check_eq(message.arguments[0], "Error from bar"); + } else if (aMessage.originAttributes && + aMessage.originAttributes.addonId == "bar") { + do_check_eq(aMessage.level, "error"); + do_check_eq(aMessage.arguments[0], "Error from bar"); seenTypes |= 2; } else { - do_check_eq(message.level, "log"); - do_check_eq(message.arguments[0], "Hello from default console"); + do_check_eq(aMessage.level, "log"); + do_check_eq(aMessage.arguments[0], "Hello from default console"); seenTypes |= 4; } seenMessages++; diff --git a/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js b/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js index 452d01847306..d729e747398d 100644 --- a/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js +++ b/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js @@ -1,13 +1,13 @@ +/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test DevToolsUtils.defineLazyPrototypeGetter function Class() {} DevToolsUtils.defineLazyPrototypeGetter(Class.prototype, "foo", () => []); + function run_test() { test_prototype_attributes(); test_instance_attributes(); diff --git a/devtools/shared/tests/unit/test_executeSoon.js b/devtools/shared/tests/unit/test_executeSoon.js index 78bdcd6a4ea3..6154a3e67e35 100644 --- a/devtools/shared/tests/unit/test_executeSoon.js +++ b/devtools/shared/tests/unit/test_executeSoon.js @@ -11,6 +11,7 @@ */ var { executeSoon } = require("devtools/shared/DevToolsUtils"); +var promise = require("promise"); var defer = require("devtools/shared/defer"); var Services = require("Services"); diff --git a/devtools/shared/tests/unit/test_flatten.js b/devtools/shared/tests/unit/test_flatten.js index 11c2ac047479..f5a186770cc0 100644 --- a/devtools/shared/tests/unit/test_flatten.js +++ b/devtools/shared/tests/unit/test_flatten.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test ThreadSafeDevToolsUtils.flatten function run_test() { diff --git a/devtools/shared/tests/unit/test_independent_loaders.js b/devtools/shared/tests/unit/test_independent_loaders.js index 6d3aaead6935..20abed27d208 100644 --- a/devtools/shared/tests/unit/test_independent_loaders.js +++ b/devtools/shared/tests/unit/test_independent_loaders.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - /** * Ensure that each instance of the Dev Tools loader contains its own loader * instance, and also returns unique objects. This ensures there is no sharing diff --git a/devtools/shared/tests/unit/test_isSet.js b/devtools/shared/tests/unit/test_isSet.js index a9e1fcafa9ab..f85d6ae3c3f1 100644 --- a/devtools/shared/tests/unit/test_isSet.js +++ b/devtools/shared/tests/unit/test_isSet.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test ThreadSafeDevToolsUtils.isSet function run_test() { diff --git a/devtools/shared/tests/unit/test_require.js b/devtools/shared/tests/unit/test_require.js index 2d10d1e0f8c0..005e5665633e 100644 --- a/devtools/shared/tests/unit/test_require.js +++ b/devtools/shared/tests/unit/test_require.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test require // Ensure that DevtoolsLoader.require doesn't spawn multiple diff --git a/devtools/shared/tests/unit/test_require_lazy.js b/devtools/shared/tests/unit/test_require_lazy.js index d545653d6244..8ef5a7d23e7b 100644 --- a/devtools/shared/tests/unit/test_require_lazy.js +++ b/devtools/shared/tests/unit/test_require_lazy.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test devtools.lazyRequireGetter function run_test() { @@ -20,8 +18,7 @@ function run_test() { const o2 = {}; let loader = new DevToolsLoader(); - // We have to init the loader by loading any module before - // lazyRequireGetter is available + // We have to init the loader by loading any module before lazyRequireGetter is available loader.require("devtools/shared/DevToolsUtils"); loader.lazyRequireGetter(o2, name, path); diff --git a/devtools/shared/tests/unit/test_require_raw.js b/devtools/shared/tests/unit/test_require_raw.js index 1cfd0d3f3d22..5bec82b55bb0 100644 --- a/devtools/shared/tests/unit/test_require_raw.js +++ b/devtools/shared/tests/unit/test_require_raw.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test require using "raw!". function run_test() { diff --git a/devtools/shared/tests/unit/test_safeErrorString.js b/devtools/shared/tests/unit/test_safeErrorString.js index afde7d7c97c5..9892f34d1e63 100644 --- a/devtools/shared/tests/unit/test_safeErrorString.js +++ b/devtools/shared/tests/unit/test_safeErrorString.js @@ -2,8 +2,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test DevToolsUtils.safeErrorString function run_test() { diff --git a/devtools/shared/tests/unit/test_stack.js b/devtools/shared/tests/unit/test_stack.js index 7342526e45eb..ef747c83f6de 100644 --- a/devtools/shared/tests/unit/test_stack.js +++ b/devtools/shared/tests/unit/test_stack.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - // Test stack.js. function run_test() { diff --git a/devtools/shared/touch/simulator-content.js b/devtools/shared/touch/simulator-content.js index 6c9f3f2bfdec..0b10579ca586 100644 --- a/devtools/shared/touch/simulator-content.js +++ b/devtools/shared/touch/simulator-content.js @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - /* globals addMessageListener, sendAsyncMessage, docShell */ + /* globals addMessageListener, sendAsyncMessage */ "use strict"; const { utils: Cu } = Components; diff --git a/devtools/shared/touch/simulator-core.js b/devtools/shared/touch/simulator-core.js index 52ff5c124df2..6933f9207cbd 100644 --- a/devtools/shared/touch/simulator-core.js +++ b/devtools/shared/touch/simulator-core.js @@ -1,9 +1,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* global XPCNativeWrapper */ - "use strict"; const { Ci, Cu } = require("chrome"); @@ -275,14 +272,12 @@ SimulatorCore.prototype = { } } let unwrapped = XPCNativeWrapper.unwrap(target); - /* eslint-disable no-inline-comments */ unwrapped.sendTouchEvent(name, clone([0]), // event type, id clone([evt.clientX]), // x clone([evt.clientY]), // y clone([1]), clone([1]), // rx, ry clone([0]), clone([0]), // rotation, force 1); // count - /* eslint-enable no-inline-comments */ return; } let document = target.ownerDocument; @@ -344,10 +339,10 @@ SimulatorCore.prototype = { let utils = content.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindowUtils); - let allowZoom = {}; - let minZoom = {}; - let maxZoom = {}; - let autoSize = {}; + let allowZoom = {}, + minZoom = {}, + maxZoom = {}, + autoSize = {}; utils.getViewportInfo(content.innerWidth, content.innerHeight, {}, allowZoom, minZoom, maxZoom, {}, {}, autoSize); @@ -357,15 +352,14 @@ SimulatorCore.prototype = { // delay. But Firefox didn't support this property now, we can't get // this value from utils.getVisitedDependentComputedStyle() to check // if we should suppress 300ms delay. - /* eslint-disable no-inline-comments */ if (!allowZoom.value || // user-scalable = no minZoom.value === maxZoom.value || // minimum-scale = maximum-scale autoSize.value // width = device-width ) { - /* eslint-enable no-inline-comments */ return 0; + } else { + return 300; } - return 300; } };