Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6fd4b1f654c63cea8bd2afdbbd634b7b3a46e562
https://github.com/WebKit/WebKit/commit/6fd4b1f654c63cea8bd2afdbbd634b7b3a46e562
Author: BJ Burg <[email protected]>
Date: 2026-05-25 (Mon, 25 May 2026)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/dom/Document.h
M Source/WebCore/inspector/InstrumentingAgents.h
M Source/WebCore/inspector/PageInspectorController.h
A Source/WebCore/inspector/hooks/PageAgentInstrumentation.h
M Source/WebKit/CMakeLists.txt
M Source/WebKit/DerivedSources-input.xcfilelist
M Source/WebKit/DerivedSources-output.xcfilelist
M Source/WebKit/DerivedSources.make
M Source/WebKit/Sources.txt
M Source/WebKit/SourcesCocoa.txt
A Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.cpp
A Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.h
A Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.messages.in
M Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
M Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Source/WebKit/WebProcess/Inspector/FrameNetworkAgentProxy.cpp
A Source/WebKit/WebProcess/Inspector/PageAgentProxy.cpp
A Source/WebKit/WebProcess/Inspector/PageAgentProxy.h
M Source/WebKit/WebProcess/Inspector/WebInspectorBackend.cpp
M Source/WebKit/WebProcess/Inspector/WebInspectorBackend.h
M Source/WebKit/WebProcess/Inspector/WebInspectorBackend.messages.in
M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Log Message:
-----------
[Site Isolation] Web Inspector: add ProxyingPageAgent and PageAgentProxy
stubs for cross-process Page domain instrumentation
https://bugs.webkit.org/show_bug.cgi?id=306075
Reviewed by Qianlang Chen.
Cross-origin iframes and cross-origin top-level navigations under
Site Isolation run in separate WebContent processes, so
InspectorPageAgent in the original process no longer sees frame
lifecycle for those frames. Add the skeleton for cross-process Page
domain instrumentation: PageAgentProxy in the WebContent process
forwards frame lifecycle events via IPC, ProxyingPageAgent in the
UIProcess receives them and dispatches protocol events to the
frontend. Same octopus pattern as ProxyingNetworkAgent.
Frame lifecycle events forwarded end-to-end:
- Page.frameNavigated, Page.frameDetached
- Page.domContentEventFired, Page.loadEventFired (per-frame)
== Two lifecycles ==
The agent participates in two distinct lifecycles, and conflating
them is the easy way to leak a receiver registration:
- Agent lifecycle: ProxyingPageAgent itself, scoped to the inspector
frontend connection. connectFrontend creates the agent;
disconnectFrontend (or disconnectAllFrontends) tears it down.
- Instrumentation lifecycle: per (WebProcessProxy, WebPageProxyIdentifier)
pair currently being inspected. Enable installs an IPC receiver
on that process for the agent's .messages.in; disable removes it.
While instrumentation is enabled on a (process, page), the agent
holds two paired things: the IPC receiver registration AND a
Ref<WebProcessProxy> in m_pinnedInstrumentedProcesses. The pin keeps
the proxy alive long enough for disable to reach
removeMessageReceiver regardless of where in the agent lifecycle the
disable runs.
== Instrumentation lifecycle hooks ==
WebPageInspectorController drives instrumentation enable/disable on
five transitions:
- didCreateFrame: new cross-origin iframe spawns a new WebContent
process; enable on that (process, page) if no prior registration.
- willDestroyFrame: iframe is torn down; if it was the last frame
on this (process, page), disable.
- didCommitProvisionalFrame: cross-origin nav within an iframe
swaps WebProcessProxies; disable on (oldProcess, oldWebPageID),
then enable on (newProcess, newWebPageID).
- didCommitProvisionalPage: top-level cross-origin nav; same
(oldProcess, oldWebPageID) -> (newProcess, newWebPageID) pairing
at the page level.
- connectFrontend / disconnectFrontend: bulk enable/disable across
every currently-tracked (process, page) when the inspector itself
transitions.
== What is stubbed ==
These Page backend commands return empty/error responses; bug links
track the real implementations:
- getResourceTree, searchInResource, searchInResources:
https://bugs.webkit.org/show_bug.cgi?id=308896
- setBootstrapScript: https://bugs.webkit.org/show_bug.cgi?id=308897
- reload, overrideSetting, overrideUserAgent, overrideUserPreference:
https://bugs.webkit.org/show_bug.cgi?id=308898
- setShowPaintRects, setShowRulers:
https://bugs.webkit.org/show_bug.cgi?id=308899
- getCookies, setCookie, deleteCookie:
https://bugs.webkit.org/show_bug.cgi?id=308900
loaderId uses a placeholder until document identifier forwarding
lands: https://bugs.webkit.org/show_bug.cgi?id=308895.
== Test plan ==
Existing site-isolation/inspector/target/ tests (target.html,
target-cross-origin-page-navigation.html) and console domain tests
(message-from-iframe.html, message-from-worker.html) continue to
pass, confirming InstrumentingAgents registration does not interfere
with existing instrumentation.
* Source/WebCore/inspector/hooks/PageAgentInstrumentation.h: Added.
(Inspector::PageAgentInstrumentation::PageAgentInstrumentation):
Abstract interface for page instrumentation hooks, parallel to
NetworkAgentInstrumentation.h.
* Source/WebCore/inspector/InstrumentingAgents.h:
Add pageAgentProxy slot.
* Source/WebCore/inspector/PageInspectorController.h:
Add WEBCORE_EXPORT to executionStopwatch().
* Source/WebCore/dom/Document.h:
Add WEBCORE_EXPORT to suggestedMIMEType() (first cross-framework
use from Source/WebKit/).
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.cpp: Added.
(Inspector::ProxyingPageAgent::ProxyingPageAgent):
(Inspector::ProxyingPageAgent::didCreateFrontendAndBackend):
(Inspector::ProxyingPageAgent::willDestroyFrontendAndBackend):
(Inspector::ProxyingPageAgent::enableInstrumentationForProcess):
(Inspector::ProxyingPageAgent::disableInstrumentationForProcess):
Pair the IPC receiver registration with a Ref<WebProcessProxy> pin
in m_pinnedInstrumentedProcesses; the pin is dropped when the last
(process, pageID) registration for that process goes away.
(Inspector::ProxyingPageAgent::removeAllRegisteredReceivers):
Walk the pinned process refs (not WebProcessProxy::processForIdentifier)
so disable always reaches a live proxy regardless of agent-lifecycle
ordering.
(Inspector::ProxyingPageAgent::enable):
(Inspector::ProxyingPageAgent::disable):
(Inspector::ProxyingPageAgent::frameNavigated):
Receive IPC from PageAgentProxy, dispatch Page.frameNavigated with
deterministic frame/loader IDs. FIXME: loaderId uses a placeholder
until document identifier forwarding is implemented
(https://bugs.webkit.org/show_bug.cgi?id=308895).
(Inspector::ProxyingPageAgent::domContentEventFired):
(Inspector::ProxyingPageAgent::loadEventFired):
(Inspector::ProxyingPageAgent::frameDetached):
(Inspector::ProxyingPageAgent::getResourceTree):
(Inspector::ProxyingPageAgent::reload):
(Inspector::ProxyingPageAgent::overrideUserAgent):
(Inspector::ProxyingPageAgent::overrideSetting):
(Inspector::ProxyingPageAgent::overrideUserPreference):
(Inspector::ProxyingPageAgent::getCookies):
(Inspector::ProxyingPageAgent::setCookie):
(Inspector::ProxyingPageAgent::deleteCookie):
(Inspector::ProxyingPageAgent::getResourceContent):
(Inspector::ProxyingPageAgent::setBootstrapScript):
(Inspector::ProxyingPageAgent::searchInResource):
(Inspector::ProxyingPageAgent::searchInResources):
(Inspector::ProxyingPageAgent::setShowRulers):
(Inspector::ProxyingPageAgent::setShowPaintRects):
Stubbed command handlers. See bug links above.
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.h: Added.
* Source/WebKit/UIProcess/Inspector/Agents/ProxyingPageAgent.messages.in: Added.
IPC messages: FrameNavigated, DomContentEventFired, LoadEventFired,
FrameDetached.
* Source/WebKit/WebProcess/Inspector/PageAgentProxy.cpp: Added.
(WebKit::PageAgentProxy::PageAgentProxy):
(WebKit::PageAgentProxy::didCreateFrontendAndBackend):
(WebKit::PageAgentProxy::willDestroyFrontendAndBackend):
(WebKit::PageAgentProxy::enable):
(WebKit::PageAgentProxy::disable):
(WebKit::PageAgentProxy::frameNavigated):
Forward Page.frameNavigated via IPC to UIProcess ProxyingPageAgent.
(WebKit::PageAgentProxy::frameDetached):
(WebKit::PageAgentProxy::domContentEventFired):
(WebKit::PageAgentProxy::loadEventFired):
(WebKit::PageAgentProxy::loaderDetachedFromFrame):
(WebKit::PageAgentProxy::accessibilitySettingsDidChange):
(WebKit::PageAgentProxy::defaultUserPreferencesDidChange):
(WebKit::PageAgentProxy::defaultAppearanceDidChange):
(WebKit::PageAgentProxy::applyUserAgentOverride):
(WebKit::PageAgentProxy::applyEmulatedMedia):
(WebKit::PageAgentProxy::didClearWindowObjectInWorld):
(WebKit::PageAgentProxy::didPaint):
(WebKit::PageAgentProxy::didLayout):
(WebKit::PageAgentProxy::didScroll):
(WebKit::PageAgentProxy::didRecalculateStyle):
No-op stubs for PageAgentInstrumentation hooks not yet forwarded.
* Source/WebKit/WebProcess/Inspector/PageAgentProxy.h: Added.
* Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h:
* Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp:
(WebKit::WebPageInspectorController::connectFrontend):
(WebKit::WebPageInspectorController::disconnectFrontend):
(WebKit::WebPageInspectorController::disconnectAllFrontends):
(WebKit::WebPageInspectorController::didCreateFrame):
(WebKit::WebPageInspectorController::willDestroyFrame):
(WebKit::WebPageInspectorController::didCommitProvisionalFrame):
(WebKit::WebPageInspectorController::didCommitProvisionalPage):
(WebKit::WebPageInspectorController::createLazyAgents):
Drive ProxyingPageAgent enable/disable through the five lifecycle
hooks above.
* Source/WebKit/WebProcess/Inspector/WebInspectorBackend.h:
* Source/WebKit/WebProcess/Inspector/WebInspectorBackend.cpp:
(WebKit::WebInspectorBackend::enablePageInstrumentation):
(WebKit::WebInspectorBackend::disablePageInstrumentation):
* Source/WebKit/WebProcess/Inspector/WebInspectorBackend.messages.in:
Add EnablePageInstrumentation, DisablePageInstrumentation.
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
Fix missing HTMLVideoElement.h include exposed by unified source
reordering.
* Source/WebKit/UIProcess/wpe/WebPasteboardProxyWPE.cpp:
* Source/WebKit/WebProcess/Inspector/FrameNetworkAgentProxy.cpp:
Drive-by build fixes for missing includes exposed by unified source
reordering.
* Source/WebKit/CMakeLists.txt:
* Source/WebKit/Sources.txt:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
Canonical link: https://commits.webkit.org/313867@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications