You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3c91014
Browse filesBrowse the repository at this point in the historyBrowse files
Web Inspector: [Site isolation] "Inspect Element" on a cross-origin iframe's content opens Web Inspector but doesn't scroll to/select the node
https://bugs.webkit.org/show_bug.cgi?id=326924
rdar://187827968
Reviewed by Qianlang Chen.
With Site Isolation on, choosing Inspect Element on a node inside a cross-site iframe opened
Web Inspector but did not select the node in the Elements tab. The node lives in another process,
so the page DOM agent has no node for it, and frame targets have no Inspector domain to deliver
Inspector.inspect. Even when the node was reported through DOM.inspect, its frame document was not
yet spliced into the page tree, so the Elements tab had nothing to reveal.
To fix this, Inspect Element now takes one of two routes depending on where the node lives. A node
in the main frame, or in a same-site frame in the main frame's process, still goes through the page
DOM agent exactly as before. Any other node goes through the DOM agent of its own frame, which
sends DOM.inspect, the event the frontend already routes to inspectElementInFrameTarget(). A
same-site frame nested under a cross-site one takes this second route too, since the page agent's
tree stops at the remote <iframe> and cannot reach it. Picking an element in inspect mode inside a
frame target now reports the same way. If the inspector is opened by the very click that chose the
node, the frame holds on to the node until a frontend connects.
The frontend then has to connect that frame's document to the page tree before the Elements tab
can show it, and that needs the <iframe> elements above it. Those live in the parent frame's
process, so the inspected frame cannot supply them. This adds DOM.requestFrameOwner(frameId), which
asks a frame's agent to push the owner element of one of its child frames, along with its path. The
existing frameId splice then attaches the document below it. Starting from the inspected node, the
frontend asks the page target for the owner of its frame. If the page target cannot answer, it asks
every frame target; only the parent frame's target can, since each frame agent only looks at its
direct children. This does not depend on the frontend's frame model or on the parent's document
having arrived: each frame target was sent DOM.getDocument when it was initialized, so that reply
arrives before the pushed owner. It repeats one level up if that owner is itself inside a document
that is not spliced yet. This keeps working for nested cross-site frames. Once the node is connected
to the page document, the Elements tab reveals it. If an owner cannot be found, the node is revealed
as it was before.
This is easy to reason about because it only asks for what the node needs: one owner per level,
instead of searching the page tree for iframes. It also reuses the frameId-based splicing instead of
adding a second way to connect frame documents.
No new tests: It seems WebKitTestRunner cannot drive the Inspect Element context menu inside a
cross-site frame.
* Source/JavaScriptCore/inspector/protocol/DOM.json:
* Source/WebCore/inspector/FrameInspectorController.cpp:
(WebCore::FrameInspectorController::connectFrontend):
(WebCore::FrameInspectorController::inspect):
(WebCore::FrameInspectorController::disconnectFrontend):
(WebCore::FrameInspectorController::inspectedFrameDestroyed):
* Source/WebCore/inspector/FrameInspectorController.h:
* Source/WebCore/inspector/PageInspectorController.cpp:
(WebCore::isCoveredByPageDOMAgent):
(WebCore::PageInspectorController::inspect):
* Source/WebCore/inspector/agents/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::requestFrameOwner):
* Source/WebCore/inspector/agents/InspectorDOMAgent.h:
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp:
(WebCore::m_focusNodeTimer):
(WebCore::FrameDOMAgent::willDestroyFrontendAndBackend):
(WebCore::FrameDOMAgent::getDocument):
(WebCore::FrameDOMAgent::requestFrameOwner):
(WebCore::FrameDOMAgent::focusNode):
(WebCore::m_destroyedNodesTimer): Deleted.
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.h:
* Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js:
(WI.DOMManager):
(WI.DOMManager.prototype._rootNodeOf):
(WI.DOMManager.prototype._isInPageTree):
(WI.DOMManager.prototype._revealPendingInspectedFrameNode):
(WI.DOMManager.prototype._dispatchPendingInspectedFrameNode):
(WI.DOMManager.prototype._requestFrameOwner):
(WI.DOMManager.prototype._requestFrameOwnerFromFrameTargets):
(WI.DOMManager.prototype._requestFrameOwnerFromTarget):
(WI.DOMManager.prototype._documentUpdated):
(WI.DOMManager.prototype.inspectElementInFrameTarget):
(WI.DOMManager.prototype._trySpliceUnsplicedFrameDocuments):
Canonical link: https://commits.webkit.org/324270@main
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/inspector/protocol/DOM.json
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -563,6 +563,17 @@
563
563
{ "name": "nodeId", "$ref": "NodeId", "description": "Node id for given object." }
564
564
]
565
565
},
566
+
{
567
+
"name": "requestFrameOwner",
568
+
"description": "Requests that the frame owner element (such as <code>iframe</code>) of a child frame is sent to the caller. The child frame may be hosted by another process. All nodes that form the path from the owner element to the root are also sent to the client as a series of <code>setChildNodes</code> notifications.",
569
+
"targetTypes": ["frame", "page"],
570
+
"parameters": [
571
+
{ "name": "frameId", "$ref": "Network.FrameId", "description": "Identifier of a frame whose owner element is in the document tree of this target." }
572
+
],
573
+
"returns": [
574
+
{ "name": "nodeId", "$ref": "NodeId", "description": "Node id for the frame owner element." }
575
+
]
576
+
},
566
577
{
567
578
"name": "setInspectModeEnabled",
568
579
"description": "Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted. Backend then generates 'inspect' command upon element selection.",
Inspector::Protocol::ErrorStringOr<void> highlightRect(int x, int y, int width, int height, RefPtr<JSON::Object>&& color, RefPtr<JSON::Object>&& outlineColor, std::optional<bool>&& usePageCoordinates);
0 commit comments