Bug 1283583 - Clean up code style in devtools/server/main.js. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 28 Jun 2016 19:42:30 -0500
changeset 343401 1bbc4c035fd893b9ea1039c08bd28f34b8b66574
parent 343400 9b0be364ac5445e5712e79651720ad70269ca9b9
child 343402 49a1d28776b4a2867bb8818dfab61c352cc02f49
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1283583
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1283583 - Clean up code style in devtools/server/main.js. r=ochameau MozReview-Commit-ID: 48Jr1Si8oUh
.eslintignore
devtools/.eslintrc
devtools/server/main.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -106,16 +106,17 @@ devtools/client/webconsole/**
 !devtools/client/webconsole/panel.js
 !devtools/client/webconsole/jsterm.js
 !devtools/client/webconsole/console-commands.js
 devtools/client/webide/**
 !devtools/client/webide/components/webideCli.js
 devtools/server/**
 !devtools/server/child.js
 !devtools/server/css-logic.js
+!devtools/server/main.js
 !devtools/server/actors/webbrowser.js
 !devtools/server/actors/styles.js
 !devtools/server/actors/string.js
 !devtools/server/actors/csscoverage.js
 devtools/shared/*.js
 !devtools/shared/css-lexer.js
 !devtools/shared/defer.js
 !devtools/shared/event-emitter.js
--- a/devtools/.eslintrc
+++ b/devtools/.eslintrc
@@ -11,21 +11,23 @@
     "clearTimeout": true,
     "console": true,
     "DOMParser": true,
     "dump": true,
     "exports": true,
     "isWorker": true,
     "loader": true,
     "module": true,
+    "reportError": true,
     "require": true,
     "setInterval": true,
     "setTimeout": true,
+    "uneval": true,
+    "URL": true,
     "XMLHttpRequest": true,
-    "URL": true,
     "_Iterator": true,
   },
   "rules": {
     // These are the rules that have been configured so far to match the
     // devtools coding style.
 
     // Rules from the mozilla plugin
     "mozilla/mark-test-function-used": 1,
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -1,10 +1,8 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 /**
  * Toolkit glue for the remote debugging protocol, loaded into the
@@ -14,28 +12,29 @@ var { Ci, Cc, CC, Cu, Cr } = require("ch
 var Services = require("Services");
 var { ActorPool, OriginalLocation, RegisteredActorFactory,
       ObservedActorFactory } = require("devtools/server/actors/common");
 var { LocalDebuggerTransport, ChildDebuggerTransport, WorkerDebuggerTransport } =
   require("devtools/shared/transport/transport");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
 var { dumpn, dumpv } = DevToolsUtils;
 var EventEmitter = require("devtools/shared/event-emitter");
-var Debugger = require("Debugger");
 var Promise = require("promise");
+var SyncPromise = require("devtools/shared/deprecated-sync-thenables");
 
 DevToolsUtils.defineLazyGetter(this, "DebuggerSocket", () => {
   let { DebuggerSocket } = require("devtools/shared/security/socket");
   return DebuggerSocket;
 });
 DevToolsUtils.defineLazyGetter(this, "Authentication", () => {
   return require("devtools/shared/security/auth");
 });
 DevToolsUtils.defineLazyGetter(this, "generateUUID", () => {
-  let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
+  let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"]
+                           .getService(Ci.nsIUUIDGenerator);
   return generateUUID;
 });
 
 // On B2G, `this` != Global scope, so `Ci` won't be binded on `this`
 // (i.e. this.Ci is undefined) Then later, when using loadSubScript,
 // Ci,... won't be defined for sub scripts.
 this.Ci = Ci;
 this.Cc = Cc;
@@ -46,17 +45,17 @@ this.Services = Services;
 this.ActorPool = ActorPool;
 this.DevToolsUtils = DevToolsUtils;
 this.dumpn = dumpn;
 this.dumpv = dumpv;
 
 // Overload `Components` to prevent SDK loader exception on Components
 // object usage
 Object.defineProperty(this, "Components", {
-  get: function () {
+  get() {
     return require("chrome").components;
   }
 });
 
 if (isWorker) {
   dumpn.wantLogging = true;
   dumpv.wantVerbose = true;
 } else {
@@ -64,85 +63,78 @@ if (isWorker) {
   const VERBOSE_PREF = "devtools.debugger.log.verbose";
 
   dumpn.wantLogging = Services.prefs.getBoolPref(LOG_PREF);
   dumpv.wantVerbose =
     Services.prefs.getPrefType(VERBOSE_PREF) !== Services.prefs.PREF_INVALID &&
     Services.prefs.getBoolPref(VERBOSE_PREF);
 }
 
-function loadSubScript(aURL)
-{
+function loadSubScript(url) {
   try {
     let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
-      .getService(Ci.mozIJSSubScriptLoader);
-    loader.loadSubScript(aURL, this);
+                   .getService(Ci.mozIJSSubScriptLoader);
+    loader.loadSubScript(url, this);
   } catch (e) {
-    let errorStr = "Error loading: " + aURL + ":\n" +
+    let errorStr = "Error loading: " + url + ":\n" +
                    (e.fileName ? "at " + e.fileName + " : " + e.lineNumber + "\n" : "") +
                    e + " - " + e.stack + "\n";
     dump(errorStr);
     reportError(errorStr);
     throw e;
   }
 }
 
 loader.lazyRequireGetter(this, "events", "sdk/event/core");
 
-var {defer, resolve, reject, all} = require("devtools/shared/deprecated-sync-thenables");
-this.defer = defer;
-this.resolve = resolve;
-this.reject = reject;
-this.all = all;
-
 var gRegisteredModules = Object.create(null);
 
 /**
  * The ModuleAPI object is passed to modules loaded using the
  * DebuggerServer.registerModule() API.  Modules can use this
  * object to register actor factories.
  * Factories registered through the module API will be removed
  * when the module is unregistered or when the server is
  * destroyed.
  */
 function ModuleAPI() {
   let activeTabActors = new Set();
   let activeGlobalActors = new Set();
 
   return {
     // See DebuggerServer.setRootActor for a description.
-    setRootActor: function (factory) {
+    setRootActor(factory) {
       DebuggerServer.setRootActor(factory);
     },
 
     // See DebuggerServer.addGlobalActor for a description.
-    addGlobalActor: function (factory, name) {
+    addGlobalActor(factory, name) {
       DebuggerServer.addGlobalActor(factory, name);
       activeGlobalActors.add(factory);
     },
     // See DebuggerServer.removeGlobalActor for a description.
-    removeGlobalActor: function (factory) {
+    removeGlobalActor(factory) {
       DebuggerServer.removeGlobalActor(factory);
       activeGlobalActors.delete(factory);
     },
 
     // See DebuggerServer.addTabActor for a description.
-    addTabActor: function (factory, name) {
+    addTabActor(factory, name) {
       DebuggerServer.addTabActor(factory, name);
       activeTabActors.add(factory);
     },
     // See DebuggerServer.removeTabActor for a description.
-    removeTabActor: function (factory) {
+    removeTabActor(factory) {
       DebuggerServer.removeTabActor(factory);
       activeTabActors.delete(factory);
     },
 
     // Destroy the module API object, unregistering any
     // factories registered by the module.
-    destroy: function () {
+    destroy() {
       for (let factory of activeTabActors) {
         DebuggerServer.removeTabActor(factory);
       }
       activeTabActors = null;
       for (let factory of activeGlobalActors) {
         DebuggerServer.removeGlobalActor(factory);
       }
       activeGlobalActors = null;
@@ -175,17 +167,17 @@ var DebuggerServer = {
   /**
    * Allow debugging chrome of (parent or child) processes.
    */
   allowChromeProcess: false,
 
   /**
    * Initialize the debugger server.
    */
-  init: function DS_init() {
+  init() {
     if (this.initialized) {
       return;
     }
 
     this._connections = {};
     this._nextConnID = 0;
 
     this._initialized = true;
@@ -201,17 +193,17 @@ var DebuggerServer = {
 
   /**
    * Performs cleanup tasks before shutting down the debugger server. Such tasks
    * include clearing any actor constructors added at runtime. This method
    * should be called whenever a debugger server is no longer useful, to avoid
    * memory leaks. After this method returns, the debugger server must be
    * initialized again before use.
    */
-  destroy: function DS_destroy() {
+  destroy() {
     if (!this._initialized) {
       return;
     }
 
     for (let connID of Object.getOwnPropertyNames(this._connections)) {
       this._connections[connID].close();
     }
 
@@ -226,36 +218,37 @@ var DebuggerServer = {
     this._initialized = false;
 
     dumpn("Debugger server is shut down.");
   },
 
   /**
    * Raises an exception if the server has not been properly initialized.
    */
-  _checkInit: function DS_checkInit() {
+  _checkInit() {
     if (!this._initialized) {
-      throw "DebuggerServer has not been initialized.";
+      throw new Error("DebuggerServer has not been initialized.");
     }
 
     if (!this.createRootActor) {
-      throw "Use DebuggerServer.addActors() to add a root actor implementation.";
+      throw new Error("Use DebuggerServer.addActors() to add a root actor " +
+                      "implementation.");
     }
   },
 
   /**
    * Load a subscript into the debugging global.
    *
-   * @param aURL string A url that will be loaded as a subscript into the
+   * @param url string A url that will be loaded as a subscript into the
    *        debugging global.  The user must load at least one script
    *        that implements a createRootActor() function to create the
    *        server's root actor.
    */
-  addActors: function DS_addActors(aURL) {
-    loadSubScript.call(this, aURL);
+  addActors(url) {
+    loadSubScript.call(this, url);
   },
 
   /**
    * Register a CommonJS module with the debugger server.
    * @param id string
    *        The ID of a CommonJS module.  This module must export 'register'
    *        and 'unregister' functions if no `options` argument is given.
    *        If `options` is set, the actor is going to be registered
@@ -283,32 +276,35 @@ var DebuggerServer = {
    *        - type (a dictionary of booleans with following attribute names):
    *          - "global"
    *            registers a global actor instance, if true.
    *            A global actor has the root actor as its parent.
    *          - "tab"
    *            registers a tab actor instance, if true.
    *            A new actor will be created for each tab and each app.
    */
-  registerModule: function (id, options) {
+  registerModule(id, options) {
     if (id in gRegisteredModules) {
       throw new Error("Tried to register a module twice: " + id + "\n");
     }
 
     if (options) {
       // Lazy loaded actors
       let {prefix, constructor, type} = options;
       if (typeof (prefix) !== "string") {
-        throw new Error("Lazy actor definition for '" + id + "' requires a string 'prefix' option.");
+        throw new Error(`Lazy actor definition for '${id}' requires a string ` +
+                        `'prefix' option.`);
       }
       if (typeof (constructor) !== "string") {
-        throw new Error("Lazy actor definition for '" + id + "' requires a string 'constructor' option.");
+        throw new Error(`Lazy actor definition for '${id}' requires a string ` +
+                        `'constructor' option.`);
       }
       if (!("global" in type) && !("tab" in type)) {
-        throw new Error("Lazy actor definition for '" + id + "' requires a dictionary 'type' option whose attributes can be 'global' or 'tab'.");
+        throw new Error(`Lazy actor definition for '${id}' requires a dictionary ` +
+                        `'type' option whose attributes can be 'global' or 'tab'.`);
       }
       let name = prefix + "Actor";
       let mod = {
         id: id,
         prefix: prefix,
         constructorName: constructor,
         type: type,
         globalActor: type.global,
@@ -331,24 +327,24 @@ var DebuggerServer = {
         api: moduleAPI
       };
     }
   },
 
   /**
    * Returns true if a module id has been registered.
    */
-  isModuleRegistered: function (id) {
+  isModuleRegistered(id) {
     return (id in gRegisteredModules);
   },
 
   /**
    * Unregister a previously-loaded CommonJS module from the debugger server.
    */
-  unregisterModule: function (id) {
+  unregisterModule(id) {
     let mod = gRegisteredModules[id];
     if (!mod) {
       throw new Error("Tried to unregister a module that was not previously registered.");
     }
 
     // Lazy actors
     if (mod.tabActor) {
       this.removeTabActor(mod);
@@ -371,18 +367,18 @@ var DebuggerServer = {
    *
    * /!\ Be careful when adding a new actor, especially global actors.
    * Any new global actor will be exposed and returned by the root actor.
    *
    * That's the reason why tab actors aren't loaded on demand via
    * restrictPrivileges=true, to prevent exposing them on b2g parent process's
    * root actor.
    */
-  addBrowserActors: function (aWindowType = "navigator:browser", restrictPrivileges = false) {
-    this.chromeWindowType = aWindowType;
+  addBrowserActors(windowType = "navigator:browser", restrictPrivileges = false) {
+    this.chromeWindowType = windowType;
     this.registerModule("devtools/server/actors/webbrowser");
 
     if (!restrictPrivileges) {
       this.addTabActors();
       this.registerModule("devtools/server/actors/preference", {
         prefix: "preference",
         constructor: "PreferenceActor",
         type: { global: true }
@@ -425,17 +421,17 @@ var DebuggerServer = {
       constructor: "HeapSnapshotFileActor",
       type: { global: true }
     });
   },
 
   /**
    * Install tab actors in documents loaded in content childs
    */
-  addChildActors: function () {
+  addChildActors() {
     // In case of apps being loaded in parent process, DebuggerServer is already
     // initialized and browser actors are already loaded,
     // but childtab.js hasn't been loaded yet.
     if (!DebuggerServer.tabActorFactories.hasOwnProperty("consoleActor")) {
       this.addTabActors();
     }
     // But webbrowser.js and childtab.js aren't loaded from shell.js.
     if (!this.isModuleRegistered("devtools/server/actors/webbrowser")) {
@@ -444,17 +440,17 @@ var DebuggerServer = {
     if (!("ContentActor" in this)) {
       this.addActors("resource://devtools/server/actors/childtab.js");
     }
   },
 
   /**
    * Install tab actors.
    */
-  addTabActors: function () {
+  addTabActors() {
     this.registerModule("devtools/server/actors/webconsole", {
       prefix: "console",
       constructor: "WebConsoleActor",
       type: { tab: true }
     });
     this.registerModule("devtools/server/actors/inspector", {
       prefix: "inspector",
       constructor: "InspectorActor",
@@ -572,35 +568,35 @@ var DebuggerServer = {
       constructor: "PerformanceEntriesActor",
       type: { tab: true }
     });
   },
 
   /**
    * Passes a set of options to the BrowserAddonActors for the given ID.
    *
-   * @param aId string
+   * @param id string
    *        The ID of the add-on to pass the options to
-   * @param aOptions object
+   * @param options object
    *        The options.
    * @return a promise that will be resolved when complete.
    */
-  setAddonOptions: function DS_setAddonOptions(aId, aOptions) {
+  setAddonOptions(id, options) {
     if (!this._initialized) {
-      return;
+      return Promise.resolve();
     }
 
     let promises = [];
 
     // Pass to all connections
     for (let connID of Object.getOwnPropertyNames(this._connections)) {
-      promises.push(this._connections[connID].setAddonOptions(aId, aOptions));
+      promises.push(this._connections[connID].setAddonOptions(id, options));
     }
 
-    return all(promises);
+    return SyncPromise.all(promises);
   },
 
   get listeningSockets() {
     return this._listeners.length;
   },
 
   /**
    * Creates a socket listener for remote debugger connections.
@@ -612,76 +608,76 @@ var DebuggerServer = {
    * options.
    *
    * @return SocketListener
    *         A SocketListener instance that is waiting to be configured and
    *         opened is returned.  This single listener can be closed at any
    *         later time by calling |close| on the SocketListener.  If remote
    *         connections are disabled, an error is thrown.
    */
-  createListener: function () {
+  createListener() {
     if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) {
       throw new Error("Can't create listener, remote debugging disabled");
     }
     this._checkInit();
     return DebuggerSocket.createListener();
   },
 
   /**
    * Add a SocketListener instance to the server's set of active
    * SocketListeners.  This is called by a SocketListener after it is opened.
    */
-  _addListener: function (listener) {
+  _addListener(listener) {
     this._listeners.push(listener);
   },
 
   /**
    * Remove a SocketListener instance from the server's set of active
    * SocketListeners.  This is called by a SocketListener after it is closed.
    */
-  _removeListener: function (listener) {
+  _removeListener(listener) {
     this._listeners = this._listeners.filter(l => l !== listener);
   },
 
   /**
    * Closes and forgets all previously opened listeners.
    *
    * @return boolean
    *         Whether any listeners were actually closed.
    */
-  closeAllListeners: function () {
+  closeAllListeners() {
     if (!this.listeningSockets) {
       return false;
     }
 
     for (let listener of this._listeners) {
       listener.close();
     }
 
     return true;
   },
 
   /**
    * Creates a new connection to the local debugger speaking over a fake
    * transport. This connection results in straightforward calls to the onPacket
    * handlers of each side.
    *
-   * @param aPrefix string [optional]
+   * @param prefix string [optional]
    *    If given, all actors in this connection will have names starting
-   *    with |aPrefix + '/'|.
+   *    with |prefix + '/'|.
    * @returns a client-side DebuggerTransport for communicating with
    *    the newly-created connection.
    */
-  connectPipe: function DS_connectPipe(aPrefix) {
+  connectPipe(prefix) {
     this._checkInit();
 
-    let serverTransport = new LocalDebuggerTransport;
+    let serverTransport = new LocalDebuggerTransport();
     let clientTransport = new LocalDebuggerTransport(serverTransport);
     serverTransport.other = clientTransport;
-    let connection = this._onConnection(serverTransport, aPrefix);
+    let connection = this._onConnection(serverTransport, prefix);
 
     // I'm putting this here because I trust you.
     //
     // There are times, when using a local connection, when you're going
     // to be tempted to just get direct access to the server.  Resist that
     // temptation!  If you succumb to that temptation, you will make the
     // fine developers that work on Fennec and Firefox OS sad.  They're
     // professionals, they'll try to act like they understand, but deep
@@ -697,208 +693,210 @@ var DebuggerServer = {
 
     return clientTransport;
   },
 
   /**
    * In a content child process, create a new connection that exchanges
    * nsIMessageSender messages with our parent process.
    *
-   * @param aPrefix
+   * @param prefix
    *    The prefix we should use in our nsIMessageSender message names and
    *    actor names. This connection will use messages named
    *    "debug:<prefix>:packet", and all its actors will have names
    *    beginning with "<prefix>/".
    */
-  connectToParent: function (aPrefix, aScopeOrManager) {
+  connectToParent(prefix, scopeOrManager) {
     this._checkInit();
 
     let transport = isWorker ?
-                    new WorkerDebuggerTransport(aScopeOrManager, aPrefix) :
-                    new ChildDebuggerTransport(aScopeOrManager, aPrefix);
+                    new WorkerDebuggerTransport(scopeOrManager, prefix) :
+                    new ChildDebuggerTransport(scopeOrManager, prefix);
 
-    return this._onConnection(transport, aPrefix, true);
+    return this._onConnection(transport, prefix, true);
   },
 
-  connectToContent: function (aConnection, aMm) {
-    let deferred = defer();
+  connectToContent(connection, mm) {
+    let deferred = SyncPromise.defer();
 
-    let prefix = aConnection.allocID("content-process");
+    let prefix = connection.allocID("content-process");
     let actor, childTransport;
 
-    aMm.addMessageListener("debug:content-process-actor", function listener(msg) {
+    mm.addMessageListener("debug:content-process-actor", function listener(msg) {
       // Arbitrarily choose the first content process to reply
       // XXX: This code needs to be updated if we use more than one content process
-      aMm.removeMessageListener("debug:content-process-actor", listener);
+      mm.removeMessageListener("debug:content-process-actor", listener);
 
       // Pipe Debugger message from/to parent/child via the message manager
-      childTransport = new ChildDebuggerTransport(aMm, prefix);
+      childTransport = new ChildDebuggerTransport(mm, prefix);
       childTransport.hooks = {
-        onPacket: aConnection.send.bind(aConnection),
-        onClosed: function () {}
+        onPacket: connection.send.bind(connection),
+        onClosed() {}
       };
       childTransport.ready();
 
-      aConnection.setForwarding(prefix, childTransport);
+      connection.setForwarding(prefix, childTransport);
 
       dumpn("establishing forwarding for process with prefix " + prefix);
 
       actor = msg.json.actor;
 
       deferred.resolve(actor);
     });
 
-    aMm.sendAsyncMessage("DevTools:InitDebuggerServer", {
+    mm.sendAsyncMessage("DevTools:InitDebuggerServer", {
       prefix: prefix
     });
 
     function onClose() {
       Services.obs.removeObserver(onMessageManagerClose, "message-manager-close");
-      events.off(aConnection, "closed", onClose);
+      events.off(connection, "closed", onClose);
       if (childTransport) {
         // If we have a child transport, the actor has already
         // been created. We need to stop using this message manager.
         childTransport.close();
         childTransport = null;
-        aConnection.cancelForwarding(prefix);
+        connection.cancelForwarding(prefix);
 
         // ... and notify the child process to clean the tab actors.
         try {
-          aMm.sendAsyncMessage("debug:content-process-destroy");
-        } catch (e) {}
+          mm.sendAsyncMessage("debug:content-process-destroy");
+        } catch (e) {
+          // Nothing to do
+        }
       }
     }
 
-    let onMessageManagerClose = DevToolsUtils.makeInfallible(function (subject, topic, data) {
-      if (subject == aMm) {
+    let onMessageManagerClose = DevToolsUtils.makeInfallible((subject, topic, data) => {
+      if (subject == mm) {
         onClose();
-        aConnection.send({ from: actor.actor, type: "tabDetached" });
+        connection.send({ from: actor.actor, type: "tabDetached" });
       }
-    }).bind(this);
+    });
     Services.obs.addObserver(onMessageManagerClose,
                              "message-manager-close", false);
 
-    events.on(aConnection, "closed", onClose);
+    events.on(connection, "closed", onClose);
 
     return deferred.promise;
   },
 
-  connectToWorker: function (aConnection, aDbg, aId, aOptions) {
+  connectToWorker(connection, dbg, id, options) {
     return new Promise((resolve, reject) => {
       // Step 1: Ensure the worker debugger is initialized.
-      if (!aDbg.isInitialized) {
-        aDbg.initialize("resource://devtools/server/worker.js");
+      if (!dbg.isInitialized) {
+        dbg.initialize("resource://devtools/server/worker.js");
 
         // Create a listener for rpc requests from the worker debugger. Only do
         // this once, when the worker debugger is first initialized, rather than
         // for each connection.
         let listener = {
           onClose: () => {
-            aDbg.removeListener(listener);
+            dbg.removeListener(listener);
           },
 
           onMessage: (message) => {
-            let packet = JSON.parse(message);
-            if (packet.type !== "rpc") {
+            message = JSON.parse(message);
+            if (message.type !== "rpc") {
               return;
             }
 
             Promise.resolve().then(() => {
               let method = {
                 "fetch": DevToolsUtils.fetch,
-              }[packet.method];
+              }[message.method];
               if (!method) {
-                throw Error("Unknown method: " + packet.method);
+                throw Error("Unknown method: " + message.method);
               }
 
-              return method.apply(undefined, packet.params);
+              return method.apply(undefined, message.params);
             }).then((value) => {
-              aDbg.postMessage(JSON.stringify({
+              dbg.postMessage(JSON.stringify({
                 type: "rpc",
                 result: value,
                 error: null,
-                id: packet.id
+                id: message.id
               }));
             }, (reason) => {
-              aDbg.postMessage(JSON.stringify({
+              dbg.postMessage(JSON.stringify({
                 type: "rpc",
                 result: null,
                 error: reason,
-                id: packet.id
+                id: message.id
               }));
             });
           }
         };
 
-        aDbg.addListener(listener);
+        dbg.addListener(listener);
       }
 
       // Step 2: Send a connect request to the worker debugger.
-      aDbg.postMessage(JSON.stringify({
+      dbg.postMessage(JSON.stringify({
         type: "connect",
-        id: aId,
-        options: aOptions
+        id,
+        options,
       }));
 
       // Steps 3-5 are performed on the worker thread (see worker.js).
 
       // Step 6: Wait for a connection response from the worker debugger.
       let listener = {
         onClose: () => {
-          aDbg.removeListener(listener);
+          dbg.removeListener(listener);
 
           reject("closed");
         },
 
         onMessage: (message) => {
-          let packet = JSON.parse(message);
-          if (packet.type !== "connected" || packet.id !== aId) {
+          message = JSON.parse(message);
+          if (message.type !== "connected" || message.id !== id) {
             return;
           }
 
-          // The initial connection packet has been received, don't
+          // The initial connection message has been received, don't
           // need to listen any longer
-          aDbg.removeListener(listener);
+          dbg.removeListener(listener);
 
           // Step 7: Create a transport for the connection to the worker.
-          let transport = new WorkerDebuggerTransport(aDbg, aId);
+          let transport = new WorkerDebuggerTransport(dbg, id);
           transport.ready();
           transport.hooks = {
             onClosed: () => {
-              if (!aDbg.isClosed) {
-                aDbg.postMessage(JSON.stringify({
+              if (!dbg.isClosed) {
+                dbg.postMessage(JSON.stringify({
                   type: "disconnect",
-                  id: aId
+                  id,
                 }));
               }
 
-              aConnection.cancelForwarding(aId);
+              connection.cancelForwarding(id);
             },
 
             onPacket: (packet) => {
               // Ensure that any packets received from the server on the worker
               // thread are forwarded to the client on the main thread, as if
               // they had been sent by the server on the main thread.
-              aConnection.send(packet);
+              connection.send(packet);
             }
           };
 
           // Ensure that any packets received from the client on the main thread
           // to actors on the worker thread are forwarded to the server on the
           // worker thread.
-          aConnection.setForwarding(aId, transport);
+          connection.setForwarding(id, transport);
 
           resolve({
-            threadActor: packet.threadActor,
-            consoleActor: packet.consoleActor,
+            threadActor: message.threadActor,
+            consoleActor: message.consoleActor,
             transport: transport
           });
         }
       };
-      aDbg.addListener(listener);
+      dbg.addListener(listener);
     });
   },
 
   /**
    * Check if the caller is running in a content child process.
    * (Eventually set by child.js)
    *
    * @return boolean
@@ -914,17 +912,17 @@ var DebuggerServer = {
    *        The module to be required
    * @param setupChild
    *        The name of the setup helper exported by the above module
    *        (setup helper signature: function ({mm}) { ... })
    * @param waitForEval (optional)
    *        If true, the returned promise only resolves once code in child
    *        is evaluated
    */
-  setupInChild: function ({ module, setupChild, args, waitForEval }) {
+  setupInChild({ module, setupChild, args, waitForEval }) {
     if (this.isInChildProcess || this._childMessageManagers.size == 0) {
       return Promise.resolve();
     }
     let deferred = Promise.defer();
 
     // If waitForEval is set, pass a unique id and expect child.js to send
     // a message back once the code in child is evaluated.
     if (typeof (waitForEval) != "boolean") {
@@ -952,291 +950,292 @@ var DebuggerServer = {
         setupChild: setupChild,
         args: args,
         id: id,
       });
     });
 
     if (waitForEval) {
       return deferred.promise;
-    } else {
-      return Promise.resolve();
     }
+    return Promise.resolve();
   },
 
   /**
    * Live list of all currenctly attached child's message managers.
    */
   _childMessageManagers: new Set(),
 
   /**
    * Connect to a child process.
    *
-   * @param object aConnection
+   * @param object connection
    *        The debugger server connection to use.
-   * @param nsIDOMElement aFrame
+   * @param nsIDOMElement frame
    *        The browser element that holds the child process.
-   * @param function [aOnDestroy]
+   * @param function [onDestroy]
    *        Optional function to invoke when the child process closes
    *        or the connection shuts down. (Need to forget about the
    *        related TabActor)
    * @return object
    *         A promise object that is resolved once the connection is
    *         established.
    */
-  connectToChild: function (aConnection, aFrame, aOnDestroy) {
-    let deferred = defer();
+  connectToChild(connection, frame, onDestroy) {
+    let deferred = SyncPromise.defer();
 
-    let mm = aFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader
-             .messageManager;
+    let mm = frame.frameLoader.messageManager;
     mm.loadFrameScript("resource://devtools/server/child.js", false);
     this._childMessageManagers.add(mm);
 
     let actor, childTransport;
-    let prefix = aConnection.allocID("child");
+    let prefix = connection.allocID("child");
     let netMonitor = null;
 
     // provides hook to actor modules that need to exchange messages
     // between e10s parent and child processes
     let onSetupInParent = function (msg) {
       // We may have multiple connectToChild instance running for the same tab
       // and need to filter the messages. Also the DebuggerServerConnection's
       // prefix has an additional '/' and the end, so use `includes`.
       if (!msg.json.prefix.includes(prefix)) {
-        return;
+        return false;
       }
 
       let { module, setupParent } = msg.json;
-      let m, fn;
+      let m;
 
       try {
         m = require(module);
 
         if (!setupParent in m) {
-          dumpn("ERROR: module '" + module + "' does not export '" + setupParent + "'");
+          dumpn(`ERROR: module '${module}' does not export 'setupParent'`);
           return false;
         }
 
-        m[setupParent]({ mm: mm, prefix: prefix });
+        m[setupParent]({ mm, prefix });
 
         return true;
       } catch (e) {
-        let error_msg = "exception during actor module setup running in the parent process: ";
-        DevToolsUtils.reportException(error_msg + e);
-        dumpn("ERROR: " + error_msg + " \n\t module: '" + module + "' \n\t setupParent: '" + setupParent + "'\n" +
-              DevToolsUtils.safeErrorString(e));
+        let errorMessage =
+          "Exception during actor module setup running in the parent process: ";
+        DevToolsUtils.reportException(errorMessage + e);
+        dumpn(`ERROR: ${errorMessage}\n\t module: '${module}'\n\t ` +
+              `setupParent: '${setupParent}'\n${DevToolsUtils.safeErrorString(e)}`);
         return false;
       }
     };
     mm.addMessageListener("debug:setup-in-parent", onSetupInParent);
 
     let onActorCreated = DevToolsUtils.makeInfallible(function (msg) {
       if (msg.json.prefix != prefix) {
         return;
       }
       mm.removeMessageListener("debug:actor", onActorCreated);
 
       // Pipe Debugger message from/to parent/child via the message manager
       childTransport = new ChildDebuggerTransport(mm, prefix);
       childTransport.hooks = {
-        onPacket: aConnection.send.bind(aConnection),
-        onClosed: function () {}
+        onPacket: connection.send.bind(connection),
+        onClosed() {}
       };
       childTransport.ready();
 
-      aConnection.setForwarding(prefix, childTransport);
+      connection.setForwarding(prefix, childTransport);
 
       dumpn("establishing forwarding for app with prefix " + prefix);
 
       actor = msg.json.actor;
 
       let { NetworkMonitorManager } = require("devtools/shared/webconsole/network-monitor");
-      netMonitor = new NetworkMonitorManager(aFrame, actor.actor);
+      netMonitor = new NetworkMonitorManager(frame, actor.actor);
 
-      events.emit(DebuggerServer, "new-child-process", { mm: mm });
+      events.emit(DebuggerServer, "new-child-process", { mm });
 
       deferred.resolve(actor);
     }).bind(this);
     mm.addMessageListener("debug:actor", onActorCreated);
 
     let destroy = DevToolsUtils.makeInfallible(function () {
       // provides hook to actor modules that need to exchange messages
       // between e10s parent and child processes
-      DebuggerServer.emit("disconnected-from-child:" + prefix, { mm: mm, prefix: prefix });
+      DebuggerServer.emit("disconnected-from-child:" + prefix, { mm, prefix });
 
       if (childTransport) {
         // If we have a child transport, the actor has already
         // been created. We need to stop using this message manager.
         childTransport.close();
         childTransport = null;
-        aConnection.cancelForwarding(prefix);
+        connection.cancelForwarding(prefix);
 
         // ... and notify the child process to clean the tab actors.
         try {
           // Bug 1169643: Ignore any exception as the child process
           // may already be destroyed by now.
-          mm.sendAsyncMessage("debug:disconnect", { prefix: prefix });
-        } catch (e) {}
+          mm.sendAsyncMessage("debug:disconnect", { prefix });
+        } catch (e) {
+          // Nothing to do
+        }
       } else {
         // Otherwise, the app has been closed before the actor
         // had a chance to be created, so we are not able to create
         // the actor.
         deferred.resolve(null);
       }
       if (actor) {
         // The ContentActor within the child process doesn't necessary
         // have time to uninitialize itself when the app is closed/killed.
         // So ensure telling the client that the related actor is detached.
-        aConnection.send({ from: actor.actor, type: "tabDetached" });
+        connection.send({ from: actor.actor, type: "tabDetached" });
         actor = null;
       }
 
       if (netMonitor) {
         netMonitor.destroy();
         netMonitor = null;
       }
 
-      if (aOnDestroy) {
-        aOnDestroy(mm);
+      if (onDestroy) {
+        onDestroy(mm);
       }
 
       // Cleanup all listeners
       Services.obs.removeObserver(onMessageManagerClose, "message-manager-close");
       mm.removeMessageListener("debug:setup-in-parent", onSetupInParent);
       if (!actor) {
         mm.removeMessageListener("debug:actor", onActorCreated);
       }
-      events.off(aConnection, "closed", destroy);
+      events.off(connection, "closed", destroy);
 
       DebuggerServer._childMessageManagers.delete(mm);
     });
 
     // Listen for app process exit
     let onMessageManagerClose = function (subject, topic, data) {
       if (subject == mm) {
         destroy();
       }
     };
     Services.obs.addObserver(onMessageManagerClose,
                              "message-manager-close", false);
 
     // Listen for connection close to cleanup things
     // when user unplug the device or we lose the connection somehow.
-    events.on(aConnection, "closed", destroy);
+    events.on(connection, "closed", destroy);
 
-    mm.sendAsyncMessage("debug:connect", { prefix: prefix });
+    mm.sendAsyncMessage("debug:connect", { prefix });
 
     return deferred.promise;
   },
 
   /**
    * Create a new debugger connection for the given transport. Called after
    * connectPipe(), from connectToParent, or from an incoming socket
    * connection handler.
    *
-   * If present, |aForwardingPrefix| is a forwarding prefix that a parent
+   * If present, |forwardingPrefix| is a forwarding prefix that a parent
    * server is using to recognizes messages intended for this server. Ensure
-   * that all our actors have names beginning with |aForwardingPrefix + '/'|.
-   * In particular, the root actor's name will be |aForwardingPrefix + '/root'|.
+   * that all our actors have names beginning with |forwardingPrefix + '/'|.
+   * In particular, the root actor's name will be |forwardingPrefix + '/root'|.
    */
-  _onConnection: function DS_onConnection(aTransport, aForwardingPrefix, aNoRootActor = false) {
+  _onConnection(transport, forwardingPrefix, noRootActor = false) {
     let connID;
-    if (aForwardingPrefix) {
-      connID = aForwardingPrefix + "/";
+    if (forwardingPrefix) {
+      connID = forwardingPrefix + "/";
     } else {
       // Multiple servers can be started at the same time, and when that's the
       // case, they are loaded in separate devtools loaders.
       // So, use the current loader ID to prefix the connection ID and make it
       // unique.
       connID = "server" + loader.id + ".conn" + this._nextConnID++ + ".";
     }
 
-    let conn = new DebuggerServerConnection(connID, aTransport);
+    let conn = new DebuggerServerConnection(connID, transport);
     this._connections[connID] = conn;
 
     // Create a root actor for the connection and send the hello packet.
-    if (!aNoRootActor) {
+    if (!noRootActor) {
       conn.rootActor = this.createRootActor(conn);
-      if (aForwardingPrefix)
-        conn.rootActor.actorID = aForwardingPrefix + "/root";
-      else
+      if (forwardingPrefix) {
+        conn.rootActor.actorID = forwardingPrefix + "/root";
+      } else {
         conn.rootActor.actorID = "root";
+      }
       conn.addActor(conn.rootActor);
-      aTransport.send(conn.rootActor.sayHello());
+      transport.send(conn.rootActor.sayHello());
     }
-    aTransport.ready();
+    transport.ready();
 
     this.emit("connectionchange", "opened", conn);
     return conn;
   },
 
   /**
    * Remove the connection from the debugging server.
    */
-  _connectionClosed: function DS_connectionClosed(aConnection) {
-    delete this._connections[aConnection.prefix];
-    this.emit("connectionchange", "closed", aConnection);
+  _connectionClosed(connection) {
+    delete this._connections[connection.prefix];
+    this.emit("connectionchange", "closed", connection);
   },
 
   // DebuggerServer extension API.
 
-  setRootActor: function DS_setRootActor(aFunction) {
-    this.createRootActor = aFunction;
+  setRootActor(actorFactory) {
+    this.createRootActor = actorFactory;
   },
 
   /**
    * Registers handlers for new tab-scoped request types defined dynamically.
    * This is used for example by add-ons to augment the functionality of the tab
    * actor. Note that the name or actorPrefix of the request type is not allowed
    * to clash with existing protocol packet properties, like 'title', 'url' or
    * 'actor', since that would break the protocol.
    *
-   * @param aActor function, object
+   * @param actor function, object
    *      In case of function:
    *        The constructor function for this request type. This expects to be
    *        called as a constructor (i.e. with 'new'), and passed two
    *        arguments: the DebuggerServerConnection, and the BrowserTabActor
    *        with which it will be associated.
    *        Only used for deprecated eagerly loaded actors.
    *      In case of object:
    *        First argument of RegisteredActorFactory constructor.
    *        See the it's definition for more info.
    *
-   * @param aName string [optional]
+   * @param name string [optional]
    *        The name of the new request type. If this is not present, the
    *        actorPrefix property of the constructor prototype is used.
    */
-  addTabActor: function DS_addTabActor(aActor, aName) {
-    let name = aName ? aName : aActor.prototype.actorPrefix;
+  addTabActor(actor, name = actor.prototype.actorPrefix) {
     if (["title", "url", "actor"].indexOf(name) != -1) {
       throw Error(name + " is not allowed");
     }
     if (DebuggerServer.tabActorFactories.hasOwnProperty(name)) {
       throw Error(name + " already exists");
     }
-    DebuggerServer.tabActorFactories[name] = new RegisteredActorFactory(aActor, name);
+    DebuggerServer.tabActorFactories[name] = new RegisteredActorFactory(actor, name);
   },
 
   /**
    * Unregisters the handler for the specified tab-scoped request type.
    * This may be used for example by add-ons when shutting down or upgrading.
    * When unregistering an existing tab actor remove related tab factory
    * as well as all existing instances of the actor.
    *
-   * @param aActor function, object
+   * @param actor function, object
    *      In case of function:
    *        The constructor function for this request type.
    *      In case of object:
    *        Same object being given to related addTabActor call.
    */
-  removeTabActor: function DS_removeTabActor(aActor) {
+  removeTabActor(actor) {
     for (let name in DebuggerServer.tabActorFactories) {
       let handler = DebuggerServer.tabActorFactories[name];
-      if ((handler.name && handler.name == aActor.name) ||
-          (handler.id && handler.id == aActor.id)) {
+      if ((handler.name && handler.name == actor.name) ||
+          (handler.id && handler.id == actor.id)) {
         delete DebuggerServer.tabActorFactories[name];
         for (let connID of Object.getOwnPropertyNames(this._connections)) {
           // DebuggerServerConnection in child process don't have rootActor
           if (this._connections[connID].rootActor) {
             this._connections[connID].rootActor.removeActorByName(name);
           }
         }
       }
@@ -1246,59 +1245,58 @@ var DebuggerServer = {
   /**
    * Registers handlers for new browser-scoped request types defined
    * dynamically. This is used for example by add-ons to augment the
    * functionality of the root actor. Note that the name or actorPrefix of the
    * request type is not allowed to clash with existing protocol packet
    * properties, like 'from', 'tabs' or 'selected', since that would break the
    * protocol.
    *
-   * @param aActor function, object
+   * @param actor function, object
    *      In case of function:
    *        The constructor function for this request type. This expects to be
    *        called as a constructor (i.e. with 'new'), and passed two
    *        arguments: the DebuggerServerConnection, and the BrowserRootActor
    *        with which it will be associated.
    *        Only used for deprecated eagerly loaded actors.
    *      In case of object:
    *        First argument of RegisteredActorFactory constructor.
    *        See the it's definition for more info.
    *
-   * @param aName string [optional]
+   * @param name string [optional]
    *        The name of the new request type. If this is not present, the
    *        actorPrefix property of the constructor prototype is used.
    */
-  addGlobalActor: function DS_addGlobalActor(aActor, aName) {
-    let name = aName ? aName : aActor.prototype.actorPrefix;
+  addGlobalActor(actor, name = actor.prototype.actorPrefix) {
     if (["from", "tabs", "selected"].indexOf(name) != -1) {
       throw Error(name + " is not allowed");
     }
     if (DebuggerServer.globalActorFactories.hasOwnProperty(name)) {
       throw Error(name + " already exists");
     }
-    DebuggerServer.globalActorFactories[name] = new RegisteredActorFactory(aActor, name);
+    DebuggerServer.globalActorFactories[name] = new RegisteredActorFactory(actor, name);
   },
 
   /**
    * Unregisters the handler for the specified browser-scoped request type.
    * This may be used for example by add-ons when shutting down or upgrading.
    * When unregistering an existing global actor remove related global factory
    * as well as all existing instances of the actor.
    *
-   * @param aActor function, object
+   * @param actor function, object
    *      In case of function:
    *        The constructor function for this request type.
    *      In case of object:
    *        Same object being given to related addGlobalActor call.
    */
-  removeGlobalActor: function DS_removeGlobalActor(aActor) {
+  removeGlobalActor(actor) {
     for (let name in DebuggerServer.globalActorFactories) {
       let handler = DebuggerServer.globalActorFactories[name];
-      if ((handler.name && handler.name == aActor.name) ||
-          (handler.id && handler.id == aActor.id)) {
+      if ((handler.name && handler.name == actor.name) ||
+          (handler.id && handler.id == actor.id)) {
         delete DebuggerServer.globalActorFactories[name];
         for (let connID of Object.getOwnPropertyNames(this._connections)) {
           this._connections[connID].rootActor.removeActorByName(name);
         }
       }
     }
   }
 };
@@ -1335,158 +1333,161 @@ includes.forEach(name => {
 
 /**
  * Creates a DebuggerServerConnection.
  *
  * Represents a connection to this debugging global from a client.
  * Manages a set of actors and actor pools, allocates actor ids, and
  * handles incoming requests.
  *
- * @param aPrefix string
+ * @param prefix string
  *        All actor IDs created by this connection should be prefixed
- *        with aPrefix.
- * @param aTransport transport
+ *        with prefix.
+ * @param transport transport
  *        Packet transport for the debugging protocol.
  */
-function DebuggerServerConnection(aPrefix, aTransport)
-{
-  this._prefix = aPrefix;
-  this._transport = aTransport;
+function DebuggerServerConnection(prefix, transport) {
+  this._prefix = prefix;
+  this._transport = transport;
   this._transport.hooks = this;
   this._nextID = 1;
 
   this._actorPool = new ActorPool(this);
   this._extraPools = [this._actorPool];
 
   // Responses to a given actor must be returned the the client
   // in the same order as the requests that they're replying to, but
   // Implementations might finish serving requests in a different
   // order.  To keep things in order we generate a promise for each
   // request, chained to the promise for the request before it.
   // This map stores the latest request promise in the chain, keyed
   // by an actor ID string.
-  this._actorResponses = new Map;
+  this._actorResponses = new Map();
 
   /*
    * We can forward packets to other servers, if the actors on that server
    * all use a distinct prefix on their names. This is a map from prefixes
    * to transports: it maps a prefix P to a transport T if T conveys
    * packets to the server whose actors' names all begin with P + "/".
    */
-  this._forwardingPrefixes = new Map;
+  this._forwardingPrefixes = new Map();
 }
 
 DebuggerServerConnection.prototype = {
   _prefix: null,
-  get prefix() { return this._prefix; },
+  get prefix() {
+    return this._prefix;
+  },
 
   _transport: null,
-  get transport() { return this._transport; },
+  get transport() {
+    return this._transport;
+  },
 
   /**
    * Message manager used to communicate with the parent process,
    * set by child.js. Is only defined for connections instantiated
    * within a child process.
    */
   parentMessageManager: null,
 
-  close: function () {
+  close() {
     this._transport.close();
   },
 
-  send: function DSC_send(aPacket) {
-    this.transport.send(aPacket);
+  send(packet) {
+    this.transport.send(packet);
   },
 
   /**
    * Used when sending a bulk reply from an actor.
    * @see DebuggerTransport.prototype.startBulkSend
    */
-  startBulkSend: function (header) {
+  startBulkSend(header) {
     return this.transport.startBulkSend(header);
   },
 
-  allocID: function DSC_allocID(aPrefix) {
-    return this.prefix + (aPrefix || "") + this._nextID++;
+  allocID(prefix) {
+    return this.prefix + (prefix || "") + this._nextID++;
   },
 
   /**
    * Add a map of actor IDs to the connection.
    */
-  addActorPool: function DSC_addActorPool(aActorPool) {
-    this._extraPools.push(aActorPool);
+  addActorPool(actorPool) {
+    this._extraPools.push(actorPool);
   },
 
   /**
    * Remove a previously-added pool of actors to the connection.
    *
-   * @param ActorPool aActorPool
+   * @param ActorPool actorPool
    *        The ActorPool instance you want to remove.
-   * @param boolean aNoCleanup [optional]
+   * @param boolean noCleanup [optional]
    *        True if you don't want to disconnect each actor from the pool, false
    *        otherwise.
    */
-  removeActorPool: function DSC_removeActorPool(aActorPool, aNoCleanup) {
-    let index = this._extraPools.lastIndexOf(aActorPool);
+  removeActorPool(actorPool, noCleanup) {
+    let index = this._extraPools.lastIndexOf(actorPool);
     if (index > -1) {
       let pool = this._extraPools.splice(index, 1);
-      if (!aNoCleanup) {
-        pool.map(function (p) { p.destroy(); });
+      if (!noCleanup) {
+        pool.forEach(p => p.destroy());
       }
     }
   },
 
   /**
    * Add an actor to the default actor pool for this connection.
    */
-  addActor: function DSC_addActor(aActor) {
-    this._actorPool.addActor(aActor);
+  addActor(actor) {
+    this._actorPool.addActor(actor);
   },
 
   /**
    * Remove an actor to the default actor pool for this connection.
    */
-  removeActor: function DSC_removeActor(aActor) {
-    this._actorPool.removeActor(aActor);
+  removeActor(actor) {
+    this._actorPool.removeActor(actor);
   },
 
   /**
    * Match the api expected by the protocol library.
    */
-  unmanage: function (aActor) {
-    return this.removeActor(aActor);
+  unmanage(actor) {
+    return this.removeActor(actor);
   },
 
   /**
    * Look up an actor implementation for an actorID.  Will search
    * all the actor pools registered with the connection.
    *
-   * @param aActorID string
+   * @param actorID string
    *        Actor ID to look up.
    */
-  getActor: function DSC_getActor(aActorID) {
-    let pool = this.poolFor(aActorID);
+  getActor(actorID) {
+    let pool = this.poolFor(actorID);
     if (pool) {
-      return pool.get(aActorID);
+      return pool.get(actorID);
     }
 
-    if (aActorID === "root") {
+    if (actorID === "root") {
       return this.rootActor;
     }
 
     return null;
   },
 
-  _getOrCreateActor: function (actorID) {
+  _getOrCreateActor(actorID) {
     let actor = this.getActor(actorID);
     if (!actor) {
       this.transport.send({ from: actorID ? actorID : "root",
                             error: "noSuchActor",
                             message: "No such actor for ID: " + actorID });
-      return;
+      return null;
     }
 
     // Dynamically-loaded actors have to be created lazily.
     if (actor instanceof ObservedActorFactory) {
       try {
         actor = actor.createActor();
       } catch (e) {
         this.transport.send(this._unknownError(
@@ -1498,176 +1499,175 @@ DebuggerServerConnection.prototype = {
       // or ObservedActorFactory instances.
       throw new Error("Unexpected actor constructor/function in ActorPool " +
                       "for actorID=" + actorID + ".");
     }
 
     return actor;
   },
 
-  poolFor: function DSC_actorPool(aActorID) {
+  poolFor(actorID) {
     for (let pool of this._extraPools) {
-      if (pool.has(aActorID)) {
+      if (pool.has(actorID)) {
         return pool;
       }
     }
     return null;
   },
 
-  _unknownError: function DSC__unknownError(aPrefix, aError) {
-    let errorString = aPrefix + ": " + DevToolsUtils.safeErrorString(aError);
+  _unknownError(prefix, error) {
+    let errorString = prefix + ": " + DevToolsUtils.safeErrorString(error);
     reportError(errorString);
     dumpn(errorString);
     return {
       error: "unknownError",
       message: errorString
     };
   },
 
-  _queueResponse: function (from, type, response) {
-    let pendingResponse = this._actorResponses.get(from) || resolve(null);
+  _queueResponse: function (from, type, responseOrPromise) {
+    let pendingResponse = this._actorResponses.get(from) || SyncPromise.resolve(null);
     let responsePromise = pendingResponse.then(() => {
-      return response;
-    }).then(aResponse => {
-      if (!aResponse.from) {
-        aResponse.from = from;
+      return responseOrPromise;
+    }).then(response => {
+      if (!response.from) {
+        response.from = from;
       }
-      this.transport.send(aResponse);
+      this.transport.send(response);
     }).then(null, (e) => {
       let errorPacket = this._unknownError(
-        "error occurred while processing '" + type,
-        e);
+        "error occurred while processing '" + type, e);
       errorPacket.from = from;
       this.transport.send(errorPacket);
     });
 
     this._actorResponses.set(from, responsePromise);
   },
 
   /**
    * Passes a set of options to the BrowserAddonActors for the given ID.
    *
-   * @param aId string
+   * @param id string
    *        The ID of the add-on to pass the options to
-   * @param aOptions object
+   * @param options object
    *        The options.
    * @return a promise that will be resolved when complete.
    */
-  setAddonOptions: function DSC_setAddonOptions(aId, aOptions) {
+  setAddonOptions(id, options) {
     let addonList = this.rootActor._parameters.addonList;
     if (!addonList) {
-      return resolve();
+      return SyncPromise.resolve();
     }
     return addonList.getList().then((addonActors) => {
       for (let actor of addonActors) {
-        if (actor.id != aId) {
+        if (actor.id != id) {
           continue;
         }
-        actor.setOptions(aOptions);
+        actor.setOptions(options);
         return;
       }
     });
   },
 
   /* Forwarding packets to other transports based on actor name prefixes. */
 
   /*
    * Arrange to forward packets to another server. This is how we
    * forward debugging connections to child processes.
    *
-   * If we receive a packet for an actor whose name begins with |aPrefix|
-   * followed by '/', then we will forward that packet to |aTransport|.
+   * If we receive a packet for an actor whose name begins with |prefix|
+   * followed by '/', then we will forward that packet to |transport|.
    *
-   * This overrides any prior forwarding for |aPrefix|.
+   * This overrides any prior forwarding for |prefix|.
    *
-   * @param aPrefix string
+   * @param prefix string
    *    The actor name prefix, not including the '/'.
-   * @param aTransport object
+   * @param transport object
    *    A packet transport to which we should forward packets to actors
-   *    whose names begin with |(aPrefix + '/').|
+   *    whose names begin with |(prefix + '/').|
    */
-  setForwarding: function (aPrefix, aTransport) {
-    this._forwardingPrefixes.set(aPrefix, aTransport);
+  setForwarding(prefix, transport) {
+    this._forwardingPrefixes.set(prefix, transport);
   },
 
   /*
    * Stop forwarding messages to actors whose names begin with
-   * |aPrefix+'/'|. Such messages will now elicit 'noSuchActor' errors.
+   * |prefix+'/'|. Such messages will now elicit 'noSuchActor' errors.
    */
-  cancelForwarding: function (aPrefix) {
-    this._forwardingPrefixes.delete(aPrefix);
+  cancelForwarding(prefix) {
+    this._forwardingPrefixes.delete(prefix);
   },
 
-  sendActorEvent: function (actorID, eventName, event = {}) {
+  sendActorEvent(actorID, eventName, event = {}) {
     event.from = actorID;
     event.type = eventName;
     this.send(event);
   },
 
   // Transport hooks.
 
   /**
    * Called by DebuggerTransport to dispatch incoming packets as appropriate.
    *
-   * @param aPacket object
+   * @param packet object
    *        The incoming packet.
    */
-  onPacket: function DSC_onPacket(aPacket) {
+  onPacket(packet) {
     // If the actor's name begins with a prefix we've been asked to
     // forward, do so.
     //
     // Note that the presence of a prefix alone doesn't indicate that
     // forwarding is needed: in DebuggerServerConnection instances in child
     // processes, every actor has a prefixed name.
     if (this._forwardingPrefixes.size > 0) {
-      let to = aPacket.to;
+      let to = packet.to;
       let separator = to.lastIndexOf("/");
       while (separator >= 0) {
         to = to.substring(0, separator);
-        let forwardTo = this._forwardingPrefixes.get(aPacket.to.substring(0, separator));
+        let forwardTo = this._forwardingPrefixes.get(packet.to.substring(0, separator));
         if (forwardTo) {
-          forwardTo.send(aPacket);
+          forwardTo.send(packet);
           return;
         }
         separator = to.lastIndexOf("/");
       }
     }
 
-    let actor = this._getOrCreateActor(aPacket.to);
+    let actor = this._getOrCreateActor(packet.to);
     if (!actor) {
       return;
     }
 
-    var ret = null;
+    let ret = null;
 
     // handle "requestTypes" RDP request.
-    if (aPacket.type == "requestTypes") {
+    if (packet.type == "requestTypes") {
       ret = { from: actor.actorID, requestTypes: Object.keys(actor.requestTypes) };
-    } else if (actor.requestTypes && actor.requestTypes[aPacket.type]) {
+    } else if (actor.requestTypes && actor.requestTypes[packet.type]) {
       // Dispatch the request to the actor.
       try {
-        this.currentPacket = aPacket;
-        ret = actor.requestTypes[aPacket.type].bind(actor)(aPacket, this);
+        this.currentPacket = packet;
+        ret = actor.requestTypes[packet.type].bind(actor)(packet, this);
       } catch (e) {
         this.transport.send(this._unknownError(
-          "error occurred while processing '" + aPacket.type,
+          "error occurred while processing '" + packet.type,
           e));
       } finally {
         this.currentPacket = undefined;
       }
     } else {
       ret = { error: "unrecognizedPacketType",
               message: ("Actor " + actor.actorID +
                         " does not recognize the packet type " +
-                        aPacket.type) };
+                        packet.type) };
     }
 
     // There will not be a return value if a bulk reply is sent.
     if (ret) {
-      this._queueResponse(aPacket.to, aPacket.type, ret);
+      this._queueResponse(packet.to, packet.type, ret);
     }
   },
 
   /**
    * Called by the DebuggerTransport to dispatch incoming bulk packets as
    * appropriate.
    *
    * @param packet object
@@ -1691,18 +1691,18 @@ DebuggerServerConnection.prototype = {
    *          @param  output nsIAsyncOutputStream
    *                  The stream to copy to.
    *          @return Promise
    *                  The promise is resolved when copying completes or rejected
    *                  if any (unexpected) errors occur.
    *                  This object also emits "progress" events for each chunk
    *                  that is copied.  See stream-utils.js.
    */
-  onBulkPacket: function (packet) {
-    let { actor: actorKey, type, length } = packet;
+  onBulkPacket(packet) {
+    let { actor: actorKey, type } = packet;
 
     let actor = this._getOrCreateActor(actorKey);
     if (!actor) {
       return;
     }
 
     // Dispatch the request to the actor.
     let ret;
@@ -1726,77 +1726,77 @@ DebuggerServerConnection.prototype = {
     if (ret) {
       this._queueResponse(actorKey, type, ret);
     }
   },
 
   /**
    * Called by DebuggerTransport when the underlying stream is closed.
    *
-   * @param aStatus nsresult
+   * @param status nsresult
    *        The status code that corresponds to the reason for closing
    *        the stream.
    */
-  onClosed: function DSC_onClosed(aStatus) {
+  onClosed(status) {
     dumpn("Cleaning up connection.");
     if (!this._actorPool) {
       // Ignore this call if the connection is already closed.
       return;
     }
     this._actorPool = null;
 
-    events.emit(this, "closed", aStatus);
+    events.emit(this, "closed", status);
 
-    this._extraPools.map(function (p) { p.destroy(); });
+    this._extraPools.forEach(p => p.destroy());
     this._extraPools = null;
 
     this.rootActor = null;
     this._transport = null;
     DebuggerServer._connectionClosed(this);
   },
 
   /*
    * Debugging helper for inspecting the state of the actor pools.
    */
-  _dumpPools: function DSC_dumpPools() {
+  _dumpPools() {
     dumpn("/-------------------- dumping pools:");
     if (this._actorPool) {
       dumpn("--------------------- actorPool actors: " +
             uneval(Object.keys(this._actorPool._actors)));
     }
     for (let pool of this._extraPools) {
       if (pool !== this._actorPool) {
         dumpn("--------------------- extraPool actors: " +
               uneval(Object.keys(pool._actors)));
       }
     }
   },
 
   /*
    * Debugging helper for inspecting the state of an actor pool.
    */
-  _dumpPool: function DSC_dumpPools(aPool) {
+  _dumpPool(pool) {
     dumpn("/-------------------- dumping pool:");
     dumpn("--------------------- actorPool actors: " +
-          uneval(Object.keys(aPool._actors)));
+          uneval(Object.keys(pool._actors)));
   },
 
   /**
    * In a content child process, ask the DebuggerServer in the parent process
    * to execute a given module setup helper.
    *
    * @param module
    *        The module to be required
    * @param setupParent
    *        The name of the setup helper exported by the above module
    *        (setup helper signature: function ({mm}) { ... })
    * @return boolean
    *         true if the setup helper returned successfully
    */
-  setupInParent: function ({ module, setupParent }) {
+  setupInParent({ module, setupParent }) {
     if (!this.parentMessageManager) {
       return false;
     }
 
     let { sendSyncMessage } = this.parentMessageManager;
 
     return sendSyncMessage("debug:setup-in-parent", {
       prefix: this.prefix,