Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp

Issue 2373023002: Make DOM.getChildNodes & DOM.getDocument optionally pierce iframe boundaries (Closed)
Patch Set: Added a requestFrames parameter to fix the broken test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
index 0ceb294c59525ae7a89873664d29373976394f87..781522acb0d888612d0c829b766ad866b9acbc42 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
@@ -250,6 +250,7 @@ InspectorDOMAgent::InspectorDOMAgent(v8::Isolate* isolate, InspectedFrames* insp
, m_documentNodeToIdMap(new NodeToIdMap())
, m_lastNodeId(1)
, m_suppressAttributeModifiedEvent(false)
+ , m_traverseFrames(false)
, m_backendNodeIdToInspect(0)
{
}
@@ -543,9 +544,14 @@ void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth)
depth--;
+ if (m_traverseFrames && node->isFrameOwnerElement()) {
+ int iframeDocumentId = nodeMap->get(toHTMLFrameOwnerElement(node)->contentDocument()->documentElement());
+ CHECK(iframeDocumentId);
+ pushChildNodesToFrontend(iframeDocumentId, depth);
+ }
for (node = innerFirstChild(node); node; node = innerNextSibling(node)) {
int childNodeId = nodeMap->get(node);
- ASSERT(childNodeId);
+ CHECK(childNodeId);
pushChildNodesToFrontend(childNodeId, depth);
}
@@ -606,16 +612,23 @@ void InspectorDOMAgent::collectClassNamesFromSubtree(ErrorString* errorString, i
(*classNames)->addItem(className);
}
-void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const Maybe<int>& depth)
+void InspectorDOMAgent::requestChildNodes(ErrorString* errorString, int nodeId, const Maybe<int>& depth, const Maybe<bool>& traverseFrames)
{
int sanitizedDepth = depth.fromMaybe(1);
if (sanitizedDepth == 0 || sanitizedDepth < -1) {
*errorString = "Please provide a positive integer as a depth or -1 for entire subtree";
return;
}
+ bool prevMayCrossIframeBoundary = m_traverseFrames;
if (sanitizedDepth == -1)
sanitizedDepth = INT_MAX;
+ m_traverseFrames = traverseFrames.fromMaybe(false);
+
+ // Cached results may not be valid if |m_traverseFrames| changes.
+ if (prevMayCrossIframeBoundary != m_traverseFrames)
+ m_childrenRequested.clear();
+
pushChildNodesToFrontend(nodeId, sanitizedDepth);
}
@@ -1604,6 +1617,10 @@ std::unique_ptr<protocol::Array<protocol::DOM::Node>> InspectorDOMAgent::buildAr
depth--;
m_childrenRequested.add(bind(container, nodesMap));
+ if (m_traverseFrames && container->isFrameOwnerElement()) {
+ Node* iframeDocument = toHTMLFrameOwnerElement(container)->contentDocument()->documentElement();
+ children->addItem(buildObjectForNode(iframeDocument, depth, nodesMap));
pfeldman 2016/09/27 18:37:41 Those are not the children, you should report ifra
alex clarke (OOO till 29th) 2016/09/28 14:30:00 Done.
+ }
while (child) {
children->addItem(buildObjectForNode(child, depth, nodesMap));
child = innerNextSibling(child);

Powered by Google App Engine
This is Rietveld 408576698