Web Inspector: Inspecting an element inside an iframe no longer works
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 15:10:01 +0000 (15:10 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 15:10:01 +0000 (15:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76808

Reviewed by Timothy Hatcher.

Source/WebCore:

Test: http/tests/inspector/inspect-element.html

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::innerParentNode):
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMNode.prototype.getChildNodes.mycallback):
(WebInspector.DOMNode.prototype.getChildNodes):
(WebInspector.DOMNode.prototype._setChildrenPayload):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeOutline.prototype._selectedNodeChanged):

LayoutTests:

* http/tests/inspector/inspect-element-expected.txt: Added.
* http/tests/inspector/inspect-element.html: Added.
* http/tests/inspector/resources/inspect-element-iframe.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105620 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/inspect-element-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/inspect-element.html [new file with mode: 0644]
LayoutTests/http/tests/inspector/resources/inspect-element-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/front-end/DOMAgent.js
Source/WebCore/inspector/front-end/ElementsTreeOutline.js

index aa19abe..69b47db 100644 (file)
@@ -1,3 +1,14 @@
+2012-01-23  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: Inspecting an element inside an iframe no longer works
+        https://bugs.webkit.org/show_bug.cgi?id=76808
+
+        Reviewed by Timothy Hatcher.
+
+        * http/tests/inspector/inspect-element-expected.txt: Added.
+        * http/tests/inspector/inspect-element.html: Added.
+        * http/tests/inspector/resources/inspect-element-iframe.html: Added.
+
 2012-01-23  Anton Muhin  <antonm@chromium.org>
 
         Unreviewed tweaking of test expectations: it should be IMAGE instead of IMAGE+TEXT.
diff --git a/LayoutTests/http/tests/inspector/inspect-element-expected.txt b/LayoutTests/http/tests/inspector/inspect-element-expected.txt
new file mode 100644 (file)
index 0000000..0120279
--- /dev/null
@@ -0,0 +1,5 @@
+Tests that inspect element action works for iframe children (https://bugs.webkit.org/show_bug.cgi?id=76808).
+
+
+div#div
+
diff --git a/LayoutTests/http/tests/inspector/inspect-element.html b/LayoutTests/http/tests/inspector/inspect-element.html
new file mode 100644 (file)
index 0000000..c87baa5
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script src="inspector-test.js"></script>
+<script src="elements-test.js"></script>
+<script>
+
+function test()
+{
+    WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.elements);
+    WebInspector.panels.elements.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, selectedNodeChanged, this);
+    function selectedNodeChanged(event)
+    {
+        var node = event.data;
+        if (node.getAttribute("id") == "div") {
+            InspectorTest.addResult(node.appropriateSelectorFor());
+            InspectorTest.completeTest();
+        }
+    }
+    InspectorTest.evaluateInConsole("inspect(iframeDivElement)");
+}
+
+</script>
+</head>
+
+<body>
+<p>
+Tests that inspect element action works for iframe children (https://bugs.webkit.org/show_bug.cgi?id=76808).
+</p>
+
+<iframe src="resources/inspect-element-iframe.html" onload="runTest()"></iframe>
+
+</body>
+</html>
diff --git a/LayoutTests/http/tests/inspector/resources/inspect-element-iframe.html b/LayoutTests/http/tests/inspector/resources/inspect-element-iframe.html
new file mode 100644 (file)
index 0000000..2dfb541
--- /dev/null
@@ -0,0 +1,11 @@
+<html>
+
+<body>
+<div id="div">Element to inspect</div>
+</body>
+
+<script>
+top.iframeDivElement = document.getElementById("div");
+</script>
+
+</html>
index 6f00362..4fa3788 100644 (file)
@@ -1,3 +1,21 @@
+2012-01-23  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: Inspecting an element inside an iframe no longer works
+        https://bugs.webkit.org/show_bug.cgi?id=76808
+
+        Reviewed by Timothy Hatcher.
+
+        Test: http/tests/inspector/inspect-element.html
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::innerParentNode):
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.DOMNode.prototype.getChildNodes.mycallback):
+        (WebInspector.DOMNode.prototype.getChildNodes):
+        (WebInspector.DOMNode.prototype._setChildrenPayload):
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeOutline.prototype._selectedNodeChanged):
+
 2012-01-23  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: response.bodySize in HAR is invalid (negative) for cached resources
index d9941dd..0cd323f 100644 (file)
@@ -1251,6 +1251,10 @@ unsigned InspectorDOMAgent::innerChildNodeCount(Node* node)
 
 Node* InspectorDOMAgent::innerParentNode(Node* node)
 {
+    if (node->isDocumentNode()) {
+        Document* document = static_cast<Document*>(node);
+        return document->ownerElement();
+    }
     return node->parentNode();
 }
 
index f71e82f..abca727 100644 (file)
@@ -399,6 +399,10 @@ WebInspector.DOMNode.prototype = {
      */
     _setChildrenPayload: function(payloads)
     {
+        // We set children in the constructor.
+        if (this._contentDocument)
+            return;
+
         this.children = [];
         for (var i = 0; i < payloads.length; ++i) {
             var payload = payloads[i];
index 8ce014d..b5a5e90 100644 (file)
@@ -184,7 +184,7 @@ WebInspector.ElementsTreeOutline.prototype = {
 
     _selectedNodeChanged: function()
     {
-        this._eventSupport.dispatchEventToListeners(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged);
+        this._eventSupport.dispatchEventToListeners(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged, this._selectedDOMNode);
     },
 
     findTreeElement: function(node)