Title: [144057] trunk
Revision
144057
Author
[email protected]
Date
2013-02-26 07:57:50 -0800 (Tue, 26 Feb 2013)

Log Message

Web Inspector: Cannot deep expand an element that has previously been partially expanded
https://bugs.webkit.org/show_bug.cgi?id=110424

In the case where the children from the provided node have already been pushed, traverse children at the depth provided until we find children that have not been pushed yet.

Reviewed by Pavel Feldman.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144056 => 144057)


--- trunk/LayoutTests/ChangeLog	2013-02-26 15:53:23 UTC (rev 144056)
+++ trunk/LayoutTests/ChangeLog	2013-02-26 15:57:50 UTC (rev 144057)
@@ -1,3 +1,17 @@
+2013-02-25  Antoine Quint  <[email protected]>
+
+        Web Inspector: Cannot deep expand an element that has previously been partially expanded
+        https://bugs.webkit.org/show_bug.cgi?id=110424
+
+        Update existing test for InspectorDOMAgent::requestChildNodes to cover the case
+        where we want to request children for a node that already has had children pushed
+        but may not have pushed children at the depth requested.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector-protocol/dom-request-child-nodes-depth-expected.txt:
+        * inspector-protocol/dom-request-child-nodes-depth.html:
+
 2013-02-26  Martin Robinson  <[email protected]>
 
         REGRESSION (r143619): Crashes in three layout tests

Modified: trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth-expected.txt (144056 => 144057)


--- trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth-expected.txt	2013-02-26 15:53:23 UTC (rev 144056)
+++ trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth-expected.txt	2013-02-26 15:57:50 UTC (rev 144057)
@@ -9,8 +9,12 @@
 PASS: First child has one child
 PASS: First child has no .children property
 
-=== Get all children of div#depth-1 ===
+=== Get children of div#depth-1 three levels deep ===
 
+PASS: div#depth-1 has nodes 3 levels deep
+
+=== Get all children of body ===
+
 PASS: div#depth-1 has nodes 9 levels deep
 
 === Pass an invalid depth ===

Modified: trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth.html (144056 => 144057)


--- trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth.html	2013-02-26 15:53:23 UTC (rev 144056)
+++ trunk/LayoutTests/inspector-protocol/dom-request-child-nodes-depth.html	2013-02-26 15:57:50 UTC (rev 144057)
@@ -5,7 +5,7 @@
 
 function test()
 {
-
+    var firstDiv;
     var eventsCount = 0;
 
     getDocument();
@@ -17,7 +17,11 @@
         if (eventsCount === 1)
             gotImmediateChildren(messageObject);
         else if (eventsCount === 2)
+            gotAdditionalChildren(messageObject);
+        else if (eventsCount === 3)
             gotAllChildren(messageObject);
+        else
+            InspectorTest.log(JSON.stringify(messageObject, null, "    "));
     };
     
     function getDocument()
@@ -43,16 +47,35 @@
 
     function gotImmediateChildren(messageObject)
     {
+        firstDiv = messageObject.params.nodes[0];
+        assert("First child is a div", firstDiv.localName, "div");
+        assert("First child is div#depth-1", firstDiv.attributes[1], "depth-1");
+        assert("First child has one child", firstDiv.childNodeCount, 1);
+        assert("First child has no .children property", firstDiv.children, undefined);
+
+        step({
+            name: "Get children of div#depth-1 three levels deep",
+            command: "DOM.requestChildNodes",
+            parameters: {"nodeId": firstDiv.nodeId, "depth": 3}
+        });
+    };
+
+    function gotAdditionalChildren(messageObject)
+    {
+        var depth = 1;
         var firstChild = messageObject.params.nodes[0];
-        assert("First child is a div", firstChild.localName, "div");
-        assert("First child is div#depth-1", firstChild.attributes[1], "depth-1");
-        assert("First child has one child", firstChild.childNodeCount, 1);
-        assert("First child has no .children property", firstChild.children, undefined);
+        var node = firstChild;
+        while (node && node.children) {
+            depth++;
+            node = node.children[0];
+        }
 
+        assert("div#depth-1 has nodes 3 levels deep", depth, 3);
+
         step({
-            name: "Get all children of div#depth-1",
+            name: "Get all children of body",
             command: "DOM.requestChildNodes",
-            parameters: {"nodeId": firstChild.nodeId, "depth": -1}
+            parameters: {"nodeId": firstDiv.nodeId, "depth": -1}
         });
     };
 
@@ -66,19 +89,21 @@
             node = node.children[0];
         }
 
-        assert("div#depth-1 has nodes 9 levels deep", depth, 9);
+        // We have requested nodes 3-level deep so far, so
+        // we should have gotten an additional 6 levels of depth.
+        assert("div#depth-1 has nodes 9 levels deep", depth, 6);
 
         step({
             name: "Pass an invalid depth",
             command: "DOM.requestChildNodes",
-            parameters: {"nodeId": firstChild.nodeId, "depth": 0},
+            parameters: {"nodeId": firstDiv.nodeId, "depth": 0},
             callback: finishTest
         });
     };
     
     function finishTest()
     {
-        assert("Expected number of setChildNodes events", eventsCount, 2);
+        assert("Expected number of setChildNodes events", eventsCount, 3);
         
         InspectorTest.completeTest();
     };

Modified: trunk/Source/WebCore/ChangeLog (144056 => 144057)


--- trunk/Source/WebCore/ChangeLog	2013-02-26 15:53:23 UTC (rev 144056)
+++ trunk/Source/WebCore/ChangeLog	2013-02-26 15:57:50 UTC (rev 144057)
@@ -1,3 +1,16 @@
+2013-02-26  Antoine Quint  <[email protected]>
+
+        Web Inspector: Cannot deep expand an element that has previously been partially expanded
+        https://bugs.webkit.org/show_bug.cgi?id=110424
+
+        In the case where the children from the provided node have already been pushed, traverse
+        children at the depth provided until we find children that have not been pushed yet.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
+
 2013-02-26  Andrey Kosyakov  <[email protected]>
 
         Unreviewed, rolling out r144041, r144044, and r144048.

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (144056 => 144057)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-02-26 15:53:23 UTC (rev 144056)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-02-26 15:57:50 UTC (rev 144057)
@@ -443,10 +443,24 @@
     Node* node = nodeForId(nodeId);
     if (!node || (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE && node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE))
         return;
-    if (m_childrenRequested.contains(nodeId))
+
+    NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId);
+
+    if (m_childrenRequested.contains(nodeId)) {
+        if (depth <= 1)
+            return;
+
+        depth--;
+
+        for (node = innerFirstChild(node); node; node = innerNextSibling(node)) {
+            int childNodeId = nodeMap->get(node);
+            ASSERT(childNodeId);
+            pushChildNodesToFrontend(childNodeId, depth);
+        }
+
         return;
+    }
 
-    NodeToIdMap* nodeMap = m_idToNodesMap.get(nodeId);
     RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = buildArrayForContainerChildren(node, depth, nodeMap);
     m_frontend->setChildNodes(nodeId, children.release());
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to