--- a/.eslintignore
+++ b/.eslintignore
@@ -122,21 +122,16 @@ devtools/client/webaudioeditor/**
devtools/client/webconsole/net/**
devtools/client/webconsole/test/**
devtools/client/webconsole/console-output.js
devtools/client/webconsole/hudservice.js
devtools/client/webconsole/webconsole-connection-proxy.js
devtools/client/webconsole/webconsole.js
devtools/client/webide/**
!devtools/client/webide/components/webideCli.js
-devtools/server/actors/webconsole.js
-devtools/server/actors/object.js
-devtools/server/actors/script.js
-devtools/server/actors/styleeditor.js
-devtools/server/actors/stylesheets.js
devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html
devtools/server/tests/unit/xpcshell_debugging_script.js
devtools/shared/platform/content/test/test_clipboard.html
devtools/shared/qrcode/tests/mochitest/test_decode.html
devtools/shared/tests/mochitest/*.html
devtools/shared/webconsole/test/test_*.html
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -10,18 +10,18 @@ const { Cu, Ci } = require("chrome");
const { GeneratedLocation } = require("devtools/server/actors/common");
const { DebuggerServer } = require("devtools/server/main");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const { assert, dumpn } = DevToolsUtils;
loader.lazyRequireGetter(this, "ThreadSafeChromeUtils");
const TYPED_ARRAY_CLASSES = ["Uint8Array", "Uint8ClampedArray", "Uint16Array",
- "Uint32Array", "Int8Array", "Int16Array", "Int32Array", "Float32Array",
- "Float64Array"];
+ "Uint32Array", "Int8Array", "Int16Array", "Int32Array",
+ "Float32Array", "Float64Array"];
// Number of items to preview in objects, arrays, maps, sets, lists,
// collections, etc.
const OBJECT_PREVIEW_MAX_ITEMS = 10;
/**
* Creates an actor for the specified object.
*
@@ -42,29 +42,29 @@ const OBJECT_PREVIEW_MAX_ITEMS = 10;
* - incrementGripDepth
* Increment the actor's grip depth
* - decrementGripDepth
* Decrement the actor's grip depth
* - globalDebugObject
* The Debuggee Global Object as given by the ThreadActor
*/
function ObjectActor(obj, {
- createValueGrip,
+ createValueGrip: createValueGripHook,
sources,
createEnvironmentActor,
getGripDepth,
incrementGripDepth,
decrementGripDepth,
getGlobalDebugObject
}) {
assert(!obj.optimizedOut,
"Should not create object actors for optimized out values!");
this.obj = obj;
this.hooks = {
- createValueGrip,
+ createValueGrip: createValueGripHook,
sources,
createEnvironmentActor,
getGripDepth,
incrementGripDepth,
decrementGripDepth,
getGlobalDebugObject
};
this.iterators = new Set();
@@ -81,17 +81,17 @@ ObjectActor.prototype = {
let g = {
"type": "object",
"actor": this.actorID
};
// If it's a proxy, lie and tell that it belongs to an invented
// "Proxy" class, and avoid calling the [[IsExtensible]] trap
- if(this.obj.isProxy) {
+ if (this.obj.isProxy) {
g.class = "Proxy";
g.proxyTarget = this.hooks.createValueGrip(this.obj.proxyTarget);
g.proxyHandler = this.hooks.createValueGrip(this.obj.proxyHandler);
} else {
g.class = this.obj.class;
g.extensible = this.obj.isExtensible();
g.frozen = this.obj.isFrozen();
g.sealed = this.obj.isSealed();
@@ -109,17 +109,19 @@ ObjectActor.prototype = {
if (TYPED_ARRAY_CLASSES.indexOf(g.class) != -1) {
// Bug 1348761: getOwnPropertyNames is unecessary slow on TypedArrays
let length = DevToolsUtils.getProperty(this.obj, "length");
g.ownPropertyLength = length;
} else if (!["Function", "Proxy"].includes(g.class)) {
// Bug 1163520: Assert on internal functions
g.ownPropertyLength = this.obj.getOwnPropertyNames().length;
}
- } catch (e) {}
+ } catch (e) {
+ // ignored
+ }
let raw = this.obj.unsafeDereference();
// If Cu is not defined, we are running on a worker thread, where xrays
// don't exist.
if (Cu) {
raw = Cu.unwaiveXrays(raw);
}
@@ -565,17 +567,18 @@ ObjectActor.prototype = {
*/
onDependentPromises: function () {
if (this.obj.class != "Promise") {
return { error: "objectNotPromise",
message: "'dependentPromises' request is only valid for " +
"object grips with a 'Promise' class." };
}
- let promises = this.obj.promiseDependentPromises.map(p => this.hooks.createValueGrip(p));
+ let promises = this.obj.promiseDependentPromises
+ .map(p => this.hooks.createValueGrip(p));
return { promises };
},
/**
* Handle a protocol request to get the allocation stack of a promise.
*/
onAllocationStack: function () {
@@ -672,17 +675,19 @@ ObjectActor.prototype = {
* stack.
*/
_getSourceOriginalLocation: function (stack) {
let source;
// Catch any errors if the source actor cannot be found
try {
source = this.hooks.sources().getSourceActorByURL(stack.source);
- } catch (e) {}
+ } catch (e) {
+ // ignored
+ }
if (!source) {
return null;
}
return this.hooks.sources().getOriginalLocation(new GeneratedLocation(
source,
stack.line,
@@ -1358,18 +1363,18 @@ DebuggerServer.ObjectActorPreviewers = {
ownProperties: Object.create(null),
ownPropertiesLength: 2
};
if (hooks.getGripDepth() > 1) {
return true;
}
- grip.preview.ownProperties['<target>'] = {value: grip.proxyTarget};
- grip.preview.ownProperties['<handler>'] = {value: grip.proxyHandler};
+ grip.preview.ownProperties["<target>"] = {value: grip.proxyTarget};
+ grip.preview.ownProperties["<handler>"] = {value: grip.proxyHandler};
return true;
}],
};
/**
* Generic previewer for classes wrapping primitives, like String,
* Number and Boolean.
@@ -1675,17 +1680,16 @@ DebuggerServer.ObjectActorPreviewers.Obj
}
}
} else if (rawObj instanceof Ci.nsIDOMElement) {
// Add preview for DOM element attributes.
if (rawObj instanceof Ci.nsIDOMHTMLElement) {
preview.nodeName = preview.nodeName.toLowerCase();
}
- let i = 0;
preview.attributes = {};
preview.attributesLength = rawObj.attributes.length;
for (let attr of rawObj.attributes) {
preview.attributes[attr.nodeName] = hooks.createValueGrip(attr.value);
}
} else if (rawObj instanceof Ci.nsIDOMAttr) {
preview.value = hooks.createValueGrip(rawObj.value);
} else if (rawObj instanceof Ci.nsIDOMText ||
@@ -1803,43 +1807,43 @@ DebuggerServer.ObjectActorPreviewers.Obj
let keys = obj.getOwnPropertyNames();
if (keys.length == 0) {
return false;
}
// If no item is going to be displayed in preview, better display as sparse object.
// The first key should contain the smallest integer index (if any).
- if(keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) {
+ if (keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) {
return false;
}
// Pseudo-arrays should only have array indices and, optionally, a "length" property.
// Since integer indices are sorted first, check if the last property is "length".
- if(keys[keys.length-1] === "length") {
+ if (keys[keys.length - 1] === "length") {
keys.pop();
length = DevToolsUtils.getProperty(obj, "length");
} else {
// Otherwise, let length be the (presumably) greatest array index plus 1.
- length = +keys[keys.length-1] + 1;
+ length = +keys[keys.length - 1] + 1;
}
// Check if length is a valid array length, i.e. is a Uint32 number.
- if(typeof length !== "number" || length >>> 0 !== length) {
+ if (typeof length !== "number" || length >>> 0 !== length) {
return false;
}
// Ensure all keys are increasing array indices smaller than length. The order is not
// guaranteed for exotic objects but, in most cases, big array indices and properties
// which are not integer indices should be at the end. Then, iterating backwards
// allows us to return earlier when the object is not completely a pseudo-array.
let prev = length;
- for(let i = keys.length - 1; i >= 0; --i) {
+ for (let i = keys.length - 1; i >= 0; --i) {
let key = keys[i];
let numKey = key >>> 0; // ToUint32(key)
- if (numKey + '' !== key || numKey >= prev) {
+ if (numKey + "" !== key || numKey >= prev) {
return false;
}
prev = numKey;
}
grip.preview = {
kind: "ArrayLike",
length: length,
@@ -1850,17 +1854,17 @@ DebuggerServer.ObjectActorPreviewers.Obj
return true;
}
let items = grip.preview.items = [];
let numItems = Math.min(OBJECT_PREVIEW_MAX_ITEMS, length);
for (let i = 0; i < numItems; ++i) {
let desc = obj.getOwnPropertyDescriptor(i);
- if (desc && 'value' in desc) {
+ if (desc && "value" in desc) {
items.push(hooks.createValueGrip(desc.value));
} else {
items.push(null);
}
}
return true;
},
@@ -2173,18 +2177,17 @@ function createValueGrip(value, pool, ma
return value;
case "undefined":
return { type: "undefined" };
case "object":
if (value === null) {
return { type: "null" };
- }
- else if (value.optimizedOut ||
+ } else if (value.optimizedOut ||
value.uninitialized ||
value.missingArguments) {
// The slot is optimized out, an uninitialized binding, or
// arguments on a dead scope
return {
type: "null",
optimizedOut: value.optimizedOut,
uninitialized: value.uninitialized,
--- a/devtools/server/actors/script.js
+++ b/devtools/server/actors/script.js
@@ -15,17 +15,17 @@ const DevToolsUtils = require("devtools/
const flags = require("devtools/shared/flags");
const { assert, dumpn } = DevToolsUtils;
const promise = require("promise");
const xpcInspector = require("xpcInspector");
const { DevToolsWorker } = require("devtools/shared/worker/worker");
const object = require("sdk/util/object");
const { threadSpec } = require("devtools/shared/specs/script");
-const { defer, resolve, reject, all } = promise;
+const { resolve, reject, all } = promise;
loader.lazyGetter(this, "Debugger", () => {
let Debugger = require("Debugger");
hackDebugger(Debugger);
return Debugger;
});
loader.lazyRequireGetter(this, "CssLogic", "devtools/server/css-logic", true);
loader.lazyRequireGetter(this, "findCssSelector", "devtools/shared/inspector/css-logic", true);
@@ -66,51 +66,57 @@ BreakpointActorMap.prototype = {
findActors: function* (location = new OriginalLocation()) {
// Fast shortcut for when we know we won't find any actors. Surprisingly
// enough, this speeds up refreshing when there are no breakpoints set by
// about 2x!
if (this.size === 0) {
return;
}
- function* findKeys(object, key) {
+ function* findKeys(obj, key) {
if (key !== undefined) {
- if (key in object) {
+ if (key in obj) {
yield key;
}
- }
- else {
- for (let key of Object.keys(object)) {
+ } else {
+ for (key of Object.keys(obj)) {
yield key;
}
}
}
let query = {
- sourceActorID: location.originalSourceActor ? location.originalSourceActor.actorID : undefined,
+ sourceActorID: location.originalSourceActor
+ ? location.originalSourceActor.actorID
+ : undefined,
line: location.originalLine,
};
// If location contains a line, assume we are searching for a whole line
// breakpoint, and set begin/endColumn accordingly. Otherwise, we are
// searching for all breakpoints, so begin/endColumn should be left unset.
if (location.originalLine) {
query.beginColumn = location.originalColumn ? location.originalColumn : 0;
query.endColumn = location.originalColumn ? location.originalColumn + 1 : Infinity;
} else {
query.beginColumn = location.originalColumn ? query.originalColumn : undefined;
query.endColumn = location.originalColumn ? query.originalColumn + 1 : undefined;
}
- for (let sourceActorID of findKeys(this._actors, query.sourceActorID))
- for (let line of findKeys(this._actors[sourceActorID], query.line))
- for (let beginColumn of findKeys(this._actors[sourceActorID][line], query.beginColumn))
- for (let endColumn of findKeys(this._actors[sourceActorID][line][beginColumn], query.endColumn)) {
- yield this._actors[sourceActorID][line][beginColumn][endColumn];
+ for (let sourceActorID of findKeys(this._actors, query.sourceActorID)) {
+ let actor = this._actors[sourceActorID];
+ for (let line of findKeys(actor, query.line)) {
+ for (let beginColumn of findKeys(actor[line], query.beginColumn)) {
+ for (let endColumn of findKeys(actor[line][beginColumn],
+ query.endColumn)) {
+ yield actor[line][beginColumn][endColumn];
}
+ }
+ }
+ }
},
/**
* Return the BreakpointActor at the given location in this
* BreakpointActorMap.
*
* @param OriginalLocation location
* The location for which the BreakpointActor should be returned.
@@ -205,45 +211,44 @@ function SourceActorStore() {
// source identifier --> actor id
this._sourceActorIds = Object.create(null);
}
SourceActorStore.prototype = {
/**
* Lookup an existing actor id that represents this source, if available.
*/
- getReusableActorId: function (aSource, aOriginalUrl) {
- let url = this.getUniqueKey(aSource, aOriginalUrl);
+ getReusableActorId: function (source, originalUrl) {
+ let url = this.getUniqueKey(source, originalUrl);
if (url && url in this._sourceActorIds) {
return this._sourceActorIds[url];
}
return null;
},
/**
* Update a source with an actorID.
*/
- setReusableActorId: function (aSource, aOriginalUrl, actorID) {
- let url = this.getUniqueKey(aSource, aOriginalUrl);
+ setReusableActorId: function (source, originalUrl, actorID) {
+ let url = this.getUniqueKey(source, originalUrl);
if (url) {
this._sourceActorIds[url] = actorID;
}
},
/**
* Make a unique URL from a source that identifies it across reloads.
*/
- getUniqueKey: function (aSource, aOriginalUrl) {
- if (aOriginalUrl) {
+ getUniqueKey: function (source, originalUrl) {
+ if (originalUrl) {
// Original source from a sourcemap.
- return aOriginalUrl;
+ return originalUrl;
}
- else {
- return getSourceURL(aSource);
- }
+
+ return getSourceURL(source);
}
};
exports.SourceActorStore = SourceActorStore;
/**
* Manages pushing event loops and automatically pops and exits them in the
* correct order as they are resolved.
@@ -331,17 +336,19 @@ function EventLoop({ thread, connection,
this.enter = this.enter.bind(this);
this.resolve = this.resolve.bind(this);
}
EventLoop.prototype = {
entered: false,
resolved: false,
- get url() { return this._hooks.url; },
+ get url() {
+ return this._hooks.url;
+ },
/**
* Enter this nested event loop.
*/
enter: function () {
let nestData = this._hooks.preNest
? this._hooks.preNest()
: null;
@@ -405,20 +412,20 @@ EventLoop.prototype = {
* - postNest: Function called after exiting a nested event loop.
* - makeDebugger: A function that takes no arguments and instantiates
* a Debugger that manages its globals on its own.
* @param aGlobal object [optional]
* An optional (for content debugging only) reference to the content
* window.
*/
const ThreadActor = ActorClassWithSpec(threadSpec, {
- initialize: function (aParent, aGlobal) {
+ initialize: function (parent, global) {
this._state = "detached";
this._frameActors = [];
- this._parent = aParent;
+ this._parent = parent;
this._dbg = null;
this._gripDepth = 0;
this._threadLifetimePool = null;
this._tabClosed = false;
this._scripts = null;
this._pauseOnDOMEvents = null;
this._options = {
@@ -430,17 +437,17 @@ const ThreadActor = ActorClassWithSpec(t
this.sourceActorStore = new SourceActorStore();
this._debuggerSourcesSeen = null;
// A map of actorID -> actor for breakpoints created and managed by the
// server.
this._hiddenBreakpoints = new Map();
- this.global = aGlobal;
+ this.global = global;
this._allEventsListener = this._allEventsListener.bind(this);
this.onNewGlobal = this.onNewGlobal.bind(this);
this.onSourceEvent = this.onSourceEvent.bind(this);
this.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this);
this.onDebuggerStatement = this.onDebuggerStatement.bind(this);
this.onNewScript = this.onNewScript.bind(this);
this.objectGrip = this.objectGrip.bind(this);
@@ -547,23 +554,23 @@ const ThreadActor = ActorClassWithSpec(t
}
this._sources = null;
this._scripts = null;
},
/**
* Listener for our |Debugger|'s "newGlobal" event.
*/
- onNewGlobal: function (aGlobal) {
+ onNewGlobal: function (global) {
// Notify the client.
this.conn.send({
from: this.actorID,
type: "newGlobal",
// TODO: after bug 801084 lands see if we need to JSONify this.
- hostAnnotations: aGlobal.hostAnnotations
+ hostAnnotations: global.hostAnnotations
});
},
destroy: function () {
dumpn("in ThreadActor.prototype.destroy");
if (this._state == "paused") {
this.onResume();
}
@@ -596,30 +603,30 @@ const ThreadActor = ActorClassWithSpec(t
* destroy the debugger and put the actor in the exited state.
*/
exit: function () {
this.destroy();
this._state = "exited";
},
// Request handlers
- onAttach: function (aRequest) {
+ onAttach: function (request) {
if (this.state === "exited") {
return { type: "exited" };
}
if (this.state !== "detached") {
return { error: "wrongState",
message: "Current state is " + this.state };
}
this._state = "attached";
this._debuggerSourcesSeen = new WeakSet();
- Object.assign(this._options, aRequest.options || {});
+ Object.assign(this._options, request.options || {});
this.sources.setOptions(this._options);
this.sources.on("newSource", this.onSourceEvent);
this.sources.on("updatedSource", this.onSourceEvent);
// Initialize an event loop stack. This can't be done in the constructor,
// because this.conn is not yet initialized by the actor pool at that time.
this._nestedEventLoops = new EventLoopStack({
hooks: this._parent,
@@ -649,32 +656,32 @@ const ThreadActor = ActorClassWithSpec(t
// now.
return null;
} catch (e) {
reportError(e);
return { error: "notAttached", message: e.toString() };
}
},
- onDetach: function (aRequest) {
+ onDetach: function (request) {
this.destroy();
this._state = "detached";
this._debuggerSourcesSeen = null;
dumpn("ThreadActor.prototype.onDetach: returning 'detached' packet");
return {
type: "detached"
};
},
- onReconfigure: function (aRequest) {
+ onReconfigure: function (request) {
if (this.state == "exited") {
return { error: "wrongState" };
}
- const options = aRequest.options || {};
+ const options = request.options || {};
if ("observeAsmJS" in options) {
this.dbg.allowUnobservedAsmJS = !options.observeAsmJS;
}
Object.assign(this._options, options);
// Update the global source store
@@ -682,33 +689,35 @@ const ThreadActor = ActorClassWithSpec(t
return {};
},
/**
* Pause the debuggee, by entering a nested event loop, and return a 'paused'
* packet to the client.
*
- * @param Debugger.Frame aFrame
+ * @param Debugger.Frame frame
* The newest debuggee frame in the stack.
- * @param object aReason
+ * @param object reason
* An object with a 'type' property containing the reason for the pause.
* @param function onPacket
* Hook to modify the packet before it is sent. Feel free to return a
* promise.
*/
- _pauseAndRespond: function (aFrame, aReason, onPacket = function (k) { return k; }) {
+ _pauseAndRespond: function (frame, reason, onPacket = function (k) {
+ return k;
+ }) {
try {
- let packet = this._paused(aFrame);
+ let packet = this._paused(frame);
if (!packet) {
return undefined;
}
- packet.why = aReason;
+ packet.why = reason;
- let generatedLocation = this.sources.getFrameLocation(aFrame);
+ let generatedLocation = this.sources.getFrameLocation(frame);
this.sources.getOriginalLocation(generatedLocation)
.then((originalLocation) => {
if (!originalLocation.originalSourceActor) {
// The only time the source actor will be null is if there
// was a sourcemap and it tried to look up the original
// location but there was no original URL. This is a strange
// scenario so we simply don't pause.
DevToolsUtils.reportException(
@@ -728,74 +737,77 @@ const ThreadActor = ActorClassWithSpec(t
resolve(onPacket(packet))
.then(null, error => {
reportError(error);
return {
error: "unknownError",
message: error.message + "\n" + error.stack
};
})
- .then(packet => {
- this.conn.send(packet);
+ .then(pkt => {
+ this.conn.send(pkt);
});
+
+ return undefined;
});
this._pushThreadPause();
} catch (e) {
reportError(e, "Got an exception during TA__pauseAndRespond: ");
}
// If the browser tab has been closed, terminate the debuggee script
// instead of continuing. Executing JS after the content window is gone is
// a bad idea.
return this._tabClosed ? null : undefined;
},
_makeOnEnterFrame: function ({ pauseAndRespond }) {
- return aFrame => {
- const generatedLocation = this.sources.getFrameLocation(aFrame);
- let { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation(
- generatedLocation));
+ return frame => {
+ const generatedLocation = this.sources.getFrameLocation(frame);
+ let { originalSourceActor } = this.unsafeSynchronize(
+ this.sources.getOriginalLocation(generatedLocation));
let url = originalSourceActor.url;
return this.sources.isBlackBoxed(url)
? undefined
- : pauseAndRespond(aFrame);
+ : pauseAndRespond(frame);
};
},
- _makeOnPop: function ({ thread, pauseAndRespond, createValueGrip }) {
- return function (aCompletion) {
+ _makeOnPop: function (
+ { thread, pauseAndRespond, createValueGrip: createValueGripHook }) {
+ return function (completion) {
// onPop is called with 'this' set to the current frame.
const generatedLocation = thread.sources.getFrameLocation(this);
- const { originalSourceActor } = thread.unsafeSynchronize(thread.sources.getOriginalLocation(
- generatedLocation));
+ const { originalSourceActor } = thread.unsafeSynchronize(
+ thread.sources.getOriginalLocation(generatedLocation));
const url = originalSourceActor.url;
if (thread.sources.isBlackBoxed(url)) {
return undefined;
}
// Note that we're popping this frame; we need to watch for
// subsequent step events on its caller.
this.reportedPop = true;
- return pauseAndRespond(this, aPacket => {
- aPacket.why.frameFinished = {};
- if (!aCompletion) {
- aPacket.why.frameFinished.terminated = true;
- } else if (aCompletion.hasOwnProperty("return")) {
- aPacket.why.frameFinished.return = createValueGrip(aCompletion.return);
- } else if (aCompletion.hasOwnProperty("yield")) {
- aPacket.why.frameFinished.return = createValueGrip(aCompletion.yield);
+ return pauseAndRespond(this, packet => {
+ packet.why.frameFinished = {};
+ if (!completion) {
+ packet.why.frameFinished.terminated = true;
+ } else if (completion.hasOwnProperty("return")) {
+ packet.why.frameFinished.return = createValueGripHook(completion.return);
+ } else if (completion.hasOwnProperty("yield")) {
+ packet.why.frameFinished.return = createValueGripHook(completion.yield);
} else {
- aPacket.why.frameFinished.throw = createValueGrip(aCompletion.throw);
+ packet.why.frameFinished.throw = createValueGripHook(completion.throw);
}
- return aPacket;
+ return packet;
});
};
},
_makeOnStep: function ({ thread, pauseAndRespond, startFrame,
startLocation, steppingType }) {
// Breaking in place: we should always pause.
if (steppingType === "break") {
@@ -855,51 +867,51 @@ const ThreadActor = ActorClassWithSpec(t
// consider this a "step" yet).
return undefined;
};
},
/**
* Define the JS hook functions for stepping.
*/
- _makeSteppingHooks: function (aStartLocation, steppingType) {
+ _makeSteppingHooks: function (startLocation, steppingType) {
// Bind these methods and state because some of the hooks are called
// with 'this' set to the current frame. Rather than repeating the
// binding in each _makeOnX method, just do it once here and pass it
// in to each function.
const steppingHookState = {
- pauseAndRespond: (aFrame, onPacket = k=>k) => {
- return this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket);
+ pauseAndRespond: (frame, onPacket = k=>k) => {
+ return this._pauseAndRespond(frame, { type: "resumeLimit" }, onPacket);
},
createValueGrip: v => createValueGrip(v, this._pausePool,
this.objectGrip),
thread: this,
startFrame: this.youngestFrame,
- startLocation: aStartLocation,
+ startLocation: startLocation,
steppingType: steppingType
};
return {
onEnterFrame: this._makeOnEnterFrame(steppingHookState),
onPop: this._makeOnPop(steppingHookState),
onStep: this._makeOnStep(steppingHookState)
};
},
/**
* Handle attaching the various stepping hooks we need to attach when we
* receive a resume request with a resumeLimit property.
*
- * @param Object aRequest
+ * @param Object request
* The request packet received over the RDP.
* @returns A promise that resolves to true once the hooks are attached, or is
* rejected with an error packet.
*/
- _handleResumeLimit: function (aRequest) {
- let steppingType = aRequest.resumeLimit.type;
+ _handleResumeLimit: function (request) {
+ let steppingType = request.resumeLimit.type;
if (["break", "step", "next", "finish"].indexOf(steppingType) == -1) {
return reject({ error: "badParameterType",
message: "Unknown resumeLimit type" });
}
const generatedLocation = this.sources.getFrameLocation(this.youngestFrame);
return this.sources.getOriginalLocation(generatedLocation)
.then(originalLocation => {
@@ -932,35 +944,35 @@ const ThreadActor = ActorClassWithSpec(t
/**
* Clear the onStep and onPop hooks from the given frame and all of the frames
* below it.
*
* @param Debugger.Frame aFrame
* The frame we want to clear the stepping hooks from.
*/
- _clearSteppingHooks: function (aFrame) {
- if (aFrame && aFrame.live) {
- while (aFrame) {
- aFrame.onStep = undefined;
- aFrame.onPop = undefined;
- aFrame = aFrame.older;
+ _clearSteppingHooks: function (frame) {
+ if (frame && frame.live) {
+ while (frame) {
+ frame.onStep = undefined;
+ frame.onPop = undefined;
+ frame = frame.older;
}
}
},
/**
* Listen to the debuggee's DOM events if we received a request to do so.
*
- * @param Object aRequest
+ * @param Object request
* The resume request packet received over the RDP.
*/
- _maybeListenToEvents: function (aRequest) {
+ _maybeListenToEvents: function (request) {
// Break-on-DOMEvents is only supported in content debugging.
- let events = aRequest.pauseOnDOMEvents;
+ let events = request.pauseOnDOMEvents;
if (this.global && events &&
(events == "*" ||
(Array.isArray(events) && events.length))) {
this._pauseOnDOMEvents = events;
let els = Cc["@mozilla.org/eventlistenerservice;1"]
.getService(Ci.nsIEventListenerService);
els.addListenerForAllEvents(this.global, this._allEventsListener, true);
}
@@ -974,17 +986,17 @@ const ThreadActor = ActorClassWithSpec(t
this._maybeListenToEvents({
pauseOnDOMEvents: this._pauseOnDOMEvents
});
},
/**
* Handle a protocol request to resume execution of the debuggee.
*/
- onResume: function (aRequest) {
+ onResume: function (request) {
if (this._state !== "paused") {
return {
error: "wrongState",
message: "Can't resume when debuggee isn't paused. Current state is '"
+ this._state + "'",
state: this._state
};
}
@@ -998,29 +1010,29 @@ const ThreadActor = ActorClassWithSpec(t
return {
error: "wrongOrder",
message: "trying to resume in the wrong order.",
lastPausedUrl: this._nestedEventLoops.lastPausedUrl
};
}
let resumeLimitHandled;
- if (aRequest && aRequest.resumeLimit) {
- resumeLimitHandled = this._handleResumeLimit(aRequest);
+ if (request && request.resumeLimit) {
+ resumeLimitHandled = this._handleResumeLimit(request);
} else {
this._clearSteppingHooks(this.youngestFrame);
resumeLimitHandled = resolve(true);
}
return resumeLimitHandled.then(() => {
- if (aRequest) {
- this._options.pauseOnExceptions = aRequest.pauseOnExceptions;
- this._options.ignoreCaughtExceptions = aRequest.ignoreCaughtExceptions;
+ if (request) {
+ this._options.pauseOnExceptions = request.pauseOnExceptions;
+ this._options.ignoreCaughtExceptions = request.ignoreCaughtExceptions;
this.maybePauseOnExceptions();
- this._maybeListenToEvents(aRequest);
+ this._maybeListenToEvents(request);
}
let packet = this._resumed();
this._popThreadPause();
// Tell anyone who cares of the resume (as of now, that's the xpcshell harness and
// devtools-startup.js when handling the --wait-for-jsdebugger flag)
if (Services.obs) {
Services.obs.notifyObservers(this, "devtools-thread-resumed");
@@ -1038,38 +1050,37 @@ const ThreadActor = ActorClassWithSpec(t
/**
* Spin up a nested event loop so we can synchronously resolve a promise.
*
* DON'T USE THIS UNLESS YOU ABSOLUTELY MUST! Nested event loops suck: the
* world's state can change out from underneath your feet because JS is no
* longer run-to-completion.
*
- * @param aPromise
+ * @param p
* The promise we want to resolve.
* @returns The promise's resolution.
*/
- unsafeSynchronize: function (aPromise) {
+ unsafeSynchronize: function (p) {
let needNest = true;
let eventLoop;
let returnVal;
- aPromise
- .then((aResolvedVal) => {
- needNest = false;
- returnVal = aResolvedVal;
- })
- .then(null, (aError) => {
- reportError(aError, "Error inside unsafeSynchronize:");
- })
- .then(() => {
- if (eventLoop) {
- eventLoop.resolve();
- }
- });
+ p.then((resolvedVal) => {
+ needNest = false;
+ returnVal = resolvedVal;
+ })
+ .then(null, (error) => {
+ reportError(error, "Error inside unsafeSynchronize:");
+ })
+ .then(() => {
+ if (eventLoop) {
+ eventLoop.resolve();
+ }
+ });
if (needNest) {
eventLoop = this._nestedEventLoops.push();
eventLoop.enter();
}
return returnVal;
},
@@ -1119,18 +1130,19 @@ const ThreadActor = ActorClassWithSpec(t
let listeners = [];
for (let target of targets) {
let handlers = els.getListenerInfoFor(target);
for (let handler of handlers) {
// Null is returned for all-events handlers, and native event listeners
// don't provide any listenerObject, which makes them not that useful to
// a JS debugger.
- if (!handler || !handler.listenerObject || !handler.type)
+ if (!handler || !handler.listenerObject || !handler.type) {
continue;
+ }
// Create a listener-like object suitable for our purposes.
let l = Object.create(null);
l.type = handler.type;
let listener = handler.listenerObject;
let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener);
// If the listener is not callable, assume it is an event handler object.
if (!listenerDO.callable) {
// For some events we don't have permission to access the
@@ -1150,18 +1162,19 @@ const ThreadActor = ActorClassWithSpec(t
// When the listener is a bound function, we are actually interested in
// the target function.
while (listenerDO.isBoundFunction) {
listenerDO = listenerDO.boundTargetFunction;
}
l.script = listenerDO.script;
// Chrome listeners won't be converted to debuggee values, since their
// compartment is not added as a debuggee.
- if (!l.script)
+ if (!l.script) {
continue;
+ }
listeners.push(l);
}
}
return listeners;
},
/**
* Set a breakpoint on the first line of the given script that has an entry
@@ -1183,31 +1196,31 @@ const ThreadActor = ActorClassWithSpec(t
break;
}
}
},
/**
* Helper method that returns the next frame when stepping.
*/
- _getNextStepFrame: function (aFrame) {
- let stepFrame = aFrame.reportedPop ? aFrame.older : aFrame;
+ _getNextStepFrame: function (frame) {
+ let stepFrame = frame.reportedPop ? frame.older : frame;
if (!stepFrame || !stepFrame.script) {
stepFrame = null;
}
return stepFrame;
},
- onClientEvaluate: function (aRequest) {
+ onClientEvaluate: function (request) {
if (this.state !== "paused") {
return { error: "wrongState",
message: "Debuggee must be paused to evaluate code." };
}
- let frame = this._requestFrame(aRequest.frame);
+ let frame = this._requestFrame(request.frame);
if (!frame) {
return { error: "unknownFrame",
message: "Evaluation frame not found" };
}
if (!frame.environment) {
return { error: "notDebuggee",
message: "cannot access the environment of this frame." };
@@ -1216,52 +1229,52 @@ const ThreadActor = ActorClassWithSpec(t
let youngest = this.youngestFrame;
// Put ourselves back in the running state and inform the client.
let resumedPacket = this._resumed();
this.conn.send(resumedPacket);
// Run the expression.
// XXX: test syntax errors
- let completion = frame.eval(aRequest.expression);
+ let completion = frame.eval(request.expression);
// Put ourselves back in the pause state.
let packet = this._paused(youngest);
packet.why = { type: "clientEvaluated",
frameFinished: this.createProtocolCompletionValue(completion) };
// Return back to our previous pause's event loop.
return packet;
},
- onFrames: function (aRequest) {
+ onFrames: function (request) {
if (this.state !== "paused") {
return { error: "wrongState",
message: "Stack frames are only available while the debuggee is paused."};
}
- let start = aRequest.start ? aRequest.start : 0;
- let count = aRequest.count;
+ let start = request.start ? request.start : 0;
+ let count = request.count;
// Find the starting frame...
let frame = this.youngestFrame;
let i = 0;
while (frame && (i < start)) {
frame = frame.older;
i++;
}
// Return request.count frames, or all remaining
// frames if count is not defined.
let promises = [];
for (; frame && (!count || i < (start + count)); i++, frame = frame.older) {
let form = this._createFrameActor(frame).form();
form.depth = i;
- let promise = this.sources.getOriginalLocation(new GeneratedLocation(
+ let framePromise = this.sources.getOriginalLocation(new GeneratedLocation(
this.sources.createNonSourceMappedActor(frame.script.source),
form.where.line,
form.where.column
)).then((originalLocation) => {
if (!originalLocation.originalSourceActor) {
return null;
}
@@ -1269,33 +1282,33 @@ const ThreadActor = ActorClassWithSpec(t
form.where = {
source: sourceForm,
line: originalLocation.originalLine,
column: originalLocation.originalColumn
};
form.source = sourceForm;
return form;
});
- promises.push(promise);
+ promises.push(framePromise);
}
return all(promises).then(function (frames) {
// Filter null values because sourcemapping may have failed.
return { frames: frames.filter(x => !!x) };
});
},
- onReleaseMany: function (aRequest) {
- if (!aRequest.actors) {
+ onReleaseMany: function (request) {
+ if (!request.actors) {
return { error: "missingParameter",
message: "no actors were specified" };
}
let res;
- for (let actorID of aRequest.actors) {
+ for (let actorID of request.actors) {
let actor = this.threadLifetimePool.get(actorID);
if (!actor) {
if (!res) {
res = { error: "notReleasable",
message: "Only thread-lifetime actors can be released." };
}
continue;
}
@@ -1319,17 +1332,17 @@ const ThreadActor = ActorClassWithSpec(t
}
}
return all([...sourcesToScripts.values()].map(script => {
return this.sources.createSourceActors(script.source);
}));
},
- onSources: function (aRequest) {
+ onSources: function (request) {
return this._discoverSources().then(() => {
// No need to flush the new source packets here, as we are sending the
// list of sources out immediately and we don't need to invoke the
// overhead of an RDP packet for every source right now. Let the default
// timeout flush the buffered packets.
return {
sources: this.sources.iter().map(s => s.form())
@@ -1345,38 +1358,37 @@ const ThreadActor = ActorClassWithSpec(t
* caches won't hold on to the Debugger.Script objects leaking memory.
*/
disableAllBreakpoints: function () {
for (let bpActor of this.breakpointActorMap.findActors()) {
bpActor.removeScripts();
}
},
-
/**
* Handle a protocol request to pause the debuggee.
*/
- onInterrupt: function (aRequest) {
+ onInterrupt: function (request) {
if (this.state == "exited") {
return { type: "exited" };
} else if (this.state == "paused") {
// TODO: return the actual reason for the existing pause.
return { type: "paused", why: { type: "alreadyPaused" } };
} else if (this.state != "running") {
return { error: "wrongState",
message: "Received interrupt request in " + this.state +
" state." };
}
try {
// If execution should pause just before the next JavaScript bytecode is
// executed, just set an onEnterFrame handler.
- if (aRequest.when == "onNext") {
- let onEnterFrame = (aFrame) => {
- return this._pauseAndRespond(aFrame, { type: "interrupted", onNext: true });
+ if (request.when == "onNext") {
+ let onEnterFrame = (frame) => {
+ return this._pauseAndRespond(frame, { type: "interrupted", onNext: true });
};
this.dbg.onEnterFrame = onEnterFrame;
return { type: "willInterrupt" };
}
// If execution should pause immediately, just put ourselves in the paused
// state.
@@ -1401,17 +1413,17 @@ const ThreadActor = ActorClassWithSpec(t
reportError(e);
return { error: "notInterrupted", message: e.toString() };
}
},
/**
* Handle a protocol request to retrieve all the event listeners on the page.
*/
- onEventListeners: function (aRequest) {
+ onEventListeners: function (request) {
// This request is only supported in content debugging.
if (!this.global) {
return {
error: "notImplemented",
message: "eventListeners request is only supported in content debugging"
};
}
@@ -1446,17 +1458,17 @@ const ThreadActor = ActorClassWithSpec(t
listenerForm.capturing = handler.capturing;
listenerForm.allowsUntrusted = handler.allowsUntrusted;
listenerForm.inSystemEventGroup = handler.inSystemEventGroup;
let handlerName = "on" + listenerForm.type;
listenerForm.isEventHandler = false;
if (typeof node.hasAttribute !== "undefined") {
listenerForm.isEventHandler = !!node.hasAttribute(handlerName);
}
- if (!!node[handlerName]) {
+ if (node[handlerName]) {
listenerForm.isEventHandler = !!node[handlerName];
}
// Get the Debugger.Object for the listener object.
let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener);
// If the listener is an object with a 'handleEvent' method, use that.
if (listenerDO.class == "Object" || listenerDO.class == "XULElement") {
// For some events we don't have permission to access the
// 'handleEvent' property when running in content scope.
@@ -1483,46 +1495,46 @@ const ThreadActor = ActorClassWithSpec(t
}
}
return { listeners: listeners };
},
/**
* Return the Debug.Frame for a frame mentioned by the protocol.
*/
- _requestFrame: function (aFrameID) {
- if (!aFrameID) {
+ _requestFrame: function (frameID) {
+ if (!frameID) {
return this.youngestFrame;
}
- if (this._framePool.has(aFrameID)) {
- return this._framePool.get(aFrameID).frame;
+ if (this._framePool.has(frameID)) {
+ return this._framePool.get(frameID).frame;
}
return undefined;
},
- _paused: function (aFrame) {
+ _paused: function (frame) {
// We don't handle nested pauses correctly. Don't try - if we're
// paused, just continue running whatever code triggered the pause.
// We don't want to actually have nested pauses (although we
// have nested event loops). If code runs in the debuggee during
// a pause, it should cause the actor to resume (dropping
// pause-lifetime actors etc) and then repause when complete.
if (this.state === "paused") {
return undefined;
}
// Clear stepping hooks.
this.dbg.onEnterFrame = undefined;
this.dbg.onExceptionUnwind = undefined;
- if (aFrame) {
- aFrame.onStep = undefined;
- aFrame.onPop = undefined;
+ if (frame) {
+ frame.onStep = undefined;
+ frame.onPop = undefined;
}
// Clear DOM event breakpoints.
// XPCShell tests don't use actual DOM windows for globals and cause
// removeListenerForAllEvents to throw.
if (!isWorker && this.global && !this.global.toString().includes("Sandbox")) {
let els = Cc["@mozilla.org/eventlistenerservice;1"]
.getService(Ci.nsIEventListenerService);
@@ -1552,18 +1564,18 @@ const ThreadActor = ActorClassWithSpec(t
// Update the list of frames.
let poppedFrames = this._updateFrames();
// Send off the paused packet and spin an event loop.
let packet = { from: this.actorID,
type: "paused",
actor: this._pauseActor.actorID };
- if (aFrame) {
- packet.frame = this._createFrameActor(aFrame).form();
+ if (frame) {
+ packet.frame = this._createFrameActor(frame).form();
}
if (poppedFrames) {
packet.poppedFrames = poppedFrames;
}
return packet;
},
@@ -1609,291 +1621,291 @@ const ThreadActor = ActorClassWithSpec(t
this._frameActors = frameList;
this._framePool = framePool;
this.conn.addActorPool(framePool);
return popped;
},
- _createFrameActor: function (aFrame) {
- if (aFrame.actor) {
- return aFrame.actor;
+ _createFrameActor: function (frame) {
+ if (frame.actor) {
+ return frame.actor;
}
- let actor = new FrameActor(aFrame, this);
+ let actor = new FrameActor(frame, this);
this._frameActors.push(actor);
this._framePool.addActor(actor);
- aFrame.actor = actor;
+ frame.actor = actor;
return actor;
},
/**
* Create and return an environment actor that corresponds to the provided
* Debugger.Environment.
- * @param Debugger.Environment aEnvironment
+ * @param Debugger.Environment environment
* The lexical environment we want to extract.
- * @param object aPool
+ * @param object pool
* The pool where the newly-created actor will be placed.
- * @return The EnvironmentActor for aEnvironment or undefined for host
+ * @return The EnvironmentActor for environment or undefined for host
* functions or functions scoped to a non-debuggee global.
*/
- createEnvironmentActor: function (aEnvironment, aPool) {
- if (!aEnvironment) {
+ createEnvironmentActor: function (environment, pool) {
+ if (!environment) {
return undefined;
}
- if (aEnvironment.actor) {
- return aEnvironment.actor;
+ if (environment.actor) {
+ return environment.actor;
}
- let actor = new EnvironmentActor(aEnvironment, this);
- aPool.addActor(actor);
- aEnvironment.actor = actor;
+ let actor = new EnvironmentActor(environment, this);
+ pool.addActor(actor);
+ environment.actor = actor;
return actor;
},
/**
* Return a protocol completion value representing the given
* Debugger-provided completion value.
*/
- createProtocolCompletionValue: function (aCompletion) {
+ createProtocolCompletionValue: function (completion) {
let protoValue = {};
- if (aCompletion == null) {
+ if (completion == null) {
protoValue.terminated = true;
- } else if ("return" in aCompletion) {
- protoValue.return = createValueGrip(aCompletion.return,
+ } else if ("return" in completion) {
+ protoValue.return = createValueGrip(completion.return,
this._pausePool, this.objectGrip);
- } else if ("throw" in aCompletion) {
- protoValue.throw = createValueGrip(aCompletion.throw,
+ } else if ("throw" in completion) {
+ protoValue.throw = createValueGrip(completion.throw,
this._pausePool, this.objectGrip);
} else {
- protoValue.return = createValueGrip(aCompletion.yield,
+ protoValue.return = createValueGrip(completion.yield,
this._pausePool, this.objectGrip);
}
return protoValue;
},
/**
* Create a grip for the given debuggee object.
*
- * @param aValue Debugger.Object
+ * @param value Debugger.Object
* The debuggee object value.
- * @param aPool ActorPool
+ * @param pool ActorPool
* The actor pool where the new object actor will be added.
*/
- objectGrip: function (aValue, aPool) {
- if (!aPool.objectActors) {
- aPool.objectActors = new WeakMap();
+ objectGrip: function (value, pool) {
+ if (!pool.objectActors) {
+ pool.objectActors = new WeakMap();
}
- if (aPool.objectActors.has(aValue)) {
- return aPool.objectActors.get(aValue).grip();
- } else if (this.threadLifetimePool.objectActors.has(aValue)) {
- return this.threadLifetimePool.objectActors.get(aValue).grip();
+ if (pool.objectActors.has(value)) {
+ return pool.objectActors.get(value).grip();
+ } else if (this.threadLifetimePool.objectActors.has(value)) {
+ return this.threadLifetimePool.objectActors.get(value).grip();
}
- let actor = new PauseScopedObjectActor(aValue, {
+ let actor = new PauseScopedObjectActor(value, {
getGripDepth: () => this._gripDepth,
incrementGripDepth: () => this._gripDepth++,
decrementGripDepth: () => this._gripDepth--,
createValueGrip: v => createValueGrip(v, this._pausePool,
this.pauseObjectGrip),
sources: () => this.sources,
- createEnvironmentActor: (env, pool) =>
- this.createEnvironmentActor(env, pool),
+ createEnvironmentActor: (e, p) =>
+ this.createEnvironmentActor(e, p),
promote: () => this.threadObjectGrip(actor),
isThreadLifetimePool: () =>
actor.registeredPool !== this.threadLifetimePool,
getGlobalDebugObject: () => this.globalDebugObject
});
- aPool.addActor(actor);
- aPool.objectActors.set(aValue, actor);
+ pool.addActor(actor);
+ pool.objectActors.set(value, actor);
return actor.grip();
},
/**
* Create a grip for the given debuggee object with a pause lifetime.
*
- * @param aValue Debugger.Object
+ * @param value Debugger.Object
* The debuggee object value.
*/
- pauseObjectGrip: function (aValue) {
+ pauseObjectGrip: function (value) {
if (!this._pausePool) {
- throw "Object grip requested while not paused.";
+ throw new Error("Object grip requested while not paused.");
}
- return this.objectGrip(aValue, this._pausePool);
+ return this.objectGrip(value, this._pausePool);
},
/**
* Extend the lifetime of the provided object actor to thread lifetime.
*
- * @param aActor object
+ * @param actor object
* The object actor.
*/
- threadObjectGrip: function (aActor) {
+ threadObjectGrip: function (actor) {
// We want to reuse the existing actor ID, so we just remove it from the
// current pool's weak map and then let pool.addActor do the rest.
- aActor.registeredPool.objectActors.delete(aActor.obj);
- this.threadLifetimePool.addActor(aActor);
- this.threadLifetimePool.objectActors.set(aActor.obj, aActor);
+ actor.registeredPool.objectActors.delete(actor.obj);
+ this.threadLifetimePool.addActor(actor);
+ this.threadLifetimePool.objectActors.set(actor.obj, actor);
},
/**
* Handle a protocol request to promote multiple pause-lifetime grips to
* thread-lifetime grips.
*
* @param aRequest object
* The protocol request object.
*/
- onThreadGrips: function (aRequest) {
+ onThreadGrips: function (request) {
if (this.state != "paused") {
return { error: "wrongState" };
}
- if (!aRequest.actors) {
+ if (!request.actors) {
return { error: "missingParameter",
message: "no actors were specified" };
}
- for (let actorID of aRequest.actors) {
+ for (let actorID of request.actors) {
let actor = this._pausePool.get(actorID);
if (actor) {
this.threadObjectGrip(actor);
}
}
return {};
},
/**
* Create a long string grip that is scoped to a pause.
*
- * @param aString String
+ * @param string String
* The string we are creating a grip for.
*/
- pauseLongStringGrip: function (aString) {
- return longStringGrip(aString, this._pausePool);
+ pauseLongStringGrip: function (string) {
+ return longStringGrip(string, this._pausePool);
},
/**
* Create a long string grip that is scoped to a thread.
*
- * @param aString String
+ * @param string String
* The string we are creating a grip for.
*/
- threadLongStringGrip: function (aString) {
- return longStringGrip(aString, this._threadLifetimePool);
+ threadLongStringGrip: function (string) {
+ return longStringGrip(string, this._threadLifetimePool);
},
// JS Debugger API hooks.
/**
* A function that the engine calls when a call to a debug event hook,
* breakpoint handler, watchpoint handler, or similar function throws some
* exception.
*
- * @param aException exception
+ * @param exception exception
* The exception that was thrown in the debugger code.
*/
- uncaughtExceptionHook: function (aException) {
- dumpn("Got an exception: " + aException.message + "\n" + aException.stack);
+ uncaughtExceptionHook: function (exception) {
+ dumpn("Got an exception: " + exception.message + "\n" + exception.stack);
},
/**
* A function that the engine calls when a debugger statement has been
* executed in the specified frame.
*
- * @param aFrame Debugger.Frame
+ * @param frame Debugger.Frame
* The stack frame that contained the debugger statement.
*/
- onDebuggerStatement: function (aFrame) {
+ onDebuggerStatement: function (frame) {
// Don't pause if we are currently stepping (in or over) or the frame is
// black-boxed.
- const generatedLocation = this.sources.getFrameLocation(aFrame);
- const { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation(
- generatedLocation));
+ const generatedLocation = this.sources.getFrameLocation(frame);
+ const { originalSourceActor } = this.unsafeSynchronize(
+ this.sources.getOriginalLocation(generatedLocation));
const url = originalSourceActor ? originalSourceActor.url : null;
- return this.sources.isBlackBoxed(url) || aFrame.onStep
+ return this.sources.isBlackBoxed(url) || frame.onStep
? undefined
- : this._pauseAndRespond(aFrame, { type: "debuggerStatement" });
+ : this._pauseAndRespond(frame, { type: "debuggerStatement" });
},
/**
* A function that the engine calls when an exception has been thrown and has
* propagated to the specified frame.
*
- * @param aFrame Debugger.Frame
+ * @param youngestFrame Debugger.Frame
* The youngest remaining stack frame.
- * @param aValue object
+ * @param value object
* The exception that was thrown.
*/
- onExceptionUnwind: function (aFrame, aValue) {
+ onExceptionUnwind: function (youngestFrame, value) {
let willBeCaught = false;
- for (let frame = aFrame; frame != null; frame = frame.older) {
+ for (let frame = youngestFrame; frame != null; frame = frame.older) {
if (frame.script.isInCatchScope(frame.offset)) {
willBeCaught = true;
break;
}
}
if (willBeCaught && this._options.ignoreCaughtExceptions) {
return undefined;
}
// NS_ERROR_NO_INTERFACE exceptions are a special case in browser code,
// since they're almost always thrown by QueryInterface functions, and
// handled cleanly by native code.
- if (aValue == Cr.NS_ERROR_NO_INTERFACE) {
+ if (value == Cr.NS_ERROR_NO_INTERFACE) {
return undefined;
}
- const generatedLocation = this.sources.getFrameLocation(aFrame);
- const { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation(
- generatedLocation));
+ const generatedLocation = this.sources.getFrameLocation(youngestFrame);
+ const { originalSourceActor } = this.unsafeSynchronize(
+ this.sources.getOriginalLocation(generatedLocation));
const url = originalSourceActor ? originalSourceActor.url : null;
if (this.sources.isBlackBoxed(url)) {
return undefined;
}
try {
- let packet = this._paused(aFrame);
+ let packet = this._paused(youngestFrame);
if (!packet) {
return undefined;
}
packet.why = { type: "exception",
- exception: createValueGrip(aValue, this._pausePool,
+ exception: createValueGrip(value, this._pausePool,
this.objectGrip)
- };
+ };
this.conn.send(packet);
this._pushThreadPause();
} catch (e) {
reportError(e, "Got an exception during TA_onExceptionUnwind: ");
}
return undefined;
},
/**
* A function that the engine calls when a new script has been loaded into the
* scope of the specified debuggee global.
*
- * @param aScript Debugger.Script
+ * @param script Debugger.Script
* The source script that has been loaded into a debuggee compartment.
- * @param aGlobal Debugger.Object
+ * @param global Debugger.Object
* A Debugger.Object instance whose referent is the global object.
*/
- onNewScript: function (aScript, aGlobal) {
- this._addSource(aScript.source);
+ onNewScript: function (script, global) {
+ this._addSource(script.source);
},
/**
* A function called when there's a new or updated source from a thread actor's
* sources. Emits `newSource` and `updatedSource` on the tab actor.
*
* @param {String} name
* @param {SourceActor} source
@@ -1918,31 +1930,31 @@ const ThreadActor = ActorClassWithSpec(t
/**
* Add the provided source to the server cache.
*
* @param aSource Debugger.Source
* The source that will be stored.
* @returns true, if the source was added; false otherwise.
*/
- _addSource: function (aSource) {
- if (!this.sources.allowSource(aSource) || this._debuggerSourcesSeen.has(aSource)) {
+ _addSource: function (source) {
+ if (!this.sources.allowSource(source) || this._debuggerSourcesSeen.has(source)) {
return false;
}
- let sourceActor = this.sources.createNonSourceMappedActor(aSource);
+ let sourceActor = this.sources.createNonSourceMappedActor(source);
let bpActors = [...this.breakpointActorMap.findActors()];
if (this._options.useSourceMaps) {
let promises = [];
// Go ahead and establish the source actors for this script, which
// fetches sourcemaps if available and sends onNewSource
// notifications.
- let sourceActorsCreated = this.sources._createSourceMappedActors(aSource);
+ let sourceActorsCreated = this.sources._createSourceMappedActors(source);
if (bpActors.length) {
// We need to use unsafeSynchronize here because if the page is being reloaded,
// this call will replace the previous set of source actors for this source
// with a new one. If the source actors have not been replaced by the time
// we try to reset the breakpoints below, their location objects will still
// point to the old set of source actors, which point to different
// scripts.
@@ -1952,23 +1964,26 @@ const ThreadActor = ActorClassWithSpec(t
for (let _actor of bpActors) {
// XXX bug 1142115: We do async work in here, so we need to create a fresh
// binding because for/of does not yet do that in SpiderMonkey.
let actor = _actor;
if (actor.isPending) {
promises.push(actor.originalLocation.originalSourceActor._setBreakpoint(actor));
} else {
- promises.push(this.sources.getAllGeneratedLocations(actor.originalLocation)
- .then((generatedLocations) => {
- if (generatedLocations.length > 0 &&
- generatedLocations[0].generatedSourceActor.actorID === sourceActor.actorID) {
- sourceActor._setBreakpointAtAllGeneratedLocations(actor, generatedLocations);
- }
- }));
+ promises.push(
+ this.sources.getAllGeneratedLocations(actor.originalLocation).then(
+ (generatedLocations) => {
+ if (generatedLocations.length > 0 &&
+ generatedLocations[0].generatedSourceActor
+ .actorID === sourceActor.actorID) {
+ sourceActor._setBreakpointAtAllGeneratedLocations(
+ actor, generatedLocations);
+ }
+ }));
}
}
if (promises.length > 0) {
this.unsafeSynchronize(promise.all(promises));
}
} else {
// Bug 1225160: If addSource is called in response to a new script
@@ -1989,27 +2004,26 @@ const ThreadActor = ActorClassWithSpec(t
} else {
actor.originalLocation.originalSourceActor._setBreakpointAtGeneratedLocation(
actor, GeneratedLocation.fromOriginalLocation(actor.originalLocation)
);
}
}
}
- this._debuggerSourcesSeen.add(aSource);
+ this._debuggerSourcesSeen.add(source);
return true;
},
-
/**
* Get prototypes and properties of multiple objects.
*/
- onPrototypesAndProperties: function (aRequest) {
+ onPrototypesAndProperties: function (request) {
let result = {};
- for (let actorID of aRequest.actors) {
+ for (let actorID of request.actors) {
// This code assumes that there are no lazily loaded actors returned
// by this call.
let actor = this.conn.getActor(actorID);
if (!actor) {
return { from: this.actorID,
error: "noSuchActor" };
}
let handler = actor.onPrototypeAndProperties;
@@ -2048,51 +2062,47 @@ exports.ThreadActor = ThreadActor;
* Creates a PauseActor.
*
* PauseActors exist for the lifetime of a given debuggee pause. Used to
* scope pause-lifetime grips.
*
* @param ActorPool aPool
* The actor pool created for this pause.
*/
-function PauseActor(aPool)
-{
- this.pool = aPool;
+function PauseActor(pool) {
+ this.pool = pool;
}
PauseActor.prototype = {
actorPrefix: "pause"
};
-
/**
* A base actor for any actors that should only respond receive messages in the
* paused state. Subclasses may expose a `threadActor` which is used to help
* determine when we are in a paused state. Subclasses should set their own
* "constructor" property if they want better error messages. You should never
* instantiate a PauseScopedActor directly, only through subclasses.
*/
-function PauseScopedActor()
-{
+function PauseScopedActor() {
}
/**
* A function decorator for creating methods to handle protocol messages that
* should only be received while in the paused state.
*
- * @param aMethod Function
+ * @param method Function
* The function we are decorating.
*/
-PauseScopedActor.withPaused = function (aMethod) {
+PauseScopedActor.withPaused = function (method) {
return function () {
if (this.isPaused()) {
- return aMethod.apply(this, arguments);
- } else {
- return this._wrongState();
+ return method.apply(this, arguments);
}
+ return this._wrongState();
};
};
PauseScopedActor.prototype = {
/**
* Returns true if we are in the paused state.
*/
@@ -2148,31 +2158,31 @@ Object.assign(PauseScopedObjectActor.pro
onParameterNames:
PauseScopedActor.withPaused(ObjectActor.prototype.onParameterNames),
/**
* Handle a protocol request to promote a pause-lifetime grip to a
* thread-lifetime grip.
*
- * @param aRequest object
+ * @param request object
* The protocol request object.
*/
- onThreadGrip: PauseScopedActor.withPaused(function (aRequest) {
+ onThreadGrip: PauseScopedActor.withPaused(function (request) {
this.hooks.promote();
return {};
}),
/**
* Handle a protocol request to release a thread-lifetime grip.
*
- * @param aRequest object
+ * @param request object
* The protocol request object.
*/
- onRelease: PauseScopedActor.withPaused(function (aRequest) {
+ onRelease: PauseScopedActor.withPaused(function (request) {
if (this.hooks.isThreadLifetimePool()) {
return { error: "notReleasable",
message: "Only thread-lifetime actors can be released." };
}
this.release();
return {};
}),
@@ -2224,40 +2234,37 @@ function hackDebugger(Debugger) {
* Helper property for quickly getting to the line number a stack frame is
* currently paused at.
*/
Object.defineProperty(Debugger.Frame.prototype, "line", {
configurable: true,
get: function () {
if (this.script) {
return this.script.getOffsetLocation(this.offset).lineNumber;
- } else {
- return null;
}
+ return null;
}
});
}
-
/**
* Creates an actor for handling chrome debugging. ChromeDebuggerActor is a
* thin wrapper over ThreadActor, slightly changing some of its behavior.
*
- * @param aConnection object
+ * @param connection object
* The DebuggerServerConnection with which this ChromeDebuggerActor
* is associated. (Currently unused, but required to make this
* constructor usable with addGlobalActor.)
*
- * @param aParent object
+ * @param parent object
* This actor's parent actor. See ThreadActor for a list of expected
* properties.
*/
-function ChromeDebuggerActor(aConnection, aParent)
-{
- ThreadActor.prototype.initialize.call(this, aParent);
+function ChromeDebuggerActor(connection, parent) {
+ ThreadActor.prototype.initialize.call(this, parent);
}
ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype);
Object.assign(ChromeDebuggerActor.prototype, {
constructor: ChromeDebuggerActor,
// A constant prefix that will be used to form the actor ID by the server.
@@ -2265,27 +2272,27 @@ Object.assign(ChromeDebuggerActor.protot
});
exports.ChromeDebuggerActor = ChromeDebuggerActor;
/**
* Creates an actor for handling add-on debugging. AddonThreadActor is
* a thin wrapper over ThreadActor.
*
- * @param aConnection object
+ * @param connection object
* The DebuggerServerConnection with which this AddonThreadActor
* is associated. (Currently unused, but required to make this
* constructor usable with addGlobalActor.)
*
- * @param aParent object
+ * @param parent object
* This actor's parent actor. See ThreadActor for a list of expected
* properties.
*/
-function AddonThreadActor(aConnect, aParent) {
- ThreadActor.prototype.initialize.call(this, aParent);
+function AddonThreadActor(connection, parent) {
+ ThreadActor.prototype.initialize.call(this, parent);
}
AddonThreadActor.prototype = Object.create(ThreadActor.prototype);
Object.assign(AddonThreadActor.prototype, {
constructor: AddonThreadActor,
// A constant prefix that will be used to form the actor ID by the server.
@@ -2294,25 +2301,25 @@ Object.assign(AddonThreadActor.prototype
exports.AddonThreadActor = AddonThreadActor;
// Utility functions.
/**
* Report the given error in the error console and to stdout.
*
- * @param Error aError
+ * @param Error error
* The error object you wish to report.
- * @param String aPrefix
+ * @param String prefix
* An optional prefix for the reported error message.
*/
var oldReportError = reportError;
-this.reportError = function (aError, aPrefix = "") {
- assert(aError instanceof Error, "Must pass Error objects to reportError");
- let msg = aPrefix + aError.message + ":\n" + aError.stack;
+this.reportError = function (error, prefix = "") {
+ assert(error instanceof Error, "Must pass Error objects to reportError");
+ let msg = prefix + error.message + ":\n" + error.stack;
oldReportError(msg);
dumpn(msg);
};
/**
* Find the scripts which contain offsets that are an entry point to the given
* line.
*
@@ -2354,13 +2361,12 @@ exports.unwrapDebuggerObjectGlobal = wra
//
// Note that addon sandboxes have a DOMWindow as their prototype. So make
// sure that we can touch the prototype too (whatever it is), in case _it_
// is it a nuked window reference. We force stringification to make sure
// that any dead object proxies make themselves known.
let global = wrappedGlobal.unsafeDereference();
Object.getPrototypeOf(global) + "";
return global;
- }
- catch (e) {
+ } catch (e) {
return undefined;
}
};
--- a/devtools/server/actors/styleeditor.js
+++ b/devtools/server/actors/styleeditor.js
@@ -1,40 +1,37 @@
/* 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} = require("chrome");
-const Services = require("Services");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const promise = require("promise");
const events = require("sdk/event/core");
const protocol = require("devtools/shared/protocol");
-const {Arg, method, RetVal} = protocol;
const {fetch} = require("devtools/shared/DevToolsUtils");
const {oldStyleSheetSpec, styleEditorSpec} = require("devtools/shared/specs/styleeditor");
loader.lazyGetter(this, "CssLogic", () => require("devtools/shared/inspector/css-logic"));
var TRANSITION_CLASS = "moz-styleeditor-transitioning";
var TRANSITION_DURATION_MS = 500;
-var TRANSITION_RULE = "\
-:root.moz-styleeditor-transitioning, :root.moz-styleeditor-transitioning * {\
-transition-duration: " + TRANSITION_DURATION_MS + "ms !important; \
-transition-delay: 0ms !important;\
-transition-timing-function: ease-out !important;\
-transition-property: all !important;\
-}";
-
-var LOAD_ERROR = "error-load";
+var TRANSITION_RULE = ":root.moz-styleeditor-transitioning, " +
+ ":root.moz-styleeditor-transitioning * {\n" +
+ "transition-duration: " + TRANSITION_DURATION_MS +
+ "ms !important;\n" +
+ "transition-delay: 0ms !important;\n" +
+ "transition-timing-function: ease-out !important;\n" +
+ "transition-property: all !important;\n" +
+ "}";
var OldStyleSheetActor = protocol.ActorClassWithSpec(oldStyleSheetSpec, {
- toString: function() {
+ toString: function () {
return "[OldStyleSheetActor " + this.actorID + "]";
},
/**
* Window of target
*/
get window() {
return this._window || this.parentActor.window;
@@ -54,37 +51,36 @@ var OldStyleSheetActor = protocol.ActorC
return this.rawSheet.href;
},
/**
* Retrieve the index (order) of stylesheet in the document.
*
* @return number
*/
- get styleSheetIndex()
- {
+ get styleSheetIndex() {
if (this._styleSheetIndex == -1) {
for (let i = 0; i < this.document.styleSheets.length; i++) {
if (this.document.styleSheets[i] == this.rawSheet) {
this._styleSheetIndex = i;
break;
}
}
}
return this._styleSheetIndex;
},
- initialize: function (aStyleSheet, aParentActor, aWindow) {
+ initialize: function (styleSheet, parentActor, window) {
protocol.Actor.prototype.initialize.call(this, null);
- this.rawSheet = aStyleSheet;
- this.parentActor = aParentActor;
+ this.rawSheet = styleSheet;
+ this.parentActor = parentActor;
this.conn = this.parentActor.conn;
- this._window = aWindow;
+ this._window = window;
// text and index are unknown until source load
this.text = null;
this._styleSheetIndex = -1;
this._transitionRefCount = 0;
// if this sheet has an @import, then it's rules are loaded async
@@ -128,18 +124,17 @@ var OldStyleSheetActor = protocol.ActorC
disabled: this.rawSheet.disabled,
title: this.rawSheet.title,
system: !CssLogic.isContentStylesheet(this.rawSheet),
styleSheetIndex: this.styleSheetIndex
};
try {
form.ruleCount = this.rawSheet.cssRules.length;
- }
- catch (e) {
+ } catch (e) {
// stylesheet had an @import rule that wasn't loaded yet
}
return form;
},
/**
* Toggle the disabled property of the style sheet
*
@@ -205,18 +200,17 @@ var OldStyleSheetActor = protocol.ActorC
});
},
/**
* Get the charset of the stylesheet according to the character set rules
* defined in <http://www.w3.org/TR/CSS2/syndata.html#charset>.
* Note that some of the algorithm is implemented in DevToolsUtils.fetch.
*/
- _getCSSCharset: function ()
- {
+ _getCSSCharset: function () {
let sheet = this.rawSheet;
if (sheet) {
// Do we have a @charset rule in the stylesheet?
// step 2 of syndata.html (without the BOM check).
if (sheet.cssRules) {
let rules = sheet.cssRules;
if (rules.length
&& rules.item(0).type == Ci.nsIDOMCSSRule.CHARSET_RULE) {
@@ -260,18 +254,17 @@ var OldStyleSheetActor = protocol.ActorC
DOMUtils.parseStyleSheet(this.rawSheet, text);
this.text = text;
this._notifyPropertyChanged("ruleCount");
if (transition) {
this._insertTransistionRule();
- }
- else {
+ } else {
this._notifyStyleApplied();
}
},
/**
* Insert a catch-all transition rule into the document. Set a timeout
* to remove the rule after a certain time.
*/
@@ -291,100 +284,96 @@ var OldStyleSheetActor = protocol.ActorC
this.window.setTimeout(this._onTransitionEnd.bind(this),
Math.floor(TRANSITION_DURATION_MS * 1.1));
},
/**
* This cleans up class and rule added for transition effect and then
* notifies that the style has been applied.
*/
- _onTransitionEnd: function ()
- {
+ _onTransitionEnd: function () {
if (--this._transitionRefCount == 0) {
this.document.documentElement.classList.remove(TRANSITION_CLASS);
this.rawSheet.deleteRule(this.rawSheet.cssRules.length - 1);
}
events.emit(this, "style-applied");
}
});
exports.OldStyleSheetActor = OldStyleSheetActor;
/**
* Creates a StyleEditorActor. StyleEditorActor provides remote access to the
* stylesheets of a document.
*/
-var StyleEditorActor = exports.StyleEditorActor = protocol.ActorClassWithSpec(styleEditorSpec, {
+var StyleEditorActor = protocol.ActorClassWithSpec(styleEditorSpec, {
/**
* The window we work with, taken from the parent actor.
*/
get window() {
return this.parentActor.window;
},
/**
* The current content document of the window we work with.
*/
get document() {
return this.window.document;
},
- form: function ()
- {
+ form: function () {
return { actor: this.actorID };
},
initialize: function (conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, null);
this.parentActor = tabActor;
// keep a map of sheets-to-actors so we don't create two actors for one sheet
this._sheets = new Map();
},
/**
* Destroy the current StyleEditorActor instance.
*/
- destroy: function ()
- {
+ destroy: function () {
this._sheets.clear();
},
/**
* Called by client when target navigates to a new document.
* Adds load listeners to document.
*/
newDocument: function () {
// delete previous document's actors
this._clearStyleSheetActors();
// Note: listening for load won't be necessary once
// https://bugzilla.mozilla.org/show_bug.cgi?id=839103 is fixed
if (this.document.readyState == "complete") {
this._onDocumentLoaded();
- }
- else {
+ } else {
this.window.addEventListener("load", this._onDocumentLoaded);
}
return {};
},
/**
* Event handler for document loaded event. Add actor for each stylesheet
* and send an event notifying of the load
*/
_onDocumentLoaded: function (event) {
if (event) {
this.window.removeEventListener("load", this._onDocumentLoaded);
}
let documents = [this.document];
- var forms = [];
+ let forms = [];
for (let doc of documents) {
let sheetForms = this._addStyleSheets(doc.styleSheets);
forms = forms.concat(sheetForms);
// Recursively handle style sheets of the documents in iframes.
for (let iframe of doc.getElementsByTagName("iframe")) {
documents.push(iframe.contentDocument);
}
}
@@ -396,18 +385,17 @@ var StyleEditorActor = exports.StyleEdit
* Add all the stylesheets to the map and create an actor for each one
* if not already created. Send event that there are new stylesheets.
*
* @param {[DOMStyleSheet]} styleSheets
* Stylesheets to add
* @return {[object]}
* Array of actors for each StyleSheetActor created
*/
- _addStyleSheets: function (styleSheets)
- {
+ _addStyleSheets: function (styleSheets) {
let sheets = [];
for (let i = 0; i < styleSheets.length; i++) {
let styleSheet = styleSheets[i];
sheets.push(styleSheet);
// Get all sheets, including imported ones
let imports = this._getImported(styleSheet);
sheets = sheets.concat(imports);
@@ -420,18 +408,17 @@ var StyleEditorActor = exports.StyleEdit
/**
* Create a new actor for a style sheet, if it hasn't already been created.
*
* @param {DOMStyleSheet} styleSheet
* The style sheet to create an actor for.
* @return {StyleSheetActor}
* The actor for this style sheet
*/
- _createStyleSheetActor: function (styleSheet)
- {
+ _createStyleSheetActor: function (styleSheet) {
if (this._sheets.has(styleSheet)) {
return this._sheets.get(styleSheet);
}
let actor = new OldStyleSheetActor(styleSheet, this);
this.manage(actor);
this._sheets.set(styleSheet, actor);
@@ -442,32 +429,31 @@ var StyleEditorActor = exports.StyleEdit
* Get all the stylesheets @imported from a stylesheet.
*
* @param {DOMStyleSheet} styleSheet
* Style sheet to search
* @return {array}
* All the imported stylesheets
*/
_getImported: function (styleSheet) {
- let imported = [];
+ let imported = [];
- for (let i = 0; i < styleSheet.cssRules.length; i++) {
+ for (let i = 0; i < styleSheet.cssRules.length; i++) {
let rule = styleSheet.cssRules[i];
if (rule.type == Ci.nsIDOMCSSRule.IMPORT_RULE) {
// Associated styleSheet may be null if it has already been seen due to
// duplicate @imports for the same URL.
if (!rule.styleSheet) {
continue;
}
imported.push(rule.styleSheet);
// recurse imports in this stylesheet as well
imported = imported.concat(this._getImported(rule.styleSheet));
- }
- else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
+ } else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
// @import rules must precede all others except @charset
break;
}
}
return imported;
},
/**
@@ -505,24 +491,8 @@ var StyleEditorActor = exports.StyleEdit
});
XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () {
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
});
exports.StyleEditorActor = StyleEditorActor;
-/**
- * Normalize multiple relative paths towards the base paths on the right.
- */
-function normalize(...aURLs) {
- let base = Services.io.newURI(aURLs.pop());
- let url;
- while ((url = aURLs.pop())) {
- base = Services.io.newURI(url, null, base);
- }
- return base.spec;
-}
-
-function dirname(aPath) {
- return Services.io.newURI(
- ".", null, Services.io.newURI(aPath)).spec;
-}
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -33,18 +33,16 @@ var TRANSITION_RULE_SELECTOR =
`:root${TRANSITION_PSEUDO_CLASS}, :root${TRANSITION_PSEUDO_CLASS} *`;
var TRANSITION_RULE = `${TRANSITION_RULE_SELECTOR} {
transition-duration: ${TRANSITION_DURATION_MS}ms !important;
transition-delay: 0ms !important;
transition-timing-function: ease-out !important;
transition-property: all !important;
}`;
-var LOAD_ERROR = "error-load";
-
// The possible kinds of style-applied events.
// UPDATE_PRESERVING_RULES means that the update is guaranteed to
// preserve the number and order of rules on the style sheet.
// UPDATE_GENERAL covers any other kind of change to the style sheet.
const UPDATE_PRESERVING_RULES = 0;
exports.UPDATE_PRESERVING_RULES = UPDATE_PRESERVING_RULES;
const UPDATE_GENERAL = 1;
exports.UPDATE_GENERAL = UPDATE_GENERAL;
@@ -56,22 +54,22 @@ exports.UPDATE_GENERAL = UPDATE_GENERAL;
// edited text to be collected.
let modifiedStyleSheets = new WeakMap();
/**
* Actor representing an original source of a style sheet that was specified
* in a source map.
*/
var OriginalSourceActor = protocol.ActorClassWithSpec(originalSourceSpec, {
- initialize: function (aUrl, aSourceMap, aParentActor) {
+ initialize: function (url, sourceMap, parentActor) {
protocol.Actor.prototype.initialize.call(this, null);
- this.url = aUrl;
- this.sourceMap = aSourceMap;
- this.parentActor = aParentActor;
+ this.url = url;
+ this.sourceMap = sourceMap;
+ this.parentActor = parentActor;
this.conn = this.parentActor.conn;
this.text = null;
},
form: function () {
return {
actor: this.actorID, // actorID is set when it's added to a pool
@@ -88,19 +86,19 @@ var OriginalSourceActor = protocol.Actor
if (content) {
this.text = content;
return promise.resolve(content);
}
let options = {
policy: Ci.nsIContentPolicy.TYPE_INTERNAL_STYLESHEET,
window: this.window
};
- return fetch(this.url, options).then(({content}) => {
- this.text = content;
- return content;
+ return fetch(this.url, options).then(({content: text}) => {
+ this.text = text;
+ return text;
});
},
/**
* Protocol method to get the text of this source.
*/
getText: function () {
return this._getText().then((text) => {
@@ -121,40 +119,40 @@ var MediaRuleActor = protocol.ActorClass
get document() {
return this.window.document;
},
get matches() {
return this.mql ? this.mql.matches : null;
},
- initialize: function (aMediaRule, aParentActor) {
+ initialize: function (mediaRule, parentActor) {
protocol.Actor.prototype.initialize.call(this, null);
- this.rawRule = aMediaRule;
- this.parentActor = aParentActor;
+ this.rawRule = mediaRule;
+ this.parentActor = parentActor;
this.conn = this.parentActor.conn;
this._matchesChange = this._matchesChange.bind(this);
- this.line = DOMUtils.getRuleLine(aMediaRule);
- this.column = DOMUtils.getRuleColumn(aMediaRule);
+ this.line = DOMUtils.getRuleLine(mediaRule);
+ this.column = DOMUtils.getRuleColumn(mediaRule);
try {
- this.mql = this.window.matchMedia(aMediaRule.media.mediaText);
+ this.mql = this.window.matchMedia(mediaRule.media.mediaText);
} catch (e) {
+ // Ignored
}
if (this.mql) {
this.mql.addListener(this._matchesChange);
}
},
- destroy: function ()
- {
+ destroy: function () {
if (this.mql) {
this.mql.removeListener(this._matchesChange);
}
protocol.Actor.prototype.destroy.call(this);
},
form: function (detail) {
@@ -232,18 +230,17 @@ var StyleSheetActor = protocol.ActorClas
return href;
},
/**
* Retrieve the index (order) of stylesheet in the document.
*
* @return number
*/
- get styleSheetIndex()
- {
+ get styleSheetIndex() {
if (this._styleSheetIndex == -1) {
for (let i = 0; i < this.document.styleSheets.length; i++) {
if (this.document.styleSheets[i] == this.rawSheet) {
this._styleSheetIndex = i;
break;
}
}
}
@@ -253,24 +250,24 @@ var StyleSheetActor = protocol.ActorClas
destroy: function () {
if (this._transitionTimeout) {
this.window.clearTimeout(this._transitionTimeout);
removePseudoClassLock(
this.document.documentElement, TRANSITION_PSEUDO_CLASS);
}
},
- initialize: function (aStyleSheet, aParentActor, aWindow) {
+ initialize: function (styleSheet, parentActor, window) {
protocol.Actor.prototype.initialize.call(this, null);
- this.rawSheet = aStyleSheet;
- this.parentActor = aParentActor;
+ this.rawSheet = styleSheet;
+ this.parentActor = parentActor;
this.conn = this.parentActor.conn;
- this._window = aWindow;
+ this._window = window;
// text and index are unknown until source load
this.text = null;
this._styleSheetIndex = -1;
},
/**
* Test whether all the rules in this sheet have associated source.
@@ -301,18 +298,17 @@ var StyleSheetActor = protocol.ActorClas
*
* @return {Promise}
* Promise that resolves with a CSSRuleList
*/
getCSSRules: function () {
let rules;
try {
rules = this.rawSheet.cssRules;
- }
- catch (e) {
+ } catch (e) {
// sheet isn't loaded yet
}
if (rules) {
return promise.resolve(rules);
}
if (!this.ownerNode) {
@@ -350,36 +346,34 @@ var StyleSheetActor = protocol.ActorClas
if (detail === "actorid") {
return this.actorID;
}
let docHref;
if (this.ownerNode) {
if (this.ownerNode instanceof Ci.nsIDOMHTMLDocument) {
docHref = this.ownerNode.location.href;
- }
- else if (this.ownerNode.ownerDocument && this.ownerNode.ownerDocument.location) {
+ } else if (this.ownerNode.ownerDocument && this.ownerNode.ownerDocument.location) {
docHref = this.ownerNode.ownerDocument.location.href;
}
}
let form = {
actor: this.actorID, // actorID is set when this actor is added to a pool
href: this.href,
nodeHref: docHref,
disabled: this.rawSheet.disabled,
title: this.rawSheet.title,
system: !CssLogic.isContentStylesheet(this.rawSheet),
styleSheetIndex: this.styleSheetIndex
};
try {
form.ruleCount = this.rawSheet.cssRules.length;
- }
- catch (e) {
+ } catch (e) {
// stylesheet had an @import rule that wasn't loaded yet
this.getCSSRules().then(() => {
this._notifyPropertyChanged("ruleCount");
});
}
return form;
},
@@ -592,48 +586,48 @@ var StyleSheetActor = protocol.ActorClas
return deferred.promise;
},
/**
* Clear and unmanage the original source actors for this stylesheet.
*/
_clearOriginalSources: function () {
- for (actor in this._originalSources) {
+ for (let actor in this._originalSources) {
this.unmanage(actor);
}
this._originalSources = null;
},
/**
* Sets the source map's sourceRoot to be relative to the source map url.
*/
- _setSourceMapRoot: function (aSourceMap, aAbsSourceMapURL, aScriptURL) {
- if (aScriptURL.startsWith("blob:")) {
- aScriptURL = aScriptURL.replace("blob:", "");
+ _setSourceMapRoot: function (sourceMap, absSourceMapURL, scriptURL) {
+ if (scriptURL.startsWith("blob:")) {
+ scriptURL = scriptURL.replace("blob:", "");
}
const base = dirname(
- aAbsSourceMapURL.startsWith("data:")
- ? aScriptURL
- : aAbsSourceMapURL);
- aSourceMap.sourceRoot = aSourceMap.sourceRoot
- ? normalize(aSourceMap.sourceRoot, base)
+ absSourceMapURL.startsWith("data:")
+ ? scriptURL
+ : absSourceMapURL);
+ sourceMap.sourceRoot = sourceMap.sourceRoot
+ ? normalize(sourceMap.sourceRoot, base)
: base;
},
/**
* Get the source map url specified in the text of a stylesheet.
*
* @param {string} content
* The text of the style sheet.
* @return {string}
* Url of source map.
*/
_extractSourceMapUrl: function (content) {
- var matches = /sourceMappingURL\=([^\s\*]*)/.exec(content);
+ let matches = /sourceMappingURL\=([^\s\*]*)/.exec(content);
if (matches) {
return matches[1];
}
return null;
},
/**
* Protocol method that gets the location in the original source of a
@@ -684,18 +678,17 @@ var StyleSheetActor = protocol.ActorClas
});
},
/**
* Get the charset of the stylesheet according to the character set rules
* defined in <http://www.w3.org/TR/CSS2/syndata.html#charset>.
* Note that some of the algorithm is implemented in DevToolsUtils.fetch.
*/
- _getCSSCharset: function ()
- {
+ _getCSSCharset: function () {
let sheet = this.rawSheet;
if (sheet) {
// Do we have a @charset rule in the stylesheet?
// step 2 of syndata.html (without the BOM check).
if (sheet.cssRules) {
let rules = sheet.cssRules;
if (rules.length
&& rules.item(0).type == Ci.nsIDOMCSSRule.CHARSET_RULE) {
@@ -742,18 +735,17 @@ var StyleSheetActor = protocol.ActorClas
modifiedStyleSheets.set(this.rawSheet, text);
this.text = text;
this._notifyPropertyChanged("ruleCount");
if (transition) {
this._insertTransistionRule(kind);
- }
- else {
+ } else {
events.emit(this, "style-applied", kind, this);
}
this._getMediaRules().then((rules) => {
events.emit(this, "media-rules-changed", rules);
});
},
@@ -765,26 +757,26 @@ var StyleSheetActor = protocol.ActorClas
addPseudoClassLock(this.document.documentElement, TRANSITION_PSEUDO_CLASS);
// We always add the rule since we've just reset all the rules
this.rawSheet.insertRule(TRANSITION_RULE, this.rawSheet.cssRules.length);
// Set up clean up and commit after transition duration (+buffer)
// @see _onTransitionEnd
this.window.clearTimeout(this._transitionTimeout);
- this._transitionTimeout = this.window.setTimeout(this._onTransitionEnd.bind(this, kind),
- TRANSITION_DURATION_MS + TRANSITION_BUFFER_MS);
+ this._transitionTimeout = this.window.setTimeout(
+ this._onTransitionEnd.bind(this, kind),
+ TRANSITION_DURATION_MS + TRANSITION_BUFFER_MS);
},
/**
* This cleans up class and rule added for transition effect and then
* notifies that the style has been applied.
*/
- _onTransitionEnd: function (kind)
- {
+ _onTransitionEnd: function (kind) {
this._transitionTimeout = null;
removePseudoClassLock(this.document.documentElement, TRANSITION_PSEUDO_CLASS);
let index = this.rawSheet.cssRules.length - 1;
let rule = this.rawSheet.cssRules[index];
if (rule.selectorText == TRANSITION_RULE_SELECTOR) {
this.rawSheet.deleteRule(index);
}
@@ -809,18 +801,17 @@ var StyleSheetsActor = protocol.ActorCla
/**
* The current content document of the window we work with.
*/
get document() {
return this.window.document;
},
- form: function ()
- {
+ form: function () {
return { actor: this.actorID };
},
initialize: function (conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, null);
this.parentActor = tabActor;
},
@@ -878,18 +869,17 @@ var StyleSheetsActor = protocol.ActorCla
* create an actor for each one if not already created.
*
* @param {Window} win
* Window for which to add stylesheets
*
* @return {Promise}
* Promise that resolves to an array of StyleSheetActors
*/
- _addStyleSheets: function (win)
- {
+ _addStyleSheets: function (win) {
return Task.spawn(function* () {
let doc = win.document;
// readyState can be uninitialized if an iframe has just been created but
// it has not started to load yet.
if (doc.readyState === "loading" || doc.readyState === "uninitialized") {
// Wait for the document to load first.
yield listenOnce(win, "DOMContentLoaded", true);
@@ -943,28 +933,26 @@ var StyleSheetsActor = protocol.ActorCla
continue;
}
let actor = this.parentActor.createStyleSheetActor(rule.styleSheet);
imported.push(actor);
// recurse imports in this stylesheet as well
let children = yield this._getImported(doc, actor);
imported = imported.concat(children);
- }
- else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
+ } else if (rule.type != Ci.nsIDOMCSSRule.CHARSET_RULE) {
// @import rules must precede all others except @charset
break;
}
}
return imported;
}.bind(this));
},
-
/**
* Create a new style sheet in the document with the given text.
* Return an actor for it.
*
* @param {object} request
* Debugging protocol request object, with 'text property'
* @return {object}
* Object with 'styelSheet' property for form on new actor.
@@ -984,21 +972,21 @@ var StyleSheetsActor = protocol.ActorCla
}
});
exports.StyleSheetsActor = StyleSheetsActor;
/**
* Normalize multiple relative paths towards the base paths on the right.
*/
-function normalize(...aURLs) {
- let base = Services.io.newURI(aURLs.pop());
+function normalize(...urls) {
+ let base = Services.io.newURI(urls.pop());
let url;
- while ((url = aURLs.pop())) {
+ while ((url = urls.pop())) {
base = Services.io.newURI(url, null, base);
}
return base.spec;
}
-function dirname(aPath) {
+function dirname(path) {
return Services.io.newURI(
- ".", null, Services.io.newURI(aPath)).spec;
+ ".", null, Services.io.newURI(path)).spec;
}
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1,16 +1,18 @@
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
/* vim: set 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";
+/* global XPCNativeWrapper */
+
const Services = require("Services");
const { Cc, Ci, Cu } = require("chrome");
const { DebuggerServer, ActorPool } = require("devtools/server/main");
const { ThreadActor } = require("devtools/server/actors/script");
const { ObjectActor, LongStringActor, createValueGrip, stringIsLong } = require("devtools/server/actors/object");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const ErrorDocs = require("devtools/server/actors/errordocs");
@@ -39,42 +41,42 @@ if (isWorker) {
loader.lazyRequireGetter(this, "ConsoleReflowListener", "devtools/server/actors/utils/webconsole-listeners", true);
}
/**
* The WebConsoleActor implements capabilities needed for the Web Console
* feature.
*
* @constructor
- * @param object aConnection
+ * @param object connection
* The connection to the client, DebuggerServerConnection.
- * @param object [aParentActor]
+ * @param object [parentActor]
* Optional, the parent actor.
*/
-function WebConsoleActor(aConnection, aParentActor)
-{
- this.conn = aConnection;
- this.parentActor = aParentActor;
+function WebConsoleActor(connection, parentActor) {
+ this.conn = connection;
+ this.parentActor = parentActor;
this._actorPool = new ActorPool(this.conn);
this.conn.addActorPool(this._actorPool);
this._prefs = {};
this.dbg = this.parentActor.makeDebugger();
this._netEvents = new Map();
this._gripDepth = 0;
this._listeners = new Set();
this._lastConsoleInputEvaluation = undefined;
this.objectGrip = this.objectGrip.bind(this);
this._onWillNavigate = this._onWillNavigate.bind(this);
this._onChangedToplevelDocument = this._onChangedToplevelDocument.bind(this);
- events.on(this.parentActor, "changed-toplevel-document", this._onChangedToplevelDocument);
+ events.on(this.parentActor, "changed-toplevel-document",
+ this._onChangedToplevelDocument);
this._onObserverNotification = this._onObserverNotification.bind(this);
if (this.parentActor.isRootActor) {
Services.obs.addObserver(this._onObserverNotification,
"last-pb-context-exited");
}
this.traits = {
customNetworkRequest: !this._parentIsContentActor,
@@ -171,18 +173,17 @@ WebConsoleActor.prototype =
/**
* Get a window to use for the browser console.
*
* @private
* @return nsIDOMWindow
* The window to use, or null if no window could be found.
*/
- _getWindowForBrowserConsole: function WCA__getWindowForBrowserConsole()
- {
+ _getWindowForBrowserConsole: function () {
// Check if our last used chrome window is still live.
let window = this._lastChromeWindow && this._lastChromeWindow.get();
// If not, look for a new one.
if (!window || window.closed) {
window = this.parentActor.window;
if (!window) {
// Try to find the Browser Console window to use instead.
window = Services.wm.getMostRecentWindow("devtools:webconsole");
@@ -204,21 +205,20 @@ WebConsoleActor.prototype =
/**
* Store a newly found window on the actor to be used in the future.
*
* @private
* @param nsIDOMWindow window
* The window to store on the actor (can be null).
*/
- _handleNewWindow: function WCA__handleNewWindow(window)
- {
+ _handleNewWindow: function (window) {
if (window) {
if (this._hadChromeWindow) {
- Services.console.logStringMessage('Webconsole context has changed');
+ Services.console.logStringMessage("Webconsole context has changed");
}
this._lastChromeWindow = Cu.getWeakReference(window);
this._hadChromeWindow = true;
} else {
this._lastChromeWindow = null;
}
},
@@ -239,18 +239,18 @@ WebConsoleActor.prototype =
_lastChromeWindow: null,
// The evalWindow is used at the scope for JS evaluation.
_evalWindow: null,
get evalWindow() {
return this._evalWindow || this.window;
},
- set evalWindow(aWindow) {
- this._evalWindow = aWindow;
+ set evalWindow(window) {
+ this._evalWindow = window;
if (!this._progressListenerActive) {
events.on(this.parentActor, "will-navigate", this._onWillNavigate);
this._progressListenerActive = true;
}
},
/**
@@ -302,35 +302,35 @@ WebConsoleActor.prototype =
_webConsoleCommandsCache: null,
actorPrefix: "console",
get globalDebugObject() {
return this.parentActor.threadActor.globalDebugObject;
},
- grip: function WCA_grip()
- {
+ grip: function () {
return { actor: this.actorID };
},
- hasNativeConsoleAPI: function WCA_hasNativeConsoleAPI(aWindow) {
+ hasNativeConsoleAPI: function (window) {
if (isWorker) {
// Can't use XPCNativeWrapper as a way to check for console API in workers
return true;
}
let isNative = false;
try {
// We are very explicitly examining the "console" property of
// the non-Xrayed object here.
- let console = aWindow.wrappedJSObject.console;
- isNative = new XPCNativeWrapper(console).IS_NATIVE_CONSOLE
+ let console = window.wrappedJSObject.console;
+ isNative = new XPCNativeWrapper(console).IS_NATIVE_CONSOLE;
+ } catch (ex) {
+ // ignored
}
- catch (ex) { }
return isNative;
},
_findProtoChain: ThreadActor.prototype._findProtoChain,
_removeFromProtoChain: ThreadActor.prototype._removeFromProtoChain,
/**
* Destroy the current WebConsoleActor instance.
@@ -390,225 +390,215 @@ WebConsoleActor.prototype =
},
/**
* Create and return an environment actor that corresponds to the provided
* Debugger.Environment. This is a straightforward clone of the ThreadActor's
* method except that it stores the environment actor in the web console
* actor's pool.
*
- * @param Debugger.Environment aEnvironment
+ * @param Debugger.Environment environment
* The lexical environment we want to extract.
- * @return The EnvironmentActor for aEnvironment or undefined for host
+ * @return The EnvironmentActor for |environment| or |undefined| for host
* functions or functions scoped to a non-debuggee global.
*/
- createEnvironmentActor: function WCA_createEnvironmentActor(aEnvironment) {
- if (!aEnvironment) {
+ createEnvironmentActor: function (environment) {
+ if (!environment) {
return undefined;
}
- if (aEnvironment.actor) {
- return aEnvironment.actor;
+ if (environment.actor) {
+ return environment.actor;
}
- let actor = new EnvironmentActor(aEnvironment, this);
+ let actor = new EnvironmentActor(environment, this);
this._actorPool.addActor(actor);
- aEnvironment.actor = actor;
+ environment.actor = actor;
return actor;
},
/**
* Create a grip for the given value.
*
- * @param mixed aValue
+ * @param mixed value
* @return object
*/
- createValueGrip: function WCA_createValueGrip(aValue)
- {
- return createValueGrip(aValue, this._actorPool, this.objectGrip);
+ createValueGrip: function (value) {
+ return createValueGrip(value, this._actorPool, this.objectGrip);
},
/**
* Make a debuggee value for the given value.
*
- * @param mixed aValue
+ * @param mixed value
* The value you want to get a debuggee value for.
- * @param boolean aUseObjectGlobal
+ * @param boolean useObjectGlobal
* If |true| the object global is determined and added as a debuggee,
* otherwise |this.window| is used when makeDebuggeeValue() is invoked.
* @return object
- * Debuggee value for |aValue|.
+ * Debuggee value for |value|.
*/
- makeDebuggeeValue: function WCA_makeDebuggeeValue(aValue, aUseObjectGlobal)
- {
- if (aUseObjectGlobal && typeof aValue == "object") {
+ makeDebuggeeValue: function (value, useObjectGlobal) {
+ if (useObjectGlobal && typeof value == "object") {
try {
- let global = Cu.getGlobalForObject(aValue);
+ let global = Cu.getGlobalForObject(value);
let dbgGlobal = this.dbg.makeGlobalObjectReference(global);
- return dbgGlobal.makeDebuggeeValue(aValue);
- }
- catch (ex) {
- // The above can throw an exception if aValue is not an actual object
+ return dbgGlobal.makeDebuggeeValue(value);
+ } catch (ex) {
+ // The above can throw an exception if value is not an actual object
// or 'Object in compartment marked as invisible to Debugger'
}
}
let dbgGlobal = this.dbg.makeGlobalObjectReference(this.window);
- return dbgGlobal.makeDebuggeeValue(aValue);
+ return dbgGlobal.makeDebuggeeValue(value);
},
/**
* Create a grip for the given object.
*
- * @param object aObject
+ * @param object object
* The object you want.
- * @param object aPool
+ * @param object pool
* An ActorPool where the new actor instance is added.
* @param object
* The object grip.
*/
- objectGrip: function WCA_objectGrip(aObject, aPool)
- {
- let actor = new ObjectActor(aObject, {
+ objectGrip: function (object, pool) {
+ let actor = new ObjectActor(object, {
getGripDepth: () => this._gripDepth,
incrementGripDepth: () => this._gripDepth++,
decrementGripDepth: () => this._gripDepth--,
createValueGrip: v => this.createValueGrip(v),
sources: () => DevToolsUtils.reportException("WebConsoleActor",
Error("sources not yet implemented")),
createEnvironmentActor: (env) => this.createEnvironmentActor(env),
getGlobalDebugObject: () => this.globalDebugObject
});
- aPool.addActor(actor);
+ pool.addActor(actor);
return actor.grip();
},
/**
* Create a grip for the given string.
*
- * @param string aString
+ * @param string string
* The string you want to create the grip for.
- * @param object aPool
+ * @param object pool
* An ActorPool where the new actor instance is added.
* @return object
* A LongStringActor object that wraps the given string.
*/
- longStringGrip: function WCA_longStringGrip(aString, aPool)
- {
- let actor = new LongStringActor(aString);
- aPool.addActor(actor);
+ longStringGrip: function (string, pool) {
+ let actor = new LongStringActor(string);
+ pool.addActor(actor);
return actor.grip();
},
/**
* Create a long string grip if needed for the given string.
*
* @private
- * @param string aString
+ * @param string string
* The string you want to create a long string grip for.
* @return string|object
- * A string is returned if |aString| is not a long string.
- * A LongStringActor grip is returned if |aString| is a long string.
+ * A string is returned if |string| is not a long string.
+ * A LongStringActor grip is returned if |string| is a long string.
*/
- _createStringGrip: function NEA__createStringGrip(aString)
- {
- if (aString && stringIsLong(aString)) {
- return this.longStringGrip(aString, this._actorPool);
+ _createStringGrip: function (string) {
+ if (string && stringIsLong(string)) {
+ return this.longStringGrip(string, this._actorPool);
}
- return aString;
+ return string;
},
/**
* Get an object actor by its ID.
*
- * @param string aActorID
+ * @param string actorID
* @return object
*/
- getActorByID: function WCA_getActorByID(aActorID)
- {
- return this._actorPool.get(aActorID);
+ getActorByID: function (actorID) {
+ return this._actorPool.get(actorID);
},
/**
* Release an actor.
*
- * @param object aActor
+ * @param object actor
* The actor instance you want to release.
*/
- releaseActor: function WCA_releaseActor(aActor)
- {
- this._actorPool.removeActor(aActor.actorID);
+ releaseActor: function (actor) {
+ this._actorPool.removeActor(actor.actorID);
},
/**
* Returns the latest web console input evaluation.
* This is undefined if no evaluations have been completed.
*
* @return object
*/
- getLastConsoleInputEvaluation: function WCU_getLastConsoleInputEvaluation()
- {
+ getLastConsoleInputEvaluation: function () {
return this._lastConsoleInputEvaluation;
},
// Request handlers for known packet types.
/**
* Handler for the "startListeners" request.
*
- * @param object aRequest
+ * @param object request
* The JSON request object received from the Web Console client.
* @return object
* The response object which holds the startedListeners array.
*/
- onStartListeners: function WCA_onStartListeners(aRequest)
- {
+ onStartListeners: function (request) {
let startedListeners = [];
let window = !this.parentActor.isRootActor ? this.window : null;
let messageManager = null;
if (this._parentIsContentActor) {
messageManager = this.parentActor.messageManager;
}
- while (aRequest.listeners.length > 0) {
- let listener = aRequest.listeners.shift();
+ while (request.listeners.length > 0) {
+ let listener = request.listeners.shift();
switch (listener) {
case "PageError":
// Workers don't support this message type yet
if (isWorker) {
break;
}
if (!this.consoleServiceListener) {
this.consoleServiceListener =
new ConsoleServiceListener(window, this);
this.consoleServiceListener.init();
}
startedListeners.push(listener);
break;
case "ConsoleAPI":
if (!this.consoleAPIListener) {
- // Create the consoleAPIListener (and apply the filtering options defined
- // in the parent actor).
- this.consoleAPIListener =
- new ConsoleAPIListener(window, this,
- this.parentActor.consoleAPIListenerOptions);
+ // Create the consoleAPIListener
+ // (and apply the filtering options defined in the parent actor).
+ this.consoleAPIListener = new ConsoleAPIListener(
+ window, this, this.parentActor.consoleAPIListenerOptions);
this.consoleAPIListener.init();
}
startedListeners.push(listener);
break;
case "NetworkActivity":
// Workers don't support this message type
if (isWorker) {
break;
}
if (!this.networkMonitor) {
- // Create a StackTraceCollector that's going to be shared both by the
- // NetworkMonitorChild (getting messages about requests from parent) and
- // by the NetworkMonitor that directly watches service workers requests.
+ // Create a StackTraceCollector that's going to be shared both by
+ // the NetworkMonitorChild (getting messages about requests from
+ // parent) and by the NetworkMonitor that directly watches service
+ // workers requests.
this.stackTraceCollector = new StackTraceCollector({ window });
this.stackTraceCollector.init();
let processBoundary = Services.appinfo.processType !=
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
if (messageManager && processBoundary) {
// Start a network monitor in the parent process to listen to
// most requests than happen in parent
@@ -631,18 +621,18 @@ WebConsoleActor.prototype =
if (isWorker) {
break;
}
if (this.window instanceof Ci.nsIDOMWindow) {
if (!this.consoleProgressListener) {
this.consoleProgressListener =
new ConsoleProgressListener(this.window, this);
}
- this.consoleProgressListener.startMonitor(this.consoleProgressListener.
- MONITOR_FILE_ACTIVITY);
+ this.consoleProgressListener.startMonitor(this.consoleProgressListener
+ .MONITOR_FILE_ACTIVITY);
startedListeners.push(listener);
}
break;
case "ReflowActivity":
// Workers don't support this message type
if (isWorker) {
break;
}
@@ -674,31 +664,30 @@ WebConsoleActor.prototype =
nativeConsoleAPI: this.hasNativeConsoleAPI(this.window),
traits: this.traits,
};
},
/**
* Handler for the "stopListeners" request.
*
- * @param object aRequest
+ * @param object request
* The JSON request object received from the Web Console client.
* @return object
* The response packet to send to the client: holds the
* stoppedListeners array.
*/
- onStopListeners: function WCA_onStopListeners(aRequest)
- {
+ onStopListeners: function (request) {
let stoppedListeners = [];
// If no specific listeners are requested to be detached, we stop all
// listeners.
- let toDetach = aRequest.listeners ||
- ["PageError", "ConsoleAPI", "NetworkActivity",
- "FileActivity", "ServerLogging"];
+ let toDetach = request.listeners ||
+ ["PageError", "ConsoleAPI", "NetworkActivity",
+ "FileActivity", "ServerLogging"];
while (toDetach.length > 0) {
let listener = toDetach.shift();
switch (listener) {
case "PageError":
if (this.consoleServiceListener) {
this.consoleServiceListener.destroy();
this.consoleServiceListener = null;
@@ -724,18 +713,18 @@ WebConsoleActor.prototype =
if (this.stackTraceCollector) {
this.stackTraceCollector.destroy();
this.stackTraceCollector = null;
}
stoppedListeners.push(listener);
break;
case "FileActivity":
if (this.consoleProgressListener) {
- this.consoleProgressListener.stopMonitor(this.consoleProgressListener.
- MONITOR_FILE_ACTIVITY);
+ this.consoleProgressListener.stopMonitor(this.consoleProgressListener
+ .MONITOR_FILE_ACTIVITY);
this.consoleProgressListener = null;
}
stoppedListeners.push(listener);
break;
case "ReflowActivity":
if (this.consoleReflowListener) {
this.consoleReflowListener.destroy();
this.consoleReflowListener = null;
@@ -757,25 +746,24 @@ WebConsoleActor.prototype =
return { stoppedListeners: stoppedListeners };
},
/**
* Handler for the "getCachedMessages" request. This method sends the cached
* error messages and the window.console API calls to the client.
*
- * @param object aRequest
+ * @param object request
* The JSON request object received from the Web Console client.
* @return object
* The response packet to send to the client: it holds the cached
* messages array.
*/
- onGetCachedMessages: function WCA_onGetCachedMessages(aRequest)
- {
- let types = aRequest.messageTypes;
+ onGetCachedMessages: function (request) {
+ let types = request.messageTypes;
if (!types) {
return {
error: "missingParameter",
message: "The messageTypes parameter is missing.",
};
}
let messages = [];
@@ -789,47 +777,46 @@ WebConsoleActor.prototype =
}
// See `window` definition. It isn't always a DOM Window.
let requestStartTime = this.window && this.window.performance ?
this.window.performance.timing.requestStart : 0;
let cache = this.consoleAPIListener
.getCachedMessages(!this.parentActor.isRootActor);
- cache.forEach((aMessage) => {
+ cache.forEach((cachedMessage) => {
// Filter out messages that came from a ServiceWorker but happened
// before the page was requested.
- if (aMessage.innerID === "ServiceWorker" &&
- requestStartTime > aMessage.timeStamp) {
+ if (cachedMessage.innerID === "ServiceWorker" &&
+ requestStartTime > cachedMessage.timeStamp) {
return;
}
- let message = this.prepareConsoleMessageForRemote(aMessage);
+ let message = this.prepareConsoleMessageForRemote(cachedMessage);
message._type = type;
messages.push(message);
});
break;
}
case "PageError": {
if (!this.consoleServiceListener) {
break;
}
let cache = this.consoleServiceListener
.getCachedMessages(!this.parentActor.isRootActor);
- cache.forEach((aMessage) => {
+ cache.forEach((cachedMessage) => {
let message = null;
- if (aMessage instanceof Ci.nsIScriptError) {
- message = this.preparePageErrorForRemote(aMessage);
+ if (cachedMessage instanceof Ci.nsIScriptError) {
+ message = this.preparePageErrorForRemote(cachedMessage);
message._type = type;
- }
- else {
+ } else {
message = {
_type: "LogMessage",
- message: this._createStringGrip(aMessage.message),
- timeStamp: aMessage.timeStamp,
+ message: this._createStringGrip(cachedMessage.message),
+ timeStamp: cachedMessage.timeStamp,
};
}
messages.push(message);
});
break;
}
}
}
@@ -841,71 +828,69 @@ WebConsoleActor.prototype =
},
/**
* Handler for the "evaluateJSAsync" request. This method evaluates the given
* JavaScript string and sends back a packet with a unique ID.
* The result will be returned later as an unsolicited `evaluationResult`,
* that can be associated back to this request via the `resultID` field.
*
- * @param object aRequest
+ * @param object request
* The JSON request object received from the Web Console client.
* @return object
* The response packet to send to with the unique id in the
* `resultID` field.
*/
- onEvaluateJSAsync: function WCA_onEvaluateJSAsync(aRequest)
- {
+ onEvaluateJSAsync: function (request) {
// We want to be able to run console commands without waiting
// for the first to return (see Bug 1088861).
// First, send a response packet with the id only.
let resultID = Date.now();
this.conn.send({
from: this.actorID,
resultID: resultID
});
// Then, execute the script that may pause.
- let response = this.onEvaluateJS(aRequest);
+ let response = this.onEvaluateJS(request);
response.resultID = resultID;
// Finally, send an unsolicited evaluationResult packet with
// the normal return value
this.conn.sendActorEvent(this.actorID, "evaluationResult", response);
},
/**
* Handler for the "evaluateJS" request. This method evaluates the given
* JavaScript string and sends back the result.
*
- * @param object aRequest
+ * @param object request
* The JSON request object received from the Web Console client.
* @return object
* The evaluation response packet.
*/
- onEvaluateJS: function WCA_onEvaluateJS(aRequest)
- {
- let input = aRequest.text;
+ onEvaluateJS: function (request) {
+ let input = request.text;
let timestamp = Date.now();
let evalOptions = {
- bindObjectActor: aRequest.bindObjectActor,
- frameActor: aRequest.frameActor,
- url: aRequest.url,
- selectedNodeActor: aRequest.selectedNodeActor,
- selectedObjectActor: aRequest.selectedObjectActor,
+ bindObjectActor: request.bindObjectActor,
+ frameActor: request.frameActor,
+ url: request.url,
+ selectedNodeActor: request.selectedNodeActor,
+ selectedObjectActor: request.selectedObjectActor,
};
let evalInfo = this.evalWithDebugger(input, evalOptions);
let evalResult = evalInfo.result;
let helperResult = evalInfo.helperResult;
let result, errorDocURL, errorMessage, errorNotes = null, errorGrip = null,
- frame = null;
+ frame = null;
if (evalResult) {
if ("return" in evalResult) {
result = evalResult.return;
} else if ("yield" in evalResult) {
result = evalResult.yield;
} else if ("throw" in evalResult) {
let error = evalResult.throw;
@@ -935,48 +920,54 @@ WebConsoleActor.prototype =
}
}
}
// It is possible that we won't have permission to unwrap an
// object and retrieve its errorMessageName.
try {
errorDocURL = ErrorDocs.GetURL(error);
- } catch (ex) {}
+ } catch (ex) {
+ // ignored
+ }
try {
let line = error.errorLineNumber;
let column = error.errorColumnNumber;
if (typeof line === "number" && typeof column === "number") {
// Set frame only if we have line/column numbers.
frame = {
source: "debugger eval code",
line,
column
};
}
- } catch (ex) {}
+ } catch (ex) {
+ // ignored
+ }
try {
let notes = error.errorNotes;
if (notes && notes.length) {
errorNotes = [];
for (let note of notes) {
errorNotes.push({
messageBody: this._createStringGrip(note.message),
frame: {
source: note.fileName,
line: note.lineNumber,
column: note.columnNumber,
}
});
}
}
- } catch (ex) {}
+ } catch (ex) {
+ // ignored
+ }
}
}
// If a value is encountered that the debugger server doesn't support yet,
// the console should remain functional.
let resultGrip;
try {
resultGrip = this.createValueGrip(result);
@@ -998,56 +989,54 @@ WebConsoleActor.prototype =
helperResult: helperResult,
notes: errorNotes,
};
},
/**
* The Autocomplete request handler.
*
- * @param object aRequest
+ * @param object request
* The request message - what input to autocomplete.
* @return object
* The response message - matched properties.
*/
- onAutocomplete: function WCA_onAutocomplete(aRequest)
- {
- let frameActorId = aRequest.frameActor;
+ onAutocomplete: function (request) {
+ let frameActorId = request.frameActor;
let dbgObject = null;
let environment = null;
let hadDebuggee = false;
// This is the case of the paused debugger
if (frameActorId) {
let frameActor = this.conn.getActor(frameActorId);
try {
// Need to try/catch since accessing frame.environment
// can throw "Debugger.Frame is not live"
let frame = frameActor.frame;
environment = frame.environment;
} catch (e) {
DevToolsUtils.reportException("onAutocomplete",
Error("The frame actor was not found: " + frameActorId));
}
- }
- // This is the general case (non-paused debugger)
- else {
+ } else {
+ // This is the general case (non-paused debugger)
hadDebuggee = this.dbg.hasDebuggee(this.evalWindow);
dbgObject = this.dbg.addDebuggee(this.evalWindow);
}
- let result = JSPropertyProvider(dbgObject, environment, aRequest.text,
- aRequest.cursor, frameActorId) || {};
+ let result = JSPropertyProvider(dbgObject, environment, request.text,
+ request.cursor, frameActorId) || {};
if (!hadDebuggee && dbgObject) {
this.dbg.removeDebuggee(this.evalWindow);
}
let matches = result.matches || [];
- let reqText = aRequest.text.substr(0, aRequest.cursor);
+ let reqText = request.text.substr(0, request.cursor);
// We consider '$' as alphanumerc because it is used in the names of some
// helper functions.
let lastNonAlphaIsDot = /[.][a-zA-Z0-9$]*$/.test(reqText);
if (!lastNonAlphaIsDot) {
if (!this._webConsoleCommandsCache) {
let helpers = {
sandbox: Object.create(null)
@@ -1065,104 +1054,100 @@ WebConsoleActor.prototype =
matches: matches.sort(),
matchProp: result.matchProp,
};
},
/**
* The "clearMessagesCache" request handler.
*/
- onClearMessagesCache: function WCA_onClearMessagesCache()
- {
+ onClearMessagesCache: function () {
// TODO: Bug 717611 - Web Console clear button does not clear cached errors
let windowId = !this.parentActor.isRootActor ?
WebConsoleUtils.getInnerWindowId(this.window) : null;
let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
.getService(Ci.nsIConsoleAPIStorage);
ConsoleAPIStorage.clearEvents(windowId);
- CONSOLE_WORKER_IDS.forEach((aId) => {
- ConsoleAPIStorage.clearEvents(aId);
+ CONSOLE_WORKER_IDS.forEach((id) => {
+ ConsoleAPIStorage.clearEvents(id);
});
if (this.parentActor.isRootActor) {
Services.console.logStringMessage(null); // for the Error Console
Services.console.reset();
}
return {};
},
/**
* The "getPreferences" request handler.
*
- * @param object aRequest
+ * @param object request
* The request message - which preferences need to be retrieved.
* @return object
* The response message - a { key: value } object map.
*/
- onGetPreferences: function WCA_onGetPreferences(aRequest)
- {
+ onGetPreferences: function (request) {
let prefs = Object.create(null);
- for (let key of aRequest.preferences) {
+ for (let key of request.preferences) {
prefs[key] = this._prefs[key];
}
return { preferences: prefs };
},
/**
* The "setPreferences" request handler.
*
- * @param object aRequest
+ * @param object request
* The request message - which preferences need to be updated.
*/
- onSetPreferences: function WCA_onSetPreferences(aRequest)
- {
- for (let key in aRequest.preferences) {
- this._prefs[key] = aRequest.preferences[key];
+ onSetPreferences: function (request) {
+ for (let key in request.preferences) {
+ this._prefs[key] = request.preferences[key];
if (this.networkMonitor) {
if (key == "NetworkMonitor.saveRequestAndResponseBodies") {
this.networkMonitor.saveRequestAndResponseBodies = this._prefs[key];
if (this.networkMonitorChild) {
this.networkMonitorChild.saveRequestAndResponseBodies =
this._prefs[key];
}
} else if (key == "NetworkMonitor.throttleData") {
this.networkMonitor.throttleData = this._prefs[key];
if (this.networkMonitorChild) {
this.networkMonitorChild.throttleData = this._prefs[key];
}
}
}
}
- return { updated: Object.keys(aRequest.preferences) };
+ return { updated: Object.keys(request.preferences) };
},
// End of request handlers.
/**
* Create an object with the API we expose to the Web Console during
* JavaScript evaluation.
* This object inherits properties and methods from the Web Console actor.
*
* @private
- * @param object aDebuggerGlobal
+ * @param object debuggerGlobal
* A Debugger.Object that wraps a content global. This is used for the
* Web Console Commands.
* @return object
* The same object as |this|, but with an added |sandbox| property.
* The sandbox holds methods and properties that can be used as
* bindings during JS evaluation.
*/
- _getWebConsoleCommands: function (aDebuggerGlobal)
- {
+ _getWebConsoleCommands: function (debuggerGlobal) {
let helpers = {
window: this.evalWindow,
chromeWindow: this.chromeWindow.bind(this),
- makeDebuggeeValue: aDebuggerGlobal.makeDebuggeeValue.bind(aDebuggerGlobal),
+ makeDebuggeeValue: debuggerGlobal.makeDebuggeeValue.bind(debuggerGlobal),
createValueGrip: this.createValueGrip.bind(this),
sandbox: Object.create(null),
helperResult: null,
consoleActor: this,
};
addWebConsoleCommands(helpers);
let evalWindow = this.evalWindow;
@@ -1186,17 +1171,17 @@ WebConsoleActor.prototype =
// Workers don't have access to Cu so won't be able to exportFunction.
if (!isWorker) {
maybeExport(desc, "get");
maybeExport(desc, "set");
maybeExport(desc, "value");
}
if (desc.value) {
// Make sure the helpers can be used during eval.
- desc.value = aDebuggerGlobal.makeDebuggeeValue(desc.value);
+ desc.value = debuggerGlobal.makeDebuggeeValue(desc.value);
}
Object.defineProperty(helpers.sandbox, name, desc);
}
return helpers;
},
/**
* Evaluates a string using the debugger API.
@@ -1227,19 +1212,19 @@ WebConsoleActor.prototype =
*
* When |bindObjectActor| is used objects can come from different iframes,
* from different domains. To avoid permission-related errors when objects
* come from a different window, we also determine the object's own global,
* such that evaluation happens in the context of that global. This means that
* evaluation will happen in the object's iframe, rather than the top level
* window.
*
- * @param string aString
+ * @param string string
* String to evaluate.
- * @param object [aOptions]
+ * @param object [options]
* Options for evaluation:
* - bindObjectActor: the ObjectActor ID to use for evaluation.
* |evalWithBindings()| will be called with one additional binding:
* |_self| which will point to the Debugger.Object of the given
* ObjectActor.
* - selectedObjectActor: Like bindObjectActor, but executes with the
* top level window as the global.
* - frameActor: the FrameActor ID to use for evaluation. The given
@@ -1255,157 +1240,155 @@ WebConsoleActor.prototype =
* - dbg: the debugger where the string was evaluated.
* - frame: (optional) the frame where the string was evaluated.
* - window: the Debugger.Object for the global where the string was
* evaluated.
* - result: the result of the evaluation.
* - helperResult: any result coming from a Web Console commands
* function.
*/
- evalWithDebugger: function WCA_evalWithDebugger(aString, aOptions = {})
- {
- let trimmedString = aString.trim();
+ /* eslint-disable complexity */
+ evalWithDebugger: function (string, options = {}) {
+ let trimmedString = string.trim();
// The help function needs to be easy to guess, so we make the () optional.
if (trimmedString == "help" || trimmedString == "?") {
- aString = "help()";
+ string = "help()";
}
// Add easter egg for console.mihai().
if (trimmedString == "console.mihai()" || trimmedString == "console.mihai();") {
- aString = "\"http://incompleteness.me/blog/2015/02/09/console-dot-mihai/\"";
+ string = "\"http://incompleteness.me/blog/2015/02/09/console-dot-mihai/\"";
}
// Find the Debugger.Frame of the given FrameActor.
let frame = null, frameActor = null;
- if (aOptions.frameActor) {
- frameActor = this.conn.getActor(aOptions.frameActor);
+ if (options.frameActor) {
+ frameActor = this.conn.getActor(options.frameActor);
if (frameActor) {
frame = frameActor.frame;
- }
- else {
+ } else {
DevToolsUtils.reportException("evalWithDebugger",
- Error("The frame actor was not found: " + aOptions.frameActor));
+ Error("The frame actor was not found: " + options.frameActor));
}
}
// If we've been given a frame actor in whose scope we should evaluate the
// expression, be sure to use that frame's Debugger (that is, the JavaScript
// debugger's Debugger) for the whole operation, not the console's Debugger.
// (One Debugger will treat a different Debugger's Debugger.Object instances
// as ordinary objects, not as references to be followed, so mixing
// debuggers causes strange behaviors.)
let dbg = frame ? frameActor.threadActor.dbg : this.dbg;
let dbgWindow = dbg.makeGlobalObjectReference(this.evalWindow);
// If we have an object to bind to |_self|, create a Debugger.Object
// referring to that object, belonging to dbg.
let bindSelf = null;
- if (aOptions.bindObjectActor || aOptions.selectedObjectActor) {
- let objActor = this.getActorByID(aOptions.bindObjectActor ||
- aOptions.selectedObjectActor);
+ if (options.bindObjectActor || options.selectedObjectActor) {
+ let objActor = this.getActorByID(options.bindObjectActor ||
+ options.selectedObjectActor);
if (objActor) {
let jsObj = objActor.obj.unsafeDereference();
// If we use the makeDebuggeeValue method of jsObj's own global, then
// we'll get a D.O that sees jsObj as viewed from its own compartment -
// that is, without wrappers. The evalWithBindings call will then wrap
// jsObj appropriately for the evaluation compartment.
let global = Cu.getGlobalForObject(jsObj);
let _dbgWindow = dbg.makeGlobalObjectReference(global);
bindSelf = dbgWindow.makeDebuggeeValue(jsObj);
- if (aOptions.bindObjectActor) {
+ if (options.bindObjectActor) {
dbgWindow = _dbgWindow;
}
}
}
// Get the Web Console commands for the given debugger window.
let helpers = this._getWebConsoleCommands(dbgWindow);
let bindings = helpers.sandbox;
if (bindSelf) {
bindings._self = bindSelf;
}
- if (aOptions.selectedNodeActor) {
- let actor = this.conn.getActor(aOptions.selectedNodeActor);
+ if (options.selectedNodeActor) {
+ let actor = this.conn.getActor(options.selectedNodeActor);
if (actor) {
helpers.selectedNode = actor.rawNode;
}
}
// Check if the Debugger.Frame or Debugger.Object for the global include
// $ or $$. We will not overwrite these functions with the Web Console
// commands.
let found$ = false, found$$ = false;
if (frame) {
let env = frame.environment;
if (env) {
found$ = !!env.find("$");
found$$ = !!env.find("$$");
}
- }
- else {
+ } else {
found$ = !!dbgWindow.getOwnPropertyDescriptor("$");
found$$ = !!dbgWindow.getOwnPropertyDescriptor("$$");
}
let $ = null, $$ = null;
if (found$) {
$ = bindings.$;
delete bindings.$;
}
if (found$$) {
$$ = bindings.$$;
delete bindings.$$;
}
// Ready to evaluate the string.
- helpers.evalInput = aString;
+ helpers.evalInput = string;
let evalOptions;
- if (typeof aOptions.url == "string") {
- evalOptions = { url: aOptions.url };
+ if (typeof options.url == "string") {
+ evalOptions = { url: options.url };
}
// If the debugger object is changed from the last evaluation,
// adopt this._lastConsoleInputEvaluation value in the new debugger,
// to prevents "Debugger.Object belongs to a different Debugger" exceptions
// related to the $_ bindings.
if (this._lastConsoleInputEvaluation &&
this._lastConsoleInputEvaluation.global !== dbgWindow) {
this._lastConsoleInputEvaluation = dbg.adoptDebuggeeValue(
this._lastConsoleInputEvaluation
);
}
let result;
if (frame) {
- result = frame.evalWithBindings(aString, bindings, evalOptions);
- }
- else {
- result = dbgWindow.executeInGlobalWithBindings(aString, bindings, evalOptions);
+ result = frame.evalWithBindings(string, bindings, evalOptions);
+ } else {
+ result = dbgWindow.executeInGlobalWithBindings(string, bindings, evalOptions);
// Attempt to initialize any declarations found in the evaluated string
// since they may now be stuck in an "initializing" state due to the
// error. Already-initialized bindings will be ignored.
if ("throw" in result) {
let ast;
// Parse errors will raise an exception. We can/should ignore the error
// since it's already being handled elsewhere and we are only interested
// in initializing bindings.
try {
- ast = Parser.reflectionAPI.parse(aString);
+ ast = Parser.reflectionAPI.parse(string);
} catch (ex) {
ast = {"body": []};
}
for (let line of ast.body) {
// Only let and const declarations put bindings into an
// "initializing" state.
- if (!(line.kind == "let" || line.kind == "const"))
+ if (!(line.kind == "let" || line.kind == "const")) {
continue;
+ }
let identifiers = [];
for (let decl of line.declarations) {
switch (decl.id.type) {
case "Identifier":
// let foo = bar;
identifiers.push(decl.id.name);
break;
@@ -1421,31 +1404,33 @@ WebConsoleActor.prototype =
}
break;
case "ObjectPattern":
// let {bilbo, my} = {bilbo: "baggins", my: "precious"};
// let {blah: foo} = {blah: yabba()}
// let {blah: foo=99} = {blah: yabba()}
for (let prop of decl.id.properties) {
// key
- if (prop.key.type == "Identifier")
+ if (prop.key.type == "Identifier") {
identifiers.push(prop.key.name);
+ }
// value
if (prop.value.type == "Identifier") {
identifiers.push(prop.value.name);
} else if (prop.value.type == "AssignmentExpression") {
identifiers.push(prop.value.left.name);
}
}
break;
}
}
- for (let name of identifiers)
+ for (let name of identifiers) {
dbgWindow.forceLexicalInitializationByName(name);
+ }
}
}
}
let helperResult = helpers.helperResult;
delete helpers.evalInput;
delete helpers.helperResult;
delete helpers.selectedNode;
@@ -1464,152 +1449,148 @@ WebConsoleActor.prototype =
return {
result: result,
helperResult: helperResult,
dbg: dbg,
frame: frame,
window: dbgWindow,
};
},
+ /* eslint-enable complexity */
// Event handlers for various listeners.
/**
* Handler for messages received from the ConsoleServiceListener. This method
* sends the nsIConsoleMessage to the remote Web Console client.
*
- * @param nsIConsoleMessage aMessage
+ * @param nsIConsoleMessage message
* The message we need to send to the client.
*/
- onConsoleServiceMessage: function WCA_onConsoleServiceMessage(aMessage)
- {
+ onConsoleServiceMessage: function (message) {
let packet;
- if (aMessage instanceof Ci.nsIScriptError) {
+ if (message instanceof Ci.nsIScriptError) {
packet = {
from: this.actorID,
type: "pageError",
- pageError: this.preparePageErrorForRemote(aMessage),
+ pageError: this.preparePageErrorForRemote(message),
};
- }
- else {
+ } else {
packet = {
from: this.actorID,
type: "logMessage",
- message: this._createStringGrip(aMessage.message),
- timeStamp: aMessage.timeStamp,
+ message: this._createStringGrip(message.message),
+ timeStamp: message.timeStamp,
};
}
this.conn.send(packet);
},
/**
* Prepare an nsIScriptError to be sent to the client.
*
- * @param nsIScriptError aPageError
+ * @param nsIScriptError pageError
* The page error we need to send to the client.
* @return object
* The object you can send to the remote client.
*/
- preparePageErrorForRemote: function WCA_preparePageErrorForRemote(aPageError)
- {
+ preparePageErrorForRemote: function (pageError) {
let stack = null;
// Convert stack objects to the JSON attributes expected by client code
// Bug 1348885: If the global from which this error came from has been
// nuked, stack is going to be a dead wrapper.
- if (aPageError.stack && !Cu.isDeadWrapper(aPageError.stack)) {
+ if (pageError.stack && !Cu.isDeadWrapper(pageError.stack)) {
stack = [];
- let s = aPageError.stack;
+ let s = pageError.stack;
while (s !== null) {
stack.push({
filename: s.source,
lineNumber: s.line,
columnNumber: s.column,
functionName: s.functionDisplayName
});
s = s.parent;
}
}
- let lineText = aPageError.sourceLine;
+ let lineText = pageError.sourceLine;
if (lineText && lineText.length > DebuggerServer.LONG_STRING_INITIAL_LENGTH) {
lineText = lineText.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
}
let notesArray = null;
- let notes = aPageError.notes;
+ let notes = pageError.notes;
if (notes && notes.length) {
notesArray = [];
for (let i = 0, len = notes.length; i < len; i++) {
let note = notes.queryElementAt(i, Ci.nsIScriptErrorNote);
notesArray.push({
messageBody: this._createStringGrip(note.errorMessage),
frame: {
source: note.sourceName,
line: note.lineNumber,
column: note.columnNumber,
}
});
}
}
return {
- errorMessage: this._createStringGrip(aPageError.errorMessage),
- errorMessageName: aPageError.errorMessageName,
- exceptionDocURL: ErrorDocs.GetURL(aPageError),
- sourceName: aPageError.sourceName,
+ errorMessage: this._createStringGrip(pageError.errorMessage),
+ errorMessageName: pageError.errorMessageName,
+ exceptionDocURL: ErrorDocs.GetURL(pageError),
+ sourceName: pageError.sourceName,
lineText: lineText,
- lineNumber: aPageError.lineNumber,
- columnNumber: aPageError.columnNumber,
- category: aPageError.category,
- timeStamp: aPageError.timeStamp,
- warning: !!(aPageError.flags & aPageError.warningFlag),
- error: !!(aPageError.flags & aPageError.errorFlag),
- exception: !!(aPageError.flags & aPageError.exceptionFlag),
- strict: !!(aPageError.flags & aPageError.strictFlag),
- info: !!(aPageError.flags & aPageError.infoFlag),
- private: aPageError.isFromPrivateWindow,
+ lineNumber: pageError.lineNumber,
+ columnNumber: pageError.columnNumber,
+ category: pageError.category,
+ timeStamp: pageError.timeStamp,
+ warning: !!(pageError.flags & pageError.warningFlag),
+ error: !!(pageError.flags & pageError.errorFlag),
+ exception: !!(pageError.flags & pageError.exceptionFlag),
+ strict: !!(pageError.flags & pageError.strictFlag),
+ info: !!(pageError.flags & pageError.infoFlag),
+ private: pageError.isFromPrivateWindow,
stacktrace: stack,
notes: notesArray,
};
},
/**
* Handler for window.console API calls received from the ConsoleAPIListener.
* This method sends the object to the remote Web Console client.
*
* @see ConsoleAPIListener
- * @param object aMessage
+ * @param object message
* The console API call we need to send to the remote client.
*/
- onConsoleAPICall: function WCA_onConsoleAPICall(aMessage)
- {
+ onConsoleAPICall: function (message) {
let packet = {
from: this.actorID,
type: "consoleAPICall",
- message: this.prepareConsoleMessageForRemote(aMessage),
+ message: this.prepareConsoleMessageForRemote(message),
};
this.conn.send(packet);
},
/**
* Handler for network events. This method is invoked when a new network event
* is about to be recorded.
*
* @see NetworkEventActor
* @see NetworkMonitor from webconsole/utils.js
*
- * @param object aEvent
+ * @param object event
* The initial network request event information.
* @return object
* A new NetworkEventActor is returned. This is used for tracking the
* network request and response.
*/
- onNetworkEvent: function WCA_onNetworkEvent(aEvent)
- {
- let actor = this.getNetworkEventActor(aEvent.channelId);
- actor.init(aEvent);
+ onNetworkEvent: function (event) {
+ let actor = this.getNetworkEventActor(event.channelId);
+ actor.init(event);
let packet = {
from: this.actorID,
type: "networkEvent",
eventActor: actor.grip()
};
this.conn.send(packet);
@@ -1621,17 +1602,17 @@ WebConsoleActor.prototype =
* Get the NetworkEventActor for a nsIHttpChannel, if it exists,
* otherwise create a new one.
*
* @param string channelId
* The id of the channel for the network event.
* @return object
* The NetworkEventActor for the given channel.
*/
- getNetworkEventActor: function WCA_getNetworkEventActor(channelId) {
+ getNetworkEventActor: function (channelId) {
let actor = this._netEvents.get(channelId);
if (actor) {
// delete from map as we should only need to do this check once
this._netEvents.delete(channelId);
return actor;
}
actor = new NetworkEventActor(this);
@@ -1693,65 +1674,62 @@ WebConsoleActor.prototype =
};
},
/**
* Handler for file activity. This method sends the file request information
* to the remote Web Console client.
*
* @see ConsoleProgressListener
- * @param string aFileURI
+ * @param string fileURI
* The requested file URI.
*/
- onFileActivity: function WCA_onFileActivity(aFileURI)
- {
+ onFileActivity: function (fileURI) {
let packet = {
from: this.actorID,
type: "fileActivity",
- uri: aFileURI,
+ uri: fileURI,
};
this.conn.send(packet);
},
/**
* Handler for reflow activity. This method forwards reflow events to the
* remote Web Console client.
*
* @see ConsoleReflowListener
- * @param Object aReflowInfo
+ * @param Object reflowInfo
*/
- onReflowActivity: function WCA_onReflowActivity(aReflowInfo)
- {
+ onReflowActivity: function (reflowInfo) {
let packet = {
from: this.actorID,
type: "reflowActivity",
- interruptible: aReflowInfo.interruptible,
- start: aReflowInfo.start,
- end: aReflowInfo.end,
- sourceURL: aReflowInfo.sourceURL,
- sourceLine: aReflowInfo.sourceLine,
- functionName: aReflowInfo.functionName
+ interruptible: reflowInfo.interruptible,
+ start: reflowInfo.start,
+ end: reflowInfo.end,
+ sourceURL: reflowInfo.sourceURL,
+ sourceLine: reflowInfo.sourceLine,
+ functionName: reflowInfo.functionName
};
this.conn.send(packet);
},
/**
* Handler for server logging. This method forwards log events to the
* remote Web Console client.
*
* @see ServerLoggingListener
- * @param object aMessage
+ * @param object message
* The console API call on the server we need to send to the remote client.
*/
- onServerLogCall: function WCA_onServerLogCall(aMessage)
- {
+ onServerLogCall: function (message) {
// Clone all data into the content scope (that's where
// passed arguments comes from).
- let msg = Cu.cloneInto(aMessage, this.window);
+ let msg = Cu.cloneInto(message, this.window);
// All arguments within the message need to be converted into
// debuggees to properly send it to the client side.
// Use the default target: this.window as the global object
// since that's the correct scope for data in the message.
// The 'false' argument passed into prepareConsoleMessageForRemote()
// ensures that makeDebuggeeValue uses content debuggee.
// See also:
@@ -1769,114 +1747,107 @@ WebConsoleActor.prototype =
},
// End of event handlers for various listeners.
/**
* Prepare a message from the console API to be sent to the remote Web Console
* instance.
*
- * @param object aMessage
+ * @param object message
* The original message received from console-api-log-event.
* @param boolean aUseObjectGlobal
* If |true| the object global is determined and added as a debuggee,
* otherwise |this.window| is used when makeDebuggeeValue() is invoked.
* @return object
* The object that can be sent to the remote client.
*/
- prepareConsoleMessageForRemote:
- function WCA_prepareConsoleMessageForRemote(aMessage, aUseObjectGlobal = true)
- {
- let result = WebConsoleUtils.cloneObject(aMessage);
+ prepareConsoleMessageForRemote: function (message, useObjectGlobal = true) {
+ let result = WebConsoleUtils.cloneObject(message);
result.workerType = WebConsoleUtils.getWorkerType(result) || "none";
delete result.wrappedJSObject;
delete result.ID;
delete result.innerID;
delete result.consoleID;
delete result.originAttributes;
- result.arguments = Array.map(aMessage.arguments || [], (aObj) => {
- let dbgObj = this.makeDebuggeeValue(aObj, aUseObjectGlobal);
+ result.arguments = Array.map(message.arguments || [], (obj) => {
+ let dbgObj = this.makeDebuggeeValue(obj, useObjectGlobal);
return this.createValueGrip(dbgObj);
});
- result.styles = Array.map(aMessage.styles || [], (aString) => {
- return this.createValueGrip(aString);
+ result.styles = Array.map(message.styles || [], (string) => {
+ return this.createValueGrip(string);
});
- result.category = aMessage.category || "webdev";
+ result.category = message.category || "webdev";
return result;
},
/**
* Find the XUL window that owns the content window.
*
* @return Window
* The XUL window that owns the content window.
*/
- chromeWindow: function WCA_chromeWindow()
- {
+ chromeWindow: function () {
let window = null;
try {
window = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell)
.chromeEventHandler.ownerGlobal;
- }
- catch (ex) {
+ } catch (ex) {
// The above can fail because chromeEventHandler is not available for all
// kinds of |this.window|.
}
return window;
},
/**
* Notification observer for the "last-pb-context-exited" topic.
*
* @private
- * @param object aSubject
+ * @param object subject
* Notification subject - in this case it is the inner window ID that
* was destroyed.
- * @param string aTopic
+ * @param string topic
* Notification topic.
*/
- _onObserverNotification: function WCA__onObserverNotification(aSubject, aTopic)
- {
- switch (aTopic) {
+ _onObserverNotification: function (subject, topic) {
+ switch (topic) {
case "last-pb-context-exited":
this.conn.send({
from: this.actorID,
type: "lastPrivateContextExited",
});
break;
}
},
/**
* The "will-navigate" progress listener. This is used to clear the current
* eval scope.
*/
- _onWillNavigate: function WCA__onWillNavigate({ window, isTopLevel })
- {
+ _onWillNavigate: function ({ window, isTopLevel }) {
if (isTopLevel) {
this._evalWindow = null;
events.off(this.parentActor, "will-navigate", this._onWillNavigate);
this._progressListenerActive = false;
}
},
/**
* This listener is called when we switch to another frame,
* mostly to unregister previous listeners and start listening on the new document.
*/
- _onChangedToplevelDocument: function WCA__onChangedToplevelDocument()
- {
+ _onChangedToplevelDocument: function () {
// Convert the Set to an Array
let listeners = [...this._listeners];
// Unregister existing listener on the previous document
// (pass a copy of the array as it will shift from it)
this.onStopListeners({listeners: listeners.slice()});
// This method is called after this.window is changed,
@@ -1944,18 +1915,17 @@ NetworkEventActor.prototype =
_timings: null,
_longStringActors: null,
actorPrefix: "netEvent",
/**
* Returns a grip for this actor for returning in a protocol message.
*/
- grip: function NEA_grip()
- {
+ grip: function () {
return {
actor: this.actorID,
startedDateTime: this._startedDateTime,
timeStamp: Date.parse(this._startedDateTime),
url: this._request.url,
method: this._request.method,
isXHR: this._isXHR,
cause: this._cause,
@@ -1963,18 +1933,17 @@ NetworkEventActor.prototype =
fromServiceWorker: this._fromServiceWorker,
private: this._private,
};
},
/**
* Releases this actor from the pool.
*/
- release: function NEA_release()
- {
+ release: function () {
for (let grip of this._longStringActors) {
let actor = this.parent.getActorByID(grip.actor);
if (actor) {
this.parent.releaseActor(actor);
}
}
this._longStringActors = new Set();
@@ -1982,404 +1951,383 @@ NetworkEventActor.prototype =
this.parent._netEvents.delete(this.channel);
}
this.parent.releaseActor(this);
},
/**
* Handle a protocol request to release a grip.
*/
- onRelease: function NEA_onRelease()
- {
+ onRelease: function () {
this.release();
return {};
},
/**
* Set the properties of this actor based on it's corresponding
* network event.
*
- * @param object aNetworkEvent
+ * @param object networkEvent
* The network event associated with this actor.
*/
- init: function NEA_init(aNetworkEvent)
- {
- this._startedDateTime = aNetworkEvent.startedDateTime;
- this._isXHR = aNetworkEvent.isXHR;
- this._cause = aNetworkEvent.cause;
- this._fromCache = aNetworkEvent.fromCache;
- this._fromServiceWorker = aNetworkEvent.fromServiceWorker;
+ init: function (networkEvent) {
+ this._startedDateTime = networkEvent.startedDateTime;
+ this._isXHR = networkEvent.isXHR;
+ this._cause = networkEvent.cause;
+ this._fromCache = networkEvent.fromCache;
+ this._fromServiceWorker = networkEvent.fromServiceWorker;
for (let prop of ["method", "url", "httpVersion", "headersSize"]) {
- this._request[prop] = aNetworkEvent[prop];
+ this._request[prop] = networkEvent[prop];
}
- this._discardRequestBody = aNetworkEvent.discardRequestBody;
- this._discardResponseBody = aNetworkEvent.discardResponseBody;
- this._private = aNetworkEvent.private;
+ this._discardRequestBody = networkEvent.discardRequestBody;
+ this._discardResponseBody = networkEvent.discardResponseBody;
+ this._private = networkEvent.private;
},
/**
* The "getRequestHeaders" packet type handler.
*
* @return object
* The response packet - network request headers.
*/
- onGetRequestHeaders: function NEA_onGetRequestHeaders()
- {
+ onGetRequestHeaders: function () {
return {
from: this.actorID,
headers: this._request.headers,
headersSize: this._request.headersSize,
rawHeaders: this._request.rawHeaders,
};
},
/**
* The "getRequestCookies" packet type handler.
*
* @return object
* The response packet - network request cookies.
*/
- onGetRequestCookies: function NEA_onGetRequestCookies()
- {
+ onGetRequestCookies: function () {
return {
from: this.actorID,
cookies: this._request.cookies,
};
},
/**
* The "getRequestPostData" packet type handler.
*
* @return object
* The response packet - network POST data.
*/
- onGetRequestPostData: function NEA_onGetRequestPostData()
- {
+ onGetRequestPostData: function () {
return {
from: this.actorID,
postData: this._request.postData,
postDataDiscarded: this._discardRequestBody,
};
},
/**
* The "getSecurityInfo" packet type handler.
*
* @return object
* The response packet - connection security information.
*/
- onGetSecurityInfo: function NEA_onGetSecurityInfo()
- {
+ onGetSecurityInfo: function () {
return {
from: this.actorID,
securityInfo: this._securityInfo,
};
},
/**
* The "getResponseHeaders" packet type handler.
*
* @return object
* The response packet - network response headers.
*/
- onGetResponseHeaders: function NEA_onGetResponseHeaders()
- {
+ onGetResponseHeaders: function () {
return {
from: this.actorID,
headers: this._response.headers,
headersSize: this._response.headersSize,
rawHeaders: this._response.rawHeaders,
};
},
/**
* The "getResponseCookies" packet type handler.
*
* @return object
* The response packet - network response cookies.
*/
- onGetResponseCookies: function NEA_onGetResponseCookies()
- {
+ onGetResponseCookies: function () {
return {
from: this.actorID,
cookies: this._response.cookies,
};
},
/**
* The "getResponseContent" packet type handler.
*
* @return object
* The response packet - network response content.
*/
- onGetResponseContent: function NEA_onGetResponseContent()
- {
+ onGetResponseContent: function () {
return {
from: this.actorID,
content: this._response.content,
contentDiscarded: this._discardResponseBody,
};
},
/**
* The "getEventTimings" packet type handler.
*
* @return object
* The response packet - network event timings.
*/
- onGetEventTimings: function NEA_onGetEventTimings()
- {
+ onGetEventTimings: function () {
return {
from: this.actorID,
timings: this._timings,
totalTime: this._totalTime
};
},
/** ****************************************************************
* Listeners for new network event data coming from NetworkMonitor.
******************************************************************/
/**
* Add network request headers.
*
- * @param array aHeaders
+ * @param array headers
* The request headers array.
- * @param string aRawHeaders
+ * @param string rawHeaders
* The raw headers source.
*/
- addRequestHeaders: function NEA_addRequestHeaders(aHeaders, aRawHeaders)
- {
- this._request.headers = aHeaders;
- this._prepareHeaders(aHeaders);
+ addRequestHeaders: function (headers, rawHeaders) {
+ this._request.headers = headers;
+ this._prepareHeaders(headers);
- var rawHeaders = this.parent._createStringGrip(aRawHeaders);
+ rawHeaders = this.parent._createStringGrip(rawHeaders);
if (typeof rawHeaders == "object") {
this._longStringActors.add(rawHeaders);
}
this._request.rawHeaders = rawHeaders;
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "requestHeaders",
- headers: aHeaders.length,
+ headers: headers.length,
headersSize: this._request.headersSize,
};
this.conn.send(packet);
},
/**
* Add network request cookies.
*
- * @param array aCookies
+ * @param array cookies
* The request cookies array.
*/
- addRequestCookies: function NEA_addRequestCookies(aCookies)
- {
- this._request.cookies = aCookies;
- this._prepareHeaders(aCookies);
+ addRequestCookies: function (cookies) {
+ this._request.cookies = cookies;
+ this._prepareHeaders(cookies);
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "requestCookies",
- cookies: aCookies.length,
+ cookies: cookies.length,
};
this.conn.send(packet);
},
/**
* Add network request POST data.
*
- * @param object aPostData
+ * @param object postData
* The request POST data.
*/
- addRequestPostData: function NEA_addRequestPostData(aPostData)
- {
- this._request.postData = aPostData;
- aPostData.text = this.parent._createStringGrip(aPostData.text);
- if (typeof aPostData.text == "object") {
- this._longStringActors.add(aPostData.text);
+ addRequestPostData: function (postData) {
+ this._request.postData = postData;
+ postData.text = this.parent._createStringGrip(postData.text);
+ if (typeof postData.text == "object") {
+ this._longStringActors.add(postData.text);
}
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "requestPostData",
- dataSize: aPostData.text.length,
+ dataSize: postData.text.length,
discardRequestBody: this._discardRequestBody,
};
this.conn.send(packet);
},
/**
* Add the initial network response information.
*
- * @param object aInfo
+ * @param object info
* The response information.
- * @param string aRawHeaders
+ * @param string rawHeaders
* The raw headers source.
*/
- addResponseStart: function NEA_addResponseStart(aInfo, aRawHeaders)
- {
- var rawHeaders = this.parent._createStringGrip(aRawHeaders);
+ addResponseStart: function (info, rawHeaders) {
+ rawHeaders = this.parent._createStringGrip(rawHeaders);
if (typeof rawHeaders == "object") {
this._longStringActors.add(rawHeaders);
}
this._response.rawHeaders = rawHeaders;
- this._response.httpVersion = aInfo.httpVersion;
- this._response.status = aInfo.status;
- this._response.statusText = aInfo.statusText;
- this._response.headersSize = aInfo.headersSize;
- this._discardResponseBody = aInfo.discardResponseBody;
+ this._response.httpVersion = info.httpVersion;
+ this._response.status = info.status;
+ this._response.statusText = info.statusText;
+ this._response.headersSize = info.headersSize;
+ this._discardResponseBody = info.discardResponseBody;
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "responseStart",
- response: aInfo
+ response: info
};
this.conn.send(packet);
},
/**
* Add connection security information.
*
* @param object info
* The object containing security information.
*/
- addSecurityInfo: function NEA_addSecurityInfo(info)
- {
+ addSecurityInfo: function (info) {
this._securityInfo = info;
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "securityInfo",
state: info.state,
};
this.conn.send(packet);
},
/**
* Add network response headers.
*
- * @param array aHeaders
+ * @param array headers
* The response headers array.
*/
- addResponseHeaders: function NEA_addResponseHeaders(aHeaders)
- {
- this._response.headers = aHeaders;
- this._prepareHeaders(aHeaders);
+ addResponseHeaders: function (headers) {
+ this._response.headers = headers;
+ this._prepareHeaders(headers);
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "responseHeaders",
- headers: aHeaders.length,
+ headers: headers.length,
headersSize: this._response.headersSize,
};
this.conn.send(packet);
},
/**
* Add network response cookies.
*
- * @param array aCookies
+ * @param array cookies
* The response cookies array.
*/
- addResponseCookies: function NEA_addResponseCookies(aCookies)
- {
- this._response.cookies = aCookies;
- this._prepareHeaders(aCookies);
+ addResponseCookies: function (cookies) {
+ this._response.cookies = cookies;
+ this._prepareHeaders(cookies);
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "responseCookies",
- cookies: aCookies.length,
+ cookies: cookies.length,
};
this.conn.send(packet);
},
/**
* Add network response content.
*
- * @param object aContent
+ * @param object content
* The response content.
- * @param boolean aDiscardedResponseBody
+ * @param boolean discardedResponseBody
* Tells if the response content was recorded or not.
*/
- addResponseContent:
- function NEA_addResponseContent(aContent, aDiscardedResponseBody)
- {
- this._response.content = aContent;
- aContent.text = this.parent._createStringGrip(aContent.text);
- if (typeof aContent.text == "object") {
- this._longStringActors.add(aContent.text);
+ addResponseContent: function (content, discardedResponseBody) {
+ this._response.content = content;
+ content.text = this.parent._createStringGrip(content.text);
+ if (typeof content.text == "object") {
+ this._longStringActors.add(content.text);
}
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "responseContent",
- mimeType: aContent.mimeType,
- contentSize: aContent.size,
- encoding: aContent.encoding,
- transferredSize: aContent.transferredSize,
- discardResponseBody: aDiscardedResponseBody,
+ mimeType: content.mimeType,
+ contentSize: content.size,
+ encoding: content.encoding,
+ transferredSize: content.transferredSize,
+ discardResponseBody: discardedResponseBody,
};
this.conn.send(packet);
},
/**
* Add network event timing information.
*
- * @param number aTotal
+ * @param number total
* The total time of the network event.
- * @param object aTimings
+ * @param object timings
* Timing details about the network event.
*/
- addEventTimings: function NEA_addEventTimings(aTotal, aTimings)
- {
- this._totalTime = aTotal;
- this._timings = aTimings;
+ addEventTimings: function (total, timings) {
+ this._totalTime = total;
+ this._timings = timings;
let packet = {
from: this.actorID,
type: "networkEventUpdate",
updateType: "eventTimings",
- totalTime: aTotal
+ totalTime: total
};
this.conn.send(packet);
},
/**
* Prepare the headers array to be sent to the client by using the
* LongStringActor for the header values, when needed.
*
* @private
* @param array aHeaders
*/
- _prepareHeaders: function NEA__prepareHeaders(aHeaders)
- {
- for (let header of aHeaders) {
+ _prepareHeaders: function (headers) {
+ for (let header of headers) {
header.value = this.parent._createStringGrip(header.value);
if (typeof header.value == "object") {
this._longStringActors.add(header.value);
}
}
},
};