Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d4c2cda063f739ff61e7d8f8757ed1424a7e89c
      
https://github.com/WebKit/WebKit/commit/1d4c2cda063f739ff61e7d8f8757ed1424a7e89c
  Author: BJ Burg <[email protected]>
  Date:   2026-06-04 (Thu, 04 Jun 2026)

  Changed paths:
    M Source/WebKit/Modules/OSX_Private.modulemap
    M Source/WebKit/Modules/iOS_Private.modulemap
    M Source/WebKit/Sources.txt
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/UIProcess/API/APIAutomationSessionClient.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionPrivateForTesting.h
    A Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionTesting.mm
    M Source/WebKit/UIProcess/Automation/Automation.json
    A Source/WebKit/UIProcess/Automation/InspectorPassthroughChannel.cpp
    A Source/WebKit/UIProcess/Automation/InspectorPassthroughChannel.h
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.h
    M Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h
    M Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebKit/WebPage/SendInspectorMessage.swift

  Log Message:
  -----------
  Web Inspector: support testing backend commands using Automation protocol
https://bugs.webkit.org/show_bug.cgi?id=315624
rdar://177998955

Reviewed by Wenson Hsieh and Abrar Rahman Protyasha.

WebKit has no in-process way to drive the Inspector backend dispatcher
from API tests: the existing transports (RemoteInspector XPC, Web
Automation over RemoteWebDriver) both require an out-of-process driver,
and Inspector protocol coverage today lives in LayoutTests which
exercise the frontend rather than the backend. This patch adds two new
Automation commands that relay Inspector backend messages between a
remote driver and a browsing context's Inspector controller, plus the
in-process plumbing needed to test the dispatch path from TestWebKitAPI
without RemoteInspector.

New Automation.sendInspectorMessage (in) and
Automation.receiveInspectorMessage (out) carry an opaque UTF-8 JSON
literal alongside a BrowsingContextHandle. InspectorPassthroughChannel
is the per-context FrontendChannel that hands outbound backend messages
to WebAutomationSession, which dispatches receiveInspectorMessage back
over the same Automation transport; inbound messages go through
WebAutomationSession::sendInspectorMessage into the page's
WebInspectorBackendDispatcher.

Testing: Adds an in-process Swift API test exercising the dispatch path.

(AutomationSendInspectorMessageTests.roundTripTargetSetPauseOnStart):
(AutomationSendInspectorMessageTests.deniedWhenGateReturnsFalse):
(AutomationSendInspectorMessageTests.windowNotFoundForUnknownHandle):

* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* Source/WebKit/Sources.txt:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/APIAutomationSessionClient.h:
(API::AutomationSessionClient::shouldEnableInspectorTesting):
* Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionPrivateForTesting.h: 
Added.
* Source/WebKit/UIProcess/API/Cocoa/_WKAutomationSessionTesting.mm: Added.
(-[_WKAutomationSessionTestChannel dealloc]):
(-[_WKAutomationSession _registerWebViewForTesting:]):
(-[_WKAutomationSession _setMessageToFrontendHandlerForTesting:]):
(-[_WKAutomationSession _dispatchMessageFromRemoteForTesting:]):
* Source/WebKit/UIProcess/Automation/Automation.json:
* Source/WebKit/UIProcess/Automation/InspectorPassthroughChannel.cpp: Added.
(WebKit::InspectorPassthroughChannel::InspectorPassthroughChannel):
(WebKit::InspectorPassthroughChannel::sendMessageToFrontend):
* Source/WebKit/UIProcess/Automation/InspectorPassthroughChannel.h: Added.
* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::~WebAutomationSession):
(WebKit::WebAutomationSession::sendInspectorMessage):
(WebKit::WebAutomationSession::sendInspectorMessageToClient):
(WebKit::WebAutomationSession::terminate):
(WebKit::WebAutomationSession::disconnectInspectorPassthroughChannel):
(WebKit::WebAutomationSession::disconnectAllInspectorPassthroughChannels):
(WebKit::WebAutomationSession::willClosePage):
* Source/WebKit/UIProcess/Automation/WebAutomationSession.h:
(isType):
* Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.h:
* Source/WebKit/UIProcess/Cocoa/AutomationSessionClient.mm:
(WebKit::AutomationSessionClient::AutomationSessionClient):
(WebKit::AutomationSessionClient::shouldEnableInspectorTesting):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/SendInspectorMessage.swift: Added.
(TestSendInspectorMessageDelegate.allowInspectorTesting):
(TestSendInspectorMessageDelegate._automationSessionShouldEnableInspectorTesting(_:)):
(AnyEncodable.encode(to:)):
(decode(_:)):
(findMessage(withOuterId:in:)):
(findEvent(named:in:)):
(findReceiveEvent(withInnerId:in:)):
(CapturedMessages.strings):
(SessionFixture.captured):
(AutomationSendInspectorMessageTests.roundTripTargetSetPauseOnStart):
(AutomationSendInspectorMessageTests.deniedWhenGateReturnsFalse):
(AutomationSendInspectorMessageTests.windowNotFoundForUnknownHandle):

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



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

Reply via email to