Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 054e73ac03d3c384c6eebbde8eca54ebf8343879
      
https://github.com/WebKit/WebKit/commit/054e73ac03d3c384c6eebbde8eca54ebf8343879
  Author: Qianlang Chen <[email protected]>
  Date:   2026-09-23 (Wed, 23 Sep 2026)

  Changed paths:
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-action-detach-cross-origin-iframe-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-action-detach-cross-origin-iframe.html
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-condition-detach-cross-origin-iframe-expected.txt
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-condition-detach-cross-origin-iframe.html
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-action-detach-frame.html
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-condition-detach-frame.html
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-detach-frame-script.js
    A 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-detach-test-utilities.js
    M Source/WebCore/inspector/FrameDebugger.cpp
    M Source/WebKit/UIProcess/API/C/WKPage.cpp
    M Source/WebKit/UIProcess/API/C/WKPagePrivate.h
    M Source/WebKit/UIProcess/API/cpp/WKCast.h
    M Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp
    M Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h
    M Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
    M Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
    M Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
    M Tools/WebKitTestRunner/TestInvocation.cpp

  Log Message:
  -----------
  [Site Isolation] Web Inspector: Closing inspector during a breakpoint action 
doesn't stop remaining actions, and page stays paused
https://bugs.webkit.org/show_bug.cgi?id=323797
rdar://187046297

Reviewed by BJ Burg.

Under Site Isolation, closing Web Inspector while a breakpoint's
condition or actions were still running left the pause standing. From a
breakpoint action, the remaining actions kept running and the frame
stayed paused in a nested run loop with no frontend left to resume it.
>From a breakpoint condition the frame did not stay paused, but the
condition's exception was reported to a console nobody was listening to
instead of being abandoned.

detach() is what unwinds the pause. It clears m_currentCallFrame, and it
clears the global object's debugger pointer, which makes isAttached()
false. evaluateBreakpointActions() checks isAttached() after every
action and returns there, which is what drops the remaining actions.
pauseIfNeeded() checks m_currentCallFrame once
evaluateBreakpointActions() returns and skips handlePause() when it is
null, which is why the frame does not stay paused.
evaluateBreakpointCondition() uses that same m_currentCallFrame check to
abandon the condition's exception instead of reporting it.

Every Debugger subclass has to undo in detachDebugger() what its
attachDebugger() did. PageDebugger releases its global objects through
Page::setDebugger(nullptr), and WorkerDebugger through
WorkerOrWorkletScriptController::detachDebugger(). FrameDebugger's
detachDebugger() only recompiled JS functions and never released
anything, so detach() never ran and none of the guards above fired.
PageDebugger does not cover for it either, since its attachDebugger()
early-returns under Site Isolation.

This gives FrameDebugger::detachDebugger() the same loop as its
attachDebugger(), guarded by isAttached() so that it only releases
global objects this debugger owns -- attachDebugger() deliberately skips
any that already have a debugger. It passes TerminatingDebuggingSession
rather than switching to GlobalObjectIsDestructing when isBeingDestroyed
the way JSGlobalObjectDebugger does, because isBeingDestroyed here means
the inspected frame is going away, not that the JSGlobalObject is
destructing; skipping clearDebuggerRequests() would leave stale debugger
requests on CodeBlocks that are still live. Page and WorkerDebugger pass
the same reason for the same event, and like them the loop is not
guarded by isBeingDestroyed -- only the recompile is.

Tests: 
http/tests/site-isolation/inspector/debugger/breakpoint-action-detach-cross-origin-iframe.html
       
http/tests/site-isolation/inspector/debugger/breakpoint-condition-detach-cross-origin-iframe.html

Reaching that frame target needed a new hook: a protocol test tears the
frontend down synchronously but cannot address an out-of-process frame,
since InspectorStubFrontend only knows the local main frame; an
inspector-test reaches frame targets but closes asynchronously, landing
a run loop turn after breakpoint evaluation has already finished. This
adds testRunner.disconnectFrameInspectorTarget(), which asks the UI
process to disconnect the calling frame's inspector target through
the new WKPageDisconnectInspectorFrameTargetForTesting(). That calls
FrameInspectorTargetProxy::disconnect(), the same path that closing the
inspector takes, and so sends the existing DisconnectInspector message
to the frame's process. It is scoped to just that target, so the page
target's connection, which the test harness reports results over,
stays untouched. The hook is UI-process SPI rather than InjectedBundle
SPI because InjectedBundle is being phased out.

* 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-action-detach-cross-origin-iframe-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-action-detach-cross-origin-iframe.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-condition-detach-cross-origin-iframe-expected.txt:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/breakpoint-condition-detach-cross-origin-iframe.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-action-detach-frame.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-condition-detach-frame.html:
 Added.
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-detach-frame-script.js:
 Added.
(functionWithBreakpoint):
* 
LayoutTests/http/tests/site-isolation/inspector/debugger/resources/breakpoint-detach-test-utilities.js:
 Added.
(messagesFromFrameJoined):
(runFunctionWithBreakpointInFrame):
(TestPage.registerInitializer.window.setBreakpointInFrameScript.async 
setBreakpointInFrameScript):
* Source/WebCore/inspector/FrameDebugger.cpp:
(WebCore::FrameDebugger::detachDebugger):
* Source/WebKit/UIProcess/API/C/WKPage.cpp:
(WKPageDisconnectInspectorFrameTargetForTesting):
* Source/WebKit/UIProcess/API/C/WKPagePrivate.h:
* Source/WebKit/UIProcess/API/cpp/WKCast.h:
* Source/WebKit/UIProcess/Inspector/WebPageInspectorController.cpp:
(WebKit::WebPageInspectorController::disconnectFrameTargetForTesting):
* Source/WebKit/UIProcess/Inspector/WebPageInspectorController.h:
* Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::disconnectFrameInspectorTarget):
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.h:
* Tools/WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

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



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

Reply via email to