Bug 857262 - Inspector DocumentWalker: Reparent walker to SVGDocument only if a node contains a document; not if it just implements getSVGDocument. r=miker
authorSami Jaktholm <sjakthol@outlook.com>
Sat, 19 Jul 2014 23:32:00 -0400
changeset 217002 33c83c1d99805a025893b46e0d4cc5652bc1ef50
parent 217001 f659f3d98472d4c2e771c9f7d3c4281f3718eb94
child 217003 ba903b7f347f1aaa14faefa1c33a0fa64ffa6673
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiker
bugs857262
milestone33.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 857262 - Inspector DocumentWalker: Reparent walker to SVGDocument only if a node contains a document; not if it just implements getSVGDocument. r=miker
toolkit/devtools/server/actors/inspector.js
toolkit/devtools/server/tests/mochitest/inspector-traversal-data.html
toolkit/devtools/server/tests/mochitest/test_inspector-traversal.html
--- a/toolkit/devtools/server/actors/inspector.js
+++ b/toolkit/devtools/server/actors/inspector.js
@@ -3007,29 +3007,29 @@ DocumentWalker.prototype = {
   },
 
   firstChild: function() {
     let node = this.walker.currentNode;
     if (!node)
       return null;
     if (node.contentDocument) {
       return this._reparentWalker(node.contentDocument);
-    } else if (node.getSVGDocument) {
+    } else if (node.getSVGDocument && node.getSVGDocument()) {
       return this._reparentWalker(node.getSVGDocument());
     }
     return this.walker.firstChild();
   },
 
   lastChild: function() {
     let node = this.walker.currentNode;
     if (!node)
       return null;
     if (node.contentDocument) {
       return this._reparentWalker(node.contentDocument);
-    } else if (node.getSVGDocument) {
+    } else if (node.getSVGDocument && node.getSVGDocument()) {
       return this._reparentWalker(node.getSVGDocument());
     }
     return this.walker.lastChild();
   },
 
   previousSibling: function DW_previousSibling() this.walker.previousSibling(),
   nextSibling: function DW_nextSibling() this.walker.nextSibling()
 };
--- a/toolkit/devtools/server/tests/mochitest/inspector-traversal-data.html
+++ b/toolkit/devtools/server/tests/mochitest/inspector-traversal-data.html
@@ -46,10 +46,13 @@
     <div id="x">x</div>
     <div id="y">y</div>
     <div id="z">z</div>
   </div>
   <div id="longlist-sibling">
     <div id="longlist-sibling-firstchild"></div>
   </div>
   <p id="edit-html"></p>
+  <object>
+      <div id="1"></div>
+  </object>
 </body>
 </html>
--- a/toolkit/devtools/server/tests/mochitest/test_inspector-traversal.html
+++ b/toolkit/devtools/server/tests/mochitest/test_inspector-traversal.html
@@ -209,16 +209,24 @@ addTest(function testLongListTraversal()
   }).then(() => {
     // maxNodes near the end should only return what's left
     return gWalker.children(longList, { maxNodes: 5, start: allChildren[24] }).then(
       nodeArrayChecker(false, true, 'yz')
     );
   }).then(runNextTest));
 });
 
+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.");