From 3e02aa5978268d680af3e6ea21f8f54ff58058f5 Mon Sep 17 00:00:00 2001 From: Dalimil Hajek Date: Mon, 16 Jan 2017 12:51:00 -0500 Subject: [PATCH] Bug 1322085 - Make devtools/server/actors/*.js eslint-clean. r=ntim --- .eslintignore | 17 +- devtools/.eslintrc.js | 2 +- devtools/server/actors/actor-registry.js | 4 - devtools/server/actors/addon.js | 83 ++++---- devtools/server/actors/addons.js | 1 - devtools/server/actors/animation.js | 7 +- devtools/server/actors/breakpoint.js | 13 +- devtools/server/actors/call-watcher.js | 72 ++++--- devtools/server/actors/canvas.js | 69 +++--- devtools/server/actors/child-process.js | 5 +- devtools/server/actors/childtab.js | 3 +- devtools/server/actors/chrome.js | 26 +-- devtools/server/actors/common.js | 89 ++++---- devtools/server/actors/css-properties.js | 2 +- devtools/server/actors/device.js | 5 +- devtools/server/actors/director-manager.js | 80 ++++--- devtools/server/actors/director-registry.js | 10 +- devtools/server/actors/environment.js | 5 +- devtools/server/actors/errordocs.js | 6 +- devtools/server/actors/eventlooplag.js | 2 +- devtools/server/actors/frame.js | 2 +- devtools/server/actors/framerate.js | 3 +- devtools/server/actors/gcli.js | 14 +- devtools/server/actors/heap-snapshot-file.js | 1 - devtools/server/actors/highlighters.js | 11 +- devtools/server/actors/monitor.js | 12 +- devtools/server/actors/performance-entries.js | 2 + .../server/actors/performance-recording.js | 4 +- devtools/server/actors/performance.js | 1 - devtools/server/actors/preference.js | 10 +- devtools/server/actors/pretty-print-worker.js | 7 +- devtools/server/actors/process.js | 13 +- devtools/server/actors/profiler.js | 2 +- devtools/server/actors/reflow.js | 7 +- devtools/server/actors/root.js | 94 +++++---- devtools/server/actors/settings.js | 6 +- devtools/server/actors/source.js | 196 ++++++++++-------- devtools/server/actors/storage.js | 12 +- devtools/server/actors/timeline.js | 2 +- .../actors/utils/map-uri-to-addon-id.js | 2 - .../actors/utils/webconsole-listeners.js | 9 +- devtools/server/actors/webaudio.js | 66 +++--- devtools/server/actors/webgl.js | 70 ++++--- devtools/server/actors/worker.js | 4 +- 44 files changed, 566 insertions(+), 485 deletions(-) diff --git a/.eslintignore b/.eslintignore index 6be7747c81a4..a93286a2e20e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,7 +6,7 @@ obj*/** # We ignore all these directories by default, until we get them enabled. # If you are enabling a directory, please add directory specific exclusions -# below. +# below. addon-sdk/** build/** caps/** @@ -102,16 +102,11 @@ devtools/client/webconsole/webconsole-connection-proxy.js devtools/client/webconsole/webconsole.js devtools/client/webide/** !devtools/client/webide/components/webideCli.js -devtools/server/actors/*.js -!devtools/server/actors/csscoverage.js -!devtools/server/actors/inspector.js -!devtools/server/actors/layout.js -!devtools/server/actors/string.js -!devtools/server/actors/styles.js -!devtools/server/actors/tab.js -!devtools/server/actors/webbrowser.js -!devtools/server/actors/webextension.js -!devtools/server/actors/webextension-inspected-window.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/** !devtools/server/tests/browser/browser_webextension_inspected_window.js devtools/server/tests/mochitest/** diff --git a/devtools/.eslintrc.js b/devtools/.eslintrc.js index e8223135af3f..16999dea8d3a 100644 --- a/devtools/.eslintrc.js +++ b/devtools/.eslintrc.js @@ -30,7 +30,7 @@ module.exports = { "uneval": true, "URL": true, "WebSocket": true, - "XMLHttpRequest": true, + "XMLHttpRequest": true }, "rules": { // These are the rules that have been configured so far to match the diff --git a/devtools/server/actors/actor-registry.js b/devtools/server/actors/actor-registry.js index 6a083ba6f9b6..90e6136bb09d 100644 --- a/devtools/server/actors/actor-registry.js +++ b/devtools/server/actors/actor-registry.js @@ -5,11 +5,7 @@ "use strict"; const protocol = require("devtools/shared/protocol"); -const { method, custom, Arg, Option, RetVal } = protocol; -const { Cu, CC, components } = require("chrome"); -const Services = require("Services"); -const { DebuggerServer } = require("devtools/server/main"); const { registerActor, unregisterActor } = require("devtools/server/actors/utils/actor-registry-utils"); const { actorActorSpec, actorRegistrySpec } = require("devtools/shared/specs/actor-registry"); diff --git a/devtools/server/actors/addon.js b/devtools/server/actors/addon.js index 014ccfb31d54..3520c06f1a2e 100644 --- a/devtools/server/actors/addon.js +++ b/devtools/server/actors/addon.js @@ -20,9 +20,9 @@ loader.lazyRequireGetter(this, "WebConsoleActor", "devtools/server/actors/webcon loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); -function BrowserAddonActor(aConnection, aAddon) { - this.conn = aConnection; - this._addon = aAddon; +function BrowserAddonActor(connection, addon) { + this.conn = connection; + this._addon = addon; this._contextPool = new ActorPool(this.conn); this.conn.addActorPool(this._contextPool); this.threadActor = null; @@ -70,7 +70,7 @@ BrowserAddonActor.prototype = { return this._sources; }, - form: function BAA_form() { + form: function BAAForm() { assert(this.actorID, "addon should have an actorID."); if (!this._consoleActor) { this._consoleActor = new AddonConsoleActor(this._addon, this.conn, this); @@ -103,31 +103,31 @@ BrowserAddonActor.prototype = { AddonManager.removeAddonListener(this); }, - setOptions: function BAA_setOptions(aOptions) { - if ("global" in aOptions) { - this._global = aOptions.global; + setOptions: function BAASetOptions(options) { + if ("global" in options) { + this._global = options.global; } }, - onInstalled: function BAA_updateAddonWrapper(aAddon) { - if (aAddon.id != this._addon.id) { + onInstalled: function BAAUpdateAddonWrapper(addon) { + if (addon.id != this._addon.id) { return; } // Update the AddonManager's addon object on reload/update. - this._addon = aAddon; + this._addon = addon; }, - onDisabled: function BAA_onDisabled(aAddon) { - if (aAddon != this._addon) { + onDisabled: function BAAOnDisabled(addon) { + if (addon != this._addon) { return; } this._global = null; }, - onUninstalled: function BAA_onUninstalled(aAddon) { - if (aAddon != this._addon) { + onUninstalled: function BAAOnUninstalled(addon) { + if (addon != this._addon) { return; } @@ -142,7 +142,7 @@ BrowserAddonActor.prototype = { this.destroy(); }, - onAttach: function BAA_onAttach() { + onAttach: function BAAOnAttach() { if (this.exited) { return { type: "exited" }; } @@ -155,7 +155,7 @@ BrowserAddonActor.prototype = { return { type: "tabAttached", threadActor: this.threadActor.actorID }; }, - onDetach: function BAA_onDetach() { + onDetach: function BAAOnDetach() { if (!this.attached) { return { error: "wrongState" }; } @@ -168,10 +168,11 @@ BrowserAddonActor.prototype = { return { type: "detached" }; }, - onReload: function BAA_onReload() { + onReload: function BAAOnReload() { return this._addon.reload() .then(() => { - return {}; // send an empty response + // send an empty response + return {}; }); }, @@ -201,15 +202,17 @@ BrowserAddonActor.prototype = { * Return true if the given global is associated with this addon and should be * added as a debuggee, false otherwise. */ - _shouldAddNewGlobalAsDebuggee: function (aGlobal) { - const global = unwrapDebuggerObjectGlobal(aGlobal); + _shouldAddNewGlobalAsDebuggee: function (givenGlobal) { + const global = unwrapDebuggerObjectGlobal(givenGlobal); try { // This will fail for non-Sandbox objects, hence the try-catch block. let metadata = Cu.getSandboxMetadata(global); if (metadata) { return metadata.addonID === this.id; } - } catch (e) {} + } catch (e) { + // ignore + } if (global instanceof Ci.nsIDOMWindow) { return mapURIToAddonID(global.document.documentURIObject) == this.id; @@ -217,13 +220,12 @@ BrowserAddonActor.prototype = { // Check the global for a __URI__ property and then try to map that to an // add-on - let uridescriptor = aGlobal.getOwnPropertyDescriptor("__URI__"); + let uridescriptor = givenGlobal.getOwnPropertyDescriptor("__URI__"); if (uridescriptor && "value" in uridescriptor && uridescriptor.value) { let uri; try { uri = Services.io.newURI(uridescriptor.value); - } - catch (e) { + } catch (e) { DevToolsUtils.reportException( "BrowserAddonActor.prototype._shouldAddNewGlobalAsDebuggee", new Error("Invalid URI: " + uridescriptor.value) @@ -244,9 +246,9 @@ BrowserAddonActor.prototype = { * sure every script and source with a URL is stored when debugging * add-ons. */ - _allowSource: function (aSource) { + _allowSource: function (source) { // XPIProvider.jsm evals some code in every add-on's bootstrap.js. Hide it. - if (aSource.url === "resource://gre/modules/addons/XPIProvider.jsm") { + if (source.url === "resource://gre/modules/addons/XPIProvider.jsm") { return false; } @@ -273,17 +275,16 @@ BrowserAddonActor.prototype.requestTypes = { * console feature. * * @constructor - * @param object aAddon + * @param object addon * The add-on that this console watches. - * @param object aConnection + * @param object connection * The connection to the client, DebuggerServerConnection. - * @param object aParentActor + * @param object parentActor * The parent BrowserAddonActor actor. */ -function AddonConsoleActor(aAddon, aConnection, aParentActor) -{ - this.addon = aAddon; - WebConsoleActor.call(this, aConnection, aParentActor); +function AddonConsoleActor(addon, connection, parentActor) { + this.addon = addon; + WebConsoleActor.call(this, connection, parentActor); } AddonConsoleActor.prototype = Object.create(WebConsoleActor.prototype); @@ -316,17 +317,16 @@ update(AddonConsoleActor.prototype, { /** * 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 ACA_onStartListeners(aRequest) - { + onStartListeners: function ACAOnStartListeners(request) { let startedListeners = []; - while (aRequest.listeners.length > 0) { - let listener = aRequest.listeners.shift(); + while (request.listeners.length > 0) { + let listener = request.listeners.shift(); switch (listener) { case "ConsoleAPI": if (!this.consoleAPIListener) { @@ -346,5 +346,8 @@ update(AddonConsoleActor.prototype, { }, }); -AddonConsoleActor.prototype.requestTypes = Object.create(WebConsoleActor.prototype.requestTypes); -AddonConsoleActor.prototype.requestTypes.startListeners = AddonConsoleActor.prototype.onStartListeners; +AddonConsoleActor.prototype.requestTypes = Object.create( + WebConsoleActor.prototype.requestTypes +); +AddonConsoleActor.prototype.requestTypes.startListeners = + AddonConsoleActor.prototype.onStartListeners; diff --git a/devtools/server/actors/addons.js b/devtools/server/actors/addons.js index 297a3a438098..e24115ef18fb 100644 --- a/devtools/server/actors/addons.js +++ b/devtools/server/actors/addons.js @@ -34,7 +34,6 @@ const AddonsActor = protocol.ActorClassWithSpec(addonsSpec, { // with. Provide a flag that the client can use to detect when it // gets upgraded to a real actor object. return { id: addon.id, actor: false }; - }), }); diff --git a/devtools/server/actors/animation.js b/devtools/server/actors/animation.js index f40d3fd3f510..7515cc98f05d 100644 --- a/devtools/server/actors/animation.js +++ b/devtools/server/actors/animation.js @@ -27,9 +27,8 @@ const {Cu} = require("chrome"); const promise = require("promise"); -const {Task} = require("devtools/shared/task"); const protocol = require("devtools/shared/protocol"); -const {Actor, ActorClassWithSpec} = protocol; +const {Actor} = protocol; const {animationPlayerSpec, animationsSpec} = require("devtools/shared/specs/animation"); const events = require("sdk/event/core"); @@ -474,8 +473,8 @@ exports.AnimationPlayerActor = AnimationPlayerActor; /** * The Animations actor lists animation players for a given node. */ -var AnimationsActor = exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, { - initialize: function(conn, tabActor) { +exports.AnimationsActor = protocol.ActorClassWithSpec(animationsSpec, { + initialize: function (conn, tabActor) { Actor.prototype.initialize.call(this, conn); this.tabActor = tabActor; diff --git a/devtools/server/actors/breakpoint.js b/devtools/server/actors/breakpoint.js index 8435bbb45150..d8d5a404b84b 100644 --- a/devtools/server/actors/breakpoint.js +++ b/devtools/server/actors/breakpoint.js @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* global assert */ + "use strict"; const { ActorClassWithSpec } = require("devtools/shared/protocol"); @@ -111,7 +113,9 @@ let BreakpointActor = ActorClassWithSpec(breakpointSpec, { } else if (completion.toString) { message = completion.toString(); } - } catch (ex) {} + } catch (ex) { + // ignore + } return { result: true, message: message @@ -119,12 +123,11 @@ let BreakpointActor = ActorClassWithSpec(breakpointSpec, { } else if (completion.yield) { assert(false, "Shouldn't ever get yield completions from an eval"); } else { - return { result: completion.return ? true : false }; + return { result: !!completion.return }; } - } else { - // The evaluation was killed (possibly by the slow script dialog) - return { result: undefined }; } + // The evaluation was killed (possibly by the slow script dialog) + return { result: undefined }; }, /** diff --git a/devtools/server/actors/call-watcher.js b/devtools/server/actors/call-watcher.js index 5729f9508927..0417c9ca8d23 100644 --- a/devtools/server/actors/call-watcher.js +++ b/devtools/server/actors/call-watcher.js @@ -3,13 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {Cc, Ci, Cu, Cr} = require("chrome"); +/* global XPCNativeWrapper */ + +const {Ci, Cu} = require("chrome"); const events = require("sdk/event/core"); const protocol = require("devtools/shared/protocol"); const {serializeStack, parseStack} = require("toolkit/loader"); -const {on, once, off, emit} = events; -const {method, Arg, Option, RetVal} = protocol; +const {on, off, emit} = events; const { functionCallSpec, callWatcherSpec } = require("devtools/shared/specs/call-watcher"); const { CallWatcherFront } = require("devtools/shared/fronts/call-watcher"); @@ -48,7 +49,11 @@ var FunctionCallActor = protocol.ActorClassWithSpec(functionCallSpec, { * Determines whether or not FunctionCallActor stores a weak reference * to the underlying objects. */ - initialize: function (conn, [window, global, caller, type, name, stack, timestamp, args, result], holdWeak) { + initialize: function ( + conn, + [window, global, caller, type, name, stack, timestamp, args, result], + holdWeak + ) { protocol.Actor.prototype.initialize.call(this, conn); this.details = { @@ -76,9 +81,8 @@ var FunctionCallActor = protocol.ActorClassWithSpec(functionCallSpec, { args: { get: () => weakRefs.args.get() }, result: { get: () => weakRefs.result.get() }, }); - } - // Otherwise, hold strong references to the objects. - else { + } else { + // Otherwise, hold strong references to the objects. this.details.window = window; this.details.caller = caller; this.details.args = args; @@ -226,7 +230,7 @@ var FunctionCallActor = protocol.ActorClassWithSpec(functionCallSpec, { /** * This actor observes function calls on certain objects or globals. */ -var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(callWatcherSpec, { +exports.CallWatcherActor = protocol.ActorClassWithSpec(callWatcherSpec, { initialize: function (conn, tabActor) { protocol.Actor.prototype.initialize.call(this, conn); this.tabActor = tabActor; @@ -255,7 +259,9 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca * created, in order to instrument the specified objects and become * aware of everything the content does with them. */ - setup: function ({ tracedGlobals, tracedFunctions, startRecording, performReload, holdWeak, storeCalls }) { + setup: function ({ + tracedGlobals, tracedFunctions, startRecording, performReload, holdWeak, storeCalls + }) { if (this._initialized) { return; } @@ -362,23 +368,22 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca * Instruments a method, getter or setter on the specified target object to * invoke a callback whenever it is called. */ - function overrideSymbol(global, target, name, callback) { + function overrideSymbol(global, target, name, subcallback) { let propertyDescriptor = Object.getOwnPropertyDescriptor(target, name); if (propertyDescriptor.get || propertyDescriptor.set) { - overrideAccessor(global, target, name, propertyDescriptor, callback); + overrideAccessor(global, target, name, propertyDescriptor, subcallback); return; } if (propertyDescriptor.writable && typeof propertyDescriptor.value == "function") { - overrideFunction(global, target, name, propertyDescriptor, callback); - return; + overrideFunction(global, target, name, propertyDescriptor, subcallback); } } /** * Instruments a function on the specified target object. */ - function overrideFunction(global, target, name, descriptor, callback) { + function overrideFunction(global, target, name, descriptor, subcallback) { // Invoking .apply on an unxrayed content function doesn't work, because // the arguments array is inaccessible to it. Get Xrays back. let originalFunc = Cu.unwaiveXrays(target[name]); @@ -395,7 +400,8 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca let type = CallWatcherFront.METHOD_FUNCTION; let stack = getStack(name); let timestamp = self.tabActor.window.performance.now() - self._timestampEpoch; - callback(unwrappedWindow, global, this, type, name, stack, timestamp, args, result); + subcallback(unwrappedWindow, global, this, type, name, stack, timestamp, + args, result); } return result; }, target, { defineAs: name }); @@ -410,7 +416,7 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca /** * Instruments a getter or setter on the specified target object. */ - function overrideAccessor(global, target, name, descriptor, callback) { + function overrideAccessor(global, target, name, descriptor, subcallback) { // Invoking .apply on an unxrayed content function doesn't work, because // the arguments array is inaccessible to it. Get Xrays back. let originalGetter = Cu.unwaiveXrays(target.__lookupGetter__(name)); @@ -418,26 +424,32 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca Object.defineProperty(target, name, { get: function (...args) { - if (!originalGetter) return undefined; + if (!originalGetter) { + return undefined; + } let result = Cu.waiveXrays(originalGetter.apply(this, args)); if (self._recording) { let type = CallWatcherFront.GETTER_FUNCTION; let stack = getStack(name); let timestamp = self.tabActor.window.performance.now() - self._timestampEpoch; - callback(unwrappedWindow, global, this, type, name, stack, timestamp, args, result); + subcallback(unwrappedWindow, global, this, type, name, stack, timestamp, + args, result); } return result; }, set: function (...args) { - if (!originalSetter) return; + if (!originalSetter) { + return; + } originalSetter.apply(this, args); if (self._recording) { let type = CallWatcherFront.SETTER_FUNCTION; let stack = getStack(name); let timestamp = self.tabActor.window.performance.now() - self._timestampEpoch; - callback(unwrappedWindow, global, this, type, name, stack, timestamp, args, undefined); + subcallback(unwrappedWindow, global, this, type, name, stack, timestamp, + args, undefined); } }, configurable: descriptor.configurable, @@ -450,12 +462,13 @@ var CallWatcherActor = exports.CallWatcherActor = protocol.ActorClassWithSpec(ca * a function is called. */ function getStack(caller) { + let stack; try { // Using Components.stack wouldn't be a better idea, since it's // much slower because it attempts to retrieve the C++ stack as well. throw new Error(); } catch (e) { - var stack = e.stack; + stack = e.stack; } // Of course, using a simple regex like /(.*?)@(.*):(\d*):\d*/ would be @@ -588,7 +601,8 @@ function getBitToEnumValue(type, object, arg) { } // Cache the combined bitmask value - return table[arg] = flags.join(" | ") || arg; + table[arg] = flags.join(" | ") || arg; + return table[arg]; } /** @@ -598,8 +612,9 @@ function getBitToEnumValue(type, object, arg) { * * We use toolkit/loader's parseStack and serializeStack rather than the * parsing done in the local `getStack` function, because it does not expose - * column number, would have to change the protocol models `call-stack-items` and `call-details` - * which hurts backwards compatibility, and the local `getStack` is an optimized, hot function. + * column number, would have to change the protocol models `call-stack-items` + * and `call-details` which hurts backwards compatibility, and the local `getStack` + * is an optimized, hot function. */ function createContentError(e, win) { let { message, name, stack } = e; @@ -614,14 +629,15 @@ function createContentError(e, win) { error = new constructor(message, name); Object.defineProperties(error, { code: { value: e.code }, - columnNumber: { value: 0 }, // columnNumber is always 0 for DOMExceptions? - filename: { value: fileName }, // note the lowercase `filename` + // columnNumber is always 0 for DOMExceptions? + columnNumber: { value: 0 }, + // note the lowercase `filename` + filename: { value: fileName }, lineNumber: { value: lineNumber }, result: { value: e.result }, stack: { value: serializeStack(parsedStack) } }); - } - else { + } else { // Constructing an error here retains all the stack information, // and we can add message, fileName and lineNumber via constructor, though // need to manually add columnNumber. diff --git a/devtools/server/actors/canvas.js b/devtools/server/actors/canvas.js index f6e1f57ecfe0..5542eeff0f7c 100644 --- a/devtools/server/actors/canvas.js +++ b/devtools/server/actors/canvas.js @@ -3,28 +3,22 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {Cc, Ci, Cu, Cr} = require("chrome"); -const events = require("sdk/event/core"); +/* global XPCNativeWrapper */ + const promise = require("promise"); const protocol = require("devtools/shared/protocol"); const {CallWatcherActor} = require("devtools/server/actors/call-watcher"); const {CallWatcherFront} = require("devtools/shared/fronts/call-watcher"); -const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const {WebGLPrimitiveCounter} = require("devtools/server/primitive"); const { frameSnapshotSpec, canvasSpec, CANVAS_CONTEXTS, ANIMATION_GENERATORS, - LOOP_GENERATORS, - DRAW_CALLS, - INTERESTING_CALLS, + LOOP_GENERATORS } = require("devtools/shared/specs/canvas"); const {CanvasFront} = require("devtools/shared/fronts/canvas"); -const {on, once, off, emit} = events; -const {method, custom, Arg, Option, RetVal} = protocol; - /** * This actor represents a recorded animation frame snapshot, along with * all the corresponding canvas' context methods invoked in that frame, @@ -73,7 +67,6 @@ var FrameSnapshotActor = protocol.ActorClassWithSpec(frameSnapshotSpec, { * function was called. */ generateScreenshotFor: function (functionCall) { - let caller = functionCall.details.caller; let global = functionCall.details.global; let canvas = this._contentCanvas; @@ -91,14 +84,20 @@ var FrameSnapshotActor = protocol.ActorClassWithSpec(frameSnapshotSpec, { last: index }); - let { replayContext, replayContextScaling, lastDrawCallIndex, doCleanup } = replayData; + let { + replayContext, + replayContextScaling, + lastDrawCallIndex, + doCleanup + } = replayData; let [left, top, width, height] = replayData.replayViewport; let screenshot; // Depending on the canvas' context, generating a screenshot is done // in different ways. if (global == "WebGLRenderingContext") { - screenshot = ContextUtils.getPixelsForWebGL(replayContext, left, top, width, height); + screenshot = ContextUtils.getPixelsForWebGL(replayContext, left, top, + width, height); screenshot.flipped = true; } else if (global == "CanvasRenderingContext2D") { screenshot = ContextUtils.getPixelsFor2D(replayContext, left, top, width, height); @@ -120,7 +119,7 @@ var FrameSnapshotActor = protocol.ActorClassWithSpec(frameSnapshotSpec, { * of a 2D or WebGL context, to provide information regarding all the calls * made when drawing frame inside an animation loop. */ -var CanvasActor = exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, { +exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, { // Reset for each recording, boolean indicating whether or not // any draw calls were called for a recording. _animationContainsDrawCall: false, @@ -190,7 +189,8 @@ var CanvasActor = exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, /** * Records a snapshot of all the calls made during the next animation frame. * The animation should be implemented via the de-facto requestAnimationFrame - * utility, or inside recursive `setTimeout`s. `setInterval` at this time are not supported. + * utility, or inside recursive `setTimeout`s. `setInterval` at this time are + * not supported. */ recordAnimationFrame: function () { if (this._callWatcher.isRecording()) { @@ -251,7 +251,6 @@ var CanvasActor = exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, if (CanvasFront.DRAW_CALLS.has(name) && this._animationStarted) { this._handleDrawCall(functionCall); this._webGLPrimitiveCounter.handleDrawPrimitive(functionCall); - return; } }, @@ -261,11 +260,10 @@ var CanvasActor = exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, _handleAnimationFrame: function (functionCall) { if (!this._animationStarted) { this._handleAnimationFrameBegin(); - } - // Check to see if draw calls occurred yet, as it could be future frames, - // like in the scenario where requestAnimationFrame is called to trigger an animation, - // and rAF is at the beginning of the animate loop. - else if (this._animationContainsDrawCall) { + } else if (this._animationContainsDrawCall) { + // Check to see if draw calls occurred yet, as it could be future frames, + // like in the scenario where requestAnimationFrame is called to trigger + // an animation, and rAF is at the beginning of the animate loop. this._handleAnimationFrameEnd(functionCall); } }, @@ -294,7 +292,8 @@ var CanvasActor = exports.CanvasActor = protocol.ActorClassWithSpec(canvasSpec, let index = this._lastDrawCallIndex; let width = this._lastContentCanvasWidth; let height = this._lastContentCanvasHeight; - let flipped = !!this._lastThumbnailFlipped; // undefined -> false + // undefined -> false + let flipped = !!this._lastThumbnailFlipped; let pixels = ContextUtils.getPixelStorage()["8bit"]; let primitiveResult = this._webGLPrimitiveCounter.getCounts(); let animationFrameEndScreenshot = { @@ -409,8 +408,8 @@ var ContextUtils = { srcX = 0, srcY = 0, srcWidth = gl.canvas.width, srcHeight = gl.canvas.height, - dstHeight = srcHeight) - { + dstHeight = srcHeight + ) { let contentPixels = ContextUtils.getPixelStorage(srcWidth, srcHeight); let { "8bit": charView, "32bit": intView } = contentPixels; gl.readPixels(srcX, srcY, srcWidth, srcHeight, gl.RGBA, gl.UNSIGNED_BYTE, charView); @@ -441,8 +440,8 @@ var ContextUtils = { srcX = 0, srcY = 0, srcWidth = ctx.canvas.width, srcHeight = ctx.canvas.height, - dstHeight = srcHeight) - { + dstHeight = srcHeight + ) { let { data } = ctx.getImageData(srcX, srcY, srcWidth, srcHeight); let { "32bit": intView } = ContextUtils.usePixelStorage(data.buffer); return this.resizePixels(intView, srcWidth, srcHeight, dstHeight); @@ -564,9 +563,8 @@ var ContextUtils = { gl.bindFramebuffer(gl.FRAMEBUFFER, oldFramebuffer); gl.viewport.apply(gl, oldViewport); }; - } - // In case of 2D contexts, draw everything on a separate canvas context. - else if (contextType == "CanvasRenderingContext2D") { + } else if (contextType == "CanvasRenderingContext2D") { + // In case of 2D contexts, draw everything on a separate canvas context. let contentDocument = canvas.ownerDocument; let replayCanvas = contentDocument.createElement("canvas"); replayCanvas.width = w; @@ -589,7 +587,8 @@ var ContextUtils = { // Also prevent WebGL context calls that try to change the viewport // while our custom framebuffer is bound. if (name == "viewport") { - let framebufferBinding = replayContext.getParameter(replayContext.FRAMEBUFFER_BINDING); + let framebufferBinding = replayContext.getParameter( + replayContext.FRAMEBUFFER_BINDING); if (framebufferBinding == customFramebuffer) { replayContext.viewport.apply(replayContext, customViewport); continue; @@ -645,10 +644,11 @@ var ContextUtils = { usePixelStorage: function (buffer) { let array8bit = new Uint8Array(buffer); let array32bit = new Uint32Array(buffer); - return this._currentPixelStorage = { + this._currentPixelStorage = { "8bit": array8bit, "32bit": array32bit }; + return this._currentPixelStorage; }, /** @@ -680,14 +680,17 @@ var ContextUtils = { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, + gl.UNSIGNED_BYTE, null); let depthBuffer = gl.createRenderbuffer(); gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer); gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, colorBuffer, 0); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthBuffer); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, + colorBuffer, 0); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, + depthBuffer); gl.bindTexture(gl.TEXTURE_2D, oldTextureBinding); gl.bindRenderbuffer(gl.RENDERBUFFER, oldRenderbufferBinding); diff --git a/devtools/server/actors/child-process.js b/devtools/server/actors/child-process.js index ba2a77077e40..a017193f12a0 100644 --- a/devtools/server/actors/child-process.js +++ b/devtools/server/actors/child-process.js @@ -10,14 +10,13 @@ const { ChromeDebuggerActor } = require("devtools/server/actors/script"); const { WebConsoleActor } = require("devtools/server/actors/webconsole"); const makeDebugger = require("devtools/server/actors/utils/make-debugger"); const { ActorPool } = require("devtools/server/main"); -const Services = require("Services"); const { assert } = require("devtools/shared/DevToolsUtils"); const { TabSources } = require("./utils/TabSources"); loader.lazyRequireGetter(this, "WorkerActorList", "devtools/server/actors/worker-list", true); -function ChildProcessActor(aConnection) { - this.conn = aConnection; +function ChildProcessActor(connection) { + this.conn = connection; this._contextPool = new ActorPool(this.conn); this.conn.addActorPool(this._contextPool); this.threadActor = null; diff --git a/devtools/server/actors/childtab.js b/devtools/server/actors/childtab.js index 626489da7f79..dd4b3f4cf320 100644 --- a/devtools/server/actors/childtab.js +++ b/devtools/server/actors/childtab.js @@ -26,8 +26,7 @@ var { TabActor } = require("devtools/server/actors/tab"); * the prefix used in protocol to create IDs for each actor. * Used as ID identifying this particular TabActor from the parent process. */ -function ContentActor(connection, chromeGlobal, prefix) -{ +function ContentActor(connection, chromeGlobal, prefix) { this._chromeGlobal = chromeGlobal; this._prefix = prefix; TabActor.call(this, connection, chromeGlobal); diff --git a/devtools/server/actors/chrome.js b/devtools/server/actors/chrome.js index c6ec1dcf71e5..b708b13e4431 100644 --- a/devtools/server/actors/chrome.js +++ b/devtools/server/actors/chrome.js @@ -27,11 +27,11 @@ const makeDebugger = require("./utils/make-debugger"); * Global actors are now only the actors that are meant to be global, * and are no longer related to any specific scope/document. * - * @param aConnection DebuggerServerConnection + * @param connection DebuggerServerConnection * The connection to the client. */ -function ChromeActor(aConnection) { - TabActor.call(this, aConnection); +function ChromeActor(connection) { + TabActor.call(this, connection); // This creates a Debugger instance for chrome debugging all globals. this.makeDebugger = makeDebugger.bind(null, { @@ -88,16 +88,16 @@ Object.defineProperty(ChromeActor.prototype, "docShells", { } }); -ChromeActor.prototype.observe = function (aSubject, aTopic, aData) { - TabActor.prototype.observe.call(this, aSubject, aTopic, aData); +ChromeActor.prototype.observe = function (subject, topic, data) { + TabActor.prototype.observe.call(this, subject, topic, data); if (!this.attached) { return; } - if (aTopic == "chrome-webnavigation-create") { - aSubject.QueryInterface(Ci.nsIDocShell); - this._onDocShellCreated(aSubject); - } else if (aTopic == "chrome-webnavigation-destroy") { - this._onDocShellDestroy(aSubject); + if (topic == "chrome-webnavigation-create") { + subject.QueryInterface(Ci.nsIDocShell); + this._onDocShellCreated(subject); + } else if (topic == "chrome-webnavigation-destroy") { + this._onDocShellDestroy(subject); } }; @@ -113,7 +113,6 @@ ChromeActor.prototype._attach = function () { Services.obs.addObserver(this, "chrome-webnavigation-destroy", false); // Iterate over all top-level windows. - let docShells = []; let e = Services.ww.getWindowEnumerator(); while (e.hasMoreElements()) { let window = e.getNext(); @@ -125,6 +124,7 @@ ChromeActor.prototype._attach = function () { } this._progressListener.watch(docShell); } + return undefined; }; ChromeActor.prototype._detach = function () { @@ -136,7 +136,6 @@ ChromeActor.prototype._detach = function () { Services.obs.removeObserver(this, "chrome-webnavigation-destroy"); // Iterate over all top-level windows. - let docShells = []; let e = Services.ww.getWindowEnumerator(); while (e.hasMoreElements()) { let window = e.getNext(); @@ -150,6 +149,7 @@ ChromeActor.prototype._detach = function () { } TabActor.prototype._detach.call(this); + return undefined; }; /* ThreadActor hooks. */ @@ -172,7 +172,7 @@ ChromeActor.prototype.preNest = function () { /** * Prepare to exit a nested event loop by enabling debuggee events. */ -ChromeActor.prototype.postNest = function (aNestData) { +ChromeActor.prototype.postNest = function (nestData) { // Enable events in all open windows. let e = Services.wm.getEnumerator(null); while (e.hasMoreElements()) { diff --git a/devtools/server/actors/common.js b/devtools/server/actors/common.js index a40bbd81eab2..2a36543fc3ac 100644 --- a/devtools/server/actors/common.js +++ b/devtools/server/actors/common.js @@ -78,7 +78,8 @@ function RegisteredActorFactory(options, prefix) { } } } -RegisteredActorFactory.prototype.createObservedActorFactory = function (conn, parentActor) { +RegisteredActorFactory.prototype.createObservedActorFactory = function (conn, + parentActor) { return new ObservedActorFactory(this._getConstructor, this._prefix, conn, parentActor); }; exports.RegisteredActorFactory = RegisteredActorFactory; @@ -110,9 +111,9 @@ function ObservedActorFactory(getConstructor, prefix, conn, parentActor) { } ObservedActorFactory.prototype.createActor = function () { // Fetch the actor constructor - let c = this._getConstructor(); + let C = this._getConstructor(); // Instantiate a new actor instance - let instance = new c(this._conn, this._parentActor); + let instance = new C(this._conn, this._parentActor); instance.conn = this._conn; instance.parentID = this._parentActor.actorID; // We want the newly-constructed actor to completely replace the factory @@ -124,21 +125,20 @@ ObservedActorFactory.prototype.createActor = function () { }; exports.ObservedActorFactory = ObservedActorFactory; - /** * Methods shared between RootActor and BrowserTabActor. */ /** - * Populate |this._extraActors| as specified by |aFactories|, reusing whatever + * Populate |this._extraActors| as specified by |factories|, reusing whatever * actors are already there. Add all actors in the final extra actors table to - * |aPool|. + * |pool|. * * The root actor and the tab actor use this to instantiate actors that other * parts of the browser have specified with DebuggerServer.addTabActor and * DebuggerServer.addGlobalActor. * - * @param aFactories + * @param factories * An object whose own property names are the names of properties to add to * some reply packet (say, a tab actor grip or the "listTabs" response * form), and whose own property values are actor constructor functions, as @@ -146,7 +146,7 @@ exports.ObservedActorFactory = ObservedActorFactory; * * @param this * The BrowserRootActor or BrowserTabActor with which the new actors will - * be associated. It should support whatever API the |aFactories| + * be associated. It should support whatever API the |factories| * constructor functions might be interested in, as it is passed to them. * For the sake of CommonCreateExtraActors itself, it should have at least * the following properties: @@ -162,44 +162,44 @@ exports.ObservedActorFactory = ObservedActorFactory; * - actorID * The actor's name, for use as the new actors' parentID. */ -exports.createExtraActors = function createExtraActors(aFactories, aPool) { +exports.createExtraActors = function createExtraActors(factories, pool) { // Walk over global actors added by extensions. - for (let name in aFactories) { + for (let name in factories) { let actor = this._extraActors[name]; if (!actor) { // Register another factory, but this time specific to this connection. // It creates a fake actor that looks like an regular actor in the pool, // but without actually instantiating the actor. // It will only be instantiated on the first request made to the actor. - actor = aFactories[name].createObservedActorFactory(this.conn, this); + actor = factories[name].createObservedActorFactory(this.conn, this); this._extraActors[name] = actor; } // If the actor already exists in the pool, it may have been instantiated, // so make sure not to overwrite it by a non-instantiated version. - if (!aPool.has(actor.actorID)) { - aPool.addActor(actor); + if (!pool.has(actor.actorID)) { + pool.addActor(actor); } } }; /** * Append the extra actors in |this._extraActors|, constructed by a prior call - * to CommonCreateExtraActors, to |aObject|. + * to CommonCreateExtraActors, to |object|. * - * @param aObject + * @param object * The object to which the extra actors should be added, under the - * property names given in the |aFactories| table passed to + * property names given in the |factories| table passed to * CommonCreateExtraActors. * * @param this * The BrowserRootActor or BrowserTabActor whose |_extraActors| table we * should use; see above. */ -exports.appendExtraActors = function appendExtraActors(aObject) { +exports.appendExtraActors = function appendExtraActors(object) { for (let name in this._extraActors) { let actor = this._extraActors[name]; - aObject[name] = actor.actorID; + object[name] = actor.actorID; } }; @@ -210,9 +210,8 @@ exports.appendExtraActors = function appendExtraActors(aObject) { * used to accumulate and quickly dispose of groups of actors that * share a lifetime. */ -function ActorPool(aConnection) -{ - this.conn = aConnection; +function ActorPool(connection) { + this.conn = connection; this._actors = {}; } @@ -220,7 +219,7 @@ ActorPool.prototype = { /** * Destroy the pool. This will remove all actors from the pool. */ - destroy: function AP_destroy() { + destroy: function APDestroy() { for (let id in this._actors) { this.removeActor(this._actors[id]); } @@ -230,27 +229,27 @@ ActorPool.prototype = { * Add an actor to the pool. If the actor doesn't have an ID, allocate one * from the connection. * - * @param Object aActor + * @param Object actor * The actor to be added to the pool. */ - addActor: function AP_addActor(aActor) { - aActor.conn = this.conn; - if (!aActor.actorID) { - let prefix = aActor.actorPrefix; - if (!prefix && typeof aActor == "function") { + addActor: function APAddActor(actor) { + actor.conn = this.conn; + if (!actor.actorID) { + let prefix = actor.actorPrefix; + if (!prefix && typeof actor == "function") { // typeName is a convention used with protocol.js-based actors - prefix = aActor.prototype.actorPrefix || aActor.prototype.typeName; + prefix = actor.prototype.actorPrefix || actor.prototype.typeName; } - aActor.actorID = this.conn.allocID(prefix || undefined); + actor.actorID = this.conn.allocID(prefix || undefined); } // If the actor is already in a pool, remove it without destroying it. - if (aActor.registeredPool) { - delete aActor.registeredPool._actors[aActor.actorID]; + if (actor.registeredPool) { + delete actor.registeredPool._actors[actor.actorID]; } - aActor.registeredPool = this; + actor.registeredPool = this; - this._actors[aActor.actorID] = aActor; + this._actors[actor.actorID] = actor; }, /** @@ -268,26 +267,26 @@ ActorPool.prototype = { } }, - get: function AP_get(aActorID) { - return this._actors[aActorID] || undefined; + get: function APGet(actorID) { + return this._actors[actorID] || undefined; }, - has: function AP_has(aActorID) { - return aActorID in this._actors; + has: function APHas(actorID) { + return actorID in this._actors; }, /** * Returns true if the pool is empty. */ - isEmpty: function AP_isEmpty() { + isEmpty: function APIsEmpty() { return Object.keys(this._actors).length == 0; }, /** * Match the api expected by the protocol library. */ - unmanage: function (aActor) { - return this.removeActor(aActor); + unmanage: function (actor) { + return this.removeActor(actor); }, forEach: function (callback) { @@ -475,14 +474,14 @@ exports.GeneratedLocation = GeneratedLocation; * The expected state. * @param String activity * Additional info about what's going on. - * @param Function method + * @param Function methodFunc * The actor method to proceed with when the actor is in the expected * state. * * @returns Function * The decorated method. */ -function expectState(expectedState, method, activity) { +function expectState(expectedState, methodFunc, activity) { return function (...args) { if (this.state !== expectedState) { const msg = `Wrong state while ${activity}:` + @@ -491,7 +490,7 @@ function expectState(expectedState, method, activity) { return promise.reject(new Error(msg)); } - return method.apply(this, args); + return methodFunc.apply(this, args); }; } @@ -517,7 +516,7 @@ exports.actorBridge = actorBridge; * Like `actorBridge`, but without a spec definition, for when the actor is * created with `ActorClassWithSpec` rather than vanilla `ActorClass`. */ -function actorBridgeWithSpec (methodName) { +function actorBridgeWithSpec(methodName) { return method(function () { return this.bridge[methodName].apply(this.bridge, arguments); }); diff --git a/devtools/server/actors/css-properties.js b/devtools/server/actors/css-properties.js index 2a4538378584..06c60fe50c95 100644 --- a/devtools/server/actors/css-properties.js +++ b/devtools/server/actors/css-properties.js @@ -13,7 +13,7 @@ loader.lazyGetter(this, "DOMUtils", () => { const protocol = require("devtools/shared/protocol"); const { ActorClassWithSpec, Actor } = protocol; const { cssPropertiesSpec } = require("devtools/shared/specs/css-properties"); -const { CSS_PROPERTIES, CSS_TYPES } = require("devtools/shared/css/properties-db"); +const { CSS_TYPES } = require("devtools/shared/css/properties-db"); const { cssColors } = require("devtools/shared/css/color-db"); exports.CssPropertiesActor = ActorClassWithSpec(cssPropertiesSpec, { diff --git a/devtools/server/actors/device.js b/devtools/server/actors/device.js index 44d94923dfd3..fb99e3b9a19a 100644 --- a/devtools/server/actors/device.js +++ b/devtools/server/actors/device.js @@ -4,7 +4,6 @@ "use strict"; -const {Ci} = require("chrome"); const Services = require("Services"); const protocol = require("devtools/shared/protocol"); const promise = require("promise"); @@ -14,7 +13,7 @@ const {getSystemInfo, getSetting} = require("devtools/shared/system"); const {deviceSpec} = require("devtools/shared/specs/device"); const FileReader = require("FileReader"); -var DeviceActor = exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, { +exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, { _desc: null, getDescription: function () { @@ -40,7 +39,7 @@ var DeviceActor = exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, screenshotToDataURL: function () { let window = Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType); - var devicePixelRatio = window.devicePixelRatio; + let { devicePixelRatio } = window; let canvas = window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); let width = window.innerWidth; let height = window.innerHeight; diff --git a/devtools/server/actors/director-manager.js b/devtools/server/actors/director-manager.js index 027a456db3ac..a626ab890824 100644 --- a/devtools/server/actors/director-manager.js +++ b/devtools/server/actors/director-manager.js @@ -9,8 +9,7 @@ const protocol = require("devtools/shared/protocol"); const { Cu, Ci } = require("chrome"); -const { on, once, off, emit } = events; -const { method, Arg, Option, RetVal, types } = protocol; +const { on, off, emit } = events; const { sandbox, evaluate } = require("sdk/loader/sandbox"); const { Class } = require("sdk/core/heritage"); @@ -38,7 +37,7 @@ const ERR_DIRECTOR_UNINSTALLED_SCRIPTID = "uninstalled director-script id"; * A MessagePort Actor allowing communication through messageport events * over the remote debugging protocol. */ -var MessagePortActor = exports.MessagePortActor = protocol.ActorClassWithSpec(messagePortSpec, { +var MessagePortActor = protocol.ActorClassWithSpec(messagePortSpec, { /** * Create a MessagePort actor. * @@ -91,7 +90,7 @@ var MessagePortActor = exports.MessagePortActor = protocol.ActorClassWithSpec(me // and call the actor start method to start receiving messages // from the MessagePort's queue. this.port.onmessage = (evt) => { - var ports; + let ports; // TODO: test these wrapped ports if (Array.isArray(evt.ports)) { @@ -138,18 +137,20 @@ var MessagePortActor = exports.MessagePortActor = protocol.ActorClassWithSpec(me }, }); +exports.MessagePortActor = MessagePortActor; + /** - * The Director Script Actor manage javascript code running in a non-privileged sandbox with the same - * privileges of the target global (browser tab or a firefox os app). + * The Director Script Actor manage javascript code running in a non-privileged sandbox + * with the same privileges of the target global (browser tab or a firefox os app). * - * After retrieving an instance of this actor (from the tab director actor), you'll need to set it up - * by calling setup(). + * After retrieving an instance of this actor (from the tab director actor), you'll + * need to set it up by calling setup(). * - * After the setup, this actor will automatically attach/detach the content script (and optionally a - * directly connect the debugger client and the content script using a MessageChannel) on tab - * navigation. + * After the setup, this actor will automatically attach/detach the content script + * (and optionally a directly connect the debugger client and the content script using + * a MessageChannel) on tab navigation. */ -var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithSpec(directorScriptSpec, { +var DirectorScriptActor = protocol.ActorClassWithSpec(directorScriptSpec, { /** * Creates the director script actor * @@ -184,8 +185,8 @@ var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithS }, /** - * Starts listening to the tab global created, in order to create the director-script sandbox - * using the configured scriptCode, attached/detached automatically to the tab + * Starts listening to the tab global created, in order to create the director-script + * sandbox using the configured scriptCode, attached/detached automatically to the tab * window on tab navigation. * * @param Boolean reload @@ -204,7 +205,8 @@ var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithS on(this.tabActor, "window-ready", this._onGlobalCreated); on(this.tabActor, "window-destroyed", this._onGlobalDestroyed); - // optional skip attach (needed by director-manager for director scripts bulk activation) + // optional skip attach (needed by director-manager for director scripts + // bulk activation) if (skipAttach) { return; } @@ -213,7 +215,11 @@ var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithS this.window.location.reload(); } else { // fake a global created event to attach without reload - this._onGlobalCreated({ id: getWindowID(this.window), window: this.window, isTopLevel: true }); + this._onGlobalCreated({ + id: getWindowID(this.window), + window: this.window, + isTopLevel: true + }); } }, @@ -272,7 +278,7 @@ var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithS // attach the global window this._lastAttachedWinId = id; - var port = this._scriptSandbox.attach(window, id); + let port = this._scriptSandbox.attach(window, id); this._onDirectorScriptAttach(window, port); } catch (e) { this._onDirectorScriptError(e); @@ -334,10 +340,13 @@ var DirectorScriptActor = exports.DirectorScriptActor = protocol.ActorClassWithS } }); +exports.DirectorScriptActor = DirectorScriptActor; + /** - * The DirectorManager Actor is a tab actor which manages enabling/disabling director scripts. + * The DirectorManager Actor is a tab actor which manages enabling/disabling + * director scripts. */ -const DirectorManagerActor = exports.DirectorManagerActor = protocol.ActorClassWithSpec(directorManagerSpec, { +exports.DirectorManagerActor = protocol.ActorClassWithSpec(directorManagerSpec, { /* init & destroy methods */ initialize: function (conn, tabActor) { protocol.Actor.prototype.initialize.call(this, conn); @@ -438,7 +447,7 @@ const DirectorManagerActor = exports.DirectorManagerActor = protocol.ActorClassW * (and create the actor instance if it doesn't exists yet). */ getByScriptId: function (scriptId) { - var id = scriptId; + let id = scriptId; // raise an unknown director-script id exception if (!DirectorRegistry.checkInstalled(id)) { console.error(ERR_DIRECTOR_UNKNOWN_SCRIPTID, id); @@ -454,7 +463,6 @@ const DirectorManagerActor = exports.DirectorManagerActor = protocol.ActorClassW // test lazy director-script (e.g. uninstalled in the parent process) if (!directorScriptDefinition) { - console.error(ERR_DIRECTOR_UNINSTALLED_SCRIPTID, id); throw Error(ERR_DIRECTOR_UNINSTALLED_SCRIPTID); } @@ -491,12 +499,12 @@ const DirectorScriptSandbox = Class({ }, attach: function (window, innerId) { - this._innerId = innerId, + this._innerId = innerId; this._window = window; this._proto = Cu.createObjectIn(this._window); - var id = this._scriptId; - var uri = this._scriptCode; + let id = this._scriptId; + let uri = this._scriptCode; this._sandbox = sandbox(window, { sandboxName: uri, @@ -515,7 +523,7 @@ const DirectorScriptSandbox = Class({ // create a CommonJS module object which match the interface from addon-sdk // (addon-sdk/sources/lib/toolkit/loader.js#L678-L686) - var module = Cu.cloneInto(Object.create(null, { + let module = Cu.cloneInto(Object.create(null, { id: { enumerable: true, value: id }, uri: { enumerable: true, value: uri }, exports: { enumerable: true, value: Cu.createObjectIn(this._sandbox) } @@ -530,7 +538,11 @@ const DirectorScriptSandbox = Class({ exports: { enumerable: true, value: module.exports }, console: { enumerable: true, - value: Cu.cloneInto(directorScriptConsole, this._sandbox, { cloneFunctions: true }) + value: Cu.cloneInto( + directorScriptConsole, + this._sandbox, + { cloneFunctions: true } + ) } }); @@ -544,7 +556,8 @@ const DirectorScriptSandbox = Class({ }); // TODO: if the debugger target is local, the debugger client could pass - // to the director actor the resource url instead of the entire javascript source code. + // to the director actor the resource url instead of the entire javascript + // source code. // evaluate the director script source in the sandbox evaluate(this._sandbox, this._scriptCode, "javascript:" + this._scriptCode); @@ -553,14 +566,17 @@ const DirectorScriptSandbox = Class({ let { port1, port2 } = new this._window.MessageChannel(); // prepare the unload callbacks queue - var sandboxOnUnloadQueue = this._sandboxOnUnloadQueue = []; + let sandboxOnUnloadQueue = this._sandboxOnUnloadQueue = []; // create the attach options - var attachOptions = this._attachOptions = Cu.createObjectIn(this._sandbox); + let attachOptions = this._attachOptions = Cu.createObjectIn(this._sandbox); Object.defineProperties(attachOptions, { port: { enumerable: true, value: port1 }, window: { enumerable: true, value: window }, - scriptOptions: { enumerable: true, value: Cu.cloneInto(this._scriptOptions, this._sandbox) }, + scriptOptions: { + enumerable: true, + value: Cu.cloneInto(this._scriptOptions, this._sandbox) + }, onUnload: { enumerable: true, value: Cu.cloneInto(function (cb) { @@ -573,7 +589,7 @@ const DirectorScriptSandbox = Class({ }); // select the attach method - var exports = this._proto.module.exports; + let exports = this._proto.module.exports; if (this._scriptOptions && "attachMethod" in this._scriptOptions) { this._sandboxOnAttach = exports[this._scriptOptions.attachMethod]; } else { @@ -591,7 +607,7 @@ const DirectorScriptSandbox = Class({ return port2; }, - destroy: function (onError) { + destroy: function (onError) { // evaluate queue unload methods if any while (this._sandboxOnUnloadQueue && this._sandboxOnUnloadQueue.length > 0) { let cb = this._sandboxOnUnloadQueue.pop(); diff --git a/devtools/server/actors/director-registry.js b/devtools/server/actors/director-registry.js index 54584bcdedef..5e318b14c52b 100644 --- a/devtools/server/actors/director-registry.js +++ b/devtools/server/actors/director-registry.js @@ -21,8 +21,10 @@ const ERR_DIRECTOR_INSTALL_EMPTY = "Trying to install an empty director-script"; const ERR_DIRECTOR_UNINSTALL_UNKNOWN = "Trying to uninstall an unkown director-script"; const ERR_DIRECTOR_PARENT_UNKNOWN_METHOD = "Unknown parent process method"; -const ERR_DIRECTOR_CHILD_NOTIMPLEMENTED_METHOD = "Unexpected call to notImplemented method"; -const ERR_DIRECTOR_CHILD_MULTIPLE_REPLIES = "Unexpected multiple replies to called parent method"; +const ERR_DIRECTOR_CHILD_NOTIMPLEMENTED_METHOD = + "Unexpected call to notImplemented method"; +const ERR_DIRECTOR_CHILD_MULTIPLE_REPLIES = + "Unexpected multiple replies to called parent method"; const ERR_DIRECTOR_CHILD_NO_REPLY = "Unexpected no reply to called parent method"; /** @@ -148,7 +150,7 @@ exports.setupParentProcess = function setupParentProcess({ mm, prefix }) { * The DirectorRegistry Actor is a global actor which manages install/uninstall of * director scripts definitions. */ -const DirectorRegistryActor = exports.DirectorRegistryActor = protocol.ActorClassWithSpec(directorRegistrySpec, { +exports.DirectorRegistryActor = protocol.ActorClassWithSpec(directorRegistrySpec, { /* init & destroy methods */ initialize: function (conn, parentActor) { protocol.Actor.prototype.initialize.call(this, conn); @@ -191,7 +193,7 @@ const DirectorRegistryActor = exports.DirectorRegistryActor = protocol.ActorClas } function callParentProcess(method, ...args) { - var reply = sendSyncMessage("debug:director-registry-request", { + let reply = sendSyncMessage("debug:director-registry-request", { method: method, args: args }); diff --git a/devtools/server/actors/environment.js b/devtools/server/actors/environment.js index bd03586eb1e0..c52f54a034af 100644 --- a/devtools/server/actors/environment.js +++ b/devtools/server/actors/environment.js @@ -5,6 +5,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +/* global Debugger */ + const { ActorClassWithSpec } = require("devtools/shared/protocol"); const { createValueGrip } = require("devtools/server/actors/object"); const { environmentSpec } = require("devtools/shared/specs/environment"); @@ -90,10 +92,11 @@ let EnvironmentActor = ActorClassWithSpec(environmentSpec, { this.obj.setVariable(name, value); } catch (e) { if (e instanceof Debugger.DebuggeeWouldRun) { - throw { + const errorObject = { error: "threadWouldRun", message: "Assigning a value would cause the debuggee to run" }; + throw errorObject; } else { throw e; } diff --git a/devtools/server/actors/errordocs.js b/devtools/server/actors/errordocs.js index 4c7940314250..270b1b85fdbc 100644 --- a/devtools/server/actors/errordocs.js +++ b/devtools/server/actors/errordocs.js @@ -10,7 +10,8 @@ "use strict"; const baseURL = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/"; -const params = "?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default"; +const params = + "?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default"; const ErrorDocs = { JSMSG_READ_ONLY: "Read-only", JSMSG_BAD_ARRAY_LENGTH: "Invalid_array_length", @@ -71,7 +72,7 @@ const ErrorCategories = { exports.GetURL = (error) => { if (!error) { - return; + return undefined; } let doc = ErrorDocs[error.errorMessageName]; @@ -83,4 +84,5 @@ exports.GetURL = (error) => { if (categoryURL) { return categoryURL + params; } + return undefined; }; diff --git a/devtools/server/actors/eventlooplag.js b/devtools/server/actors/eventlooplag.js index 6e0a101c9a7b..d4789b164091 100644 --- a/devtools/server/actors/eventlooplag.js +++ b/devtools/server/actors/eventlooplag.js @@ -17,7 +17,7 @@ const {Actor, ActorClassWithSpec} = require("devtools/shared/protocol"); const events = require("sdk/event/core"); const {eventLoopLagSpec} = require("devtools/shared/specs/eventlooplag"); -var EventLoopLagActor = exports.EventLoopLagActor = ActorClassWithSpec(eventLoopLagSpec, { +exports.EventLoopLagActor = ActorClassWithSpec(eventLoopLagSpec, { _observerAdded: false, /** diff --git a/devtools/server/actors/frame.js b/devtools/server/actors/frame.js index 4511bcebf57a..6a786ded69ea 100644 --- a/devtools/server/actors/frame.js +++ b/devtools/server/actors/frame.js @@ -72,7 +72,7 @@ let FrameActor = ActorClassWithSpec(frameSpec, { threadActor.objectGrip); form.arguments = this._args(); if (this.frame.script) { - var generatedLocation = this.threadActor.sources.getFrameLocation(this.frame); + let generatedLocation = this.threadActor.sources.getFrameLocation(this.frame); form.where = { source: generatedLocation.generatedSourceActor.form(), line: generatedLocation.generatedLine, diff --git a/devtools/server/actors/framerate.js b/devtools/server/actors/framerate.js index 872cd7360617..72559df5d00d 100644 --- a/devtools/server/actors/framerate.js +++ b/devtools/server/actors/framerate.js @@ -5,7 +5,6 @@ const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol"); const { actorBridgeWithSpec } = require("devtools/server/actors/common"); -const { on, once, off, emit } = require("sdk/event/core"); const { Framerate } = require("devtools/server/performance/framerate"); const { framerateSpec } = require("devtools/shared/specs/framerate"); @@ -15,7 +14,7 @@ const { framerateSpec } = require("devtools/shared/specs/framerate"); * * @see devtools/server/performance/framerate.js for documentation. */ -var FramerateActor = exports.FramerateActor = ActorClassWithSpec(framerateSpec, { +exports.FramerateActor = ActorClassWithSpec(framerateSpec, { initialize: function (conn, tabActor) { Actor.prototype.initialize.call(this, conn); this.bridge = new Framerate(tabActor); diff --git a/devtools/server/actors/gcli.js b/devtools/server/actors/gcli.js index 7282c3619255..c19938d7f9d3 100644 --- a/devtools/server/actors/gcli.js +++ b/devtools/server/actors/gcli.js @@ -4,10 +4,7 @@ "use strict"; -const { Task } = require("devtools/shared/task"); -const { - method, Arg, Option, RetVal, Actor, ActorClassWithSpec -} = require("devtools/shared/protocol"); +const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol"); const { gcliSpec } = require("devtools/shared/specs/gcli"); const events = require("sdk/event/core"); const { createSystem } = require("gcli/system"); @@ -22,7 +19,8 @@ const GcliActor = ActorClassWithSpec(gcliSpec, { this._commandsChanged = this._commandsChanged.bind(this); this._tabActor = tabActor; - this._requisitionPromise = undefined; // see _getRequisition() + // see _getRequisition() + this._requisitionPromise = undefined; }, destroy: function () { @@ -196,11 +194,13 @@ const GcliActor = ActorClassWithSpec(gcliSpec, { this._requisitionPromise = this._system.load().then(() => { const environment = { get chromeWindow() { - throw new Error("environment.chromeWindow is not available in runAt:server commands"); + throw new Error("environment.chromeWindow is not available in runAt:server" + + " commands"); }, get chromeDocument() { - throw new Error("environment.chromeDocument is not available in runAt:server commands"); + throw new Error("environment.chromeDocument is not available in runAt:server" + + " commands"); }, get window() { diff --git a/devtools/server/actors/heap-snapshot-file.js b/devtools/server/actors/heap-snapshot-file.js index 545f2265d329..88644345f88b 100644 --- a/devtools/server/actors/heap-snapshot-file.js +++ b/devtools/server/actors/heap-snapshot-file.js @@ -5,7 +5,6 @@ "use strict"; const protocol = require("devtools/shared/protocol"); -const { method, Arg } = protocol; const Services = require("Services"); const { Task } = require("devtools/shared/task"); diff --git a/devtools/server/actors/highlighters.js b/devtools/server/actors/highlighters.js index d084c93c972e..4ca3f374119c 100644 --- a/devtools/server/actors/highlighters.js +++ b/devtools/server/actors/highlighters.js @@ -82,7 +82,7 @@ exports.register = register; /** * The HighlighterActor class */ -var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(highlighterSpec, { +exports.HighlighterActor = protocol.ActorClassWithSpec(highlighterSpec, { initialize: function (inspector, autohide) { protocol.Actor.prototype.initialize.call(this, null); @@ -255,7 +255,8 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi // If shift is pressed, this is only a preview click, send the event to // the client, but don't stop picking. if (event.shiftKey) { - events.emit(this._walker, "picker-node-previewed", this._findAndAttachElement(event)); + events.emit(this._walker, "picker-node-previewed", + this._findAndAttachElement(event)); return; } @@ -351,8 +352,8 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi (!IS_OSX && event.ctrlKey && event.shiftKey)) { this.cancelPick(); events.emit(this._walker, "picker-node-canceled"); - return; } + return; default: return; } @@ -370,7 +371,7 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi /** * This pick method also focuses the highlighter's target window. */ - pickAndFocus: function() { + pickAndFocus: function () { // Go ahead and pass on the results to help future-proof this method. let pickResults = this.pick(); this._highlighterEnv.window.focus(); @@ -429,7 +430,7 @@ var HighlighterActor = exports.HighlighterActor = protocol.ActorClassWithSpec(hi * A generic highlighter actor class that instantiate a highlighter given its * type name and allows to show/hide it. */ -var CustomHighlighterActor = exports.CustomHighlighterActor = protocol.ActorClassWithSpec(customHighlighterSpec, { +exports.CustomHighlighterActor = protocol.ActorClassWithSpec(customHighlighterSpec, { /** * Create a highlighter instance given its typename * The typename must be one of HIGHLIGHTER_CLASSES and the class must diff --git a/devtools/server/actors/monitor.js b/devtools/server/actors/monitor.js index 4684abf1be79..60e9f20615db 100644 --- a/devtools/server/actors/monitor.js +++ b/devtools/server/actors/monitor.js @@ -8,8 +8,8 @@ const {Ci, Cc} = require("chrome"); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const Services = require("Services"); -function MonitorActor(aConnection) { - this.conn = aConnection; +function MonitorActor(connection) { + this.conn = connection; this._updates = []; this._started = false; } @@ -118,9 +118,10 @@ var USSAgent = { }, start: function () { - USSAgent._mgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager); + USSAgent._mgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService( + Ci.nsIMemoryReporterManager); if (!USSAgent._mgr.residentUnique) { - throw "Couldn't get USS."; + throw new Error("Couldn't get USS."); } USSAgent.update(); }, @@ -132,7 +133,8 @@ var USSAgent = { } USSAgent._packet.time = Date.now(); USSAgent._packet.value = USSAgent._mgr.residentUnique; - Services.obs.notifyObservers(null, "devtools-monitor-update", JSON.stringify(USSAgent._packet)); + Services.obs.notifyObservers(null, "devtools-monitor-update", + JSON.stringify(USSAgent._packet)); USSAgent._timeout = setTimeout(USSAgent.update, 300); }, diff --git a/devtools/server/actors/performance-entries.js b/devtools/server/actors/performance-entries.js index e6a34b0b8f23..f461016b8205 100644 --- a/devtools/server/actors/performance-entries.js +++ b/devtools/server/actors/performance-entries.js @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + /** * The performanceEntries actor emits events corresponding to performance * entries. It receives `performanceentry` events containing the performance diff --git a/devtools/server/actors/performance-recording.js b/devtools/server/actors/performance-recording.js index ef590749535c..946183c6066f 100644 --- a/devtools/server/actors/performance-recording.js +++ b/devtools/server/actors/performance-recording.js @@ -4,7 +4,6 @@ "use strict"; -const { Cu } = require("chrome"); const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol"); const { performanceRecordingSpec } = require("devtools/shared/specs/performance-recording"); @@ -27,7 +26,8 @@ const PerformanceRecordingActor = ActorClassWithSpec(performanceRecordingSpec, m } let form = { - actor: this.actorID, // actorID is set when this is added to a pool + // actorID is set when this is added to a pool + actor: this.actorID, configuration: this._configuration, startingBufferStatus: this._startingBufferStatus, console: this._console, diff --git a/devtools/server/actors/performance.js b/devtools/server/actors/performance.js index ac65320de195..6eaee8161478 100644 --- a/devtools/server/actors/performance.js +++ b/devtools/server/actors/performance.js @@ -4,7 +4,6 @@ "use strict"; -const { Cu } = require("chrome"); const { Task } = require("devtools/shared/task"); const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol"); const { actorBridgeWithSpec } = require("devtools/server/actors/common"); diff --git a/devtools/server/actors/preference.js b/devtools/server/actors/preference.js index 8d4140155821..efab90d4c4ac 100644 --- a/devtools/server/actors/preference.js +++ b/devtools/server/actors/preference.js @@ -2,9 +2,10 @@ * 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/. */ -const {Cc, Ci, Cu, CC} = require("chrome"); +"use strict"; + +const {Ci} = require("chrome"); const protocol = require("devtools/shared/protocol"); -const {Arg, method, RetVal} = protocol; const Services = require("Services"); const {preferenceSpec} = require("devtools/shared/specs/preference"); @@ -15,7 +16,8 @@ exports.register = function (handle) { exports.unregister = function (handle) { }; -var PreferenceActor = exports.PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, { +var PreferenceActor = protocol.ActorClassWithSpec(preferenceSpec, { + typeName: "preference", getBoolPref: function (name) { @@ -79,3 +81,5 @@ var PreferenceActor = exports.PreferenceActor = protocol.ActorClassWithSpec(pref Services.prefs.savePrefFile(null); }, }); + +exports.PreferenceActor = PreferenceActor; diff --git a/devtools/server/actors/pretty-print-worker.js b/devtools/server/actors/pretty-print-worker.js index 5fc6b6959c8d..f0461dcf7f53 100644 --- a/devtools/server/actors/pretty-print-worker.js +++ b/devtools/server/actors/pretty-print-worker.js @@ -4,6 +4,10 @@ * 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 importScripts, workerHelper, self, prettyFast */ + /** * This file is meant to be loaded as a ChromeWorker. It accepts messages which * have data of the form: @@ -43,8 +47,7 @@ workerHelper.createTask(self, "pretty-print", ({ url, indent, source }) => { code: prettified.code, mappings: prettified.map._mappings }; - } - catch (e) { + } catch (e) { return new Error(e.message + "\n" + e.stack); } }); diff --git a/devtools/server/actors/process.js b/devtools/server/actors/process.js index ff1c4313f7a9..e8eff08aa16b 100644 --- a/devtools/server/actors/process.js +++ b/devtools/server/actors/process.js @@ -7,7 +7,8 @@ var { Cc, Ci } = require("chrome"); loader.lazyGetter(this, "ppmm", () => { - return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster); + return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService( + Ci.nsIMessageBroadcaster); }); function ProcessActorList() { @@ -24,9 +25,13 @@ ProcessActorList.prototype = { let processes = []; for (let i = 0; i < ppmm.childCount; i++) { processes.push({ - id: i, // XXX: may not be a perfect id, but process message manager doesn't expose anything... - parent: i == 0, // XXX Weak, but appear to be stable - tabCount: undefined, // TODO: exposes process message manager on frameloaders in order to compute this + // XXX: may not be a perfect id, but process message manager doesn't + // expose anything... + id: i, + // XXX Weak, but appear to be stable + parent: i == 0, + // TODO: exposes process message manager on frameloaders in order to compute this + tabCount: undefined, }); } this._mustNotify = true; diff --git a/devtools/server/actors/profiler.js b/devtools/server/actors/profiler.js index bb23b6641d5c..9ec2fa047be4 100644 --- a/devtools/server/actors/profiler.js +++ b/devtools/server/actors/profiler.js @@ -16,7 +16,7 @@ loader.lazyRequireGetter(this, "events", "sdk/event/core"); * * @see devtools/server/performance/profiler.js for documentation. */ -var ProfilerActor = exports.ProfilerActor = ActorClassWithSpec(profilerSpec, { +exports.ProfilerActor = ActorClassWithSpec(profilerSpec, { initialize: function (conn) { Actor.prototype.initialize.call(this, conn); this._onProfilerEvent = this._onProfilerEvent.bind(this); diff --git a/devtools/server/actors/reflow.js b/devtools/server/actors/reflow.js index 286b0d08ba77..619d84b69c62 100644 --- a/devtools/server/actors/reflow.js +++ b/devtools/server/actors/reflow.js @@ -27,7 +27,6 @@ const {Ci} = require("chrome"); const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); const protocol = require("devtools/shared/protocol"); -const {method, Arg} = protocol; const events = require("sdk/event/core"); const Heritage = require("sdk/core/heritage"); const EventEmitter = require("devtools/shared/event-emitter"); @@ -36,7 +35,7 @@ const {reflowSpec} = require("devtools/shared/specs/reflow"); /** * The reflow actor tracks reflows and emits events about them. */ -var ReflowActor = exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, { +exports.ReflowActor = protocol.ActorClassWithSpec(reflowSpec, { initialize: function (conn, tabActor) { protocol.Actor.prototype.initialize.call(this, conn); @@ -199,7 +198,7 @@ Observable.prototype = { var gIgnoreLayoutChanges = false; exports.setIgnoreLayoutChanges = function (ignore, syncReflowNode) { if (syncReflowNode) { - let forceSyncReflow = syncReflowNode.offsetWidth; + let forceSyncReflow = syncReflowNode.offsetWidth; // eslint-disable-line } gIgnoreLayoutChanges = ignore; }; @@ -432,7 +431,7 @@ function ReflowObserver(tabActor, callback) { ReflowObserver.prototype = Heritage.extend(Observable.prototype, { QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver, - Ci.nsISupportsWeakReference]), + Ci.nsISupportsWeakReference]), _startListeners: function (windows) { for (let window of windows) { diff --git a/devtools/server/actors/root.js b/devtools/server/actors/root.js index 9ff3b978974a..1cc6db6da8f2 100644 --- a/devtools/server/actors/root.js +++ b/devtools/server/actors/root.js @@ -7,12 +7,12 @@ "use strict"; const { Cc, Ci, Cu } = require("chrome"); -const Services = require("Services"); const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common"); const { DebuggerServer } = require("devtools/server/main"); loader.lazyGetter(this, "ppmm", () => { - return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster); + return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService( + Ci.nsIMessageBroadcaster); }); /* Root actor for the remote debugging protocol. */ @@ -20,12 +20,12 @@ loader.lazyGetter(this, "ppmm", () => { /** * Create a remote debugging protocol root actor. * - * @param aConnection + * @param connection * The DebuggerServerConnection whose root actor we are constructing. * - * @param aParameters - * The properties of |aParameters| provide backing objects for the root - * actor's requests; if a given property is omitted from |aParameters|, the + * @param parameters + * The properties of |parameters| provide backing objects for the root + * actor's requests; if a given property is omitted from |parameters|, the * root actor won't implement the corresponding requests or notifications. * Supported properties: * @@ -89,13 +89,14 @@ loader.lazyGetter(this, "ppmm", () => { * actually produce any actors until they are reached in the course of * iteration: alliterative lazy live lists. */ -function RootActor(aConnection, aParameters) { - this.conn = aConnection; - this._parameters = aParameters; +function RootActor(connection, parameters) { + this.conn = connection; + this._parameters = parameters; this._onTabListChanged = this.onTabListChanged.bind(this); this._onAddonListChanged = this.onAddonListChanged.bind(this); this._onWorkerListChanged = this.onWorkerListChanged.bind(this); - this._onServiceWorkerRegistrationListChanged = this.onServiceWorkerRegistrationListChanged.bind(this); + this._onServiceWorkerRegistrationListChanged = + this.onServiceWorkerRegistrationListChanged.bind(this); this._onProcessListChanged = this.onProcessListChanged.bind(this); this._extraActors = {}; @@ -271,7 +272,8 @@ RootActor.prototype = { this._globalActorPool = new ActorPool(this.conn); this.conn.addActorPool(this._globalActorPool); } - this._createExtraActors(this._parameters.globalActorFactories, this._globalActorPool); + this._createExtraActors(this._parameters.globalActorFactories, + this._globalActorPool); /* * Drop the old actorID -> actor map. Actors that still mattered were * added to the new map; others will go away. @@ -327,15 +329,16 @@ RootActor.prototype = { if (error.error) { // Pipe expected errors as-is to the client return error; - } else { - return { error: "noTab", - message: "Unexpected error while calling getTab(): " + error }; } + return { + error: "noTab", + message: "Unexpected error while calling getTab(): " + error + }; }); }, onTabListChanged: function () { - this.conn.send({ from: this.actorID, type:"tabListChanged" }); + this.conn.send({ from: this.actorID, type: "tabListChanged" }); /* It's a one-shot notification; no need to watch any more. */ this._parameters.tabList.onListChanged = null; }, @@ -452,18 +455,18 @@ RootActor.prototype = { this._parameters.processList.onListChanged = null; }, - onGetProcess: function (aRequest) { + onGetProcess: function (request) { if (!DebuggerServer.allowChromeProcess) { return { error: "forbidden", message: "You are not allowed to debug chrome." }; } - if (("id" in aRequest) && typeof (aRequest.id) != "number") { + if (("id" in request) && typeof (request.id) != "number") { return { error: "wrongParameter", message: "getProcess requires a valid `id` attribute." }; } // If the request doesn't contains id parameter or id is 0 // (id == 0, based on onListProcesses implementation) - if ((!("id" in aRequest)) || aRequest.id === 0) { + if ((!("id" in request)) || request.id === 0) { if (!this._chromeActor) { // Create a ChromeActor for the parent process let { ChromeActor } = require("devtools/server/actors/chrome"); @@ -472,35 +475,34 @@ RootActor.prototype = { } return { form: this._chromeActor.form() }; - } else { - let { id } = aRequest; - let mm = ppmm.getChildAt(id); - if (!mm) { - return { error: "noProcess", - message: "There is no process with id '" + id + "'." }; - } - let form = this._processActors.get(id); - if (form) { - return { form }; - } - let onDestroy = () => { - this._processActors.delete(id); - }; - return DebuggerServer.connectToContent(this.conn, mm, onDestroy) - .then(form => { - this._processActors.set(id, form); - return { form }; - }); } + + let { id } = request; + let mm = ppmm.getChildAt(id); + if (!mm) { + return { error: "noProcess", + message: "There is no process with id '" + id + "'." }; + } + let form = this._processActors.get(id); + if (form) { + return { form }; + } + let onDestroy = () => { + this._processActors.delete(id); + }; + return DebuggerServer.connectToContent(this.conn, mm, onDestroy).then(formResult => { + this._processActors.set(id, formResult); + return { form: formResult }; + }); }, /* This is not in the spec, but it's used by tests. */ - onEcho: function (aRequest) { + onEcho: function (request) { /* - * Request packets are frozen. Copy aRequest, so that + * Request packets are frozen. Copy request, so that * DebuggerServerConnection.onPacket can attach a 'from' property. */ - return Cu.cloneInto(aRequest, {}); + return Cu.cloneInto(request, {}); }, onProtocolDescription: function () { @@ -513,11 +515,11 @@ RootActor.prototype = { /** * Remove the extra actor (added by DebuggerServer.addGlobalActor or - * DebuggerServer.addTabActor) name |aName|. + * DebuggerServer.addTabActor) name |name|. */ - removeActorByName: function (aName) { - if (aName in this._extraActors) { - const actor = this._extraActors[aName]; + removeActorByName: function (name) { + if (name in this._extraActors) { + const actor = this._extraActors[name]; if (this._globalActorPool.has(actor)) { this._globalActorPool.removeActor(actor); } @@ -525,10 +527,10 @@ RootActor.prototype = { // Iterate over TabActor instances to also remove tab actors // created during listTabs for each document. this._tabActorPool.forEach(tab => { - tab.removeActorByName(aName); + tab.removeActorByName(name); }); } - delete this._extraActors[aName]; + delete this._extraActors[name]; } } }; diff --git a/devtools/server/actors/settings.js b/devtools/server/actors/settings.js index 179c82aa5fd9..acb6e97f3a81 100644 --- a/devtools/server/actors/settings.js +++ b/devtools/server/actors/settings.js @@ -38,7 +38,9 @@ function getDefaultSettings() { try { defaultSettings = JSON.parse(rawstr); - } catch (e) { } + } catch (e) { + // ignore + } stream.close(); } @@ -115,7 +117,7 @@ var SettingsActor = exports.SettingsActor = protocol.ActorClassWithSpec(settings let req = lock.get("*"); req.onsuccess = function () { - for (var name in req.result) { + for (let name in req.result) { settings[name] = { value: req.result[name], hasUserValue: self._hasUserSetting(name, req.result[name]) diff --git a/devtools/server/actors/source.js b/devtools/server/actors/source.js index 6438258c00f6..99db7ea9952d 100644 --- a/devtools/server/actors/source.js +++ b/devtools/server/actors/source.js @@ -11,12 +11,11 @@ const Services = require("Services"); const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint"); const { OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common"); const { createValueGrip } = require("devtools/server/actors/object"); -const { ActorClassWithSpec, Arg, RetVal, method } = require("devtools/shared/protocol"); +const { ActorClassWithSpec } = require("devtools/shared/protocol"); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const { assert, fetch } = DevToolsUtils; const { joinURI } = require("devtools/shared/path"); const promise = require("promise"); -const { defer, resolve, reject, all } = promise; const { sourceSpec } = require("devtools/shared/specs/source"); loader.lazyRequireGetter(this, "SourceMapConsumer", "source-map", true); @@ -44,7 +43,6 @@ function getSourceURL(source, window) { if (source.displayURL && source.introductionScript && !isEvalSource(source.introductionScript.source)) { - if (source.introductionScript.source.url === "debugger eval code") { if (window) { // If this is a named eval script created from the console, make it @@ -52,15 +50,13 @@ function getSourceURL(source, window) { // when we care about this. return joinURI(window.location.href, source.displayURL); } - } - else { + } else { return joinURI(source.introductionScript.source.url, source.displayURL); } } return source.displayURL; - } - else if (source.url === "debugger eval code") { + } else if (source.url === "debugger eval code") { // Treat code evaluated by the console as unnamed eval scripts return null; } @@ -74,28 +70,28 @@ exports.getSourceURL = getSourceURL; * * Of course, this works only for URIs pointing to local resources. * - * @param aURI + * @param uri * URI to resolve * @return * resolved nsIURI */ -function resolveURIToLocalPath(aURI) { +function resolveURIToLocalPath(uri) { let resolved; - switch (aURI.scheme) { + switch (uri.scheme) { case "jar": case "file": - return aURI; + return uri; case "chrome": - resolved = Cc["@mozilla.org/chrome/chrome-registry;1"]. - getService(Ci.nsIChromeRegistry).convertChromeURL(aURI); + resolved = Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIChromeRegistry).convertChromeURL(uri); return resolveURIToLocalPath(resolved); case "resource": - resolved = Cc["@mozilla.org/network/protocol;1?name=resource"]. - getService(Ci.nsIResProtocolHandler).resolveURI(aURI); - aURI = Services.io.newURI(resolved); - return resolveURIToLocalPath(aURI); + resolved = Cc["@mozilla.org/network/protocol;1?name=resource"] + .getService(Ci.nsIResProtocolHandler).resolveURI(uri); + uri = Services.io.newURI(resolved); + return resolveURIToLocalPath(uri); default: return null; @@ -182,20 +178,36 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { return this._isInlineSource; }, - get threadActor() { return this._threadActor; }, - get sources() { return this._threadActor.sources; }, - get dbg() { return this.threadActor.dbg; }, - get source() { return this._source; }, - get generatedSource() { return this._generatedSource; }, - get breakpointActorMap() { return this.threadActor.breakpointActorMap; }, + get threadActor() { + return this._threadActor; + }, + get sources() { + return this._threadActor.sources; + }, + get dbg() { + return this.threadActor.dbg; + }, + get source() { + return this._source; + }, + get generatedSource() { + return this._generatedSource; + }, + get breakpointActorMap() { + return this.threadActor.breakpointActorMap; + }, get url() { if (this.source) { return getSourceURL(this.source, this.threadActor._parent.window); } return this._originalUrl; }, - get addonID() { return this._addonID; }, - get addonPath() { return this._addonPath; }, + get addonID() { + return this._addonID; + }, + get addonPath() { + return this._addonPath; + }, get prettyPrintWorker() { return this.threadActor.prettyPrintWorker; @@ -233,10 +245,10 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { }, _mapSourceToAddon: function () { + let nsuri; try { - var nsuri = Services.io.newURI(this.url.split(" -> ").pop()); - } - catch (e) { + nsuri = Services.io.newURI(this.url.split(" -> ").pop()); + } catch (e) { // We can't do anything with an invalid URI return; } @@ -255,8 +267,7 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { if (localURI instanceof Ci.nsIJARURI) { // The path in the add-on is easy for jar: uris this._addonPath = localURI.JAREntry; - } - else if (localURI instanceof Ci.nsIFileURL) { + } else if (localURI instanceof Ci.nsIFileURL) { // For file: uris walk up to find the last directory that is part of the // add-on let target = localURI.file; @@ -310,7 +321,9 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { c = c.replace(/\n/g, "\\n"); console.error("\t\t", c); }); - } catch (e) { } + } catch (e) { + // ignore + } }, _getSourceText: function () { @@ -346,53 +359,52 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { this._contentType === "text/wasm")) { return toResolvedContent(this.source.text); } - else { - // Only load the HTML page source from cache (which exists when - // there are inline sources). Otherwise, we can't trust the - // cache because we are most likely here because we are - // fetching the original text for sourcemapped code, and the - // page hasn't requested it before (if it has, it was a - // previous debugging session). - let loadFromCache = this.isInlineSource; - // Fetch the sources with the same principal as the original document - let win = this.threadActor._parent.window; - let principal, cacheKey; - // On xpcshell, we don't have a window but a Sandbox - if (!isWorker && win instanceof Ci.nsIDOMWindow) { - let webNav = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - let channel = webNav.currentDocumentChannel; - principal = channel.loadInfo.loadingPrincipal; + // Only load the HTML page source from cache (which exists when + // there are inline sources). Otherwise, we can't trust the + // cache because we are most likely here because we are + // fetching the original text for sourcemapped code, and the + // page hasn't requested it before (if it has, it was a + // previous debugging session). + let loadFromCache = this.isInlineSource; - // Retrieve the cacheKey in order to load POST requests from cache - // Note that chrome:// URLs don't support this interface. - if (loadFromCache && - webNav.currentDocumentChannel instanceof Ci.nsICacheInfoChannel) { - cacheKey = webNav.currentDocumentChannel.cacheKey; - assert( - cacheKey, - "Could not fetch the cacheKey from the related document." - ); - } + // Fetch the sources with the same principal as the original document + let win = this.threadActor._parent.window; + let principal, cacheKey; + // On xpcshell, we don't have a window but a Sandbox + if (!isWorker && win instanceof Ci.nsIDOMWindow) { + let webNav = win.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation); + let channel = webNav.currentDocumentChannel; + principal = channel.loadInfo.loadingPrincipal; + + // Retrieve the cacheKey in order to load POST requests from cache + // Note that chrome:// URLs don't support this interface. + if (loadFromCache && + webNav.currentDocumentChannel instanceof Ci.nsICacheInfoChannel) { + cacheKey = webNav.currentDocumentChannel.cacheKey; + assert( + cacheKey, + "Could not fetch the cacheKey from the related document." + ); } - - let sourceFetched = fetch(this.url, { - principal, - cacheKey, - loadFromCache - }); - - // Record the contentType we just learned during fetching - return sourceFetched - .then(result => { - this._contentType = result.contentType; - return result; - }, error => { - this._reportLoadSourceError(error, map); - throw error; - }); } + + let sourceFetched = fetch(this.url, { + principal, + cacheKey, + loadFromCache + }); + + // Record the contentType we just learned during fetching + return sourceFetched + .then(result => { + this._contentType = result.contentType; + return result; + }, error => { + this._reportLoadSourceError(error, map); + throw error; + }); }); }, @@ -456,7 +468,7 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { * Handler for the "source" packet. */ onSource: function () { - return resolve(this._init) + return promise.resolve(this._init) .then(this._getSourceText) .then(({ content, contentType }) => { return { @@ -465,10 +477,10 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { contentType: contentType }; }) - .then(null, aError => { - reportError(aError, "Got an exception during SA_onSource: "); + .then(null, error => { + reportError(error, "Got an exception during SA_onSource: "); throw new Error("Could not load the source for " + this.url + ".\n" + - DevToolsUtils.safeErrorString(aError)); + DevToolsUtils.safeErrorString(error)); }); }, @@ -498,7 +510,7 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { * Return a function that sends a request to the pretty print worker, waits on * the worker's response, and then returns the pretty printed code. * - * @param Number aIndent + * @param Number indent * The number of spaces to indent by the code by, when we send the * request to the pretty print worker. * @returns Function @@ -506,11 +518,11 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { * is resolved with `{ code, mappings }` where `code` is the pretty * printed code, and `mappings` is an array of source mappings. */ - _sendToPrettyPrintWorker: function (aIndent) { + _sendToPrettyPrintWorker: function (indent) { return ({ content }) => { return this.prettyPrintWorker.performTask("pretty-print", { url: this.url, - indent: aIndent, + indent, source: content }); }; @@ -576,9 +588,9 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { sm = SourceMapConsumer.fromSourceMap(prevMap); } - let sources = this.threadActor.sources; - sources.clearSourceMapCache(source.sourceMapURL); - sources.setSourceMapHard(source, null, sm); + let actorSources = this.threadActor.sources; + actorSources.clearSourceMapCache(source.sourceMapURL); + actorSources.setSourceMapHard(source, null, sm); }); }, @@ -588,7 +600,6 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { disablePrettyPrint: function () { let source = this.generatedSource || this.source; let sources = this.threadActor.sources; - let sm = sources.getSourceMap(source); sources.clearSourceMapCache(source.sourceMapURL, { hard: true }); @@ -641,10 +652,11 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { */ setBreakpoint: function (line, column, condition, noSliding) { if (this.threadActor.state !== "paused") { - throw { + let errorObject = { error: "wrongState", message: "Cannot set breakpoint while debuggee is running." }; + throw errorObject; } let location = new OriginalLocation(this, line, column); @@ -763,11 +775,11 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { // Find the script that spans the largest amount of code to // determine the bounds for sliding. - const largestScript = scripts.reduce((largestScript, script) => { - if (script.lineCount > largestScript.lineCount) { + const largestScript = scripts.reduce((largestScr, script) => { + if (script.lineCount > largestScr.lineCount) { return script; } - return largestScript; + return largestScr; }); const maxLine = largestScript.startLine + largestScript.lineCount - 1; @@ -805,8 +817,9 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { } return promise.resolve(actor); - } else { - return this.sources.getAllGeneratedLocations(originalLocation).then((generatedLocations) => { + } + return this.sources.getAllGeneratedLocations(originalLocation) + .then((generatedLocations) => { this._setBreakpointAtAllGeneratedLocations( actor, generatedLocations @@ -814,7 +827,6 @@ let SourceActor = ActorClassWithSpec(sourceSpec, { return actor; }); - } }, _setBreakpointAtAllGeneratedLocations: function (actor, generatedLocations) { diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js index 8e07b8d20c2d..35fa2172e79f 100644 --- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -1487,7 +1487,7 @@ function DatabaseMetadata(origin, db, storage) { let objectStore = transaction.objectStore(transaction.objectStoreNames[i]); this._objectStores.push([transaction.objectStoreNames[i], - new ObjectStoreMetadata(objectStore)]); + new ObjectStoreMetadata(objectStore)]); } } } @@ -1924,7 +1924,7 @@ var indexedDBHelpers = { }, removeDB: Task.async(function* (host, principal, dbName) { - let result = new promise(resolve => { + let result = new Promise(resolve => { let {name, storage} = this.splitNameAndStorage(dbName); let request = indexedDBForStorage.deleteForPrincipal(principal, name, @@ -1961,7 +1961,7 @@ var indexedDBHelpers = { let {name, storage} = this.splitNameAndStorage(dbName); try { - db = yield new promise((resolve, reject) => { + db = yield new Promise((resolve, reject) => { let request = this.openWithPrincipal(principal, name, storage); request.onsuccess = ev => resolve(ev.target.result); request.onerror = ev => reject(ev.target.error); @@ -1970,7 +1970,7 @@ var indexedDBHelpers = { let transaction = db.transaction(storeName, "readwrite"); let store = transaction.objectStore(storeName); - yield new promise((resolve, reject) => { + yield new Promise((resolve, reject) => { let request = store.delete(id); request.onsuccess = () => resolve(); request.onerror = ev => reject(ev.target.error); @@ -1994,7 +1994,7 @@ var indexedDBHelpers = { let {name, storage} = this.splitNameAndStorage(dbName); try { - db = yield new promise((resolve, reject) => { + db = yield new Promise((resolve, reject) => { let request = this.openWithPrincipal(principal, name, storage); request.onsuccess = ev => resolve(ev.target.result); request.onerror = ev => reject(ev.target.error); @@ -2003,7 +2003,7 @@ var indexedDBHelpers = { let transaction = db.transaction(storeName, "readwrite"); let store = transaction.objectStore(storeName); - yield new promise((resolve, reject) => { + yield new Promise((resolve, reject) => { let request = store.clear(); request.onsuccess = () => resolve(); request.onerror = ev => reject(ev.target.error); diff --git a/devtools/server/actors/timeline.js b/devtools/server/actors/timeline.js index 4c1d52d741fc..118196aa4165 100644 --- a/devtools/server/actors/timeline.js +++ b/devtools/server/actors/timeline.js @@ -26,7 +26,7 @@ const events = require("sdk/event/core"); /** * The timeline actor pops and forwards timeline markers registered in docshells. */ -var TimelineActor = exports.TimelineActor = protocol.ActorClassWithSpec(timelineSpec, { +exports.TimelineActor = protocol.ActorClassWithSpec(timelineSpec, { /** * Initializes this actor with the provided connection and tab actor. */ diff --git a/devtools/server/actors/utils/map-uri-to-addon-id.js b/devtools/server/actors/utils/map-uri-to-addon-id.js index 262d4f003d5c..e64d840645ce 100644 --- a/devtools/server/actors/utils/map-uri-to-addon-id.js +++ b/devtools/server/actors/utils/map-uri-to-addon-id.js @@ -24,10 +24,8 @@ const GRAPHENE_ID = "{d1bfe7d9-c01e-4237-998b-7b5f960a4314}"; */ if (!Services.appinfo || Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT - /* XPCShell */ || Services.appinfo.ID === undefined - || Services.appinfo.ID == B2G_ID || Services.appinfo.ID == GRAPHENE_ID || !AddonPathService) { diff --git a/devtools/server/actors/utils/webconsole-listeners.js b/devtools/server/actors/utils/webconsole-listeners.js index f2323594bc96..ea2a290855f0 100644 --- a/devtools/server/actors/utils/webconsole-listeners.js +++ b/devtools/server/actors/utils/webconsole-listeners.js @@ -36,7 +36,8 @@ function ConsoleServiceListener(window, listener) { } exports.ConsoleServiceListener = ConsoleServiceListener; -ConsoleServiceListener.prototype = { +ConsoleServiceListener.prototype = +{ QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]), /** @@ -200,7 +201,8 @@ function ConsoleAPIListener(window, owner, {addonId} = {}) { } exports.ConsoleAPIListener = ConsoleAPIListener; -ConsoleAPIListener.prototype = { +ConsoleAPIListener.prototype = +{ QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), /** @@ -387,7 +389,8 @@ function ConsoleReflowListener(window, listener) { exports.ConsoleReflowListener = ConsoleReflowListener; -ConsoleReflowListener.prototype = { +ConsoleReflowListener.prototype = +{ QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver, Ci.nsISupportsWeakReference]), docshell: null, diff --git a/devtools/server/actors/webaudio.js b/devtools/server/actors/webaudio.js index 6255d104dcbb..f1e1dcd19b8f 100644 --- a/devtools/server/actors/webaudio.js +++ b/devtools/server/actors/webaudio.js @@ -3,26 +3,20 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {Cc, Ci, Cu, Cr} = require("chrome"); +/* global XPCNativeWrapper */ -const Services = require("Services"); +const { Cu } = require("chrome"); const events = require("sdk/event/core"); -const promise = require("promise"); const { on: systemOn, off: systemOff } = require("sdk/system/events"); const protocol = require("devtools/shared/protocol"); const { CallWatcherActor } = require("devtools/server/actors/call-watcher"); -const { CallWatcherFront } = require("devtools/shared/fronts/call-watcher"); const { createValueGrip } = require("devtools/server/actors/object"); const AutomationTimeline = require("./utils/automation-timeline"); -const { on, once, off, emit } = events; -const { types, method, Arg, Option, RetVal, preEvent } = protocol; +const { on, off, emit } = events; const { audionodeSpec, - webAudioSpec, - AUTOMATION_METHODS, - NODE_CREATION_METHODS, - NODE_ROUTING_METHODS, + webAudioSpec } = require("devtools/shared/specs/webaudio"); const { WebAudioFront } = require("devtools/shared/fronts/webaudio"); const AUDIO_NODE_DEFINITION = require("devtools/server/actors/utils/audionodes.json"); @@ -45,7 +39,8 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } return { - actor: this.actorID, // actorID is set when this is added to a pool + // actorID is set when this is added to a pool + actor: this.actorID, type: this.type, source: this.source, bypassable: this.bypassable, @@ -117,9 +112,9 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion /** * Takes a boolean, either enabling or disabling the "passThrough" option - * on an AudioNode. If a node is bypassed, an effects processing node (like gain, biquad), - * will allow the audio stream to pass through the node, unaffected. Returns - * the bypass state of the node. + * on an AudioNode. If a node is bypassed, an effects processing node (like gain, + * biquad), will allow the audio stream to pass through the node, unaffected. + * Returns the bypass state of the node. * * @param Boolean enable * Whether the bypass value should be set on or off. @@ -129,7 +124,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion let node = this.node.get(); if (node === null) { - return; + return undefined; } if (this.bypassable) { @@ -159,8 +154,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion if (isAudioParam(node, param)) { node[param].value = value; this.automation[param].setValue(value); - } - else { + } else { node[param] = value; } return undefined; @@ -239,6 +233,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } catch (e) { return constructError(e); } + return undefined; }, /** @@ -262,6 +257,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } catch (e) { return constructError(e); } + return undefined; }, /** @@ -281,6 +277,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } catch (e) { return constructError(e); } + return undefined; }, getAutomationData: function (paramName) { @@ -289,16 +286,15 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion return null; } - let events = timeline.events; let values = []; let i = 0; if (!timeline.events.length) { - return { events, values }; + return { events: timeline.events, values }; } - let firstEvent = events[0]; - let lastEvent = events[timeline.events.length - 1]; + let firstEvent = timeline.events[0]; + let lastEvent = timeline.events[timeline.events.length - 1]; // `setValueCurveAtTime` will have a duration value -- other // events will have duration of `0`. let timeDelta = (lastEvent.time + lastEvent.duration) - firstEvent.time; @@ -322,7 +318,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } } - return { events, values }; + return { events: timeline.events, values }; }, /** @@ -378,6 +374,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion } catch (e) { return constructError(e); } + return undefined; }, /** @@ -404,7 +401,7 @@ var AudioNodeActor = exports.AudioNodeActor = protocol.ActorClassWithSpec(audion * high-level methods. After instantiating this actor, you'll need to set it * up by calling setup(). */ -var WebAudioActor = exports.WebAudioActor = protocol.ActorClassWithSpec(webAudioSpec, { +exports.WebAudioActor = protocol.ActorClassWithSpec(webAudioSpec, { initialize: function (conn, tabActor) { protocol.Actor.prototype.initialize.call(this, conn); this.tabActor = tabActor; @@ -487,11 +484,9 @@ var WebAudioActor = exports.WebAudioActor = protocol.ActorClassWithSpec(webAudio // hook into the `connect` and `disconnect` methods if (WebAudioFront.NODE_ROUTING_METHODS.has(name)) { this._handleRoutingCall(functionCall); - } - else if (WebAudioFront.NODE_CREATION_METHODS.has(name)) { + } else if (WebAudioFront.NODE_CREATION_METHODS.has(name)) { this._handleCreationCall(functionCall); - } - else if (ENABLE_AUTOMATION && WebAudioFront.AUTOMATION_METHODS.has(name)) { + } else if (ENABLE_AUTOMATION && WebAudioFront.AUTOMATION_METHODS.has(name)) { this._handleAutomationCall(functionCall); } }, @@ -500,18 +495,16 @@ var WebAudioActor = exports.WebAudioActor = protocol.ActorClassWithSpec(webAudio let { caller, args, name } = functionCall.details; let source = caller; let dest = args[0]; - let isAudioParam = dest ? getConstructorName(dest) === "AudioParam" : false; + let isAudioPar = dest ? getConstructorName(dest) === "AudioParam" : false; // audionode.connect(param) - if (name === "connect" && isAudioParam) { + if (name === "connect" && isAudioPar) { this._onConnectParam(source, dest); - } - // audionode.connect(node) - else if (name === "connect") { + } else if (name === "connect") { + // audionode.connect(node) this._onConnectNode(source, dest); - } - // audionode.disconnect() - else if (name === "disconnect") { + } else if (name === "disconnect") { + // audionode.disconnect() this._onDisconnectNode(source); } }, @@ -827,7 +820,8 @@ function createObjectGrip(value) { */ function sanitizeAutomationArgs(args) { return args.reduce((newArgs, el) => { - newArgs.push(typeof el === "object" && getConstructorName(el) === "Float32Array" ? castToArray(el) : el); + let isArray = typeof el === "object" && getConstructorName(el) === "Float32Array"; + newArgs.push(isArray ? castToArray(el) : el); return newArgs; }, []); } diff --git a/devtools/server/actors/webgl.js b/devtools/server/actors/webgl.js index 137448647082..05d814720c89 100644 --- a/devtools/server/actors/webgl.js +++ b/devtools/server/actors/webgl.js @@ -3,13 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {Cc, Ci, Cu, Cr} = require("chrome"); +/* global XPCNativeWrapper */ + +const {Cu} = require("chrome"); const events = require("sdk/event/core"); const promise = require("promise"); const protocol = require("devtools/shared/protocol"); const { ContentObserver } = require("devtools/shared/content-observer"); -const { on, once, off, emit } = events; -const { method, Arg, Option, RetVal } = protocol; +const { on, off, emit } = events; const { shaderSpec, programSpec, @@ -175,7 +176,8 @@ var ProgramActor = protocol.ActorClassWithSpec(programSpec, { let proxy = this.linkedProxy; let shader = proxy.getShaderOfType(this.shaders, type); let shaderActor = new ShaderActor(this.conn, this.program, shader, proxy); - return this._shaderActorsCache[type] = shaderActor; + this._shaderActorsCache[type] = shaderActor; + return this._shaderActorsCache[type]; } }); @@ -184,7 +186,7 @@ var ProgramActor = protocol.ActorClassWithSpec(programSpec, { * high-level methods. After instantiating this actor, you'll need to set it * up by calling setup(). */ -var WebGLActor = exports.WebGLActor = protocol.ActorClassWithSpec(webGLSpec, { +exports.WebGLActor = protocol.ActorClassWithSpec(webGLSpec, { initialize: function (conn, tabActor) { protocol.Actor.prototype.initialize.call(this, conn); this.tabActor = tabActor; @@ -269,7 +271,8 @@ var WebGLActor = exports.WebGLActor = protocol.ActorClassWithSpec(webGLSpec, { * @param string selector * A string selector to select the canvas in question from the DOM. * @param Object position - * An object with an `x` and `y` property indicating coordinates of the pixel being inspected. + * An object with an `x` and `y` property indicating coordinates of + * the pixel being inspected. * @return Object * An object containing `r`, `g`, `b`, and `a` properties of the pixel. */ @@ -283,7 +286,9 @@ var WebGLActor = exports.WebGLActor = protocol.ActorClassWithSpec(webGLSpec, { let buffer = new this.tabActor.window.Uint8Array(4); buffer = XPCNativeWrapper.unwrap(buffer); - proxy.readPixels(x, height - y - 1, 1, 1, context.RGBA, context.UNSIGNED_BYTE, buffer); + proxy.readPixels( + x, height - y - 1, 1, 1, context.RGBA, context.UNSIGNED_BYTE, buffer + ); return { r: buffer[0], g: buffer[1], b: buffer[2], a: buffer[3] }; }, @@ -296,7 +301,6 @@ var WebGLActor = exports.WebGLActor = protocol.ActorClassWithSpec(webGLSpec, { return this._programActorsCache; }, - /** * Invoked whenever the current tab actor's document global is created. */ @@ -412,7 +416,9 @@ var WebGLInstrumenter = { context[funcName] = function (...glArgs) { if (timing <= 0 && !observer.suppressHandlers) { let glBreak = observer[beforeFuncName](glArgs, cache, proxy); - if (glBreak) return undefined; + if (glBreak) { + return undefined; + } } // Invoking .apply on an unxrayed content function doesn't work, because @@ -421,7 +427,9 @@ var WebGLInstrumenter = { if (timing >= 0 && !observer.suppressHandlers) { let glBreak = observer[afterFuncName](glArgs, glResult, cache, proxy); - if (glBreak) return undefined; + if (glBreak) { + return undefined; + } } return glResult; @@ -432,12 +440,14 @@ var WebGLInstrumenter = { * Override mappings for WebGL methods. */ _methods: [{ - timing: 1, // after + // after + timing: 1, functions: [ "linkProgram", "getAttribLocation", "getUniformLocation" ] }, { - timing: -1, // before + // before + timing: -1, callback: [ "toggleVertexAttribArray" ], @@ -445,7 +455,8 @@ var WebGLInstrumenter = { "enableVertexAttribArray", "disableVertexAttribArray" ] }, { - timing: -1, // before + // before + timing: -1, callback: [ "attribute_" ], @@ -455,7 +466,8 @@ var WebGLInstrumenter = { "vertexAttribPointer" ] }, { - timing: -1, // before + // before + timing: -1, callback: [ "uniform_" ], @@ -467,14 +479,16 @@ var WebGLInstrumenter = { "uniformMatrix2fv", "uniformMatrix3fv", "uniformMatrix4fv" ] }, { - timing: -1, // before + // before + timing: -1, functions: [ "useProgram", "enable", "disable", "blendColor", "blendEquation", "blendEquationSeparate", "blendFunc", "blendFuncSeparate" ] }, { - timing: 0, // before and after + // before and after + timing: 0, callback: [ "beforeDraw_", "afterDraw_" ], @@ -614,7 +628,8 @@ WebGLObserver.prototype = { */ toggleVertexAttribArray: function (glArgs, cache) { glArgs[0] = cache.getCurrentAttributeLocation(glArgs[0]); - return glArgs[0] < 0; // Return true to break original function call. + // Return true to break original function call. + return glArgs[0] < 0; }, /** @@ -627,7 +642,8 @@ WebGLObserver.prototype = { */ attribute_: function (glArgs, cache) { glArgs[0] = cache.getCurrentAttributeLocation(glArgs[0]); - return glArgs[0] < 0; // Return true to break original function call. + // Return true to break original function call. + return glArgs[0] < 0; }, /** @@ -640,7 +656,8 @@ WebGLObserver.prototype = { */ uniform_: function (glArgs, cache) { glArgs[0] = cache.getCurrentUniformLocation(glArgs[0]); - return !glArgs[0]; // Return true to break original function call. + // Return true to break original function call. + return !glArgs[0]; }, /** @@ -770,7 +787,8 @@ WebGLObserver.prototype = { // Handle program blackboxing. if (traits & PROGRAM_BLACKBOX_TRAIT) { - return true; // Return true to break original function call. + // Return true to break original function call. + return true; } // Handle program highlighting. if (traits & PROGRAM_HIGHLIGHT_TRAIT) { @@ -875,8 +893,10 @@ WebGLCache.prototype = { addProgram: function (program, traits) { this._programs.set(program, { traits: traits, - attributes: [], // keys are GLints (numbers) - uniforms: new Map() // keys are WebGLUniformLocations (objects) + // keys are GLints (numbers) + attributes: [], + // keys are WebGLUniformLocations (objects) + uniforms: new Map() }); }, @@ -1059,7 +1079,9 @@ function WebGLProxy(id, context, cache, observer) { "disableHighlighting", "readPixels" ]; - exports.forEach(e => this[e] = (...args) => this._call(e, args)); + exports.forEach(e => { + this[e] = (...args) => this._call(e, args); + }); } WebGLProxy.prototype = { @@ -1128,7 +1150,7 @@ WebGLProxy.prototype = { * @return any * The corresponding parameter's value. */ - _getFramebufferAttachmentParameter: function (type, name = "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE") { + _getFramebufferAttachmentParameter(type, name = "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE") { if (!this._getParameter("FRAMEBUFFER_BINDING")) { return null; } diff --git a/devtools/server/actors/worker.js b/devtools/server/actors/worker.js index 70b560b8eb80..df6ffba148f6 100644 --- a/devtools/server/actors/worker.js +++ b/devtools/server/actors/worker.js @@ -171,7 +171,9 @@ let WorkerActor = protocol.ActorClassWithSpec(workerSpec, { let type; try { type = this._dbg.type; - } catch (e) {} + } catch (e) { + // nothing + } if (type == Ci.nsIWorkerDebugger.TYPE_SERVICE) { let worker = this._getServiceWorkerInfo();