Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 283db2619c855c84e9ed6294218cfbbbeec8d402
https://github.com/WebKit/WebKit/commit/283db2619c855c84e9ed6294218cfbbbeec8d402
Author: Qianlang Chen <[email protected]>
Date: 2026-01-06 (Tue, 06 Jan 2026)
Changed paths:
M LayoutTests/platform/mac-wk1/TestExpectations
M Source/WebCore/inspector/CommandLineAPIHost.cpp
M Source/WebCore/inspector/CommandLineAPIHost.h
M Source/WebCore/inspector/FrameInspectorController.cpp
M Source/WebCore/inspector/FrameInspectorController.h
M Source/WebCore/inspector/PageInspectorController.cpp
M Source/WebCore/inspector/WebInjectedScriptManager.cpp
M Source/WebCore/inspector/WebInjectedScriptManager.h
M Source/WebCore/inspector/WorkerInspectorController.cpp
M Source/WebCore/inspector/WorkerInspectorController.h
Log Message:
-----------
[Site Isolation] Web Inspector: Remote iframe still can't console log with
frame target console support
rdar://166892920
https://bugs.webkit.org/show_bug.cgi?id=304511
Reviewed by BJ Burg.
Summary: Introduce client-counting to WebInjectedScriptManager to auto
set up for remote frame targets without a parent page target.
With our recent site isolation work in [1] to move the Console agent
into frame target, we intend to let frame targets use its parent page's
WebInjectedScriptManager, maintaining the "one InjectedScriptManager per
page" pattern. However, a remote web process doesn't surface a page
target to the frontend that would set up the manager upon connection.
As a result, any remote frame target will try to use an unprepared
InjectedScriptManager and its CommandLineAPIHost when adding a
console message.
[1] Related landed work:
- Shared InjectedScriptManager: https://github.com/WebKit/WebKit/pull/53561
- Move Console agent to frame target:
https://github.com/WebKit/WebKit/pull/51217
This patch makes WebInjectedScriptManager set up or torn down
automatically by introducing a client-counting strategy, to ensure the
manager is ready independently as long as there's any client connection
(page, frame, worker). Further, while not necessarily attached to one
target, the internal CommandLineAPIHost must now work with more than
one potential targets and sets of InstrumentingAgents. We address that
by making the host access the right agents according to the
JSGlobalObject, so that it can adapt to any execution context
(document, worker) without requiring explicit initialization.
The reason we kept one manager per page was that other domains that also
work with InjectedScriptManager (like Debugger and Runtime) still live
in page target. We are avoiding agents having out-of-sync states due to
being moved into frame as we go through this site isolation transition.
However, it should be worth revisiting whether objects like
InjectedScriptManager should either still be frame-isolated even in the
same process or become per-VM instead (filed follow-up
https://webkit.org/b/304949).
No new tests. The existing inspector test message-from-iframe should now
progress with --site-isolation turned on (Timeout -> Pass).
* LayoutTests/platform/mac-wk1/TestExpectations:
WK1 inspector test's teardown process when done from within a promise
doesn't seem to work well with this multi-target InjectedScriptManager
support, resulting in a crash when setOuterHTML-no-document-element
completes. This is likely about how inspector test handles completion
when there are unresolved promises, but I couldn't figure out why
that directly relates to this patch.
Given we are avoiding spending too much effort maintaining WK1
testing support (see e.g. b/299207), skip this test for now.
* Source/WebCore/inspector/CommandLineAPIHost.cpp:
(WebCore::instrumentingAgentsForGlobalObject):
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::~CommandLineAPIHost): Deleted.
(WebCore::CommandLineAPIHost::disconnect): Deleted.
Adapt to being used by more than one inspector targets and figure out
the right InstrumentingAgents to use automatically.
Remove init and disconnect which are no longer useful due to this
autonomy.
* Source/WebCore/inspector/CommandLineAPIHost.h:
(WebCore::CommandLineAPIHost::init): Deleted.
* Source/WebCore/inspector/FrameInspectorController.cpp:
(WebCore::FrameInspectorController::connectFrontend):
(WebCore::FrameInspectorController::disconnectFrontend):
(WebCore::FrameInspectorController::inspectedFrameDestroyed):
* Source/WebCore/inspector/FrameInspectorController.h:
* Source/WebCore/inspector/PageInspectorController.cpp:
(WebCore::PageInspectorController::createLazyAgents):
(WebCore::PageInspectorController::connectFrontend):
(WebCore::PageInspectorController::disconnectFrontend):
(WebCore::PageInspectorController::disconnectAllFrontends):
* Source/WebCore/inspector/WebInjectedScriptManager.cpp:
(WebCore::WebInjectedScriptManager::~WebInjectedScriptManager):
(WebCore::WebInjectedScriptManager::addClient):
(WebCore::WebInjectedScriptManager::removeClient):
(WebCore::WebInjectedScriptManager::disconnect):
* Source/WebCore/inspector/WebInjectedScriptManager.h:
* Source/WebCore/inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::workerTerminating):
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::disconnectFrontend):
(WebCore::WorkerInspectorController::createLazyAgents):
* Source/WebCore/inspector/WorkerInspectorController.h:
Make WebInjectedScriptManager client-counted. Before and after using
the manager, update the client count rather than explicitly
connecting or disconnecting the manager.
In page and worker, move the client count updating work to be in sync
with connecting and disconnecting the frontend rather than the
agents' lifetime. This creates consistency with the frame target, as
no client should dictate WebInjectedScriptManager's connection
anymore.
Expose m_instrumentingAgents in frame and worker for
CommandLineAPIHost to access.
Canonical link: https://commits.webkit.org/305166@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications