--- a/.eslintignore
+++ b/.eslintignore
@@ -112,30 +112,19 @@ devtools/server/actors/*.js
!devtools/server/actors/webbrowser.js
!devtools/server/actors/webextension.js
!devtools/server/actors/webextension-inspected-window.js
devtools/server/tests/browser/**
!devtools/server/tests/browser/browser_webextension_inspected_window.js
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
devtools/shared/webconsole/test/**
devtools/shared/worker/**
!devtools/shared/worker/worker.js
# Ignore devtools pre-processed files
--- a/devtools/shared/client/connection-manager.js
+++ b/devtools/shared/client/connection-manager.js
@@ -1,19 +1,18 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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/. */
"use strict";
-const {Cc, Ci, Cu, Cr} = require("chrome");
+const {Cc, Ci, 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");
const { Task } = require("devtools/shared/task");
const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout";
/**
@@ -65,18 +64,20 @@ const REMOTE_TIMEOUT = "devtools.debugge
* Connection.Status.CONNECTING
* Connection.Status.DISCONNECTING
* Connection.Status.DESTROYED
*
* Events (as in event-emitter.js):
* . 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
* . Connection.Events.NEW_LOG A new log line is available
*
*/
var ConnectionManager = {
@@ -163,29 +164,31 @@ Connection.prototype = {
return this._client;
},
get host() {
return this._host;
},
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);
},
get port() {
return this._port;
},
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);
},
get authentication() {
return this._authentication;
},
@@ -329,18 +332,19 @@ Connection.prototype = {
});
},
get status() {
return this._status;
},
_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);
},
_onDisconnected: function () {
this._client = null;
this._customTransport = null;
@@ -352,17 +356,19 @@ Connection.prototype = {
clearTimeout(this._timeoutID);
switch (this.status) {
case Connection.Status.CONNECTED:
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");
}
this._setStatus(Connection.Status.DISCONNECTED);
},
_onConnected: function () {
--- a/devtools/shared/client/main.js
+++ b/devtools/shared/client/main.js
@@ -2,17 +2,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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/. */
"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");
const promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
loader.lazyRequireGetter(this, "events", "sdk/event/core");
loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
loader.lazyRequireGetter(this, "DebuggerSocket", "devtools/shared/security/socket", true);
@@ -23,108 +22,107 @@ const noop = () => {};
/**
* TODO: Get rid of this API in favor of EventTarget (bug 1042642)
*
* Add simple event notification to a prototype object. Any object that has
* some use for event notifications or the observer pattern in general can be
* augmented with the necessary facilities by passing its prototype to this
* function.
*
- * @param aProto object
+ * @param proto object
* The prototype object that will be modified.
*/
-function eventSource(aProto) {
+function eventSource(proto) {
/**
* Add a listener to the event source for a given event.
*
- * @param aName string
+ * @param name string
* The event to listen for.
- * @param aListener function
+ * @param listener function
* Called when the event is fired. If the same listener
* is added more than once, it will be called once per
* addListener call.
*/
- aProto.addListener = function (aName, aListener) {
- if (typeof aListener != "function") {
+ proto.addListener = function (name, listener) {
+ if (typeof listener != "function") {
throw TypeError("Listeners must be functions.");
}
if (!this._listeners) {
this._listeners = {};
}
- this._getListeners(aName).push(aListener);
+ this._getListeners(name).push(listener);
};
/**
* 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 aName string
+ * @param name string
* The event to listen for.
- * @param aListener function
+ * @param listener function
* Called when the event is fired.
*/
- aProto.addOneTimeListener = function (aName, aListener) {
+ proto.addOneTimeListener = function (name, listener) {
let l = (...args) => {
- this.removeListener(aName, l);
- aListener.apply(null, args);
+ this.removeListener(name, l);
+ listener.apply(null, args);
};
- this.addListener(aName, l);
+ this.addListener(name, l);
};
/**
* Remove a listener from the event source previously added with
* addListener().
*
- * @param aName string
+ * @param name string
* The event name used during addListener to add the listener.
- * @param aListener function
+ * @param listener function
* The callback to remove. If addListener was called multiple
* times, all instances will be removed.
*/
- aProto.removeListener = function (aName, aListener) {
- if (!this._listeners || (aListener && !this._listeners[aName])) {
+ proto.removeListener = function (name, listener) {
+ if (!this._listeners || (listener && !this._listeners[name])) {
return;
}
- if (!aListener) {
- this._listeners[aName] = [];
- }
- else {
- this._listeners[aName] =
- this._listeners[aName].filter(function (l) { return l != aListener; });
+ if (!listener) {
+ this._listeners[name] = [];
+ } else {
+ this._listeners[name] =
+ this._listeners[name].filter(l => l != listener);
}
};
/**
* Returns the listeners for the specified event name. If none are defined it
* initializes an empty list and returns that.
*
- * @param aName string
+ * @param name string
* The event name.
*/
- aProto._getListeners = function (aName) {
- if (aName in this._listeners) {
- return this._listeners[aName];
+ proto._getListeners = function (name) {
+ if (name in this._listeners) {
+ return this._listeners[name];
}
- this._listeners[aName] = [];
- return this._listeners[aName];
+ this._listeners[name] = [];
+ return this._listeners[name];
};
/**
* Notify listeners of an event.
*
- * @param aName string
+ * @param name string
* The event to fire.
* @param arguments
* All arguments will be passed along to the listeners,
* including the name argument.
*/
- aProto.emit = function () {
+ proto.emit = function () {
if (!this._listeners) {
return;
}
let name = arguments[0];
let listeners = this._getListeners(name).slice(0);
for (let listener of listeners) {
@@ -197,19 +195,18 @@ const UnsolicitedPauses = {
"exception": "exception"
};
/**
* Creates a client for the remote debugging protocol server. This client
* 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 (aTransport)
-{
- this._transport = aTransport;
+const DebuggerClient = exports.DebuggerClient = function (transport) {
+ this._transport = transport;
this._transport.hooks = this;
// Map actor ID to client instance for each actor type.
this._clients = new Map();
this._pendingRequests = new Map();
this._activeRequests = new Map();
this._eventsEnabled = true;
@@ -219,94 +216,94 @@ const DebuggerClient = exports.DebuggerC
this.request = this.request.bind(this);
this.localTransport = this._transport.onOutputStreamReady === undefined;
/*
* As the first thing on the connection, expect a greeting packet from
* the connection's root actor.
*/
this.mainRoot = null;
- this.expectReply("root", (aPacket) => {
- this.mainRoot = new RootClient(this, aPacket);
- this.emit("connected", aPacket.applicationType, aPacket.traits);
+ this.expectReply("root", (packet) => {
+ this.mainRoot = new RootClient(this, packet);
+ this.emit("connected", packet.applicationType, packet.traits);
});
};
/**
* A declarative helper for defining methods that send requests to the server.
*
- * @param aPacketSkeleton
+ * @param packetSkeleton
* The form of the packet to send. Can specify fields to be filled from
- * the parameters by using the |args| function.
+ * the parameters by using the |arg| 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
* the instance of the client object we are defining a method for.
* @param after
* The function to call after the response is received. It is passed the
* response, and the return value is considered the new response that
* will be passed to the callback. The |this| context is the instance of
* the client object we are defining a method for.
* @return Request
* The `Request` object that is a Promise object and resolves once
* we receive the response. (See request method for more details)
*/
-DebuggerClient.requester = function (aPacketSkeleton, config = {}) {
+DebuggerClient.requester = function (packetSkeleton, config = {}) {
let { before, after } = config;
return DevToolsUtils.makeInfallible(function (...args) {
let outgoingPacket = {
- to: aPacketSkeleton.to || this.actor
+ to: packetSkeleton.to || this.actor
};
let maxPosition = -1;
- for (let k of Object.keys(aPacketSkeleton)) {
- if (aPacketSkeleton[k] instanceof DebuggerClient.Argument) {
- let { position } = aPacketSkeleton[k];
- outgoingPacket[k] = aPacketSkeleton[k].getArgument(args);
+ for (let k of Object.keys(packetSkeleton)) {
+ if (packetSkeleton[k] instanceof DebuggerClient.Argument) {
+ let { position } = packetSkeleton[k];
+ outgoingPacket[k] = packetSkeleton[k].getArgument(args);
maxPosition = Math.max(position, maxPosition);
} else {
- outgoingPacket[k] = aPacketSkeleton[k];
+ outgoingPacket[k] = packetSkeleton[k];
}
}
if (before) {
outgoingPacket = before.call(this, outgoingPacket);
}
- return this.request(outgoingPacket, DevToolsUtils.makeInfallible((aResponse) => {
+ return this.request(outgoingPacket, DevToolsUtils.makeInfallible((response) => {
if (after) {
- let { from } = aResponse;
- aResponse = after.call(this, aResponse);
- if (!aResponse.from) {
- aResponse.from = from;
+ let { from } = response;
+ response = after.call(this, response);
+ if (!response.from) {
+ response.from = from;
}
}
// The callback is always the last parameter.
let thisCallback = args[maxPosition + 1];
if (thisCallback) {
- thisCallback(aResponse);
+ thisCallback(response);
}
}, "DebuggerClient.requester request callback"));
}, "DebuggerClient.requester");
};
-function args(aPos) {
- return new DebuggerClient.Argument(aPos);
+function arg(pos) {
+ return new DebuggerClient.Argument(pos);
}
-DebuggerClient.Argument = function (aPosition) {
- this.position = aPosition;
+DebuggerClient.Argument = function (position) {
+ this.position = position;
};
-DebuggerClient.Argument.prototype.getArgument = function (aParams) {
- if (!(this.position in aParams)) {
+DebuggerClient.Argument.prototype.getArgument = function (params) {
+ if (!(this.position in params)) {
throw new Error("Bad index into params: " + this.position);
}
- return aParams[this.position];
+ return params[this.position];
};
// Expose these to save callers the trouble of importing DebuggerSocket
DebuggerClient.socketConnect = function (options) {
// Defined here instead of just copying the function to allow lazy-load
return DebuggerSocket.connect(options);
};
DevToolsUtils.defineLazyGetter(DebuggerClient, "Authenticators", () => {
@@ -315,60 +312,60 @@ DevToolsUtils.defineLazyGetter(DebuggerC
DevToolsUtils.defineLazyGetter(DebuggerClient, "AuthenticationResult", () => {
return Authentication.AuthenticationResult;
});
DebuggerClient.prototype = {
/**
* Connect to the server and start exchanging protocol messages.
*
- * @param aOnConnected function
+ * @param onConnected function
* If specified, will be called when the greeting packet is
* received from the debugging server.
*
* @return Promise
* Resolves once connected with an array whose first element
* is the application type, by default "browser", and the second
* element is the traits object (help figure out the features
* and behaviors of the server we connect to. See RootActor).
*/
- connect: function (aOnConnected) {
+ connect: function (onConnected) {
let deferred = promise.defer();
this.emit("connect");
// Also emit the event on the |DebuggerClient| object (not on the instance),
// so it's possible to track all instances.
events.emit(DebuggerClient, "connect", this);
- this.addOneTimeListener("connected", (aName, aApplicationType, aTraits) => {
- this.traits = aTraits;
- if (aOnConnected) {
- aOnConnected(aApplicationType, aTraits);
+ this.addOneTimeListener("connected", (name, applicationType, traits) => {
+ this.traits = traits;
+ if (onConnected) {
+ onConnected(applicationType, traits);
}
- deferred.resolve([aApplicationType, aTraits]);
+ deferred.resolve([applicationType, traits]);
});
this._transport.ready();
return deferred.promise;
},
/**
* Shut down communication with the debugging server.
*
- * @param aOnClosed function
+ * @param onClosed 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 (aOnClosed) {
+ close: function (onClosed) {
let deferred = promise.defer();
- if (aOnClosed) {
- deferred.promise.then(aOnClosed);
+ if (onClosed) {
+ deferred.promise.then(onClosed);
}
// Disable detach event notifications, because event handlers will be in a
// cleared scope by the time they run.
this._eventsEnabled = false;
let cleanup = () => {
this._transport.close();
@@ -408,260 +405,268 @@ DebuggerClient.prototype = {
return deferred.promise;
},
/*
* This function exists only to preserve DebuggerClient's interface;
* new code should say 'client.mainRoot.listTabs()'.
*/
- listTabs: function (aOnResponse) { return this.mainRoot.listTabs(aOnResponse); },
+ listTabs: function (onResponse) {
+ return this.mainRoot.listTabs(onResponse);
+ },
/*
* This function exists only to preserve DebuggerClient's interface;
* new code should say 'client.mainRoot.listAddons()'.
*/
- listAddons: function (aOnResponse) { return this.mainRoot.listAddons(aOnResponse); },
+ listAddons: function (onResponse) {
+ return this.mainRoot.listAddons(onResponse);
+ },
- getTab: function (aFilter) { return this.mainRoot.getTab(aFilter); },
+ getTab: function (filter) {
+ return this.mainRoot.getTab(filter);
+ },
/**
* Attach to a tab actor.
*
- * @param string aTabActor
+ * @param string tabActor
* The actor ID for the tab to attach.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a TabClient
* (which will be undefined on error).
*/
- attachTab: function (aTabActor, aOnResponse = noop) {
- if (this._clients.has(aTabActor)) {
- let cachedTab = this._clients.get(aTabActor);
+ attachTab: function (tabActor, onResponse = noop) {
+ if (this._clients.has(tabActor)) {
+ let cachedTab = this._clients.get(tabActor);
let cachedResponse = {
cacheDisabled: cachedTab.cacheDisabled,
javascriptEnabled: cachedTab.javascriptEnabled,
traits: cachedTab.traits,
};
- DevToolsUtils.executeSoon(() => aOnResponse(cachedResponse, cachedTab));
+ DevToolsUtils.executeSoon(() => onResponse(cachedResponse, cachedTab));
return promise.resolve([cachedResponse, cachedTab]);
}
let packet = {
- to: aTabActor,
+ to: tabActor,
type: "attach"
};
- return this.request(packet).then(aResponse => {
+ return this.request(packet).then(response => {
let tabClient;
- if (!aResponse.error) {
- tabClient = new TabClient(this, aResponse);
+ if (!response.error) {
+ tabClient = new TabClient(this, response);
this.registerClient(tabClient);
}
- aOnResponse(aResponse, tabClient);
- return [aResponse, tabClient];
+ onResponse(response, tabClient);
+ return [response, tabClient];
});
},
- attachWorker: function DC_attachWorker(aWorkerActor, aOnResponse = noop) {
- let workerClient = this._clients.get(aWorkerActor);
+ attachWorker: function (workerActor, onResponse = noop) {
+ let workerClient = this._clients.get(workerActor);
if (workerClient !== undefined) {
let response = {
from: workerClient.actor,
type: "attached",
url: workerClient.url
};
- DevToolsUtils.executeSoon(() => aOnResponse(response, workerClient));
+ DevToolsUtils.executeSoon(() => onResponse(response, workerClient));
return promise.resolve([response, workerClient]);
}
- return this.request({ to: aWorkerActor, type: "attach" }).then(aResponse => {
- if (aResponse.error) {
- aOnResponse(aResponse, null);
- return [aResponse, null];
+ return this.request({ to: workerActor, type: "attach" }).then(response => {
+ if (response.error) {
+ onResponse(response, null);
+ return [response, null];
}
- let workerClient = new WorkerClient(this, aResponse);
+ workerClient = new WorkerClient(this, response);
this.registerClient(workerClient);
- aOnResponse(aResponse, workerClient);
- return [aResponse, workerClient];
+ onResponse(response, workerClient);
+ return [response, workerClient];
});
},
/**
* Attach to an addon actor.
*
- * @param string aAddonActor
+ * @param string addonActor
* The actor ID for the addon to attach.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a AddonClient
* (which will be undefined on error).
*/
- attachAddon: function DC_attachAddon(aAddonActor, aOnResponse = noop) {
+ attachAddon: function (addonActor, onResponse = noop) {
let packet = {
- to: aAddonActor,
+ to: addonActor,
type: "attach"
};
- return this.request(packet).then(aResponse => {
+ return this.request(packet).then(response => {
let addonClient;
- if (!aResponse.error) {
- addonClient = new AddonClient(this, aAddonActor);
+ if (!response.error) {
+ addonClient = new AddonClient(this, addonActor);
this.registerClient(addonClient);
this.activeAddon = addonClient;
}
- aOnResponse(aResponse, addonClient);
- return [aResponse, addonClient];
+ onResponse(response, addonClient);
+ return [response, addonClient];
});
},
/**
* Attach to a Web Console actor.
*
- * @param string aConsoleActor
+ * @param string consoleActor
* The ID for the console actor to attach to.
- * @param array aListeners
+ * @param array listeners
* The console listeners you want to start.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a WebConsoleClient
* instance (which will be undefined on error).
*/
attachConsole:
- function (aConsoleActor, aListeners, aOnResponse = noop) {
+ function (consoleActor, listeners, onResponse = noop) {
let packet = {
- to: aConsoleActor,
+ to: consoleActor,
type: "startListeners",
- listeners: aListeners,
+ listeners: listeners,
};
- return this.request(packet).then(aResponse => {
+ return this.request(packet).then(response => {
let consoleClient;
- if (!aResponse.error) {
- if (this._clients.has(aConsoleActor)) {
- consoleClient = this._clients.get(aConsoleActor);
+ if (!response.error) {
+ if (this._clients.has(consoleActor)) {
+ consoleClient = this._clients.get(consoleActor);
} else {
- consoleClient = new WebConsoleClient(this, aResponse);
+ consoleClient = new WebConsoleClient(this, response);
this.registerClient(consoleClient);
}
}
- aOnResponse(aResponse, consoleClient);
- return [aResponse, consoleClient];
+ onResponse(response, consoleClient);
+ return [response, consoleClient];
});
},
/**
* Attach to a global-scoped thread actor for chrome debugging.
*
- * @param string aThreadActor
+ * @param string threadActor
* The actor ID for the thread to attach.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a ThreadClient
* (which will be undefined on error).
- * @param object aOptions
+ * @param object options
* Configuration options.
* - useSourceMaps: whether to use source maps or not.
*/
- attachThread: function (aThreadActor, aOnResponse = noop, aOptions = {}) {
- if (this._clients.has(aThreadActor)) {
- let client = this._clients.get(aThreadActor);
- DevToolsUtils.executeSoon(() => aOnResponse({}, client));
+ attachThread: function (threadActor, onResponse = noop, options = {}) {
+ if (this._clients.has(threadActor)) {
+ let client = this._clients.get(threadActor);
+ DevToolsUtils.executeSoon(() => onResponse({}, client));
return promise.resolve([{}, client]);
}
let packet = {
- to: aThreadActor,
+ to: threadActor,
type: "attach",
- options: aOptions
+ options,
};
- return this.request(packet).then(aResponse => {
- if (!aResponse.error) {
- var threadClient = new ThreadClient(this, aThreadActor);
+ return this.request(packet).then(response => {
+ let threadClient;
+ if (!response.error) {
+ threadClient = new ThreadClient(this, threadActor);
this.registerClient(threadClient);
}
- aOnResponse(aResponse, threadClient);
- return [aResponse, threadClient];
+ onResponse(response, threadClient);
+ return [response, threadClient];
});
},
/**
* Attach to a trace actor.
*
- * @param string aTraceActor
+ * @param string traceActor
* The actor ID for the tracer to attach.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a TraceClient
* (which will be undefined on error).
*/
- attachTracer: function (aTraceActor, aOnResponse = noop) {
- if (this._clients.has(aTraceActor)) {
- let client = this._clients.get(aTraceActor);
- DevToolsUtils.executeSoon(() => aOnResponse({}, client));
+ attachTracer: function (traceActor, onResponse = noop) {
+ if (this._clients.has(traceActor)) {
+ let client = this._clients.get(traceActor);
+ DevToolsUtils.executeSoon(() => onResponse({}, client));
return promise.resolve([{}, client]);
}
let packet = {
- to: aTraceActor,
+ to: traceActor,
type: "attach"
};
- return this.request(packet).then(aResponse => {
- if (!aResponse.error) {
- var traceClient = new TraceClient(this, aTraceActor);
+ return this.request(packet).then(response => {
+ let traceClient;
+ if (!response.error) {
+ traceClient = new TraceClient(this, traceActor);
this.registerClient(traceClient);
}
- aOnResponse(aResponse, traceClient);
- return [aResponse, traceClient];
+ onResponse(response, traceClient);
+ return [response, traceClient];
});
},
/**
* Fetch the ChromeActor for the main process or ChildProcessActor for a
* a given child process ID.
*
- * @param number aId
+ * @param number id
* The ID for the process to attach (returned by `listProcesses`).
* Connected to the main process if omitted, or is 0.
*/
- getProcess: function (aId) {
+ getProcess: function (id) {
let packet = {
to: "root",
type: "getProcess"
};
- if (typeof (aId) == "number") {
- packet.id = aId;
+ if (typeof (id) == "number") {
+ packet.id = id;
}
return this.request(packet);
},
/**
* Release an object actor.
*
- * @param string aActor
+ * @param string actor
* The actor ID to send the request to.
- * @param aOnResponse function
+ * @param onResponse function
* If specified, will be called with the response packet when
* debugging server responds.
*/
release: DebuggerClient.requester({
- to: args(0),
+ to: arg(0),
type: "release"
}),
/**
* Send a request to the debugging server.
*
- * @param aRequest object
+ * @param packet object
* A JSON packet to send to the debugging server.
- * @param aOnResponse function
+ * @param onResponse function
* If specified, will be called with the JSON response packet when
* debugging server responds.
* @return Request
* This object emits a number of events to allow you to respond to
* different parts of the request lifecycle.
* It is also a Promise object, with a `then` method, that is resolved
* 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 |aOnResponse| will be bound to the
+ * because the callback provided in |onResponse| will be bound to the
* "json-reply" event automatically.
*
* Events emitted:
* * json-reply: The server replied with a JSON packet, which is
* passed as event data.
* * bulk-reply: The server replied with bulk data, which you can read
* using the event data object containing:
* * actor: Name of actor that received the packet
@@ -683,40 +688,40 @@ DebuggerClient.prototype = {
* @param output nsIAsyncOutputStream
* The stream to copy to.
* @return Promise
* The promise is resolved when copying completes or
* rejected if any (unexpected) errors occur.
* This object also emits "progress" events for each chunk
* that is copied. See stream-utils.js.
*/
- request: function (aRequest, aOnResponse) {
+ request: function (packet, onResponse) {
if (!this.mainRoot) {
throw Error("Have not yet received a hello packet from the server.");
}
- let type = aRequest.type || "";
- if (!aRequest.to) {
+ let type = packet.type || "";
+ if (!packet.to) {
throw Error("'" + type + "' request packet has no destination.");
}
if (this._closed) {
let msg = "'" + type + "' request packet to " +
- "'" + aRequest.to + "' " +
+ "'" + packet.to + "' " +
"can't be sent as the connection is closed.";
let resp = { error: "connectionClosed", message: msg };
- if (aOnResponse) {
- aOnResponse(resp);
+ if (onResponse) {
+ onResponse(resp);
}
return promise.reject(resp);
}
- let request = new Request(aRequest);
+ let request = new Request(packet);
request.format = "json";
request.stack = getStack();
- if (aOnResponse) {
- request.on("json-reply", aOnResponse);
+ if (onResponse) {
+ request.on("json-reply", onResponse);
}
this._sendOrQueueRequest(request);
// Implement a Promise like API on the returned object
// that resolves/rejects on request response
let deferred = promise.defer();
function listenerJson(resp) {
@@ -856,17 +861,17 @@ DebuggerClient.prototype = {
* actor.
*/
_sendRequest(request) {
let actor = request.actor;
this.expectReply(actor, request);
if (request.format === "json") {
this._transport.send(request.request);
- return false;
+ return;
}
this._transport.startBulkSend(request.request).then((...args) => {
request.emit("bulk-send-ready", ...args);
});
},
/**
@@ -894,131 +899,131 @@ DebuggerClient.prototype = {
let request = queue.shift();
if (queue.length === 0) {
this._pendingRequests.delete(actor);
}
this._sendRequest(request);
},
/**
- * Arrange to hand the next reply from |aActor| to the handler bound to
- * |aRequest|.
+ * Arrange to hand the next reply from |actor| to the handler bound to
+ * |request|.
*
* 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 (aActor, aRequest) {
- if (this._activeRequests.has(aActor)) {
- throw Error("clashing handlers for next reply from " + uneval(aActor));
+ expectReply: function (actor, request) {
+ if (this._activeRequests.has(actor)) {
+ throw Error("clashing handlers for next reply from " + actor);
}
// 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 aRequest === "function") {
- let handler = aRequest;
- aRequest = new Request();
- aRequest.on("json-reply", handler);
+ if (typeof request === "function") {
+ let handler = request;
+ request = new Request();
+ request.on("json-reply", handler);
}
- this._activeRequests.set(aActor, aRequest);
+ this._activeRequests.set(actor, request);
},
// Transport hooks.
/**
* Called by DebuggerTransport to dispatch incoming packets as appropriate.
*
- * @param aPacket object
+ * @param packet object
* The incoming packet.
*/
- onPacket: function (aPacket) {
- if (!aPacket.from) {
+ onPacket: function (packet) {
+ if (!packet.from) {
DevToolsUtils.reportException(
"onPacket",
new Error("Server did not specify an actor, dropping packet: " +
- JSON.stringify(aPacket)));
+ JSON.stringify(packet)));
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(aPacket.from);
+ let front = this.getActor(packet.from);
if (front) {
- front.onPacket(aPacket);
+ front.onPacket(packet);
return;
}
// Check for "forwardingCancelled" here instead of using a client to handle it.
// 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 &&
- aPacket.from == this.mainRoot.actor &&
- aPacket.type == "forwardingCancelled") {
- this.purgeRequests(aPacket.prefix);
+ packet.from == this.mainRoot.actor &&
+ packet.type == "forwardingCancelled") {
+ this.purgeRequests(packet.prefix);
return;
}
- if (this._clients.has(aPacket.from) && aPacket.type) {
- let client = this._clients.get(aPacket.from);
- let type = aPacket.type;
+ if (this._clients.has(packet.from) && packet.type) {
+ let client = this._clients.get(packet.from);
+ let type = packet.type;
if (client.events.indexOf(type) != -1) {
- client.emit(type, aPacket);
+ client.emit(type, packet);
// we ignore the rest, as the client is expected to handle this packet.
return;
}
}
let activeRequest;
// 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(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 (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 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(aPacket.from);
+ this._attemptNextRequest(packet.from);
// Packets that indicate thread state changes get special treatment.
- 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);
+ 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);
}
// TODO: Bug 1151156 - Remove once Gecko 40 is on b2g-stable.
if (!this.traits.noNeedToFakeResumptionOnNavigation) {
// 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 (aPacket.type == UnsolicitedNotifications.tabNavigated &&
- this._clients.has(aPacket.from) &&
- this._clients.get(aPacket.from).thread) {
- let thread = this._clients.get(aPacket.from).thread;
+ if (packet.type == UnsolicitedNotifications.tabNavigated &&
+ this._clients.has(packet.from) &&
+ this._clients.get(packet.from).thread) {
+ let thread = this._clients.get(packet.from).thread;
let resumption = { from: thread._actor, type: "resumed" };
thread._onThreadState(resumption);
}
}
// Only try to notify listeners on events, not responses to requests
// that lack a packet type.
- if (aPacket.type) {
- this.emit(aPacket.type, aPacket);
+ if (packet.type) {
+ this.emit(packet.type, packet);
}
if (activeRequest) {
- let emitReply = () => activeRequest.emit("json-reply", aPacket);
+ let emitReply = () => activeRequest.emit("json-reply", packet);
if (activeRequest.stack) {
callFunctionWithAsyncStack(emitReply, activeRequest.stack,
"DevTools RDP");
} else {
emitReply();
}
}
},
@@ -1049,17 +1054,17 @@ DebuggerClient.prototype = {
* The stream to copy to.
* @return Promise
* The promise is resolved when copying completes or rejected
* if any (unexpected) errors occur.
* This object also emits "progress" events for each chunk
* that is copied. See stream-utils.js.
*/
onBulkPacket: function (packet) {
- let { actor, type, length } = packet;
+ let { actor } = packet;
if (!actor) {
DevToolsUtils.reportException(
"onBulkPacket",
new Error("Server did not specify an actor, dropping bulk packet: " +
JSON.stringify(packet)));
return;
}
@@ -1079,17 +1084,17 @@ DebuggerClient.prototype = {
this._attemptNextRequest(actor);
activeRequest.emit("bulk-reply", packet);
},
/**
* Called by DebuggerTransport when the underlying stream is closed.
*
- * @param aStatus nsresult
+ * @param status nsresult
* The status code that corresponds to the reason for closing
* the stream.
*/
onClosed: function () {
this._closed = true;
this.emit("closed");
this.purgeRequests();
@@ -1275,17 +1280,19 @@ DebuggerClient.prototype = {
},
getActor: function (actorID) {
let pool = this.poolFor(actorID);
return pool ? pool.get(actorID) : null;
},
poolFor: function (actorID) {
for (let pool of this._pools) {
- if (pool.has(actorID)) return pool;
+ if (pool.has(actorID)) {
+ return pool;
+ }
}
return null;
},
/**
* Currently attached addon.
*/
activeAddon: null
@@ -1310,95 +1317,101 @@ Request.prototype = {
once: function (type, listener) {
events.once(this, type, listener);
},
emit: function (type, ...args) {
events.emit(this, type, ...args);
},
- get actor() { return this.request.to || this.request.actor; }
+ get actor() {
+ return this.request.to || this.request.actor;
+ }
};
/**
* Creates a tab client for the remote debugging protocol server. This client
* is a front to the tab actor created in the server side, hiding the protocol
* details in a traditional JavaScript API.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aForm object
+ * @param form object
* The protocol form for this tab.
*/
-function TabClient(aClient, aForm) {
- this.client = aClient;
- this._actor = aForm.from;
- this._threadActor = aForm.threadActor;
- this.javascriptEnabled = aForm.javascriptEnabled;
- this.cacheDisabled = aForm.cacheDisabled;
+function TabClient(client, form) {
+ this.client = client;
+ this._actor = form.from;
+ this._threadActor = form.threadActor;
+ this.javascriptEnabled = form.javascriptEnabled;
+ this.cacheDisabled = form.cacheDisabled;
this.thread = null;
this.request = this.client.request;
- this.traits = aForm.traits || {};
+ this.traits = form.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 aOptions
+ * @param object options
* Configuration options.
* - useSourceMaps: whether to use source maps or not.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet and a ThreadClient
* (which will be undefined on error).
*/
- attachThread: function (aOptions = {}, aOnResponse = noop) {
+ attachThread: function (options = {}, onResponse = noop) {
if (this.thread) {
- DevToolsUtils.executeSoon(() => aOnResponse({}, this.thread));
+ DevToolsUtils.executeSoon(() => onResponse({}, this.thread));
return promise.resolve([{}, this.thread]);
}
let packet = {
to: this._threadActor,
type: "attach",
- options: aOptions
+ options,
};
- return this.request(packet).then(aResponse => {
- if (!aResponse.error) {
+ return this.request(packet).then(response => {
+ if (!response.error) {
this.thread = new ThreadClient(this, this._threadActor);
this.client.registerClient(this.thread);
}
- aOnResponse(aResponse, this.thread);
- return [aResponse, this.thread];
+ onResponse(response, this.thread);
+ return [response, this.thread];
});
},
/**
* Detach the client from the tab actor.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
detach: DebuggerClient.requester({
type: "detach"
}, {
- before: function (aPacket) {
+ before: function (packet) {
if (this.thread) {
this.thread.detach();
}
- return aPacket;
+ return packet;
},
- after: function (aResponse) {
+ after: function (response) {
this.client.unregisterClient(this);
- return aResponse;
+ return response;
},
}),
/**
* Bring the window to the front.
*/
focus: DebuggerClient.requester({
type: "focus"
@@ -1411,72 +1424,72 @@ TabClient.prototype = {
* An object with a `force` property indicating whether or not
* this reload should skip the cache
*/
reload: function (options = { force: false }) {
return this._reload(options);
},
_reload: DebuggerClient.requester({
type: "reload",
- options: args(0)
+ options: arg(0)
}),
/**
* Navigate to another URL.
*
* @param string url
* The URL to navigate to.
*/
navigateTo: DebuggerClient.requester({
type: "navigateTo",
- url: args(0)
+ url: arg(0)
}),
/**
* Reconfigure the tab actor.
*
- * @param object aOptions
+ * @param object options
* A dictionary object of the new options to use in the tab actor.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
reconfigure: DebuggerClient.requester({
type: "reconfigure",
- options: args(0)
+ options: arg(0)
}),
listWorkers: DebuggerClient.requester({
type: "listWorkers"
}),
- attachWorker: function (aWorkerActor, aOnResponse) {
- this.client.attachWorker(aWorkerActor, aOnResponse);
+ attachWorker: function (workerActor, onResponse) {
+ this.client.attachWorker(workerActor, onResponse);
},
/**
* Resolve a location ({ url, line, column }) to its current
* source mapping location.
*
* @param {String} arg[0].url
* @param {Number} arg[0].line
* @param {Number?} arg[0].column
*/
resolveLocation: DebuggerClient.requester({
type: "resolveLocation",
- location: args(0)
+ location: arg(0)
}),
};
eventSource(TabClient.prototype);
-function WorkerClient(aClient, aForm) {
- this.client = aClient;
- this._actor = aForm.from;
+function WorkerClient(client, form) {
+ this.client = client;
+ this._actor = form.from;
this._isClosed = false;
- this._url = aForm.url;
+ this._url = form.url;
this._onClose = this._onClose.bind(this);
this.addListener("close", this._onClose);
this.traits = {};
}
@@ -1497,65 +1510,65 @@ WorkerClient.prototype = {
return this._url;
},
get isClosed() {
return this._isClosed;
},
detach: DebuggerClient.requester({ type: "detach" }, {
- after: function (aResponse) {
+ after: function (response) {
if (this.thread) {
this.client.unregisterClient(this.thread);
}
this.client.unregisterClient(this);
- return aResponse;
+ return response;
},
}),
- attachThread: function (aOptions = {}, aOnResponse = noop) {
+ attachThread: function (options = {}, onResponse = noop) {
if (this.thread) {
let response = [{
type: "connected",
threadActor: this.thread._actor,
consoleActor: this.consoleActor,
}, this.thread];
- DevToolsUtils.executeSoon(() => aOnResponse(response));
+ DevToolsUtils.executeSoon(() => onResponse(response));
return response;
}
// The connect call on server doesn't attach the thread as of version 44.
return this.request({
to: this._actor,
type: "connect",
- options: aOptions,
- }).then(connectReponse => {
- if (connectReponse.error) {
- aOnResponse(connectReponse, null);
+ options,
+ }).then(connectResponse => {
+ if (connectResponse.error) {
+ onResponse(connectResponse, null);
return [connectResponse, null];
}
return this.request({
- to: connectReponse.threadActor,
+ to: connectResponse.threadActor,
type: "attach",
- options: aOptions
+ options,
}).then(attachResponse => {
if (attachResponse.error) {
- aOnResponse(attachResponse, null);
+ onResponse(attachResponse, null);
}
- this.thread = new ThreadClient(this, connectReponse.threadActor);
- this.consoleActor = connectReponse.consoleActor;
+ this.thread = new ThreadClient(this, connectResponse.threadActor);
+ this.consoleActor = connectResponse.consoleActor;
this.client.registerClient(this.thread);
- aOnResponse(connectReponse, this.thread);
+ onResponse(connectResponse, this.thread);
return [connectResponse, this.thread];
});
}, error => {
- aOnResponse(error, null);
+ onResponse(error, null);
});
},
_onClose: function () {
this.removeListener("close", this._onClose);
if (this.thread) {
this.client.unregisterClient(this.thread);
@@ -1568,144 +1581,148 @@ WorkerClient.prototype = {
return Promise.resolve();
},
events: ["close"]
};
eventSource(WorkerClient.prototype);
-function AddonClient(aClient, aActor) {
- this._client = aClient;
- this._actor = aActor;
+function AddonClient(client, actor) {
+ this._client = client;
+ this._actor = actor;
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 aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
detach: DebuggerClient.requester({
type: "detach"
}, {
- after: function (aResponse) {
+ after: function (response) {
if (this._client.activeAddon === this) {
this._client.activeAddon = null;
}
this._client.unregisterClient(this);
- return aResponse;
+ return response;
},
})
};
/**
* A RootClient object represents a root actor on the server. Each
* DebuggerClient keeps a RootClient instance representing the root actor
* for the initial connection; DebuggerClient's 'listTabs' and
* 'listChildProcesses' methods forward to that root actor.
*
- * @param aClient object
+ * @param client object
* The client connection to which this actor belongs.
- * @param aGreeting string
+ * @param greeting string
* The greeting packet from the root actor we're to represent.
*
* Properties of a RootClient instance:
*
* @property actor string
* The name of this child's root actor.
* @property applicationType string
* The application type, as given in the root actor's greeting packet.
* @property traits object
* The traits object, as given in the root actor's greeting packet.
*/
-function RootClient(aClient, aGreeting) {
- this._client = aClient;
- this.actor = aGreeting.from;
- this.applicationType = aGreeting.applicationType;
- this.traits = aGreeting.traits;
+function RootClient(client, greeting) {
+ this._client = client;
+ this.actor = greeting.from;
+ this.applicationType = greeting.applicationType;
+ this.traits = greeting.traits;
}
exports.RootClient = RootClient;
RootClient.prototype = {
constructor: RootClient,
/**
* List the open tabs.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
listTabs: DebuggerClient.requester({ type: "listTabs" }),
/**
* List the installed addons.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
listAddons: DebuggerClient.requester({ type: "listAddons" }),
/**
* List the registered workers.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
listWorkers: DebuggerClient.requester({ type: "listWorkers" }),
/**
* List the registered service workers.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
listServiceWorkerRegistrations: DebuggerClient.requester({
type: "listServiceWorkerRegistrations"
}),
/**
* List the running processes.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
listProcesses: DebuggerClient.requester({ type: "listProcesses" }),
/**
* Fetch the TabActor for the currently selected tab, or for a specific
* tab given as first parameter.
*
- * @param [optional] object aFilter
+ * @param [optional] object filter
* A dictionary object with following optional attributes:
* - outerWindowID: used to match tabs in parent process
* - tabId: used to match tabs in child processes
* - tab: a reference to xul:tab element
* If nothing is specified, returns the actor for the currently
* selected tab.
*/
- getTab: function (aFilter) {
+ getTab: function (filter) {
let packet = {
to: this.actor,
type: "getTab"
};
- 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 (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 (browser.frameLoader.tabParent) {
// Tabs in child process
packet.tabId = browser.frameLoader.tabParent.tabId;
} else if (browser.outerWindowID) {
// <xul:browser> tabs in parent process
packet.outerWindowID = browser.outerWindowID;
} else {
// <iframe mozbrowser> tabs in parent process
@@ -1722,239 +1739,253 @@ RootClient.prototype = {
}
return this.request(packet);
},
/**
* Description of protocol's actors and methods.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
protocolDescription: DebuggerClient.requester({ type: "protocolDescription" }),
/*
* 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;
+ }
};
/**
* Creates a thread client for the remote debugging protocol server. This client
* is a front to the thread actor created in the server side, hiding the
* protocol details in a traditional JavaScript API.
*
- * @param aClient DebuggerClient|TabClient
+ * @param client DebuggerClient|TabClient
* The parent of the thread (tab for tab-scoped debuggers, DebuggerClient
* for chrome debuggers).
- * @param aActor string
+ * @param actor string
* The actor ID for this thread.
*/
-function ThreadClient(aClient, aActor) {
- this._parent = aClient;
- this.client = aClient instanceof DebuggerClient ? aClient : aClient.client;
- this._actor = aActor;
+function ThreadClient(client, actor) {
+ this._parent = client;
+ this.client = client instanceof DebuggerClient ? client : client.client;
+ this._actor = actor;
this._frameCache = [];
this._scriptCache = {};
this._pauseGrips = {};
this._threadGrips = {};
this.request = this.client.request;
}
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 _transport() { return this.client._transport; },
+ get actor() {
+ return this._actor;
+ },
- _assertPaused: function (aCommand) {
+ get _transport() {
+ return this.client._transport;
+ },
+
+ _assertPaused: function (command) {
if (!this.paused) {
- throw Error(aCommand + " command sent while not paused. Currently " + this._state);
+ throw Error(command + " command sent while not paused. Currently " + this._state);
}
},
/**
- * Resume a paused thread. If the optional aLimit parameter is present, then
+ * Resume a paused thread. If the optional limit parameter is present, then
* the thread will also pause when that limit is reached.
*
- * @param [optional] object aLimit
+ * @param [optional] object limit
* 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 aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
_doResume: DebuggerClient.requester({
type: "resume",
- resumeLimit: args(0)
+ resumeLimit: arg(0)
}, {
- before: function (aPacket) {
+ before: function (packet) {
this._assertPaused("resume");
// Put the client in a tentative "resuming" state so we can prevent
// further requests that should only be sent in the paused state.
this._previousState = this._state;
this._state = "resuming";
if (this._pauseOnExceptions) {
- aPacket.pauseOnExceptions = this._pauseOnExceptions;
+ packet.pauseOnExceptions = this._pauseOnExceptions;
}
if (this._ignoreCaughtExceptions) {
- aPacket.ignoreCaughtExceptions = this._ignoreCaughtExceptions;
+ packet.ignoreCaughtExceptions = this._ignoreCaughtExceptions;
}
if (this._pauseOnDOMEvents) {
- aPacket.pauseOnDOMEvents = this._pauseOnDOMEvents;
+ packet.pauseOnDOMEvents = this._pauseOnDOMEvents;
}
- return aPacket;
+ return packet;
},
- after: function (aResponse) {
- if (aResponse.error && this._state == "resuming") {
+ after: function (response) {
+ if (response.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 (aResponse.state) {
- this._state = ThreadStateTypes[aResponse.state];
+ if (response.state) {
+ this._state = ThreadStateTypes[response.state];
} else {
this._state = this._previousState;
}
}
delete this._previousState;
- return aResponse;
+ return response;
},
}),
/**
* Reconfigure the thread actor.
*
- * @param object aOptions
+ * @param object options
* A dictionary object of the new options to use in the thread actor.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
reconfigure: DebuggerClient.requester({
type: "reconfigure",
- options: args(0)
+ options: arg(0)
}),
/**
* Resume a paused thread.
*/
- resume: function (aOnResponse) {
- return this._doResume(null, aOnResponse);
+ resume: function (onResponse) {
+ return this._doResume(null, onResponse);
},
/**
* Resume then pause without stepping.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- resumeThenPause: function (aOnResponse) {
- return this._doResume({ type: "break" }, aOnResponse);
+ resumeThenPause: function (onResponse) {
+ return this._doResume({ type: "break" }, onResponse);
},
/**
* Step over a function call.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- stepOver: function (aOnResponse) {
- return this._doResume({ type: "next" }, aOnResponse);
+ stepOver: function (onResponse) {
+ return this._doResume({ type: "next" }, onResponse);
},
/**
* Step into a function call.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- stepIn: function (aOnResponse) {
- return this._doResume({ type: "step" }, aOnResponse);
+ stepIn: function (onResponse) {
+ return this._doResume({ type: "step" }, onResponse);
},
/**
* Step out of a function call.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- stepOut: function (aOnResponse) {
- return this._doResume({ type: "finish" }, aOnResponse);
+ stepOut: function (onResponse) {
+ return this._doResume({ type: "finish" }, onResponse);
},
/**
* Immediately interrupt a running thread.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- interrupt: function (aOnResponse) {
- return this._doInterrupt(null, aOnResponse);
+ interrupt: function (onResponse) {
+ return this._doInterrupt(null, onResponse);
},
/**
* Pause execution right before the next JavaScript bytecode is executed.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
- breakOnNext: function (aOnResponse) {
- return this._doInterrupt("onNext", aOnResponse);
+ breakOnNext: function (onResponse) {
+ return this._doInterrupt("onNext", onResponse);
},
/**
* Interrupt a running thread.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
_doInterrupt: DebuggerClient.requester({
type: "interrupt",
- when: args(0)
+ when: arg(0)
}),
/**
* Enable or disable pausing when an exception is thrown.
*
- * @param boolean aFlag
+ * @param boolean pauseOnExceptions
* Enables pausing if true, disables otherwise.
- * @param function aOnResponse
+ * @param boolean ignoreCaughtExceptions
+ * Whether to ignore caught exceptions
+ * @param function onResponse
* Called with the response packet.
*/
- pauseOnExceptions: function (aPauseOnExceptions,
- aIgnoreCaughtExceptions,
- aOnResponse = noop) {
- this._pauseOnExceptions = aPauseOnExceptions;
- this._ignoreCaughtExceptions = aIgnoreCaughtExceptions;
+ pauseOnExceptions: function (pauseOnExceptions,
+ ignoreCaughtExceptions,
+ onResponse = noop) {
+ this._pauseOnExceptions = pauseOnExceptions;
+ this._ignoreCaughtExceptions = ignoreCaughtExceptions;
// Otherwise send the flag using a standard resume request.
if (!this.paused) {
- return this.interrupt(aResponse => {
- if (aResponse.error) {
+ return this.interrupt(response => {
+ if (response.error) {
// Can't continue if pausing failed.
- aOnResponse(aResponse);
- return aResponse;
+ onResponse(response);
+ return response;
}
- return this.resume(aOnResponse);
+ return this.resume(onResponse);
});
}
- aOnResponse();
+ onResponse();
return promise.resolve();
},
/**
* Enable pausing when the specified DOM events are triggered. Disabling
* pausing on an event can be realized by calling this method with the updated
* array of events that doesn't contain it.
*
@@ -1983,99 +2014,99 @@ ThreadClient.prototype = {
return this.resume(onResponse);
});
},
/**
* Send a clientEvaluate packet to the debuggee. Response
* will be a resume packet.
*
- * @param string aFrame
+ * @param string frame
* The actor ID of the frame where the evaluation should take place.
- * @param string aExpression
+ * @param string expression
* The expression that will be evaluated in the scope of the frame
* above.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
eval: DebuggerClient.requester({
type: "clientEvaluate",
- frame: args(0),
- expression: args(1)
+ frame: arg(0),
+ expression: arg(1)
}, {
- before: function (aPacket) {
+ before: function (packet) {
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 aPacket;
+ return packet;
},
- after: function (aResponse) {
- if (aResponse.error) {
+ after: function (response) {
+ if (response.error) {
// There was an error resuming, back to paused state.
this._state = "paused";
}
- return aResponse;
+ return response;
},
}),
/**
* Detach from the thread actor.
*
- * @param function aOnResponse
+ * @param function onResponse
* Called with the response packet.
*/
detach: DebuggerClient.requester({
type: "detach"
}, {
- after: function (aResponse) {
+ after: function (response) {
this.client.unregisterClient(this);
this._parent.thread = null;
- return aResponse;
+ return response;
},
}),
/**
* Release multiple thread-lifetime object actors. If any pause-lifetime
* actors are included in the request, a |notReleasable| error will return,
* but all the thread-lifetime ones will have been released.
*
* @param array actors
* An array with actor IDs to release.
*/
releaseMany: DebuggerClient.requester({
type: "releaseMany",
- actors: args(0),
+ actors: arg(0),
}),
/**
* Promote multiple pause-lifetime object actors to thread-lifetime ones.
*
* @param array actors
* An array with actor IDs to promote.
*/
threadGrips: DebuggerClient.requester({
type: "threadGrips",
- actors: args(0)
+ actors: arg(0)
}),
/**
* Return the event listeners defined on the page.
*
- * @param aOnResponse Function
+ * @param onResponse Function
* Called with the thread's response.
*/
eventListeners: DebuggerClient.requester({
type: "eventListeners"
}),
/**
* Request the loaded sources for the current thread.
*
- * @param aOnResponse Function
+ * @param onResponse Function
* Called with the thread's response.
*/
getSources: DebuggerClient.requester({
type: "sources"
}),
/**
* Clear the thread's source script cache. A scriptscleared event
@@ -2086,75 +2117,77 @@ ThreadClient.prototype = {
this._scriptCache = {};
this.emit("scriptscleared");
}
},
/**
* Request frames from the callstack for the current thread.
*
- * @param aStart integer
+ * @param start integer
* The number of the youngest stack frame to return (the youngest
* frame is 0).
- * @param aCount integer
+ * @param count integer
* The maximum number of frames to return, or null to return all
* frames.
- * @param aOnResponse function
+ * @param onResponse function
* Called with the thread's response.
*/
getFrames: DebuggerClient.requester({
type: "frames",
- start: args(0),
- count: args(1)
+ start: arg(0),
+ count: arg(1)
}),
/**
* An array of cached frames. Clients can observe the framesadded and
* 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.
*/
get moreFrames() {
return this.paused && (!this._frameCache || this._frameCache.length == 0
|| !this._frameCache[this._frameCache.length - 1].oldest);
},
/**
- * Ensure that at least aTotal stack frames have been loaded in the
+ * Ensure that at least total 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 aTotal number
+ * @param total number
* The minimum number of stack frames to be included.
- * @param aCallback function
+ * @param callback function
* Optional callback function called when frames have been loaded
* @returns true if a framesadded notification should be expected.
*/
- fillFrames: function (aTotal, aCallback = noop) {
+ fillFrames: function (total, callback = noop) {
this._assertPaused("fillFrames");
- if (this._frameCache.length >= aTotal) {
+ if (this._frameCache.length >= total) {
return false;
}
let numFrames = this._frameCache.length;
- this.getFrames(numFrames, aTotal - numFrames, (aResponse) => {
- if (aResponse.error) {
- aCallback(aResponse);
+ this.getFrames(numFrames, total - numFrames, (response) => {
+ if (response.error) {
+ callback(response);
return;
}
let threadGrips = DevToolsUtils.values(this._threadGrips);
- for (let i in aResponse.frames) {
- let frame = aResponse.frames[i];
+ for (let i in response.frames) {
+ let frame = response.frames[i];
if (!frame.where.source) {
// Older servers use urls instead, so we need to resolve
// them to source actors
for (let grip of threadGrips) {
if (grip instanceof SourceClient && grip.url === frame.url) {
frame.where.source = grip._form;
}
}
@@ -2162,17 +2195,17 @@ ThreadClient.prototype = {
this._frameCache[frame.depth] = frame;
}
// If we got as many frames as we asked for, there might be more
// frames available.
this.emit("framesadded");
- aCallback(aResponse);
+ callback(response);
});
return true;
},
/**
* Clear the thread's stack frame cache. A framescleared event
* will be sent.
@@ -2182,82 +2215,82 @@ ThreadClient.prototype = {
this._frameCache = [];
this.emit("framescleared");
}
},
/**
* Return a ObjectClient object for the given object grip.
*
- * @param aGrip object
+ * @param grip object
* A pause-lifetime object grip returned by the protocol.
*/
- pauseGrip: function (aGrip) {
- if (aGrip.actor in this._pauseGrips) {
- return this._pauseGrips[aGrip.actor];
+ pauseGrip: function (grip) {
+ if (grip.actor in this._pauseGrips) {
+ return this._pauseGrips[grip.actor];
}
- let client = new ObjectClient(this.client, aGrip);
- this._pauseGrips[aGrip.actor] = client;
+ let client = new ObjectClient(this.client, grip);
+ this._pauseGrips[grip.actor] = client;
return client;
},
/**
* Get or create a long string client, checking the grip client cache if it
* already exists.
*
- * @param aGrip Object
+ * @param grip Object
* The long string grip returned by the protocol.
- * @param aGripCacheName String
+ * @param gripCacheName String
* The property name of the grip client cache to check for existing
* clients in.
*/
- _longString: function (aGrip, aGripCacheName) {
- if (aGrip.actor in this[aGripCacheName]) {
- return this[aGripCacheName][aGrip.actor];
+ _longString: function (grip, gripCacheName) {
+ if (grip.actor in this[gripCacheName]) {
+ return this[gripCacheName][grip.actor];
}
- let client = new LongStringClient(this.client, aGrip);
- this[aGripCacheName][aGrip.actor] = client;
+ let client = new LongStringClient(this.client, grip);
+ this[gripCacheName][grip.actor] = client;
return client;
},
/**
* Return an instance of LongStringClient for the given long string grip that
* is scoped to the current pause.
*
- * @param aGrip Object
+ * @param grip Object
* The long string grip returned by the protocol.
*/
- pauseLongString: function (aGrip) {
- return this._longString(aGrip, "_pauseGrips");
+ pauseLongString: function (grip) {
+ return this._longString(grip, "_pauseGrips");
},
/**
* Return an instance of LongStringClient for the given long string grip that
* is scoped to the thread lifetime.
*
- * @param aGrip Object
+ * @param grip Object
* The long string grip returned by the protocol.
*/
- threadLongString: function (aGrip) {
- return this._longString(aGrip, "_threadGrips");
+ threadLongString: function (grip) {
+ return this._longString(grip, "_threadGrips");
},
/**
* Clear and invalidate all the grip clients from the given cache.
*
- * @param aGripCacheName
+ * @param gripCacheName
* The property name of the grip cache we want to clear.
*/
- _clearObjectClients: function (aGripCacheName) {
- for (let id in this[aGripCacheName]) {
- this[aGripCacheName][id].valid = false;
+ _clearObjectClients: function (gripCacheName) {
+ for (let id in this[gripCacheName]) {
+ this[gripCacheName][id].valid = false;
}
- this[aGripCacheName] = {};
+ this[gripCacheName] = {};
},
/**
* Invalidate pause-lifetime grip clients and clear the list of current grip
* clients.
*/
_clearPauseGrips: function () {
this._clearObjectClients("_pauseGrips");
@@ -2270,241 +2303,251 @@ ThreadClient.prototype = {
_clearThreadGrips: function () {
this._clearObjectClients("_threadGrips");
},
/**
* Handle thread state change by doing necessary cleanup and notifying all
* registered listeners.
*/
- _onThreadState: function (aPacket) {
- this._state = ThreadStateTypes[aPacket.type];
+ _onThreadState: function (packet) {
+ this._state = ThreadStateTypes[packet.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 = aPacket.type === "resumed" ? null : aPacket;
+ this._lastPausePacket = packet.type === "resumed" ? null : packet;
this._clearFrames();
this._clearPauseGrips();
- aPacket.type === ThreadStateTypes.detached && this._clearThreadGrips();
- this.client._eventsEnabled && this.emit(aPacket.type, aPacket);
+ packet.type === ThreadStateTypes.detached && this._clearThreadGrips();
+ this.client._eventsEnabled && this.emit(packet.type, packet);
},
getLastPausePacket: function () {
return this._lastPausePacket;
},
/**
* Return an EnvironmentClient instance for the given environment actor form.
*/
- environment: function (aForm) {
- return new EnvironmentClient(this.client, aForm);
+ environment: function (form) {
+ return new EnvironmentClient(this.client, form);
},
/**
* Return an instance of SourceClient for the given source actor form.
*/
- source: function (aForm) {
- if (aForm.actor in this._threadGrips) {
- return this._threadGrips[aForm.actor];
+ source: function (form) {
+ if (form.actor in this._threadGrips) {
+ return this._threadGrips[form.actor];
}
- return this._threadGrips[aForm.actor] = new SourceClient(this, aForm);
+ this._threadGrips[form.actor] = new SourceClient(this, form);
+ return this._threadGrips[form.actor];
},
/**
* Request the prototype and own properties of mutlipleObjects.
*
- * @param aOnResponse function
+ * @param onResponse function
* Called with the request's response.
* @param actors [string]
* List of actor ID of the queried objects.
*/
getPrototypesAndProperties: DebuggerClient.requester({
type: "prototypesAndProperties",
- actors: args(0)
+ actors: arg(0)
}),
events: ["newSource"]
};
eventSource(ThreadClient.prototype);
/**
* Creates a tracing profiler client for the remote debugging protocol
* server. This client is a front to the trace actor created on the
* server side, hiding the protocol details in a traditional
* JavaScript API.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aActor string
+ * @param actor string
* The actor ID for this thread.
*/
-function TraceClient(aClient, aActor) {
- this._client = aClient;
- this._actor = aActor;
+function TraceClient(client, actor) {
+ this._client = client;
+ this._actor = actor;
this._activeTraces = new Set();
this._waitingPackets = new Map();
this._expectedPacket = 0;
this.request = this._client.request;
this.events = [];
}
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.
*/
detach: DebuggerClient.requester({
type: "detach"
}, {
- after: function (aResponse) {
+ after: function (response) {
this._client.unregisterClient(this);
- return aResponse;
+ return response;
},
}),
/**
* Start a new trace.
*
- * @param aTrace [string]
+ * @param trace [string]
* An array of trace types to be recorded by the new trace.
*
- * @param aName string
+ * @param name string
* The name of the new trace.
*
- * @param aOnResponse function
+ * @param onResponse function
* Called with the request's response.
*/
startTrace: DebuggerClient.requester({
type: "startTrace",
- name: args(1),
- trace: args(0)
+ name: arg(1),
+ trace: arg(0)
}, {
- after: function (aResponse) {
- if (aResponse.error) {
- return aResponse;
+ after: function (response) {
+ if (response.error) {
+ return response;
}
if (!this.tracing) {
this._waitingPackets.clear();
this._expectedPacket = 0;
}
- this._activeTraces.add(aResponse.name);
+ this._activeTraces.add(response.name);
- return aResponse;
+ return response;
},
}),
/**
* End a trace. If a name is provided, stop the named
* trace. Otherwise, stop the most recently started trace.
*
- * @param aName string
+ * @param name string
* The name of the trace to stop.
*
- * @param aOnResponse function
+ * @param onResponse function
* Called with the request's response.
*/
stopTrace: DebuggerClient.requester({
type: "stopTrace",
- name: args(0)
+ name: arg(0)
}, {
- after: function (aResponse) {
- if (aResponse.error) {
- return aResponse;
+ after: function (response) {
+ if (response.error) {
+ return response;
}
- this._activeTraces.delete(aResponse.name);
+ this._activeTraces.delete(response.name);
- return aResponse;
+ return response;
},
})
};
/**
* Grip clients are used to retrieve information about the relevant object.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aGrip object
+ * @param grip object
* A pause-lifetime object grip returned by the protocol.
*/
-function ObjectClient(aClient, aGrip)
-{
- this._grip = aGrip;
- this._client = aClient;
+function ObjectClient(client, grip) {
+ this._grip = grip;
+ this._client = client;
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,
get isFrozen() {
return this._grip.frozen;
},
get isSealed() {
return this._grip.sealed;
},
get isExtensible() {
return this._grip.extensible;
},
getDefinitionSite: DebuggerClient.requester({
type: "definitionSite"
}, {
- before: function (aPacket) {
+ before: function (packet) {
if (this._grip.class != "Function") {
throw new Error("getDefinitionSite is only valid for function grips.");
}
- return aPacket;
+ return packet;
}
}),
/**
* Request the names of a function's formal parameters.
*
- * @param aOnResponse function
+ * @param onResponse function
* Called with an object of the form:
* { parameterNames:[<parameterName>, ...] }
* where each <parameterName> is the name of a parameter.
*/
getParameterNames: DebuggerClient.requester({
type: "parameterNames"
}, {
- before: function (aPacket) {
- if (this._grip["class"] !== "Function") {
+ before: function (packet) {
+ if (this._grip.class !== "Function") {
throw new Error("getParameterNames is only valid for function grips.");
}
- return aPacket;
+ return packet;
},
}),
/**
* Request the names of the properties defined on the object and not its
* prototype.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
getOwnPropertyNames: DebuggerClient.requester({
type: "ownPropertyNames"
}),
/**
* Request the prototype and own properties of the object.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
getPrototypeAndProperties: DebuggerClient.requester({
type: "prototypeAndProperties"
}),
/**
* Request a PropertyIteratorClient instance to ease listing
* properties for this object.
@@ -2516,35 +2559,35 @@ ObjectClient.prototype = {
* e.g. properties names between `0` and `object.length`.
* - ignoreNonIndexedProperties Boolean
* If true, filters out items that aren't array items
* e.g. properties names that are not a number between `0`
* and `object.length`.
* - sort Boolean
* If true, the iterator will sort the properties by name
* before dispatching them.
- * @param aOnResponse function Called with the client instance.
+ * @param onResponse function Called with the client instance.
*/
enumProperties: DebuggerClient.requester({
type: "enumProperties",
- options: args(0)
+ options: arg(0)
}, {
- after: function (aResponse) {
- if (aResponse.iterator) {
- return { iterator: new PropertyIteratorClient(this._client, aResponse.iterator) };
+ after: function (response) {
+ if (response.iterator) {
+ return { iterator: new PropertyIteratorClient(this._client, response.iterator) };
}
- return aResponse;
+ return response;
},
}),
/**
* Request a PropertyIteratorClient instance to enumerate entries in a
* Map/Set-like object.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
enumEntries: DebuggerClient.requester({
type: "enumEntries"
}, {
before: function (packet) {
if (!["Map", "WeakMap", "Set", "WeakSet"].includes(this._grip.class)) {
throw new Error("enumEntries is only valid for Map/Set-like grips.");
}
@@ -2558,84 +2601,84 @@ ObjectClient.prototype = {
}
return response;
}
}),
/**
* Request the property descriptor of the object's specified property.
*
- * @param aName string The name of the requested property.
- * @param aOnResponse function Called with the request's response.
+ * @param name string The name of the requested property.
+ * @param onResponse function Called with the request's response.
*/
getProperty: DebuggerClient.requester({
type: "property",
- name: args(0)
+ name: arg(0)
}),
/**
* Request the prototype of the object.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
getPrototype: DebuggerClient.requester({
type: "prototype"
}),
/**
* Request the display string of the object.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
getDisplayString: DebuggerClient.requester({
type: "displayString"
}),
/**
* Request the scope of the object.
*
- * @param aOnResponse function Called with the request's response.
+ * @param onResponse function Called with the request's response.
*/
getScope: DebuggerClient.requester({
type: "scope"
}, {
- before: function (aPacket) {
+ before: function (packet) {
if (this._grip.class !== "Function") {
throw new Error("scope is only valid for function grips.");
}
- return aPacket;
+ return packet;
},
}),
/**
* Request the promises directly depending on the current promise.
*/
getDependentPromises: DebuggerClient.requester({
type: "dependentPromises"
}, {
- before: function (aPacket) {
+ before: function (packet) {
if (this._grip.class !== "Promise") {
throw new Error("getDependentPromises is only valid for promise " +
"grips.");
}
- return aPacket;
+ return packet;
}
}),
/**
* Request the stack to the promise's allocation point.
*/
getPromiseAllocationStack: DebuggerClient.requester({
type: "allocationStack"
}, {
- before: function (aPacket) {
+ before: function (packet) {
if (this._grip.class !== "Promise") {
throw new Error("getAllocationStack is only valid for promise grips.");
}
- return aPacket;
+ return packet;
}
}),
/**
* Request the stack to the promise's fulfillment point.
*/
getPromiseFulfillmentStack: DebuggerClient.requester({
type: "fulfillmentStack"
@@ -2667,132 +2710,144 @@ ObjectClient.prototype = {
/**
* A PropertyIteratorClient provides a way to access to property names and
* values of an object efficiently, slice by slice.
* Note that the properties can be sorted in the backend,
* this is controled while creating the PropertyIteratorClient
* from ObjectClient.enumProperties.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aGrip Object
+ * @param grip Object
* A PropertyIteratorActor grip returned by the protocol via
* TabActor.enumProperties request.
*/
-function PropertyIteratorClient(aClient, aGrip) {
- this._grip = aGrip;
- this._client = aClient;
+function PropertyIteratorClient(client, grip) {
+ this._grip = grip;
+ this._client = client;
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
* indexes parameter.
*
* @param indexes Array
* An array of property indexes.
- * @param aCallback Function
+ * @param callback Function
* The function called when we receive the property names.
*/
names: DebuggerClient.requester({
type: "names",
- indexes: args(0)
+ indexes: arg(0)
}, {}),
/**
* Get a set of following property value(s).
*
* @param start Number
* The index of the first property to fetch.
* @param count Number
* The number of properties to fetch.
- * @param aCallback Function
+ * @param callback Function
* The function called when we receive the property values.
*/
slice: DebuggerClient.requester({
type: "slice",
- start: args(0),
- count: args(1)
+ start: arg(0),
+ count: arg(1)
}, {}),
/**
* Get all the property values.
*
- * @param aCallback Function
+ * @param callback Function
* The function called when we receive the property values.
*/
all: DebuggerClient.requester({
type: "all"
}, {}),
};
/**
* A LongStringClient provides a way to access "very long" strings from the
* debugger server.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aGrip Object
+ * @param grip Object
* A pause-lifetime long string grip returned by the protocol.
*/
-function LongStringClient(aClient, aGrip) {
- this._grip = aGrip;
- this._client = aClient;
+function LongStringClient(client, grip) {
+ this._grip = grip;
+ this._client = client;
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 aStart to aEnd.
+ * Get the substring of this LongString from start to end.
*
- * @param aStart Number
+ * @param start Number
* The starting index.
- * @param aEnd Number
+ * @param end Number
* The ending index.
- * @param aCallback Function
+ * @param callback Function
* The function called when we receive the substring.
*/
substring: DebuggerClient.requester({
type: "substring",
- start: args(0),
- end: args(1)
+ start: arg(0),
+ end: arg(1)
}),
};
/**
* A SourceClient provides a way to access the source text of a script.
*
- * @param aClient ThreadClient
+ * @param client ThreadClient
* The thread client parent.
- * @param aForm Object
+ * @param form Object
* The form sent across the remote debugging protocol.
*/
-function SourceClient(aClient, aForm) {
- this._form = aForm;
- this._isBlackBoxed = aForm.isBlackBoxed;
- this._isPrettyPrinted = aForm.isPrettyPrinted;
- this._activeThread = aClient;
- this._client = aClient.client;
+function SourceClient(client, form) {
+ this._form = form;
+ this._isBlackBoxed = form.isBlackBoxed;
+ this._isPrettyPrinted = form.isPrettyPrinted;
+ this._activeThread = client;
+ this._client = client.client;
}
SourceClient.prototype = {
get _transport() {
return this._client._transport;
},
get isBlackBoxed() {
return this._isBlackBoxed;
@@ -2808,57 +2863,57 @@ SourceClient.prototype = {
},
get url() {
return this._form.url;
},
/**
* Black box this SourceClient's source.
*
- * @param aCallback Function
+ * @param callback Function
* The callback function called when we receive the response from the server.
*/
blackBox: DebuggerClient.requester({
type: "blackbox"
}, {
- after: function (aResponse) {
- if (!aResponse.error) {
+ after: function (response) {
+ if (!response.error) {
this._isBlackBoxed = true;
if (this._activeThread) {
this._activeThread.emit("blackboxchange", this);
}
}
- return aResponse;
+ return response;
}
}),
/**
* Un-black box this SourceClient's source.
*
- * @param aCallback Function
+ * @param callback Function
* The callback function called when we receive the response from the server.
*/
unblackBox: DebuggerClient.requester({
type: "unblackbox"
}, {
- after: function (aResponse) {
- if (!aResponse.error) {
+ after: function (response) {
+ if (!response.error) {
this._isBlackBoxed = false;
if (this._activeThread) {
this._activeThread.emit("blackboxchange", this);
}
}
- return aResponse;
+ return response;
}
}),
/**
* Get Executable Lines from a source
*
- * @param aCallback Function
+ * @param callback Function
* The callback function called when we receive the response from the server.
*/
getExecutableLines: function (cb = noop) {
let packet = {
to: this._form.actor,
type: "getExecutableLines"
};
@@ -2866,202 +2921,206 @@ SourceClient.prototype = {
cb(res.lines);
return res.lines;
});
},
/**
* Get a long string grip for this SourceClient's source.
*/
- source: function (aCallback = noop) {
+ source: function (callback = noop) {
let packet = {
to: this._form.actor,
type: "source"
};
- return this._client.request(packet).then(aResponse => {
- return this._onSourceResponse(aResponse, aCallback);
+ return this._client.request(packet).then(response => {
+ return this._onSourceResponse(response, callback);
});
},
/**
* Pretty print this source's text.
*/
- prettyPrint: function (aIndent, aCallback = noop) {
+ prettyPrint: function (indent, callback = noop) {
const packet = {
to: this._form.actor,
type: "prettyPrint",
- indent: aIndent
+ indent
};
- return this._client.request(packet).then(aResponse => {
- if (!aResponse.error) {
+ return this._client.request(packet).then(response => {
+ if (!response.error) {
this._isPrettyPrinted = true;
this._activeThread._clearFrames();
this._activeThread.emit("prettyprintchange", this);
}
- return this._onSourceResponse(aResponse, aCallback);
+ return this._onSourceResponse(response, callback);
});
},
/**
* Stop pretty printing this source's text.
*/
- disablePrettyPrint: function (aCallback = noop) {
+ disablePrettyPrint: function (callback = noop) {
const packet = {
to: this._form.actor,
type: "disablePrettyPrint"
};
- return this._client.request(packet).then(aResponse => {
- if (!aResponse.error) {
+ return this._client.request(packet).then(response => {
+ if (!response.error) {
this._isPrettyPrinted = false;
this._activeThread._clearFrames();
this._activeThread.emit("prettyprintchange", this);
}
- return this._onSourceResponse(aResponse, aCallback);
+ return this._onSourceResponse(response, callback);
});
},
- _onSourceResponse: function (aResponse, aCallback) {
- if (aResponse.error) {
- aCallback(aResponse);
- return aResponse;
+ _onSourceResponse: function (response, callback) {
+ if (response.error) {
+ callback(response);
+ return response;
}
- if (typeof aResponse.source === "string") {
- aCallback(aResponse);
- return aResponse;
+ if (typeof response.source === "string") {
+ callback(response);
+ return response;
}
- let { contentType, source } = aResponse;
+ let { contentType, source } = response;
let longString = this._activeThread.threadLongString(source);
- return longString.substring(0, longString.length).then(function (aResponse) {
- if (aResponse.error) {
- aCallback(aResponse);
- return aReponse;
+ return longString.substring(0, longString.length).then(function (resp) {
+ if (resp.error) {
+ callback(resp);
+ return resp;
}
- let response = {
- source: aResponse.substring,
+ let newResponse = {
+ source: resp.substring,
contentType: contentType
};
- aCallback(response);
- return response;
+ callback(newResponse);
+ return newResponse;
});
},
/**
* Request to set a breakpoint in the specified location.
*
- * @param object aLocation
+ * @param object location
* The location and condition of the breakpoint in
* the form of { line[, column, condition] }.
- * @param function aOnResponse
+ * @param function onResponse
* Called with the thread's response.
*/
- setBreakpoint: function ({ line, column, condition, noSliding }, aOnResponse = noop) {
+ setBreakpoint: function ({ line, column, condition, noSliding }, onResponse = noop) {
// A helper function that sets the breakpoint.
- let doSetBreakpoint = aCallback => {
+ let doSetBreakpoint = callback => {
let root = this._client.mainRoot;
let location = {
- line: line,
- column: column
+ line,
+ column,
};
let packet = {
to: this.actor,
type: "setBreakpoint",
- location: location,
- condition: condition,
- noSliding: noSliding
+ location,
+ condition,
+ noSliding,
};
// Backwards compatibility: send the breakpoint request to the
// thread if the server doesn't support Debugger.Source actors.
if (!root.traits.debuggerSourceActors) {
packet.to = this._activeThread.actor;
packet.location.url = this.url;
}
- return this._client.request(packet).then(aResponse => {
+ return this._client.request(packet).then(response => {
// Ignoring errors, since the user may be setting a breakpoint in a
// dead script that will reappear on a page reload.
let bpClient;
- if (aResponse.actor) {
+ if (response.actor) {
bpClient = new BreakpointClient(
this._client,
this,
- aResponse.actor,
+ response.actor,
location,
root.traits.conditionalBreakpoints ? condition : undefined
);
}
- aOnResponse(aResponse, bpClient);
- if (aCallback) {
- aCallback();
+ onResponse(response, bpClient);
+ if (callback) {
+ callback();
}
- return [aResponse, bpClient];
+ return [response, bpClient];
});
};
// If the debuggee is paused, just set the breakpoint.
if (this._activeThread.paused) {
return doSetBreakpoint();
}
// Otherwise, force a pause in order to set the breakpoint.
- return this._activeThread.interrupt().then(aResponse => {
- if (aResponse.error) {
+ return this._activeThread.interrupt().then(response => {
+ if (response.error) {
// Can't set the breakpoint if pausing failed.
- aOnResponse(aResponse);
- return aResponse;
+ onResponse(response);
+ return response;
}
- const { type, why } = aResponse;
+ const { type, why } = response;
const cleanUp = type == "paused" && why.type == "interrupted"
? () => this._activeThread.resume()
: noop;
return doSetBreakpoint(cleanUp);
});
}
};
/**
* Breakpoint clients are used to remove breakpoints that are no longer used.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aSourceClient SourceClient
+ * @param sourceClient SourceClient
* The source where this breakpoint exists
- * @param aActor string
+ * @param actor string
* The actor ID for this breakpoint.
- * @param aLocation object
+ * @param location object
* The location of the breakpoint. This is an object with two properties:
* url and line.
- * @param aCondition string
+ * @param condition string
* The conditional expression of the breakpoint
*/
-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;
+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;
this.request = this._client.request;
// The condition property should only exist if it's a truthy value
- if (aCondition) {
- this.condition = aCondition;
+ if (condition) {
+ this.condition = condition;
}
}
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.
*/
remove: DebuggerClient.requester({
type: "delete"
}),
@@ -3069,117 +3128,116 @@ BreakpointClient.prototype = {
* Determines if this breakpoint has a condition
*/
hasCondition: function () {
let root = this._client.mainRoot;
// XXX bug 990137: We will remove support for client-side handling of
// conditional breakpoints
if (root.traits.conditionalBreakpoints) {
return "condition" in this;
- } else {
- return "conditionalExpression" in this;
}
+ return "conditionalExpression" in this;
},
/**
* Get the condition of this breakpoint. Currently we have to
* support locally emulated conditional breakpoints until the
* debugger servers are updated (see bug 990137). We used a
* different property when moving it server-side to ensure that we
* are testing the right code.
*/
getCondition: function () {
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, aCondition) {
+ setCondition: function (gThreadClient, condition) {
let root = this._client.mainRoot;
let deferred = promise.defer();
if (root.traits.conditionalBreakpoints) {
let info = {
line: this.location.line,
column: this.location.column,
- condition: aCondition
+ condition: condition
};
// Remove the current breakpoint and add a new one with the
// condition.
- this.remove(aResponse => {
- if (aResponse && aResponse.error) {
- deferred.reject(aResponse);
+ this.remove(response => {
+ if (response && response.error) {
+ deferred.reject(response);
return;
}
- this.source.setBreakpoint(info, (aResponse, aNewBreakpoint) => {
- if (aResponse && aResponse.error) {
- deferred.reject(aResponse);
+ this.source.setBreakpoint(info, (resp, newBreakpoint) => {
+ if (resp && resp.error) {
+ deferred.reject(resp);
} else {
- deferred.resolve(aNewBreakpoint);
+ deferred.resolve(newBreakpoint);
}
});
});
} else {
// The property shouldn't even exist if the condition is blank
- if (aCondition === "") {
+ if (condition === "") {
delete this.conditionalExpression;
- }
- else {
- this.conditionalExpression = aCondition;
+ } else {
+ this.conditionalExpression = condition;
}
deferred.resolve(this);
}
return deferred.promise;
}
};
eventSource(BreakpointClient.prototype);
/**
* Environment clients are used to manipulate the lexical environment actors.
*
- * @param aClient DebuggerClient
+ * @param client DebuggerClient
* The debugger client parent.
- * @param aForm Object
+ * @param form Object
* The form sent across the remote debugging protocol.
*/
-function EnvironmentClient(aClient, aForm) {
- this._client = aClient;
- this._form = aForm;
+function EnvironmentClient(client, form) {
+ this._client = client;
+ this._form = form;
this.request = this._client.request;
}
exports.EnvironmentClient = EnvironmentClient;
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.
*/
getBindings: DebuggerClient.requester({
type: "bindings"
}),
/**
* Changes the value of the identifier whose name is name (a string) to that
* represented by value (a grip).
*/
assign: DebuggerClient.requester({
type: "assign",
- name: args(0),
- value: args(1)
+ name: arg(0),
+ value: arg(1)
})
};
eventSource(EnvironmentClient.prototype);
--- a/devtools/shared/discovery/discovery.js
+++ b/devtools/shared/discovery/discovery.js
@@ -42,18 +42,18 @@ const UDPSocket = CC("@mozilla.org/netwo
const SCAN_PORT = 50624;
const UPDATE_PORT = 50625;
const ADDRESS = "224.0.0.115";
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;
});
XPCOMUtils.defineLazyGetter(this, "sysInfo", () => {
return Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
});
@@ -72,17 +72,18 @@ function log(msg) {
/**
* Each Transport instance owns a single UDPSocket.
* @param port integer
* The port to listen on for incoming UDP multicast packets.
*/
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) {
log("Failed to start new socket: " + e);
}
}
Transport.prototype = {
@@ -141,17 +142,18 @@ Transport.prototype = {
*/
function LocalDevice() {
this._name = LocalDevice.UNKNOWN;
if ("@mozilla.org/settingsService;1" in Cc) {
this._settings =
Cc["@mozilla.org/settingsService;1"].getService(Ci.nsISettingsService);
Services.obs.addObserver(this, "mozsettings-changed", false);
}
- this._get(); // Trigger |_get| to load name eagerly
+ // Trigger |_get| to load name eagerly
+ this._get();
}
LocalDevice.SETTING = "devtools.discovery.device";
LocalDevice.UNKNOWN = "unknown";
LocalDevice.prototype = {
_get: function () {
@@ -339,44 +341,48 @@ Discovery.prototype = {
},
get Transport() {
return this._factories.Transport;
},
_startListeningForScan: function () {
if (this._transports.scan) {
- return; // Already listening
+ // Already listening
+ return;
}
log("LISTEN FOR SCAN");
this._transports.scan = new this.Transport(SCAN_PORT);
this._transports.scan.on("message", this._onRemoteScan);
},
_stopListeningForScan: function () {
if (!this._transports.scan) {
- return; // Not listening
+ // Not listening
+ return;
}
this._transports.scan.off("message", this._onRemoteScan);
this._transports.scan.destroy();
this._transports.scan = null;
},
_startListeningForUpdate: function () {
if (this._transports.update) {
- return; // Already listening
+ // Already listening
+ return;
}
log("LISTEN FOR UPDATE");
this._transports.update = new this.Transport(UPDATE_PORT);
this._transports.update.on("message", this._onRemoteUpdate);
},
_stopListeningForUpdate: function () {
if (!this._transports.update) {
- return; // Not listening
+ // Not listening
+ return;
}
this._transports.update.off("message", this._onRemoteUpdate);
this._transports.update.destroy();
this._transports.update = null;
},
_restartListening: function () {
if (this._transports.scan) {
new file mode 100644
--- /dev/null
+++ b/devtools/shared/discovery/tests/unit/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../.eslintrc.xpcshell.js"
+};
\ No newline at end of file
--- a/devtools/shared/discovery/tests/unit/test_discovery.js
+++ b/devtools/shared/discovery/tests/unit/test_discovery.js
@@ -3,17 +3,16 @@
"use strict";
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");
const { setTimeout, clearTimeout } = require("sdk/timers");
Services.prefs.setBoolPref("devtools.discovery.log", true);
do_register_cleanup(() => {
--- a/devtools/shared/performance/recording-common.js
+++ b/devtools/shared/performance/recording-common.js
@@ -4,17 +4,17 @@
"use strict";
/**
* A mixin to be used for PerformanceRecordingActor, PerformanceRecordingFront,
* and LegacyPerformanceRecording for helper methods to access data.
*/
-const PerformanceRecordingCommon = exports.PerformanceRecordingCommon = {
+exports.PerformanceRecordingCommon = {
// Private fields, only needed when a recording is started or stopped.
_console: false,
_imported: false,
_recording: false,
_completed: false,
_configuration: {},
_startingBufferStatus: null,
_localStartTime: 0,
@@ -30,68 +30,112 @@ const PerformanceRecordingCommon = expor
_profile: null,
_systemHost: null,
_systemClient: null,
/**
* 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.
* @return number
*/
getDuration: function () {
// Compute an approximate ending time for the current recording if it is
// still in progress. This is needed to ensure that the view updates even
// when new data is not being generated. If recording is completed, use
// the duration from the profiler; if between recording and being finalized,
// use the last estimated duration.
if (this.isRecording()) {
- return this._estimatedDuration = Date.now() - this._localStartTime;
- } else {
- return this._duration || this._estimatedDuration || 0;
+ this._estimatedDuration = Date.now() - this._localStartTime;
+ return this._estimatedDuration;
}
+ 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();
let duration = this.getDuration();
let markers = this.getMarkers();
let frames = this.getFrames();
let memory = this.getMemory();
let ticks = this.getTicks();
let allocations = this.getAllocations();
let profile = this.getProfile();
let configuration = this.getConfiguration();
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
+ };
},
};
--- a/devtools/shared/performance/recording-utils.js
+++ b/devtools/shared/performance/recording-utils.js
@@ -1,27 +1,27 @@
/* 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/. */
"use strict";
-const { Cc, Ci, Cu, Cr } = require("chrome");
loader.lazyRequireGetter(this, "extend",
"sdk/util/object", true);
/**
* Utility functions for managing recording models and their internal data,
* such as filtering profile samples or offsetting timestamps.
*/
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
};
}
if (type === "memory") {
return {
probability: options.allocationsSampleProbability,
maxLogLength: options.allocationsMaxLogLength
};
@@ -563,17 +563,18 @@ UniqueStacks.prototype.getOrAddFrameInde
let frameHash = this._frameHash;
let frameTable = this._frameTable;
let locationIndex = this.getOrAddStringIndex(frame.location);
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) {
return index;
}
index = frameTable.length;
frameHash[hash] = index;
new file mode 100644
--- /dev/null
+++ b/devtools/shared/performance/test/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../.eslintrc.xpcshell.js"
+};
\ No newline at end of file
--- a/devtools/shared/performance/test/head.js
+++ b/devtools/shared/performance/test/head.js
@@ -1,7 +1,10 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* exported require */
+
"use strict";
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
+var { utils: Cu } = Components;
var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
--- 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,11 +1,13 @@
/* 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
* received from the profiler.
*/
function run_test() {
run_next_test();
@@ -60,19 +62,25 @@ var EXPECTED_OUTPUT = {
},
stackTable: {
"schema": {
"prefix": 0,
"frame": 1
},
"data": [
null,
- [ 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
+
+ // 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 ]
]
},
frameTable: {
"schema": {
"location": 0,
"implementation": 1,
"optimizations": 2,
"line": 3,
--- a/devtools/shared/qrcode/index.js
+++ b/devtools/shared/qrcode/index.js
@@ -1,15 +1,14 @@
/* 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/. */
"use strict";
-const { Cu } = require("chrome");
const promise = require("promise");
const defer = require("devtools/shared/defer");
// Lazily require encoder and decoder in case only one is needed
Object.defineProperty(this, "Encoder", {
get: () => require("./encoder/index").Encoder
});
Object.defineProperty(this, "QRRSBlock", {
new file mode 100644
--- /dev/null
+++ b/devtools/shared/qrcode/tests/unit/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../.eslintrc.xpcshell.js"
+};
\ No newline at end of file
--- a/devtools/shared/security/auth.js
+++ b/devtools/shared/security/auth.js
@@ -3,17 +3,16 @@
/* 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/. */
"use strict";
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;
loader.lazyRequireGetter(this, "prompt",
"devtools/shared/security/prompt");
loader.lazyRequireGetter(this, "cert",
"devtools/shared/security/cert");
loader.lazyRequireGetter(this, "asyncStorage",
@@ -403,17 +402,18 @@ OOBCert.Client.prototype = {
let clientCert = yield cert.local.getOrCreate();
return {
sha256: clientCert.sha256Fingerprint,
k: this._createRandom()
};
}),
_createRandom() {
- const length = 16; // 16 bytes / 128 bits
+ // 16 bytes / 128 bits
+ const length = 16;
let rng = Cc["@mozilla.org/security/random-generator;1"]
.createInstance(Ci.nsIRandomGenerator);
let bytes = rng.generateRandomBytes(length);
return bytes.map(byte => byte.toString(16)).join("");
},
/**
* Send data across the OOB channel to the server to authenticate the devices.
@@ -540,19 +540,21 @@ OOBCert.Server.prototype = {
authentication: this.mode,
client,
server
});
switch (authResult) {
case AuthenticationResult.ALLOW_PERSIST:
case AuthenticationResult.ALLOW:
- break; // Further processing
+ // Further processing
+ break;
default:
- return authResult; // Abort for any negative results
+ // Abort for any negative results
+ return authResult;
}
// Examine additional data for authentication
let oob = yield this.receiveOOB();
if (!oob) {
dumpn("Invalid OOB data received");
return AuthenticationResult.DENY;
}
--- a/devtools/shared/security/cert.js
+++ b/devtools/shared/security/cert.js
@@ -2,17 +2,16 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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/. */
"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", () => {
// Ensure PSM is initialized to support TLS sockets
Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports);
return Cc["@mozilla.org/security/local-cert-service;1"]
.getService(Ci.nsILocalCertService);
});
--- a/devtools/shared/security/socket.js
+++ b/devtools/shared/security/socket.js
@@ -1,17 +1,17 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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/. */
"use strict";
-var { Ci, Cc, CC, Cr, Cu } = require("chrome");
+var { Ci, Cc, CC, Cr } = require("chrome");
// Ensure PSM is initialized to support TLS sockets
Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports);
var Services = require("Services");
var promise = require("promise");
var defer = require("devtools/shared/defer");
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
@@ -138,30 +138,32 @@ var _getTransport = Task.async(function*
s.onerror = err => reject(err);
});
return new WebSocketDebuggerTransport(socket);
}
let attempt = yield _attemptTransport(settings);
if (attempt.transport) {
- return attempt.transport; // Success
+ // Success
+ return attempt.transport;
}
// If the server cert failed validation, store a temporary override and make
// a second attempt.
if (encryption && attempt.certError) {
_storeCertOverride(attempt.s, host, port);
} else {
throw new Error("Connection failed");
}
attempt = yield _attemptTransport(settings);
if (attempt.transport) {
- return attempt.transport; // Success
+ // Success
+ return attempt.transport;
}
throw new Error("Connection failed even after cert override");
});
/**
* Make a single attempt to connect and create a DevTools transport. This could
* fail if the remote host is unreachable, for example. If there is security
@@ -351,17 +353,17 @@ function _isInputAlive(input) {
* these connections.
*/
function _storeCertOverride(s, host, port) {
let cert = s.securityInfo.QueryInterface(Ci.nsISSLStatusProvider)
.SSLStatus.serverCert;
let overrideBits = Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(host, port, cert, overrideBits,
- true /* temporary */);
+ true /* temporary */); // eslint-disable-line
}
/**
* Creates a new socket listener for remote connections to the DebuggerServer.
* This helps contain and organize the parts of the server that may differ or
* are particular to one given listener mechanism vs. another.
*/
function SocketListener() {}
new file mode 100644
--- /dev/null
+++ b/devtools/shared/security/tests/chrome/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../../testing/mochitest/chrome.eslintrc.js"
+};
--- a/devtools/shared/security/tests/chrome/test_websocket-transport.html
+++ b/devtools/shared/security/tests/chrome/test_websocket-transport.html
@@ -4,17 +4,19 @@
<meta charset="utf-8">
<title>Test the WebSocket debugger transport</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<script>
-window.onload = function() {
+"use strict";
+
+window.onload = function () {
const {require} = Components.utils.import("resource://devtools/shared/Loader.jsm", {});
const Services = require("Services");
const {DebuggerClient} = require("devtools/shared/client/main");
const {DebuggerServer} = require("devtools/server/main");
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
Services.prefs.setBoolPref("devtools.debugger.prompt-connection", false);
@@ -42,17 +44,17 @@ window.onload = function() {
host: "127.0.0.1",
port: listener.port,
webSocket: true
});
ok(transport, "Client transport created");
let client = new DebuggerClient(transport);
let onUnexpectedClose = () => {
- do_throw("Closed unexpectedly");
+ ok(false, "Closed unexpectedly");
};
client.addListener("closed", onUnexpectedClose);
yield client.connect();
yield client.listTabs();
// Send a message the server that will echo back
let message = "message";
@@ -65,12 +67,12 @@ window.onload = function() {
client.removeListener("closed", onUnexpectedClose);
transport.close();
listener.close();
is(DebuggerServer.listeningSockets, 0, "0 listening sockets");
DebuggerServer.destroy();
});
-}
+};
</script>
</body>
</html>
--- a/devtools/shared/security/tests/unit/head_dbg.js
+++ b/devtools/shared/security/tests/unit/head_dbg.js
@@ -1,88 +1,82 @@
/* Any copyright is dedicated to the Public Domain.
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");
// We do not want to log packets by default, because in some tests,
// we can be sending large amounts of data. The test harness has
// trouble dealing with logging all the data, and we end up with
// intermittent time outs (e.g. bug 775924).
// Services.prefs.setBoolPref("devtools.debugger.log", true);
// Services.prefs.setBoolPref("devtools.debugger.log.verbose", true);
// Enable remote debugging for the relevant tests.
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 'aFlags' value into an appropriate string.
-function scriptErrorFlagsToKind(aFlags) {
- var kind;
- if (aFlags & Ci.nsIScriptError.warningFlag)
+// Convert an nsIScriptError 'flags' value into an appropriate string.
+function scriptErrorFlagsToKind(flags) {
+ let kind;
+ if (flags & Ci.nsIScriptError.warningFlag) {
kind = "warning";
- if (aFlags & Ci.nsIScriptError.exceptionFlag)
+ }
+ if (flags & Ci.nsIScriptError.exceptionFlag) {
kind = "exception";
- else
+ } else {
kind = "error";
+ }
- if (aFlags & Ci.nsIScriptError.strictFlag)
+ if (flags & Ci.nsIScriptError.strictFlag) {
kind = "strict " + kind;
+ }
return kind;
}
// Register a console listener, so console messages don't just disappear
// into the ether.
-var errorCount = 0;
var listener = {
- observe: function (aMessage) {
- errorCount++;
+ observe: function (message) {
+ let string;
try {
- // If we've been given an nsIScriptError, then we can print out
- // something nicely formatted, for tools like Emacs to pick up.
- var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
- dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
- scriptErrorFlagsToKind(aMessage.flags) + ": " +
- aMessage.errorMessage + "\n");
- var string = aMessage.errorMessage;
- } catch (x) {
+ message.QueryInterface(Ci.nsIScriptError);
+ dump(message.sourceName + ":" + message.lineNumber + ": " +
+ scriptErrorFlagsToKind(message.flags) + ": " +
+ message.errorMessage + "\n");
+ string = message.errorMessage;
+ } catch (ex) {
// Be a little paranoid with message, as the whole goal here is to lose
// no information.
try {
- var string = "" + aMessage.message;
- } catch (x) {
- var string = "<error converting error message to string>";
+ string = "" + message.message;
+ } catch (e) {
+ string = "<error converting error message to string>";
}
}
// Make sure we exit all nested event loops so that the test can finish.
while (xpcInspector.eventLoopNestLevel > 0) {
xpcInspector.exitNestedEventLoop();
}
// Print in most cases, but ignore the "strict" messages
- if (!(aMessage.flags & Ci.nsIScriptError.strictFlag)) {
+ if (!(message.flags & Ci.nsIScriptError.strictFlag)) {
do_print("head_dbg.js got console message: " + string + "\n");
}
}
};
var consoleService = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
consoleService.registerListener(listener);
--- a/devtools/shared/security/tests/unit/test_oob_cert_auth.js
+++ b/devtools/shared/security/tests/unit/test_oob_cert_auth.js
@@ -33,17 +33,18 @@ add_task(function* () {
let serverCert = yield cert.local.getOrCreate();
let oobData = defer();
let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT");
let serverAuth = new AuthenticatorType.Server();
serverAuth.allowConnection = () => {
return DebuggerServer.AuthenticationResult.ALLOW;
};
- serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests
+ // Skip prompt for tests
+ serverAuth.receiveOOB = () => oobData.promise;
let listener = DebuggerServer.createListener();
ok(listener, "Socket listener created");
listener.portOrPath = -1;
listener.encryption = true;
listener.authenticator = serverAuth;
yield listener.open();
equal(DebuggerServer.listeningSockets, 1, "1 listening socket");
@@ -93,17 +94,18 @@ add_task(function* () {
equal(DebuggerServer.listeningSockets, 0, "0 listening sockets");
let oobData = defer();
let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT");
let serverAuth = new AuthenticatorType.Server();
serverAuth.allowConnection = () => {
return DebuggerServer.AuthenticationResult.ALLOW;
};
- serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests
+ // Skip prompt for tests
+ serverAuth.receiveOOB = () => oobData.promise;
let listener = DebuggerServer.createListener();
ok(listener, "Socket listener created");
listener.portOrPath = -1;
listener.encryption = true;
listener.authenticator = serverAuth;
yield listener.open();
equal(DebuggerServer.listeningSockets, 1, "1 listening socket");
@@ -156,17 +158,18 @@ add_task(function* () {
let serverCert = yield cert.local.getOrCreate();
let oobData = defer();
let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT");
let serverAuth = new AuthenticatorType.Server();
serverAuth.allowConnection = () => {
return DebuggerServer.AuthenticationResult.ALLOW;
};
- serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests
+ // Skip prompt for tests
+ serverAuth.receiveOOB = () => oobData.promise;
let clientAuth = new AuthenticatorType.Client();
clientAuth.sendOOB = ({ oob }) => {
do_print(oob);
do_print("Modifying K value, should fail");
// Pass to server, skipping prompt for tests
oobData.resolve({
k: oob.k + 1,
@@ -210,17 +213,18 @@ add_task(function* () {
let serverCert = yield cert.local.getOrCreate();
let oobData = defer();
let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT");
let serverAuth = new AuthenticatorType.Server();
serverAuth.allowConnection = () => {
return DebuggerServer.AuthenticationResult.ALLOW;
};
- serverAuth.receiveOOB = () => oobData.promise; // Skip prompt for tests
+ // Skip prompt for tests
+ serverAuth.receiveOOB = () => oobData.promise;
let clientAuth = new AuthenticatorType.Client();
clientAuth.sendOOB = ({ oob }) => {
do_print(oob);
do_print("Modifying cert hash, should fail");
// Pass to server, skipping prompt for tests
oobData.resolve({
k: oob.k,
--- a/devtools/shared/security/tests/unit/testactors.js
+++ b/devtools/shared/security/tests/unit/testactors.js
@@ -1,72 +1,74 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
const { ActorPool, appendExtraActors, createExtraActors } =
require("devtools/server/actors/common");
const { RootActor } = require("devtools/server/actors/root");
const { ThreadActor } = require("devtools/server/actors/script");
const { DebuggerServer } = require("devtools/server/main");
const promise = require("promise");
var gTestGlobals = [];
-DebuggerServer.addTestGlobal = function (aGlobal) {
- gTestGlobals.push(aGlobal);
+DebuggerServer.addTestGlobal = function (global) {
+ gTestGlobals.push(global);
};
// A mock tab list, for use by tests. This simply presents each global in
// gTestGlobals as a tab, and the list is fixed: it never calls its
// onListChanged handler.
//
// As implemented now, we consult gTestGlobals when we're constructed, not
// when we're iterated over, so tests have to add their globals before the
// root actor is created.
-function TestTabList(aConnection) {
- this.conn = aConnection;
+function TestTabList(connection) {
+ this.conn = connection;
// An array of actors for each global added with
// DebuggerServer.addTestGlobal.
this._tabActors = [];
// A pool mapping those actors' names to the actors.
- this._tabActorPool = new ActorPool(aConnection);
+ this._tabActorPool = new ActorPool(connection);
for (let global of gTestGlobals) {
- let actor = new TestTabActor(aConnection, global);
+ let actor = new TestTabActor(connection, global);
actor.selected = false;
this._tabActors.push(actor);
this._tabActorPool.addActor(actor);
}
if (this._tabActors.length > 0) {
this._tabActors[0].selected = true;
}
- aConnection.addActorPool(this._tabActorPool);
+ connection.addActorPool(this._tabActorPool);
}
TestTabList.prototype = {
constructor: TestTabList,
getList: function () {
return promise.resolve([...this._tabActors]);
}
};
-function createRootActor(aConnection) {
- let root = new RootActor(aConnection, {
- tabList: new TestTabList(aConnection),
+function createRootActor(connection) {
+ let root = new RootActor(connection, {
+ tabList: new TestTabList(connection),
globalActorFactories: DebuggerServer.globalActorFactories
});
root.applicationType = "xpcshell-tests";
return root;
}
-function TestTabActor(aConnection, aGlobal) {
- this.conn = aConnection;
- this._global = aGlobal;
+function TestTabActor(connection, global) {
+ this.conn = connection;
+ this._global = global;
this._threadActor = new ThreadActor(this, this._global);
this.conn.addActor(this._threadActor);
this._attached = false;
this._extraActors = {};
}
TestTabActor.prototype = {
constructor: TestTabActor,
@@ -91,28 +93,28 @@ TestTabActor.prototype = {
this.conn.addActorPool(this._tabActorPool);
}
this._appendExtraActors(response);
return response;
},
- onAttach: function (aRequest) {
+ onAttach: function (request) {
this._attached = true;
let response = { type: "tabAttached", threadActor: this._threadActor.actorID };
this._appendExtraActors(response);
return response;
},
- onDetach: function (aRequest) {
+ onDetach: function (request) {
if (!this._attached) {
- return { "error":"wrongState" };
+ return { "error": "wrongState" };
}
return { type: "detached" };
},
/* Support for DebuggerServer.addTabActor. */
_createExtraActors: createExtraActors,
_appendExtraActors: appendExtraActors
};
--- a/devtools/shared/shims/event-emitter.js
+++ b/devtools/shared/shims/event-emitter.js
@@ -4,20 +4,23 @@
"use strict";
/**
* This file only exists to support add-ons which import this module at a
* 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", {});
this.isWorker = false;
this.promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
factory.call(this, require, this, { exports: this });
this.EXPORTED_SYMBOLS = ["EventEmitter"];
}
--- a/devtools/shared/tests/browser/browser_async_storage.js
+++ b/devtools/shared/tests/browser/browser_async_storage.js
@@ -25,17 +25,17 @@ add_task(function* () {
value = yield asyncStorage.getItem("foo");
is(value, "overwritten", "value is correct");
yield asyncStorage.removeItem("foo");
value = yield asyncStorage.getItem("foo");
is(value, null, "value is correct");
});
add_task(function* () {
- var object = {
+ let object = {
x: 1,
y: "foo",
z: true
};
yield asyncStorage.setItem("myobj", object);
let value = yield asyncStorage.getItem("myobj");
is(object.x, value.x, "value is correct");
--- a/devtools/shared/tests/unit/exposeLoader.js
+++ b/devtools/shared/tests/unit/exposeLoader.js
@@ -1,8 +1,10 @@
/* 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);
return o;
};
--- a/devtools/shared/tests/unit/head_devtools.js
+++ b/devtools/shared/tests/unit/head_devtools.js
@@ -1,52 +1,48 @@
/* 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 {require, DevToolsLoader, devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+const { require, DevToolsLoader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const flags = require("devtools/shared/flags");
flags.testing = true;
do_register_cleanup(() => {
flags.testing = false;
});
// Register a console listener, so console messages don't just disappear
// into the ether.
// If for whatever reason the test needs to post console errors that aren't
// failures, set this to true.
var ALLOW_CONSOLE_ERRORS = false;
-var errorCount = 0;
var listener = {
- observe: function (aMessage) {
- errorCount++;
+ observe: function (message) {
+ let string;
try {
- // If we've been given an nsIScriptError, then we can print out
- // something nicely formatted, for tools like Emacs to pick up.
- var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
- dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
- scriptErrorFlagsToKind(aMessage.flags) + ": " +
- aMessage.errorMessage + "\n");
- var string = aMessage.errorMessage;
- } catch (x) {
+ message.QueryInterface(Ci.nsIScriptError);
+ dump(message.sourceName + ":" + message.lineNumber + ": " +
+ scriptErrorFlagsToKind(message.flags) + ": " +
+ message.errorMessage + "\n");
+ string = message.errorMessage;
+ } catch (ex) {
// Be a little paranoid with message, as the whole goal here is to lose
// no information.
try {
- var string = "" + aMessage.message;
- } catch (x) {
- var string = "<error converting error message to string>";
+ string = "" + message.message;
+ } catch (e) {
+ string = "<error converting error message to string>";
}
}
// Make sure we exit all nested event loops so that the test can finish.
while (DebuggerServer.xpcInspector.eventLoopNestLevel > 0) {
DebuggerServer.xpcInspector.exitNestedEventLoop();
}
--- a/devtools/shared/tests/unit/test_assert.js
+++ b/devtools/shared/tests/unit/test_assert.js
@@ -1,12 +1,14 @@
/* -*- 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.assert
ALLOW_CONSOLE_ERRORS = true;
function run_test() {
// Enable assertions.
flags.testing = true;
@@ -27,10 +29,11 @@ function run_test() {
assert(false, "this assertion should fail");
} catch (e) {
ok(e.message.startsWith("Assertion failure:"),
"Should be an assertion failure error");
assertionFailed = true;
}
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.");
}
--- a/devtools/shared/tests/unit/test_async-utils.js
+++ b/devtools/shared/tests/unit/test_async-utils.js
@@ -1,12 +1,14 @@
/* -*- 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 async-utils.js
const {Task} = require("devtools/shared/task");
// |const| will not work because
// it will make the Promise object immutable before assigning.
// Using Object.defineProperty() instead.
Object.defineProperty(this, "Promise", {
value: require("promise"),
@@ -55,22 +57,23 @@ function test_async_return(async) {
do_check_eq(ret, "foobar");
});
}
// Test that the throwing from an async function rejects the promise.
function test_async_throw(async) {
let obj = {
method: async(function* () {
- throw "boom";
+ throw new Error("boom");
})
};
return obj.method().then(null, error => {
- do_check_eq(error, "boom");
+ do_check_true(error instanceof Error);
+ do_check_eq(error.message, "boom");
});
}
// Test that asyncOnce only runs the async function once per instance and
// returns the same promise for that instance.
function test_async_once() {
let counter = 0;
@@ -111,47 +114,44 @@ function test_async_once() {
do_check_eq(ret, 1);
});
}
// Test invoke and call.
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);
callback(a + b);
}
// Test call.
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");
}
let results = yield promiseCall(multipleResults);
do_check_eq(results.length, 2);
do_check_eq(results[0], "foo");
do_check_eq(results[1], "bar");
-
// Test throwing from the function.
function thrower() {
- throw "boom";
+ throw new Error("boom");
}
yield promiseCall(thrower).then(null, error => {
- do_check_eq(error, "boom");
+ do_check_true(error instanceof Error);
+ do_check_eq(error.message, "boom");
});
});
}
--- a/devtools/shared/tests/unit/test_console_filtering.js
+++ b/devtools/shared/tests/unit/test_console_filtering.js
@@ -6,29 +6,29 @@
const { console, ConsoleAPI } = require("resource://gre/modules/Console.jsm");
const { ConsoleAPIListener } = require("devtools/server/actors/utils/webconsole-listeners");
const Services = require("Services");
var seenMessages = 0;
var seenTypes = 0;
var callback = {
- 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");
+ 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");
seenTypes |= 1;
- } else if (aMessage.originAttributes &&
- aMessage.originAttributes.addonId == "bar") {
- do_check_eq(aMessage.level, "error");
- do_check_eq(aMessage.arguments[0], "Error from bar");
+ } else if (message.originAttributes &&
+ message.originAttributes.addonId == "bar") {
+ do_check_eq(message.level, "error");
+ do_check_eq(message.arguments[0], "Error from bar");
seenTypes |= 2;
} else {
- do_check_eq(aMessage.level, "log");
- do_check_eq(aMessage.arguments[0], "Hello from default console");
+ do_check_eq(message.level, "log");
+ do_check_eq(message.arguments[0], "Hello from default console");
seenTypes |= 4;
}
seenMessages++;
}
};
function createFakeAddonWindow({addonId} = {}) {
let baseURI = Services.io.newURI("about:blank", null, null);
--- a/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js
+++ b/devtools/shared/tests/unit/test_defineLazyPrototypeGetter.js
@@ -1,18 +1,18 @@
-/* -*- 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();
test_multiple_instances();
test_callback_receiver();
}
function test_prototype_attributes() {
--- a/devtools/shared/tests/unit/test_executeSoon.js
+++ b/devtools/shared/tests/unit/test_executeSoon.js
@@ -6,17 +6,16 @@
/**
* Client request stacks should span the entire process from before making the
* request to handling the reply from the server. The server frames are not
* included, nor can they be in most cases, since the server can be a remote
* device.
*/
var { executeSoon } = require("devtools/shared/DevToolsUtils");
-var promise = require("promise");
var defer = require("devtools/shared/defer");
var Services = require("Services");
var asyncStackEnabled =
Services.prefs.getBoolPref("javascript.options.asyncstack");
do_register_cleanup(() => {
Services.prefs.setBoolPref("javascript.options.asyncstack",
--- a/devtools/shared/tests/unit/test_flatten.js
+++ b/devtools/shared/tests/unit/test_flatten.js
@@ -1,12 +1,14 @@
/* -*- 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 ThreadSafeDevToolsUtils.flatten
function run_test() {
const { flatten } = DevToolsUtils;
const flat = flatten([["a", "b", "c"],
["d", "e", "f"],
["g", "h", "i"]]);
--- a/devtools/shared/tests/unit/test_independent_loaders.js
+++ b/devtools/shared/tests/unit/test_independent_loaders.js
@@ -1,11 +1,13 @@
/* 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
* in place between loaders.
*/
function run_test() {
let loader1 = new DevToolsLoader();
let loader2 = new DevToolsLoader();
--- a/devtools/shared/tests/unit/test_isSet.js
+++ b/devtools/shared/tests/unit/test_isSet.js
@@ -1,12 +1,14 @@
/* -*- 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 ThreadSafeDevToolsUtils.isSet
function run_test() {
const { isSet } = DevToolsUtils;
equal(isSet(new Set()), true);
equal(isSet(new Map()), false);
equal(isSet({}), false);
--- a/devtools/shared/tests/unit/test_require.js
+++ b/devtools/shared/tests/unit/test_require.js
@@ -1,11 +1,13 @@
/* 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
// loader/modules when early cached
function testBug1091706() {
let loader = new DevToolsLoader();
let require = loader.require;
--- a/devtools/shared/tests/unit/test_require_lazy.js
+++ b/devtools/shared/tests/unit/test_require_lazy.js
@@ -1,11 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
// Test devtools.lazyRequireGetter
function run_test() {
const name = "asyncUtils";
const path = "devtools/shared/async-utils";
const o = {};
devtools.lazyRequireGetter(o, name, path);
const asyncUtils = require(path);
@@ -13,17 +16,18 @@ function run_test() {
// do_check_true of an equality expression.
do_check_true(o.asyncUtils === asyncUtils);
// A non-main loader should get a new object via |lazyRequireGetter|, just
// as it would via a direct |require|.
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);
do_check_true(o2.asyncUtils !== asyncUtils);
// A module required via a non-main loader that then uses |lazyRequireGetter|
// should also get the same object from that non-main loader.
let exposeLoader = loader.require("xpcshell-test/exposeLoader");
--- a/devtools/shared/tests/unit/test_require_raw.js
+++ b/devtools/shared/tests/unit/test_require_raw.js
@@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
// Test require using "raw!".
function run_test() {
let loader = new DevToolsLoader();
let require = loader.require;
let variableFileContents = require("raw!devtools/client/themes/variables.css");
ok(variableFileContents.length > 0, "raw browserRequire worked");
--- a/devtools/shared/tests/unit/test_safeErrorString.js
+++ b/devtools/shared/tests/unit/test_safeErrorString.js
@@ -1,12 +1,14 @@
/* -*- 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.safeErrorString
function run_test() {
test_with_error();
test_with_tricky_error();
test_with_string();
test_with_thrower();
test_with_psychotic();
--- a/devtools/shared/tests/unit/test_stack.js
+++ b/devtools/shared/tests/unit/test_stack.js
@@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
// Test stack.js.
function run_test() {
let loader = new DevToolsLoader();
let require = loader.require;
const {StackFrameCache} = require("devtools/server/actors/utils/stack");
--- a/devtools/shared/touch/simulator-content.js
+++ b/devtools/shared/touch/simulator-content.js
@@ -1,12 +1,12 @@
/* 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 */
+ /* globals addMessageListener, sendAsyncMessage, docShell */
"use strict";
const { utils: Cu } = Components;
const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
const { SimulatorCore } = require("devtools/shared/touch/simulator-core");
/**
* Launches SimulatorCore in the content window to simulate touch events
--- a/devtools/shared/touch/simulator-core.js
+++ b/devtools/shared/touch/simulator-core.js
@@ -1,11 +1,14 @@
/* 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");
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
var systemAppOrigin = (function () {
let systemOrigin = "_";
try {
@@ -267,22 +270,24 @@ SimulatorCore.prototype = {
} else if (name == "touchend") {
// If we have a "fast" tap, don't send a click as both will be turned
// into a click and that breaks eg. checkboxes.
if (Date.now() - this.touchstartTime < delay) {
this.cancelClick = true;
}
}
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;
let content = this.getContent(target);
if (!content) {
return;
}
@@ -334,33 +339,34 @@ SimulatorCore.prototype = {
let content = this.getContent(evt.target);
if (!content) {
return 0;
}
let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
- let allowZoom = {},
- minZoom = {},
- maxZoom = {},
- autoSize = {};
+ let allowZoom = {};
+ let minZoom = {};
+ let maxZoom = {};
+ let autoSize = {};
utils.getViewportInfo(content.innerWidth, content.innerHeight, {},
allowZoom, minZoom, maxZoom, {}, {}, autoSize);
// FIXME: On Safari and Chrome mobile platform, if the css property
// touch-action set to none or manipulation would also suppress 300ms
// 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;
}
};
exports.SimulatorCore = SimulatorCore;