Bug 1262439 - 3 - inspector and eye-dropper eslint cleanup; r=me
authorPatrick Brosset <pbrosset@mozilla.com>
Mon, 06 Jun 2016 15:11:27 +0200
changeset 331362 d8b8d18ab36df94ed7073695c7202125661f3c69
parent 331361 d6064e5bc48fe772a9de113cf91db881a57fdecc
child 331363 ac3078c8bf35bc5fbb9b754e61e4ca368fbd99bf
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1262439
milestone50.0a1
Bug 1262439 - 3 - inspector and eye-dropper eslint cleanup; r=me MozReview-Commit-ID: KZsd47QSvue
.eslintignore
devtools/server/actors/inspector.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -108,16 +108,18 @@ devtools/client/webconsole/**
 !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/inspector.js
+!devtools/server/actors/highlighters/eye-dropper.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/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -48,41 +48,37 @@
  * So to be able to answer "all the children of a given node that we have
  * seen on the client side", we guarantee that every time we've seen a node,
  * we connect it up through its parents.
  */
 
 const {Cc, Ci, Cu} = require("chrome");
 const Services = require("Services");
 const protocol = require("devtools/shared/protocol");
-const {Arg, Option, method, RetVal, types} = protocol;
 const {LongStringActor} = require("devtools/server/actors/string");
 const promise = require("promise");
 const {Task} = require("devtools/shared/task");
-const object = require("sdk/util/object");
 const events = require("sdk/event/core");
-const {Class} = require("sdk/core/heritage");
 const {WalkerSearch} = require("devtools/server/actors/utils/walker-search");
 const {PageStyleActor, getFontPreviewData} = require("devtools/server/actors/styles");
 const {
   HighlighterActor,
   CustomHighlighterActor,
   isTypeRegistered,
   HighlighterEnvironment
 } = require("devtools/server/actors/highlighters");
 const {EyeDropper} = require("devtools/server/actors/highlighters/eye-dropper");
 const {
   isAnonymous,
   isNativeAnonymous,
   isXBLAnonymous,
   isShadowAnonymous,
   getFrameElement
 } = require("devtools/shared/layout/utils");
-const {getLayoutChangesObserver, releaseLayoutChangesObserver} =
-  require("devtools/server/actors/layout");
+const {getLayoutChangesObserver, releaseLayoutChangesObserver} = require("devtools/server/actors/layout");
 const nodeFilterConstants = require("devtools/shared/dom-node-filter-constants");
 
 loader.lazyRequireGetter(this, "CSS", "CSS");
 
 const {EventParsers} = require("devtools/shared/event-parsers");
 const {nodeSpec, nodeListSpec, walkerSpec, inspectorSpec} = require("devtools/shared/specs/inspector");
 
 const FONT_FAMILY_PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog";
@@ -439,44 +435,44 @@ var NodeActor = exports.NodeActor = prot
    * Gets event listeners and adds their information to the events array.
    *
    * @param  {Node} node
    *         Node for which we are to get listeners.
    */
   getEventListeners: function (node) {
     let parsers = this._eventParsers;
     let dbg = this.parent().tabActor.makeDebugger();
-    let events = [];
+    let listeners = [];
 
     for (let [, {getListeners, normalizeHandler}] of parsers) {
       try {
         let eventInfos = getListeners(node);
 
         if (!eventInfos) {
           continue;
         }
 
         for (let eventInfo of eventInfos) {
           if (normalizeHandler) {
             eventInfo.normalizeHandler = normalizeHandler;
           }
 
-          this.processHandlerForEvent(node, events, dbg, eventInfo);
+          this.processHandlerForEvent(node, listeners, dbg, eventInfo);
         }
       } catch (e) {
         // An object attached to the node looked like a listener but wasn't...
         // do nothing.
       }
     }
 
-    events.sort((a, b) => {
+    listeners.sort((a, b) => {
       return a.type.localeCompare(b.type);
     });
 
-    return events;
+    return listeners;
   },
 
   /**
    * Process a handler
    *
    * @param  {Node} node
    *         The node for which we want information.
    * @param  {Array} events
@@ -498,17 +494,17 @@ var NodeActor = exports.NodeActor = prot
    *             tags: tags,
    *             DOM0: true,
    *             capturing: true,
    *             hide: {
    *               dom0: true
    *             }
    *           }
    */
-  processHandlerForEvent: function (node, events, dbg, eventInfo) {
+  processHandlerForEvent: function (node, listeners, dbg, eventInfo) {
     let type = eventInfo.type || "";
     let handler = eventInfo.handler;
     let tags = eventInfo.tags || "";
     let hide = eventInfo.hide || {};
     let override = eventInfo.override || {};
     let global = Cu.getGlobalForObject(handler);
     let globalDO = dbg.addDebuggee(global);
     let listenerDO = globalDO.makeDebuggeeValue(handler);
@@ -589,17 +585,17 @@ var NodeActor = exports.NodeActor = prot
                            override.searchString : searchString,
       tags: tags,
       DOM0: typeof override.dom0 !== "undefined" ? override.dom0 : dom0,
       capturing: typeof override.capturing !== "undefined" ?
                         override.capturing : eventInfo.capturing,
       hide: hide
     };
 
-    events.push(eventObj);
+    listeners.push(eventObj);
 
     dbg.removeDebuggee(globalDO);
   },
 
   /**
    * Returns a LongStringActor with the node's value.
    */
   getNodeValue: function () {
@@ -1295,18 +1291,18 @@ var WalkerActor = protocol.ActorClassWit
     }
     let maxNodes = options.maxNodes || -1;
     if (maxNodes == -1) {
       maxNodes = Number.MAX_VALUE;
     }
 
     // We're going to create a few document walkers with the same filter,
     // make it easier.
-    let getFilteredWalker = node => {
-      return this.getDocumentWalker(node, options.whatToShow);
+    let getFilteredWalker = documentWalkerNode => {
+      return this.getDocumentWalker(documentWalkerNode, options.whatToShow);
     };
 
     // Need to know the first and last child.
     let rawNode = node.rawNode;
     let firstChild = getFilteredWalker(rawNode).firstChild();
     let lastChild = getFilteredWalker(rawNode).lastChild();
 
     if (!firstChild) {
@@ -2104,32 +2100,32 @@ var WalkerActor = protocol.ActorClassWit
 
   /**
    * Insert a node into the DOM.
    */
   insertBefore: function (node, parent, sibling) {
     if (isNodeDead(node) ||
         isNodeDead(parent) ||
         (sibling && isNodeDead(sibling))) {
-      return null;
+      return;
     }
 
     let rawNode = node.rawNode;
     let rawParent = parent.rawNode;
     let rawSibling = sibling ? sibling.rawNode : null;
 
     // Don't bother inserting a node if the document position isn't going
     // to change. This prevents needless iframes reloading and mutations.
     if (rawNode.parentNode === rawParent) {
       let currentNextSibling = this.nextSibling(node);
       currentNextSibling = currentNextSibling ? currentNextSibling.rawNode :
                                                 null;
 
       if (rawNode === rawSibling || currentNextSibling === rawSibling) {
-        return null;
+        return;
       }
     }
 
     rawParent.insertBefore(rawNode, rawSibling);
   },
 
   /**
    * Editing a node's tagname actually means creating a new node with the same
@@ -2147,32 +2143,32 @@ var WalkerActor = protocol.ActorClassWit
     // Create a new element with the same attributes as the current element and
     // prepare to replace the current node with it.
     let newNode;
     try {
       newNode = nodeDocument(oldNode).createElement(tagName);
     } catch (x) {
       // Failed to create a new element with that tag name, ignore the change,
       // and signal the error to the front.
-      return Promise.reject(new Error("Could not change node's tagName to " +
-        tagName));
+      return Promise.reject(new Error("Could not change node's tagName to " + tagName));
     }
 
     let attrs = oldNode.attributes;
     for (let i = 0; i < attrs.length; i++) {
       newNode.setAttribute(attrs[i].name, attrs[i].value);
     }
 
     // Insert the new node, and transfer the old node's children.
     oldNode.parentNode.insertBefore(newNode, oldNode);
     while (oldNode.firstChild) {
       newNode.appendChild(oldNode.firstChild);
     }
 
     oldNode.remove();
+    return null;
   },
 
   /**
    * Get any pending mutation records.  Must be called by the client after
    * the `new-mutations` notification is received.  Returns an array of
    * mutation records.
    *
    * Mutation records have a basic structure:
@@ -2577,17 +2573,17 @@ var WalkerActor = protocol.ActorClassWit
     return this.attachElement(obj);
   },
 });
 
 /**
  * Server side of the inspector actor, which is used to create
  * inspector-related actors, including the walker.
  */
-var InspectorActor = exports.InspectorActor = protocol.ActorClassWithSpec(inspectorSpec, {
+exports.InspectorActor = protocol.ActorClassWithSpec(inspectorSpec, {
   initialize: function (conn, tabActor) {
     protocol.Actor.prototype.initialize.call(this, conn);
     this.tabActor = tabActor;
 
     this._onColorPicked = this._onColorPicked.bind(this);
     this._onColorPickCanceled = this._onColorPickCanceled.bind(this);
     this.destroyEyeDropper = this.destroyEyeDropper.bind(this);
   },
@@ -2820,16 +2816,17 @@ function nodeDocument(node) {
 
 function nodeDocshell(node) {
   let doc = node ? nodeDocument(node) : null;
   let win = doc ? doc.defaultView : null;
   if (win) {
     return win.QueryInterface(Ci.nsIInterfaceRequestor)
               .getInterface(Ci.nsIDocShell);
   }
+  return null;
 }
 
 function isNodeDead(node) {
   return !node || !node.rawNode || Cu.isDeadWrapper(node.rawNode);
 }
 
 /**
  * Wrapper for inDeepTreeWalker.  Adds filtering to the traversal methods.
@@ -3025,17 +3022,17 @@ function ensureImageLoaded(image, timeou
   let onLoad = AsyncUtils.listenOnce(image, "load");
 
   // Reject if loading fails.
   let onError = AsyncUtils.listenOnce(image, "error").then(() => {
     return promise.reject("Image '" + image.src + "' failed to load.");
   });
 
   // Don't timeout when testing. This is never settled.
-  let onAbort = new promise(() => {});
+  let onAbort = new Promise(() => {});
 
   if (!DevToolsUtils.testing) {
     // Tests are not running. Reject the promise after given timeout.
     onAbort = DevToolsUtils.waitForTime(timeout).then(() => {
       return promise.reject("Image '" + image.src + "' took too long to load.");
     });
   }