← All issues

Web Inspector: introduce FrameDOMAgent for cross-origin iframe DOM tree access

c48671a

Source/WebCore/inspector/agents/frame/FrameDOMAgent.cpp

+FrameDOMAgent::FrameDOMAgent(WebCore::Frame& frame, BackendDispatcher& backendDispatcher)
+ : InspectorAgentBase("DOM"_s)
+ , m_frame(frame)
+ , m_backendDispatcher(InspectorDOMBackendDispatcher::create(backendDispatcher, this))
+ , m_destroyedNodesTimer(*this, &FrameDOMAgent::destroyedNodesTimerFired)
+{ }

Source/WebInspectorUI/UserInterface/Controllers/DOMManager.js

+_initializeFrameTarget(target)
+{
+ target.DOMAgent.getDocument().then((payload) => {
+ let documentNode = this._bindFrameTargetNode(target, payload.root);
+ this._frameTargetDocuments.set(target, documentNode);
+ this._spliceFrameDocumentIntoPageTree(target, documentNode);
+ });
+}

Under WebKit's site isolation model, cross-origin iframes run in separate WebProcess instances, making their subtrees invisible to the Inspector's InspectorDOMAgent. This commit deploys an independent FrameDOMAgent into each frame's WebProcess. Node IDs are process-local integers, so the frontend scopes them as targetId:nodeId composite strings to maintain a unified view, splicing the cross-origin frame document into the page tree post-hoc. Mutation event handlers (didInsertDOMNode, didRemoveDOMNode) are wired but gated off via DOMObserver early-returns — live mutation tracking is deferred to a future patch.

This is the first step toward full cross-process DOM inspection under site isolation, expanding the Inspector's privilege boundary surface and establishing IPC plumbing future patches will build on.

🔒

Cross-process node ID scoping and splice-time ordering in this new inspector path have several edge cases worth auditing.

Subscribe to read more