Title: [213353] trunk
Revision
213353
Author
mattba...@apple.com
Date
2017-03-02 21:53:34 -0800 (Thu, 02 Mar 2017)

Log Message

Web Inspector: Should be able to push nodes in an iframe subtree to the frontend
https://bugs.webkit.org/show_bug.cgi?id=169086

Reviewed by Joseph Pecoraro.

Source/WebCore:

Test: inspector/dom/push-node-by-path-to-frontend.html

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::nodeForPath):
During top-down document traversal, descend into content document nodes
when visiting an HTMLFrameOwnerElement.

Source/WebInspectorUI:

* UserInterface/Views/DOMTreeContentView.js:
(WebInspector.DOMTreeContentView.prototype._selectedNodeDidChange):
Use the URL of the main frame instead of the content frame URL.

LayoutTests:

Added test coverage for DOMTreeManager.prototype.pushNodeByPathToFrontend,
which now supports pushing iframe document nodes (#document) and their descendants.

* inspector/dom/push-node-by-path-to-frontend-expected.txt: Added.
* inspector/dom/push-node-by-path-to-frontend.html: Added.
* inspector/dom/resources/frameset-frame.html: Added.
* inspector/dom/resources/frameset-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213352 => 213353)


--- trunk/LayoutTests/ChangeLog	2017-03-03 05:40:00 UTC (rev 213352)
+++ trunk/LayoutTests/ChangeLog	2017-03-03 05:53:34 UTC (rev 213353)
@@ -1,3 +1,18 @@
+2017-03-02  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: Should be able to push nodes in an iframe subtree to the frontend
+        https://bugs.webkit.org/show_bug.cgi?id=169086
+
+        Reviewed by Joseph Pecoraro.
+
+        Added test coverage for DOMTreeManager.prototype.pushNodeByPathToFrontend,
+        which now supports pushing iframe document nodes (#document) and their descendants.
+
+        * inspector/dom/push-node-by-path-to-frontend-expected.txt: Added.
+        * inspector/dom/push-node-by-path-to-frontend.html: Added.
+        * inspector/dom/resources/frameset-frame.html: Added.
+        * inspector/dom/resources/frameset-iframe.html: Added.
+
 2017-03-02  Antoine Quint  <grao...@apple.com>
 
         LayoutTest media/modern-media-controls/tracks-support/tracks-support-click-track-in-panel.html is a flaky timeout

Added: trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend-expected.txt (0 => 213353)


--- trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend-expected.txt	2017-03-03 05:53:34 UTC (rev 213353)
@@ -0,0 +1,17 @@
+Test for DOM.pushNodeByPathToFrontend.
+
+  
+
+== Running test suite: DOM.pushNodeByPathToFrontend
+-- Running test case: InlineFrameDocumentNode
+Push node with path: 1,HTML,1,BODY,1,IFRAME,0,#document
+PASS: Pushed node has correct path.
+
+-- Running test case: InlineFrameDOMNode
+Push node with path: 1,HTML,1,BODY,2,IFRAME,0,#document,0,HTML,1,BODY,0,DIV
+PASS: Pushed node has correct path.
+
+-- Running test case: InlineFrameFramesetDOMNode
+Push node with path: 1,HTML,1,BODY,3,IFRAME,0,#document,0,HTML,1,FRAMESET,0,FRAME,0,#document,0,HTML,1,BODY,0,P
+PASS: Pushed node has correct path.
+

Added: trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend.html (0 => 213353)


--- trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/push-node-by-path-to-frontend.html	2017-03-03 05:53:34 UTC (rev 213353)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("DOM.pushNodeByPathToFrontend");
+
+    function addTestCase({name, description, path}) {
+        suite.addTestCase({
+            name, description,
+            test(resolve, reject) {
+                InspectorTest.log("Push node with path: " + path);
+                WebInspector.domTreeManager.pushNodeByPathToFrontend(path, (nodeIdentifier) => {
+                    if (!nodeIdentifier) {
+                        reject();
+                        return;
+                    }
+
+                    let node = WebInspector.domTreeManager.nodeForId(nodeIdentifier);
+                    InspectorTest.expectEqual(node.path(), path, "Pushed node has correct path.");
+                    resolve();
+                });
+            }
+        });
+    }
+
+    addTestCase({
+        name: "InlineFrameDocumentNode",
+        description: "Check that a child frame document node can be pushed.",
+        path: "1,HTML,1,BODY,1,IFRAME,0,#document"
+    });
+
+    addTestCase({
+        name: "InlineFrameDOMNode",
+        description: "Check that a node belonging to an inline frame's DOM can be pushed.",
+        path: "1,HTML,1,BODY,2,IFRAME,0,#document,0,HTML,1,BODY,0,DIV"
+    });
+
+    addTestCase({
+        name: "InlineFrameFramesetDOMNode",
+        description: "Check that a node belonging to a frameset frame's DOM can be pushed.",
+        path: "1,HTML,1,BODY,3,IFRAME,0,#document,0,HTML,1,FRAMESET,0,FRAME,0,#document,0,HTML,1,BODY,0,P"
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for DOM.pushNodeByPathToFrontend.</p>
+<iframe src=""
+<iframe srcdoc="<div></div>"></iframe>
+<iframe src=""
+</body>
+</html>

Added: trunk/LayoutTests/inspector/dom/resources/frameset-frame.html (0 => 213353)


--- trunk/LayoutTests/inspector/dom/resources/frameset-frame.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/resources/frameset-frame.html	2017-03-03 05:53:34 UTC (rev 213353)
@@ -0,0 +1,6 @@
+<html>
+    <head></head>
+    <body>
+        <p>Frameset frame contents.</p>
+    </body>
+</html>

Added: trunk/LayoutTests/inspector/dom/resources/frameset-iframe.html (0 => 213353)


--- trunk/LayoutTests/inspector/dom/resources/frameset-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/dom/resources/frameset-iframe.html	2017-03-03 05:53:34 UTC (rev 213353)
@@ -0,0 +1,6 @@
+<html>
+    <head></head>
+    <frameset>
+        <frame src=""
+    </frameset>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (213352 => 213353)


--- trunk/Source/WebCore/ChangeLog	2017-03-03 05:40:00 UTC (rev 213352)
+++ trunk/Source/WebCore/ChangeLog	2017-03-03 05:53:34 UTC (rev 213353)
@@ -1,3 +1,17 @@
+2017-03-02  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: Should be able to push nodes in an iframe subtree to the frontend
+        https://bugs.webkit.org/show_bug.cgi?id=169086
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: inspector/dom/push-node-by-path-to-frontend.html
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::nodeForPath):
+        During top-down document traversal, descend into content document nodes
+        when visiting an HTMLFrameOwnerElement.
+
 2017-03-02  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r213274.

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (213352 => 213353)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2017-03-03 05:40:00 UTC (rev 213352)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2017-03-03 05:53:34 UTC (rev 213353)
@@ -2147,28 +2147,37 @@
 {
     // The path is of form "1,HTML,2,BODY,1,DIV"
     if (!m_document)
-        return 0;
+        return nullptr;
 
     Node* node = m_document.get();
     Vector<String> pathTokens;
     path.split(',', false, pathTokens);
     if (!pathTokens.size())
-        return 0;
+        return nullptr;
+
     for (size_t i = 0; i < pathTokens.size() - 1; i += 2) {
         bool success = true;
         unsigned childNumber = pathTokens[i].toUInt(&success);
         if (!success)
-            return 0;
-        if (childNumber >= innerChildNodeCount(node))
-            return 0;
+            return nullptr;
 
-        Node* child = innerFirstChild(node);
-        String childName = pathTokens[i + 1];
-        for (size_t j = 0; child && j < childNumber; ++j)
-            child = innerNextSibling(child);
+        Node* child;
+        if (is<HTMLFrameOwnerElement>(*node)) {
+            ASSERT(!childNumber);
+            auto& frameOwner = downcast<HTMLFrameOwnerElement>(*node);
+            child = frameOwner.contentDocument();
+        } else {
+            if (childNumber >= innerChildNodeCount(node))
+                return nullptr;
 
+            child = innerFirstChild(node);
+            for (size_t j = 0; child && j < childNumber; ++j)
+                child = innerNextSibling(child);
+        }
+
+        const auto& childName = pathTokens[i + 1];
         if (!child || child->nodeName() != childName)
-            return 0;
+            return nullptr;
         node = child;
     }
     return node;

Modified: trunk/Source/WebInspectorUI/ChangeLog (213352 => 213353)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-03-03 05:40:00 UTC (rev 213352)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-03-03 05:53:34 UTC (rev 213353)
@@ -1,3 +1,14 @@
+2017-03-02  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: Should be able to push nodes in an iframe subtree to the frontend
+        https://bugs.webkit.org/show_bug.cgi?id=169086
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WebInspector.DOMTreeContentView.prototype._selectedNodeDidChange):
+        Use the URL of the main frame instead of the content frame URL.
+
 2017-03-01  Devin Rousso  <dcrousso+web...@gmail.com>
 
         Web Inspector: Annotators should not be enabled if the TextEditor is not visible

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (213352 => 213353)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2017-03-03 05:40:00 UTC (rev 213352)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2017-03-03 05:53:34 UTC (rev 213353)
@@ -372,7 +372,7 @@
     {
         var selectedDOMNode = this._domTreeOutline.selectedDOMNode();
         if (selectedDOMNode && !this._dontSetLastSelectedNodePath)
-            this._lastSelectedNodePathSetting.value = {url: selectedDOMNode.ownerDocument.documentURL.hash, path: selectedDOMNode.path()};
+            this._lastSelectedNodePathSetting.value = {url: WebInspector.frameResourceManager.mainFrame.url.hash, path: selectedDOMNode.path()};
 
         if (selectedDOMNode)
             ConsoleAgent.addInspectedNode(selectedDOMNode.id);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to