Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c48671aa521f9e8f4ac533e447b1889510dac80c
      
https://github.com/WebKit/WebKit/commit/c48671aa521f9e8f4ac533e447b1889510dac80c
  Author: Anuj Panta <[email protected]>
  Date:   2026-04-30 (Thu, 30 Apr 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/getDocument-frame-target-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/getDocument-frame-target.html
    A 
LayoutTests/http/tests/site-isolation/inspector/dom/resources/dom-frame.html
    M Source/JavaScriptCore/inspector/protocol/DOM.json
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/inspector/FrameInspectorController.cpp
    M Source/WebCore/inspector/FrameInspectorController.h
    M Source/WebCore/inspector/InspectorInstrumentation.cpp
    M Source/WebCore/inspector/InstrumentingAgents.h
    A Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp
    A Source/WebCore/inspector/agents/frame/FrameDOMAgent.h
    A Source/WebCore/inspector/agents/frame/FrameDOMAgentStubs.cpp
    M Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js
    M Source/WebInspectorUI/UserInterface/Models/DOMNode.js
    M Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js
    M Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js

  Log Message:
  -----------
  Web Inspector: introduce FrameDOMAgent for cross-origin iframe DOM tree access
https://bugs.webkit.org/show_bug.cgi?id=310129
rdar://172766956

Reviewed by Qianlang Chen.

This patch introduces FrameDOMAgent, a per-frame DOM agent that lives in each
frame's WebProcess and handles DOM protocol commands independently.

The read-only DOM tree access subset is implemented: getDocument, 
requestChildNodes
getAttributes, requestAssignedSlot, and requestAssignedNodes
DOM tree mutation event handlers are implemented in the agent but not
yet wired to InspectorInstrumentation — DOMObserver guards frame-target events 
with early
returns for now

Each FrameDOMAgent maintains its own node-ID-to-Node binding maps, independent 
from
InspectorDOMAgent. This is necessary because node IDs are process-local — an ID 
from one
WebProcess cannot be dereferenced in another. The frontend mirrors this by 
scoping
frame-target node IDs as "targetId:nodeId" strings in DOMManager's shared 
idToDOMNode map
preventing collisions between agents whose counters both start at 1

On the frontend, when a FrameTarget appears, DOMManager sends DOM.getDocument 
to the frame
agent, constructs DOMNode objects with scoped IDs, and splices the frame 
document into
page tree as the contentDocument of the matching iframe element. This makes 
cross-origin
iframes display inline in the Elements panel, matching same-origin iframe 
behavior
DOMNode.requestChildNodes and getSubtree route commands to the correct backend 
target
the owningTarget property, which walks the parent chain to find the owning 
frame target

Under site isolation in the main process, both InspectorDOMAgent and 
FrameDOMAgent are active on the
same nodes. The page agent owns the main tree (keyed in _idToDOMNode by raw 
numeric ID),
FrameDOMAgent owns each cross-origin frame's subtree (keyed by 
"targetId:nodeId"), and the Elements
tab crosses between them through a spliced contentDocument via 
DOMNode.owningTarget. Mutation events
from FrameDOMAgent are gated off for now; future patches enable them behind a 
per-domain setting.

Test: http/tests/site-isolation/inspector/dom/getDocument-frame-target.html

* 
LayoutTests/http/tests/site-isolation/inspector/dom/getDocument-frame-target-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/dom/getDocument-frame-target.html:
 Added.
* LayoutTests/http/tests/site-isolation/inspector/dom/resources/dom-frame.html: 
Added.
* Source/JavaScriptCore/inspector/protocol/DOM.json:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/inspector/FrameInspectorController.cpp:
(WebCore::FrameInspectorController::createLazyAgents):
(WebCore::FrameInspectorController::createRuntimeAgent): Deleted.
* Source/WebCore/inspector/FrameInspectorController.h:
* Source/WebCore/inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::frameDocumentUpdatedImpl):
* Source/WebCore/inspector/InstrumentingAgents.h:
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp: Added.
(WebCore::containsOnlyASCIIWhitespace):
(WebCore::shadowRootType):
(WebCore::customElementState):
(WebCore::pseudoElementType):
(WebCore::computeContentSecurityPolicySHA256Hash):
(WebCore::FrameDOMAgent::FrameDOMAgent):
(WebCore::m_destroyedNodesTimer):
(WebCore::FrameDOMAgent::didCreateFrontendAndBackend):
(WebCore::FrameDOMAgent::willDestroyFrontendAndBackend):
(WebCore::FrameDOMAgent::bind):
(WebCore::FrameDOMAgent::unbind):
(WebCore::FrameDOMAgent::boundNodeId):
(WebCore::FrameDOMAgent::nodeForId):
(WebCore::FrameDOMAgent::discardBindings):
(WebCore::FrameDOMAgent::assertNode):
(WebCore::FrameDOMAgent::assertElement):
(WebCore::FrameDOMAgent::buildObjectForNode):
(WebCore::FrameDOMAgent::buildArrayForElementAttributes):
(WebCore::FrameDOMAgent::buildArrayForContainerChildren):
(WebCore::FrameDOMAgent::buildArrayForPseudoElements):
(WebCore::FrameDOMAgent::pushChildNodesToFrontend):
(WebCore::FrameDOMAgent::pushNodePathToFrontend):
(WebCore::FrameDOMAgent::setDocument):
(WebCore::FrameDOMAgent::reset):
(WebCore::FrameDOMAgent::getDocument):
(WebCore::FrameDOMAgent::requestChildNodes):
(WebCore::FrameDOMAgent::getAttributes):
(WebCore::FrameDOMAgent::requestAssignedSlot):
(WebCore::FrameDOMAgent::requestAssignedNodes):
(WebCore::FrameDOMAgent::didInsertDOMNode):
(WebCore::FrameDOMAgent::didRemoveDOMNode):
(WebCore::FrameDOMAgent::willDestroyDOMNode):
(WebCore::FrameDOMAgent::destroyedNodesTimerFired):
(WebCore::FrameDOMAgent::willModifyDOMAttr):
(WebCore::FrameDOMAgent::didModifyDOMAttr):
(WebCore::FrameDOMAgent::didRemoveDOMAttr):
(WebCore::FrameDOMAgent::characterDataModified):
(WebCore::FrameDOMAgent::didInvalidateStyleAttr):
(WebCore::FrameDOMAgent::didPushShadowRoot):
(WebCore::FrameDOMAgent::willPopShadowRoot):
(WebCore::FrameDOMAgent::didChangeCustomElementState):
(WebCore::FrameDOMAgent::pseudoElementCreated):
(WebCore::FrameDOMAgent::pseudoElementDestroyed):
(WebCore::FrameDOMAgent::frameDocumentUpdated):
* Source/WebCore/inspector/agents/frame/FrameDOMAgent.h: Added.
* Source/WebCore/inspector/agents/frame/FrameDOMAgentStubs.cpp: Added.
(WebCore::FrameDOMAgent::querySelector):
(WebCore::FrameDOMAgent::querySelectorAll):
(WebCore::FrameDOMAgent::setNodeName):
(WebCore::FrameDOMAgent::setNodeValue):
(WebCore::FrameDOMAgent::removeNode):
(WebCore::FrameDOMAgent::setAttributeValue):
(WebCore::FrameDOMAgent::setAttributesAsText):
(WebCore::FrameDOMAgent::removeAttribute):
(WebCore::FrameDOMAgent::getSupportedEventNames):
(WebCore::FrameDOMAgent::getDataBindingsForNode):
(WebCore::FrameDOMAgent::getAssociatedDataForNode):
(WebCore::FrameDOMAgent::getEventListenersForNode):
(WebCore::FrameDOMAgent::setEventListenerDisabled):
(WebCore::FrameDOMAgent::setBreakpointForEventListener):
(WebCore::FrameDOMAgent::removeBreakpointForEventListener):
(WebCore::FrameDOMAgent::getAccessibilityPropertiesForNode):
(WebCore::FrameDOMAgent::getOuterHTML):
(WebCore::FrameDOMAgent::setOuterHTML):
(WebCore::FrameDOMAgent::insertAdjacentHTML):
(WebCore::FrameDOMAgent::performSearch):
(WebCore::FrameDOMAgent::getSearchResults):
(WebCore::FrameDOMAgent::discardSearchResults):
(WebCore::FrameDOMAgent::requestNode):
(WebCore::FrameDOMAgent::setInspectModeEnabled):
(WebCore::FrameDOMAgent::highlightRect):
(WebCore::FrameDOMAgent::highlightQuad):
(WebCore::FrameDOMAgent::highlightSelector):
(WebCore::FrameDOMAgent::highlightNode):
(WebCore::FrameDOMAgent::highlightNodeList):
(WebCore::FrameDOMAgent::hideHighlight):
(WebCore::FrameDOMAgent::highlightFrame):
(WebCore::FrameDOMAgent::showGridOverlay):
(WebCore::FrameDOMAgent::hideGridOverlay):
(WebCore::FrameDOMAgent::showFlexOverlay):
(WebCore::FrameDOMAgent::hideFlexOverlay):
(WebCore::FrameDOMAgent::pushNodeByPathToFrontend):
(WebCore::FrameDOMAgent::resolveNode):
(WebCore::FrameDOMAgent::moveTo):
(WebCore::FrameDOMAgent::undo):
(WebCore::FrameDOMAgent::redo):
(WebCore::FrameDOMAgent::markUndoableState):
(WebCore::FrameDOMAgent::focus):
(WebCore::FrameDOMAgent::setInspectedNode):
(WebCore::FrameDOMAgent::setAllowEditingUserAgentShadowTrees):
(WebCore::FrameDOMAgent::getMediaStats):
* Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js:
(WI.DOMManager):
(WI.DOMManager.prototype.initializeTarget):
(WI.DOMManager.prototype._initializeFrameTarget):
(WI.DOMManager.prototype._spliceFrameDocumentIntoPageTree):
(WI.DOMManager.prototype._ensurePageBodyChildrenLoaded):
(WI.DOMManager.prototype._trySpliceFrameDocumentIntoNode):
(WI.DOMManager.prototype._trySpliceUnsplicedFrameDocuments):
(WI.DOMManager.prototype._handleTargetRemoved):
(WI.DOMManager.prototype._cleanupFrameTarget):
(WI.DOMManager.prototype.frameTargetDocumentForTarget):
(WI.DOMManager.prototype.nodeForIdInFrameTarget):
(WI.DOMManager.prototype._frameTargetSetChildNodes):
(WI.DOMManager.prototype._frameTargetDocumentUpdated):
(WI.DOMManager.prototype._frameTargetUnbind):
(WI.DOMManager.prototype._setDocument):
(WI.DOMManager.prototype._setChildNodes):
(WI.DOMManager.prototype._childNodeCountUpdated):
(WI.DOMManager.prototype._childNodeInserted):
(WI.DOMManager.prototype._childNodeRemoved):
(WI.DOMManager.prototype.hideDOMNodeHighlight):
(WI.DOMManager.prototype.setBreakpointForEventListener):
(WI.DOMManager.prototype._handleEventBreakpointDisabledStateChanged):
* Source/WebInspectorUI/UserInterface/Models/DOMNode.js:
(WI.DOMNode.prototype.get owningTarget):
(WI.DOMNode.prototype.get backendNodeId):
(WI.DOMNode.prototype.highlight):
(WI.DOMNode.prototype.getChildNodes):
(WI.DOMNode.prototype.getSubtree):
(WI.DOMNode.prototype.async requestAssignedSlot):
(WI.DOMNode.prototype.async requestAssignedNodes):
(WI.DOMNode.prototype._insertChild):
(WI.DOMNode.prototype._setChildrenPayload):
* Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js:
(WI.CSSObserver.prototype.nodeLayoutFlagsChanged):
(WI.CSSObserver.prototype.nodeLayoutContextTypeChanged):
(WI.CSSObserver):
* Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js:
(WI.DOMObserver.prototype.documentUpdated):
(WI.DOMObserver.prototype.inspect):
(WI.DOMObserver.prototype.setChildNodes):
(WI.DOMObserver.prototype.attributeModified):
(WI.DOMObserver.prototype.attributeRemoved):
(WI.DOMObserver.prototype.inlineStyleInvalidated):
(WI.DOMObserver.prototype.characterDataModified):
(WI.DOMObserver.prototype.childNodeCountUpdated):
(WI.DOMObserver.prototype.childNodeInserted):
(WI.DOMObserver.prototype.childNodeRemoved):
(WI.DOMObserver.prototype.willDestroyDOMNode):
(WI.DOMObserver.prototype.shadowRootPushed):
(WI.DOMObserver.prototype.shadowRootPopped):
(WI.DOMObserver.prototype.customElementStateChanged):
(WI.DOMObserver.prototype.pseudoElementAdded):
(WI.DOMObserver.prototype.pseudoElementRemoved):
(WI.DOMObserver.prototype.didAddEventListener):
(WI.DOMObserver.prototype.willRemoveEventListener):
(WI.DOMObserver.prototype.didFireEvent):
(WI.DOMObserver.prototype.powerEfficientPlaybackStateChanged):
(WI.DOMObserver):

Canonical link: https://commits.webkit.org/312386@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to