Bug 1240907 - Clean up code style in test-actor-registry.js. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 06 Jul 2016 17:23:01 -0500
changeset 346230 b1345f3fb280d32784156eb7078d37a6e30091ae
parent 346229 0e7371939dd691bb277b882ab7b7bfd710896301
child 346231 7b8dcecb19336ebb963750fb35968bb840e34e35
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
bugs1240907
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 1240907 - Clean up code style in test-actor-registry.js. r=ochameau MozReview-Commit-ID: GKAKgnVDimD
.eslintignore
devtools/client/shared/test/test-actor-registry.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -94,16 +94,17 @@ devtools/client/responsivedesign/**
 devtools/client/scratchpad/**
 devtools/client/shadereditor/**
 devtools/client/shared/*.jsm
 devtools/client/shared/webgl-utils.js
 devtools/client/shared/developer-toolbar.js
 devtools/client/shared/components/test/**
 devtools/client/shared/redux/middleware/test/**
 devtools/client/shared/test/**
+!devtools/client/shared/test/test-actor-registry.js
 devtools/client/shared/widgets/*.jsm
 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/**
--- a/devtools/client/shared/test/test-actor-registry.js
+++ b/devtools/client/shared/test/test-actor-registry.js
@@ -1,105 +1,97 @@
 /* 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";
 
 (function (exports) {
-
-  var Cu = Components.utils;
-  var Ci = Components.interfaces;
-  var Cc = Components.classes;
-  var CC = Components.Constructor;
+  const Cu = Components.utils;
+  const CC = Components.Constructor;
 
-  var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-  var { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
-  var { fetch } = require("devtools/shared/DevToolsUtils");
-  var promise = require("promise");
-  var defer = require("devtools/shared/defer");
+  const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
+  const { fetch } = require("devtools/shared/DevToolsUtils");
+  const defer = require("devtools/shared/defer");
+  const { Task } = require("devtools/shared/task");
 
-  var TEST_URL_ROOT = "http://example.com/browser/devtools/client/shared/test/";
-  var ACTOR_URL = TEST_URL_ROOT + "test-actor.js";
+  const TEST_URL_ROOT = "http://example.com/browser/devtools/client/shared/test/";
+  const ACTOR_URL = TEST_URL_ROOT + "test-actor.js";
 
-// Register a test actor that can operate on the remote document
+  // Register a test actor that can operate on the remote document
   exports.registerTestActor = Task.async(function* (client) {
-  // First, instanciate ActorRegistryFront to be able to dynamically
-  // register an actor
+    // First, instanciate ActorRegistryFront to be able to dynamically register an actor
     let deferred = defer();
     client.listTabs(deferred.resolve);
     let response = yield deferred.promise;
     let { ActorRegistryFront } = require("devtools/shared/fronts/actor-registry");
     let registryFront = ActorRegistryFront(client, response);
 
-  // Then ask to register our test-actor to retrieve its front
+    // Then ask to register our test-actor to retrieve its front
     let options = {
       type: { tab: true },
       constructor: "TestActor",
       prefix: "testActor"
     };
     let testActorFront = yield registryFront.registerActor(ACTOR_URL, options);
     return testActorFront;
   });
 
-// Load the test actor in a custom sandbox
-// as we can't use SDK module loader with URIs
-  var loadFront = Task.async(function* () {
+  // Load the test actor in a custom sandbox as we can't use SDK module loader with URIs
+  let loadFront = Task.async(function* () {
     let sourceText = yield request(ACTOR_URL);
     const principal = CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")();
     const sandbox = Cu.Sandbox(principal);
-    const exports = sandbox.exports = {};
+    sandbox.exports = {};
     sandbox.require = require;
     Cu.evalInSandbox(sourceText, sandbox, "1.8", ACTOR_URL, 1);
     return sandbox.exports;
   });
 
-// Ensure fetching a live TabActor form for the targeted app
-// (helps fetching the test actor registered dynamically)
-  var getUpdatedForm = function (client, tab) {
+  // Ensure fetching a live TabActor form for the targeted app
+  // (helps fetching the test actor registered dynamically)
+  let getUpdatedForm = function (client, tab) {
     return client.getTab({tab: tab})
-               .then(response => response.tab);
+                 .then(response => response.tab);
   };
 
-// Spawn an instance of the test actor for the given toolbox
+  // Spawn an instance of the test actor for the given toolbox
   exports.getTestActor = Task.async(function* (toolbox) {
     let client = toolbox.target.client;
     return getTestActor(client, toolbox.target.tab, toolbox);
   });
 
-
-// Sometimes, we need the test actor before opening or without a toolbox
-// then just create a front for the given `tab`
+  // Sometimes, we need the test actor before opening or without a toolbox then just
+  // create a front for the given `tab`
   exports.getTestActorWithoutToolbox = Task.async(function* (tab) {
     let { DebuggerServer } = require("devtools/server/main");
     let { DebuggerClient } = require("devtools/shared/client/main");
 
-  // We need to spawn a client instance,
-  // but for that we have to first ensure a server is running
+    // We need to spawn a client instance,
+    // but for that we have to first ensure a server is running
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.addBrowserActors();
     }
     let client = new DebuggerClient(DebuggerServer.connectPipe());
 
     yield client.connect();
 
-  // We also need to make sure the test actor is registered on the server.
-    yield registerTestActor(client);
+    // We also need to make sure the test actor is registered on the server.
+    yield exports.registerTestActor(client);
 
     return getTestActor(client, tab);
   });
 
-// Fetch the content of a URI
-  var request = function (uri) {
+  // Fetch the content of a URI
+  let request = function (uri) {
     return fetch(uri).then(({ content }) => content);
   };
 
-  var getTestActor = Task.async(function* (client, tab, toolbox) {
-  // We may have to update the form in order to get the dynamically registered
-  // test actor.
+  let getTestActor = Task.async(function* (client, tab, toolbox) {
+    // We may have to update the form in order to get the dynamically registered
+    // test actor.
     let form = yield getUpdatedForm(client, tab);
 
     let { TestActorFront } = yield loadFront();
 
     return new TestActorFront(client, form, toolbox);
   });
-
 })(this);