Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2dbd6692e3892e02fc1ff2fc0d4f224b98bd0113
https://github.com/WebKit/WebKit/commit/2dbd6692e3892e02fc1ff2fc0d4f224b98bd0113
Author: Qianlang Chen <[email protected]>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
A
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator-expected.txt
A
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator.html
A
LayoutTests/http/tests/site-isolation/inspector/network/resources/iframe-with-initiators.html
A
LayoutTests/http/tests/site-isolation/inspector/network/resources/iframe-with-parser-stylesheet.html
A
LayoutTests/http/tests/site-isolation/inspector/network/resources/parser-initiated.css
A
LayoutTests/http/tests/site-isolation/inspector/network/resources/script-initiated-fetch.js
M Source/WebCore/inspector/InspectorResourceUtilities.cpp
M Source/WebCore/inspector/InspectorResourceUtilities.h
M Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
M Source/WebKit/Scripts/webkit/messages.py
M Source/WebKit/Shared/InspectorNetworkTypes.serialization.in
M Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.cpp
M Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.h
M Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.messages.in
M Source/WebKit/WebProcess/Inspector/FrameNetworkAgentProxy.cpp
Log Message:
-----------
Web Inspector: Site Isolation: Network domain initiator stack traces via IPC
https://bugs.webkit.org/show_bug.cgi?id=308891
rdar://171758685
Reviewed by BJ Burg.
Under site isolation, network events for a cross-origin iframe are
proxied from its WebContent process to the UIProcess by
ProxyingNetworkAgent, which reassembles the protocol objects the
frontend consumes. Until now it filled in a placeholder
Network.Initiator of type "Other" for every request, so the
frontend's Initiator column was empty for any resource loaded by an
out-of-process frame.
The initiator can only be determined in the process that started the
load, and only at the moment it starts: deciding whether a script is
responsible means reading the live JS execution stack, which is gone
by the time the event reaches the UIProcess. So the work has to
happen in the WebContent process and travel over IPC.
Factor the initiator logic out of InspectorNetworkAgent into two
shared helpers in InspectorResourceUtilities: copyInitiatorData(),
which inspects the JS stack, the document parser, and the request's
node identifier to produce a plain, IPC-serializable InitiatorData;
and buildInitiatorObject(), which turns an InitiatorData into the
Network.Initiator protocol object. The captured JS stack keeps its
async parent chain: copyInitiatorData() walks both the synchronous
ScriptCallStack and the AsyncStackTrace parents behind it into a
Vector of InitiatorStackTraceLevel, and buildInitiatorObject()
rebuilds the nested protocol StackTrace from it. InitiatorData and
its sub-structs get an IPC serializer, and the message generator
learns to include their header rather than forward-declare them.
FrameNetworkAgentProxy now copies the InitiatorData synchronously as
each request is sent or served from the memory cache and ships it in
the RequestWillBeSent and RequestServedFromMemoryCache messages;
ProxyingNetworkAgent builds the real Initiator from it. The existing
in-process InspectorNetworkAgent path calls the same helpers, so an
out-of-process frame and a same-process one produce identical
initiators, including the async parent chain the in-process path
already reported; that path keeps its fallback to the initiator
captured during a style recalculation when nothing is attributable at
load time.
The async parent chain travels flat rather than as a linked list.
Protocol.Console.StackTrace nests each level inside its parent, and
mirroring that on the wire with a self-referential struct would make
IPC decoding, destruction, and protocol-object construction each
recurse once per level, so a WebContent process could send a chain
deep enough to exhaust the UIProcess stack. A Vector keeps all three
iterative: element 0 is the synchronous stack and each later element
is the async parent of the one before it. The decoder additionally
caps the chain at InitiatorData::maxStackTraceLevels; real captures
stay far below that, since the debugger already truncates the chain
to its configured async stack depth.
A DOM node identifier is only reported when a page-target DOM agent
is registered, because that agent mints the identifiers the frontend
resolves; a process hosting only cross-origin iframes has none, and
reporting an id there could match an unrelated node in another
target. A FIXME tracks reporting identifiers minted by the frame
target's FrameDOMAgent instead.
Test:
http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator.html
*
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator-expected.txt:
Added.
*
LayoutTests/http/tests/site-isolation/inspector/network/cross-origin-iframe-network-initiator.html:
Added.
*
LayoutTests/http/tests/site-isolation/inspector/network/resources/iframe-with-initiators.html:
Added.
*
LayoutTests/http/tests/site-isolation/inspector/network/resources/iframe-with-parser-stylesheet.html:
Added.
*
LayoutTests/http/tests/site-isolation/inspector/network/resources/parser-initiated.css:
Added.
(body):
*
LayoutTests/http/tests/site-isolation/inspector/network/resources/script-initiated-fetch.js:
Added.
(triggerScriptInitiatedFetch):
(triggerAsyncScriptInitiatedFetch):
* Source/WebCore/inspector/InspectorResourceUtilities.cpp:
(Inspector::ResourceUtilities::copyCallFrames):
(Inspector::ResourceUtilities::appendAsyncStackTraceLevels):
(Inspector::ResourceUtilities::copyInitiatorData):
(Inspector::ResourceUtilities::toProtocol):
(Inspector::ResourceUtilities::buildStackTraceObject):
(Inspector::ResourceUtilities::buildInitiatorObject):
* Source/WebCore/inspector/InspectorResourceUtilities.h:
(Inspector::InitiatorData::isAttributed const):
* Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::buildInitiatorObject):
* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
(headers_for_type):
* Source/WebKit/Shared/InspectorNetworkTypes.serialization.in:
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.cpp:
(Inspector::ProxyingNetworkAgent::requestWillBeSent):
(Inspector::ProxyingNetworkAgent::requestServedFromMemoryCache):
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.h:
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingNetworkAgent.messages.in:
* Source/WebKit/WebProcess/Inspector/FrameNetworkAgentProxy.cpp:
(WebKit::FrameNetworkAgentProxy::willSendRequest):
(WebKit::FrameNetworkAgentProxy::willSendRequestOfType):
(WebKit::FrameNetworkAgentProxy::didLoadResourceFromMemoryCache):
Canonical link: https://commits.webkit.org/321743@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications