--- 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");
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";
const FONT_FAMILY_PREVIEW_TEXT_SIZE = 20;
@@ -437,44 +433,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
@@ -496,17 +492,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);
@@ -587,17 +583,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 () {
@@ -1293,18 +1289,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) {
@@ -2110,32 +2106,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
@@ -2153,32 +2149,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:
@@ -2583,17 +2579,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);
},
@@ -2826,16 +2822,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.
@@ -3031,17 +3028,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.");
});
}