Bug 1283583 - Clean up code style in devtools/server/child.js. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 28 Jun 2016 17:57:24 -0500
changeset 343400 9b0be364ac5445e5712e79651720ad70269ca9b9
parent 343399 20d8f274cc880211d59708b569358cc70134aff5
child 343401 1bbc4c035fd893b9ea1039c08bd28f34b8b66574
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/child.js. r=ochameau MozReview-Commit-ID: GoHv6jvX6M1
.eslintignore
devtools/server/child.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -104,16 +104,17 @@ devtools/client/sourceeditor/**
 devtools/client/webaudioeditor/**
 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/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
--- a/devtools/server/child.js
+++ b/devtools/server/child.js
@@ -1,38 +1,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+/* global addMessageListener, removeMessageListener, sendAsyncMessage */
+
 try {
-
   var chromeGlobal = this;
 
-// Encapsulate in its own scope to allows loading this frame script
-// more than once.
+  // Encapsulate in its own scope to allows loading this frame script more than once.
   (function () {
     let Cu = Components.utils;
     let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
     const DevToolsUtils = require("devtools/shared/DevToolsUtils");
     const { dumpn } = DevToolsUtils;
     const { DebuggerServer, ActorPool } = require("devtools/server/main");
 
-  // Note that this frame script may be evaluated in non-e10s build
-  // In such case, DebuggerServer is already going to be initialized.
+    // Note that this frame script may be evaluated in non-e10s build. In such case,
+    // DebuggerServer is already going to be initialized.
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.isInChildProcess = true;
     }
 
-  // In case of apps being loaded in parent process, DebuggerServer is already
-  // initialized, but child specific actors are not registered.
-  // Otherwise, for apps in child process, we need to load actors the first
-  // time we load child.js
+    // In case of apps being loaded in parent process, DebuggerServer is already
+    // initialized, but child specific actors are not registered. Otherwise, for apps in
+    // child process, we need to load actors the first time we load child.js.
     DebuggerServer.addChildActors();
 
     let connections = new Map();
 
     let onConnect = DevToolsUtils.makeInfallible(function (msg) {
       removeMessageListener("debug:connect", onConnect);
 
       let mm = msg.target;
@@ -47,72 +46,67 @@ try {
       actorPool.addActor(actor);
       conn.addActorPool(actorPool);
 
       sendAsyncMessage("debug:actor", {actor: actor.form(), prefix: prefix});
     });
 
     addMessageListener("debug:connect", onConnect);
 
-  // Allows executing module setup helper from the parent process.
-  // See also: DebuggerServer.setupInChild()
+    // Allows executing module setup helper from the parent process.
+    // See also: DebuggerServer.setupInChild()
     let onSetupInChild = DevToolsUtils.makeInfallible(msg => {
       let { module, setupChild, args } = msg.data;
-      let m, fn;
+      let m;
 
       try {
         m = require(module);
 
         if (!setupChild in m) {
-          dumpn("ERROR: module '" + module + "' does not export '" +
-              setupChild + "'");
+          dumpn(`ERROR: module '${module}' does not export 'setupChild'`);
           return false;
         }
 
         m[setupChild].apply(m, args);
-
       } catch (e) {
-        let error_msg = "exception during actor module setup running in the child process: ";
-        DevToolsUtils.reportException(error_msg + e);
-        dumpn("ERROR: " + error_msg + " \n\t module: '" + module +
-            "' \n\t setupChild: '" + setupChild + "'\n" +
-            DevToolsUtils.safeErrorString(e));
+        let errorMessage =
+          "Exception during actor module setup running in the child process: ";
+        DevToolsUtils.reportException(errorMessage + e);
+        dumpn(`ERROR: ${errorMessage}\n\t module: '${module}'\n\t ` +
+              `setupChild: '${setupChild}'\n${DevToolsUtils.safeErrorString(e)}`);
         return false;
       }
       if (msg.data.id) {
-      // Send a message back to know when it is processed
-        sendAsyncMessage("debug:setup-in-child-response",
-                       {id: msg.data.id});
+        // Send a message back to know when it is processed
+        sendAsyncMessage("debug:setup-in-child-response", {id: msg.data.id});
       }
       return true;
     });
 
     addMessageListener("debug:setup-in-child", onSetupInChild);
 
     let onDisconnect = DevToolsUtils.makeInfallible(function (msg) {
       removeMessageListener("debug:disconnect", onDisconnect);
 
-    // Call DebuggerServerConnection.close to destroy all child actors
-    // (It should end up calling DebuggerServerConnection.onClosed
-    // that would actually cleanup all actor pools)
+      // Call DebuggerServerConnection.close to destroy all child actors. It should end up
+      // calling DebuggerServerConnection.onClosed that would actually cleanup all actor
+      // pools.
       let prefix = msg.data.prefix;
       let conn = connections.get(prefix);
       if (conn) {
         conn.close();
         connections.delete(prefix);
       }
     });
     addMessageListener("debug:disconnect", onDisconnect);
 
     let onInspect = DevToolsUtils.makeInfallible(function (msg) {
-    // Store the node to be inspected in a global variable
-    // (gInspectingNode). Later we'll fetch this variable again using
-    // the findInspectingNode request over the remote debugging
-    // protocol.
+      // Store the node to be inspected in a global variable (gInspectingNode). Later
+      // we'll fetch this variable again using the findInspectingNode request over the
+      // remote debugging protocol.
       let inspector = require("devtools/server/actors/inspector");
       inspector.setInspectingNode(msg.objects.node);
     });
     addMessageListener("debug:inspect", onInspect);
   })();
-
 } catch (e) {
-  dump("Exception in app child process: " + e + "\n");
+  dump(`Exception in app child process: ${e}\n`);
 }