Skip to content

Commit

Permalink
Bug 1322085 - Make devtools/server/actors/*.js eslint-clean. r=ntim
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalimil committed Jan 16, 2017
1 parent 1667923 commit 0ffa7a3
Show file tree
Hide file tree
Showing 44 changed files with 567 additions and 486 deletions.
17 changes: 6 additions & 11 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down Expand Up @@ -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/**
Expand Down
2 changes: 1 addition & 1 deletion devtools/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions devtools/server/actors/actor-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
83 changes: 43 additions & 40 deletions devtools/server/actors/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -142,7 +142,7 @@ BrowserAddonActor.prototype = {
this.destroy();
},

onAttach: function BAA_onAttach() {
onAttach: function BAAOnAttach() {
if (this.exited) {
return { type: "exited" };
}
Expand All @@ -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" };
}
Expand All @@ -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 {};
});
},

Expand Down Expand Up @@ -201,29 +202,30 @@ 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;
}

// 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)
Expand All @@ -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;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
1 change: 0 additions & 1 deletion devtools/server/actors/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

}),
});

Expand Down
7 changes: 3 additions & 4 deletions devtools/server/actors/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;

Expand Down
13 changes: 8 additions & 5 deletions devtools/server/actors/breakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -111,20 +113,21 @@ let BreakpointActor = ActorClassWithSpec(breakpointSpec, {
} else if (completion.toString) {
message = completion.toString();
}
} catch (ex) {}
} catch (ex) {
// ignore
}
return {
result: true,
message: message
};
} 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 };
},

/**
Expand Down
Loading

0 comments on commit 0ffa7a3

Please sign in to comment.