Bug 1053898 - Remove unused WalkerActor methods parents() and siblings;r=pbro
MozReview-Commit-ID: GEjFjslgK4J
--- a/devtools/server/actors/inspector/walker.js
+++ b/devtools/server/actors/inspector/walker.js
@@ -404,53 +404,16 @@ var WalkerActor = protocol.ActorClassWit
*/
documentElement: function(node) {
let elt = isNodeDead(node)
? this.rootDoc.documentElement
: nodeDocument(node.rawNode).documentElement;
return this._ref(elt);
},
- /**
- * Return all parents of the given node, ordered from immediate parent
- * to root.
- * @param NodeActor node
- * The node whose parents are requested.
- * @param object options
- * Named options, including:
- * `sameDocument`: If true, parents will be restricted to the same
- * document as the node.
- * `sameTypeRootTreeItem`: If true, this will not traverse across
- * different types of docshells.
- */
- parents: function(node, options = {}) {
- if (isNodeDead(node)) {
- return [];
- }
-
- let walker = this.getDocumentWalker(node.rawNode);
- let parents = [];
- let cur;
- while ((cur = walker.parentNode())) {
- if (options.sameDocument &&
- nodeDocument(cur) != nodeDocument(node.rawNode)) {
- break;
- }
-
- if (options.sameTypeRootTreeItem &&
- nodeDocshell(cur).sameTypeRootTreeItem !=
- nodeDocshell(node.rawNode).sameTypeRootTreeItem) {
- break;
- }
-
- parents.push(this._ref(cur));
- }
- return parents;
- },
-
parentNode: function(node) {
let walker = this.getDocumentWalker(node.rawNode);
let parent = walker.parentNode();
if (parent) {
return this._ref(parent);
}
return null;
},
@@ -670,65 +633,16 @@ var WalkerActor = protocol.ActorClassWit
return {
hasFirst: nodes[0].rawNode == firstChild,
hasLast: nodes[nodes.length - 1].rawNode == lastChild,
nodes: nodes
};
},
/**
- * Return siblings of the given node. By default this method will return
- * all siblings of the node, but there are options that can restrict this
- * to a more manageable subset.
- *
- * If `start` or `center` are not specified, this method will center on the
- * node whose siblings are requested.
- *
- * @param NodeActor node
- * The node whose children you're curious about.
- * @param object options
- * Named options:
- * `maxNodes`: The set of nodes returned by the method will be no longer
- * than maxNodes.
- * `start`: If a node is specified, the list of nodes will start
- * with the given child. Mutally exclusive with `center`.
- * `center`: If a node is specified, the given node will be as centered
- * as possible in the list, given how close to the ends of the child
- * list it is. Mutually exclusive with `start`.
- * `whatToShow`: A bitmask of node types that should be included. See
- * https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter.
- *
- * @returns an object with three items:
- * hasFirst: true if the first child of the node is included in the list.
- * hasLast: true if the last child of the node is included in the list.
- * nodes: Child nodes returned by the request.
- */
- siblings: function(node, options = {}) {
- if (isNodeDead(node)) {
- return { hasFirst: true, hasLast: true, nodes: [] };
- }
-
- let parentNode = this.getDocumentWalker(node.rawNode, options.whatToShow)
- .parentNode();
- if (!parentNode) {
- return {
- hasFirst: true,
- hasLast: true,
- nodes: [node]
- };
- }
-
- if (!(options.start || options.center)) {
- options.center = node;
- }
-
- return this.children(this._ref(parentNode), options);
- },
-
- /**
* Get the next sibling of a given node. Getting nodes one at a time
* might be inefficient, be careful.
*
* @param object options
* Named options:
* `whatToShow`: A bitmask of node types that should be included. See
* https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter.
*/
@@ -1991,19 +1905,9 @@ var WalkerActor = protocol.ActorClassWit
if (!offsetParent) {
return null;
}
return this._ref(offsetParent);
},
});
-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;
-}
-
exports.WalkerActor = WalkerActor;
--- a/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
+++ b/devtools/server/tests/mochitest/test_inspector-dead-nodes.html
@@ -35,58 +35,30 @@ addAsyncTest(async function() {
let inspector = InspectorFront(client, tab);
gWalker = await inspector.getWalker();
runNextTest();
});
addAsyncTest(async function() {
info("Getting a nodeFront, reloading the page, and calling " +
- "walker.parents(nodeFront) before the load completes shouldn't fail");
-
- let nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1");
- let newRoot = waitForMutation(gWalker, isNewRoot);
- gDoc.defaultView.location.reload();
- await gWalker.parents(nodeFront);
- await newRoot;
-
- ok(true, "The call to walker.parents() didn't fail");
- runNextTest();
-});
-
-addAsyncTest(async function() {
- info("Getting a nodeFront, reloading the page, and calling " +
"walker.children(nodeFront) before the load completes shouldn't fail");
let nodeFront = await gWalker.querySelector(gWalker.rootNode, "body");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
await gWalker.children(nodeFront);
await newRoot;
ok(true, "The call to walker.children() didn't fail");
runNextTest();
});
addAsyncTest(async function() {
info("Getting a nodeFront, reloading the page, and calling " +
- "walker.siblings(nodeFront) before the load completes shouldn't fail");
-
- let nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1");
- let newRoot = waitForMutation(gWalker, isNewRoot);
- gDoc.defaultView.location.reload();
- await gWalker.siblings(nodeFront);
- await newRoot;
-
- ok(true, "The call to walker.siblings() didn't fail");
- runNextTest();
-});
-
-addAsyncTest(async function() {
- info("Getting a nodeFront, reloading the page, and calling " +
"walker.nextSibling(nodeFront) before the load completes shouldn't fail");
let nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1");
let newRoot = waitForMutation(gWalker, isNewRoot);
gDoc.defaultView.location.reload();
await gWalker.nextSibling(nodeFront);
await newRoot;
--- a/devtools/server/tests/mochitest/test_inspector-traversal.html
+++ b/devtools/server/tests/mochitest/test_inspector-traversal.html
@@ -219,29 +219,16 @@ addTest(function testLongListTraversal()
addTest(function testObjectNodeChildren() {
promiseDone(
gWalker.querySelector(gWalker.rootNode, "object")
.then(object => gWalker.children(object))
.then(nodeArrayChecker(true, true, "1"))
.then(runNextTest));
});
-addTest(function testSiblings() {
- promiseDone(gWalker.querySelector(gWalker.rootNode, "#a").then(a => {
- return gWalker.siblings(a, { maxNodes: 5, center: a })
- .then(nodeArrayChecker(true, false, "abcde"));
- }).then(() => {
- return gWalker.siblings(gWalker.rootNode).then(response => {
- ok(response.hasFirst && response.hasLast, "Has first and last.");
- is(response.nodes.length, 1, "Has only the document element.");
- ok(response.nodes[0] === gWalker.rootNode, "Document element is its own sibling.");
- });
- }).then(runNextTest));
-});
-
addTest(function testNextSibling() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#y").then(y => {
is(y.id, "y", "Got the right node.");
return gWalker.nextSibling(y);
}).then(z => {
is(z.id, "z", "nextSibling got the next node.");
return gWalker.nextSibling(z);
}).then(nothing => {
@@ -264,26 +251,16 @@ addTest(function testPreviousSibling() {
addTest(function testFrameTraversal() {
promiseDone(gWalker.querySelector(gWalker.rootNode, "#childFrame").then(childFrame => {
return gWalker.children(childFrame);
}).then(children => {
let nodes = children.nodes;
is(nodes.length, 1, "There should be only one child of the iframe");
is(nodes[0].nodeType, Node.DOCUMENT_NODE, "iframe child should be a document node");
return gWalker.querySelector(nodes[0], "#z");
- }).then(childDocumentZ => {
- return gWalker.parents(childDocumentZ);
- }).then(parents => {
- // Expected set of parent tag names for this item:
- let expectedParents = ["DIV", "BODY", "HTML", "#document", "IFRAME", "BODY", "HTML",
- "#document"];
- for (let parent of parents) {
- let expected = expectedParents.shift();
- is(parent.nodeName, expected, "Got expected parent");
- }
}).then(runNextTest));
});
addTest(function testLongValue() {
const testSummaryLength = 10;
const WalkerActor = require("devtools/server/actors/inspector/walker");
WalkerActor.setValueSummaryLength(testSummaryLength);
--- a/devtools/shared/specs/inspector.js
+++ b/devtools/shared/specs/inspector.js
@@ -101,42 +101,31 @@ const walkerSpec = generateActorSpec({
document: {
request: { node: Arg(0, "nullable:domnode") },
response: { node: RetVal("domnode") },
},
documentElement: {
request: { node: Arg(0, "nullable:domnode") },
response: { node: RetVal("domnode") },
},
- parents: {
- request: {
- node: Arg(0, "domnode"),
- sameDocument: Option(1),
- sameTypeRootTreeItem: Option(1)
- },
- response: {
- nodes: RetVal("array:domnode")
- },
- },
retainNode: {
request: { node: Arg(0, "domnode") },
response: {}
},
unretainNode: {
request: { node: Arg(0, "domnode") },
response: {},
},
releaseNode: {
request: {
node: Arg(0, "domnode"),
force: Option(1)
}
},
children: nodeArrayMethod,
- siblings: nodeArrayMethod,
nextSibling: traversalMethod,
previousSibling: traversalMethod,
findInspectingNode: {
request: {},
response: RetVal("disconnectedNode")
},
querySelector: {
request: {