Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4b386b5e7393fbda26d42c08f9cc38f2a6fff81b
      
https://github.com/WebKit/WebKit/commit/4b386b5e7393fbda26d42c08f9cc38f2a6fff81b
  Author: Lauro Moura <[email protected]>
  Date:   2025-05-01 (Thu, 01 May 2025)

  Changed paths:
    M Source/WebDriver/Session.cpp
    M Source/WebDriver/Session.h
    M Source/WebDriver/SessionHost.cpp
    M Source/WebDriver/SessionHost.h
    M Source/WebDriver/WebDriverService.cpp
    M Source/WebDriver/WebDriverService.h
    M Source/WebDriver/WebSocketServer.cpp
    M Source/WebDriver/WebSocketServer.h
    M Source/WebDriver/soup/WebSocketServerSoup.cpp
    M Source/WebKit/UIProcess/Automation/Automation.json
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
    M Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.cpp
    M WebDriverTests/TestExpectations.json

  Log Message:
  -----------
  [WebDriver][BiDi] Add support to relay commands with new processBidiMessage 
and bidiMessageSent in Source/WebDriver
https://bugs.webkit.org/show_bug.cgi?id=288194

Reviewed by BJ Burg.

290582@main added two new features in Automation.json:

- processBidiMessage command
- bidiMessageSent event

This pair can be used to relay BiDi commands to the browser, which in
turn can send almost ready BiDi responses and events. In this scenario,
the service acts basically as a proxy, instead of worrying with
individual commands details.

Another benefit of this is that we can move more code inside WebKit itself,
allowing the ports not using `Source/WebDriver` directly to share more code,
and keeping the service code simpler.

This commit removes the previous `Automation.json` `logEntryAdded`
event, relying on the new `bidiMessageSent` event to wrap it. In a
follow-up commit, we'll move the post-processing code in
`Session::doLogEntryAdded` back inside `WebAutomationSession` so the
service can receive the ready event body.

This commit also makes WebDriverBidiProcessor translate "inspector
protocol-like" errors into the WebDriver-BiDi messages, so the driver
can just forward it ahead.

* Source/WebDriver/Session.cpp:
(WebDriver::Session::Session): Rename EventHandler to BiDiHandler
(WebDriver::Session::dispatchBiDiMessage): Renamed from dispatch event
(WebDriver::Session::doLogEntryAdded): Better logging and no need to
check if event is enabled, as we do it in doBidiMessageSent.
(WebDriver::Session::enableGlobalEvent): No need to strip the '.'
between the module and event name, as they are not part of the
Automation.json protocol anymore.
(WebDriver::Session::disableGlobalEvent): Ditto.
(WebDriver::Session::relayBidiCommand): Forward the incoming bidi
message to the browser, replying the incoming message with the returned
payload.
(WebDriver::Session::doBidiMessageSent): Added. Unpack the received Bidi
message and process either the command reply or the incoming event.
(WebDriver::Session::dispatchEvent): Deleted.
(WebDriver::Session::toInternalEventName): Deleted.
* Source/WebDriver/Session.h: Rename EventHandler to BiDiMessageHandler
* Source/WebDriver/SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage): Ditto.
(WebDriver::SessionHost::dispatchBiDiMessage): Added.
(WebDriver::SessionHost::dispatchEvent): Deleted.
* Source/WebDriver/SessionHost.h: Rename EventHandler to
  BiDiMessageHandler
* Source/WebDriver/WebDriverService.cpp:
(WebDriver::WebDriverService::handleMessage): Fallback to
relayBidiCommand when we don't have a local method impl.
(WebDriver::WebDriverService::findBidiCommand): Simplify parameter
passing.
(WebDriver::WebDriverService::bidiSessionSubscribe): Logging.
* Source/WebDriver/WebDriverService.h:
* Source/WebKit/UIProcess/Automation/Automation.json: Remove uneeded
  logEntryAdded event.
* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp: Ditto.
(WebKit::WebAutomationSession::logEntryAdded):
* WebDriverTests/TestExpectations.json: Drive-by bug URL fix.

* Source/WebDriver/Session.cpp:
(WebDriver::Session::Session): Rename EventHandler to BidiMessageHandler
(WebDriver::Session::dispatchBidiMessage): Renamed from dispatchEvent.
This function validates the message to be forwarded to the browser.
(WebDriver::Session::doLogEntryAdded): Move event enabled check
outside.
(WebDriver::Session::enableGlobalEvent): No need to strip the '.'
between the module and event name, as they're wrapped in
'bidiMessageSent' now.
(WebDriver::Session::disableGlobalEvent): Ditto.
(WebDriver::Session::relayBidiCommand): Forward the incoming bidi
message to the browser, with the callback just observing for errors
delivering the request.
(WebDriver::Session::dispatchEvent): Deleted.
(WebDriver::Session::toInternalEventName): Deleted.
* Source/WebDriver/Session.h: Rename EventHandler to BidiMessageHandler
* Source/WebDriver/SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage): Ditto.
(WebDriver::SessionHost::dispatchBidiMessage): Replaces dispatchEvent.
(WebDriver::SessionHost::dispatchEvent): Deleted.
* Source/WebDriver/SessionHost.h: Rename EventHandler to
  BidiMessageHandler.
* Source/WebDriver/WebDriverService.cpp:
(WebDriver::WebDriverService::handleMessage): Fallback to
relayBidiCommand when we don't have a local method impl.
(WebDriver::WebDriverService::findBidiCommand): Simplify parameter
passing.
* Source/WebDriver/WebDriverService.h:
* Source/WebDriver/WebSocketServer.cpp:
(WebDriver::WebSocketServer::sendMessage): Added helpers around getting
the connection for a given SessionId.
(WebDriver::WebSocketServer::sendErrorResponse): Ditto.
* Source/WebDriver/WebSocketServer.h:
* Source/WebDriver/soup/WebSocketServerSoup.cpp:
(WebDriver::WebSocketServer::sendMessage): No need to iterate the
available sessions.
* Source/WebKit/UIProcess/Automation/Automation.json: Removed deprecated
  logEntryAdded event, relying on bidiMessageSent instead.
* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::logEntryAdded): Ditto.
* Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.cpp:
(WebKit::toBiDiErrorCode): Added, to help translate our inspector-based
errors into BiDi errors.
(WebKit::WebDriverBidiProcessor::sendBidiMessage): Add "type" field in
bidi message and translate the error message to BiDi ErrorResponse
production.
* WebDriverTests/TestExpectations.json: Drive-by gardening of W3C BiDi
  tests.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to