Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 17a80254d05ddb1a135e4357b1fa812539652ff0
      
https://github.com/WebKit/WebKit/commit/17a80254d05ddb1a135e4357b1fa812539652ff0
  Author: Serge Deh <[email protected]>
  Date:   2026-04-08 (Wed, 08 Apr 2026)

  Changed paths:
    M Source/WebKit/UIProcess/Automation/Automation.json
    M Source/WebKit/UIProcess/Automation/BidiScriptAgent.cpp
    M Source/WebKit/UIProcess/Automation/BidiScriptAgent.h
    M Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
    M Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.cpp
    M Source/WebKit/UIProcess/Automation/protocol/BidiScript.json
    M WebDriverTests/TestExpectations.json

  Log Message:
  -----------
  [WebDriver BiDi] Add preload script support in the UIProcess
https://bugs.webkit.org/show_bug.cgi?id=288057

Reviewed by BJ Burg.

Add the initial UIProcess implementation for `script.addPreloadScript` and
`script.removePreloadScript`.

This patch adds the BiDi protocol entries, preload script storage and
identifier handling, basic parameter validation, and execution hooks for new
document creation. It also wires `NoSuchScript` through the Automation error
enum so invalid preload script removals map to the correct BiDi error.

`userContexts` and `contexts` are now validated and used to filter preload
script execution. Preload script arguments are deserialized from supported
BiDi `LocalValue` forms before evaluation.

Sandbox realm execution, channel / remote reference argument handling, and
resource limits remain follow-up work.

* Source/WebKit/UIProcess/Automation/protocol/BidiScript.json:
Add `addPreloadScript` and `removePreloadScript`. Extend
`addPreloadScript` with `arguments`, `contexts`, `sandbox`, and
`userContexts` parameters.

* Source/WebKit/UIProcess/Automation/Automation.json:
Add `NoSuchScript` to the Automation error enum.

* Source/WebKit/UIProcess/Automation/BidiScriptAgent.h:
Add preload script command handlers, `PreloadScriptIdentifier`,
`PreloadScriptInfo`, and storage for ordered preload script metadata.

* Source/WebKit/UIProcess/Automation/BidiScriptAgent.cpp:
(WebKit::BidiScriptAgent::addPreloadScript): Validate and store preload script
metadata and generate script identifiers.
(WebKit::BidiScriptAgent::removePreloadScript): Remove stored preload scripts
by identifier and return `NoSuchScript` for unknown ids.
(WebKit::BidiScriptAgent::executePreloadScriptsForContext): Filter preload
scripts by browsing context and user context, deserialize supported
`LocalValue` arguments, and execute matching scripts.

* Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::navigationCommittedForFrame): Execute preload
scripts when navigation commits a new document.
(WebKit::WebAutomationSession::fragmentNavigatedForFrame): Document that
fragment navigations do not create a new document and therefore do not trigger
preload scripts.

* Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.h:
Expose `scriptAgent()` for preload script execution.

* Source/WebKit/UIProcess/Automation/WebDriverBidiProcessor.cpp:
(WebKit::toBidiErrorCode): Map `NoSuchScript` to the corresponding BiDi error
code.

* WebDriverTests/TestExpectations.json:
Update preload-script expectations to reflect the new preload script coverage,
including `PASS` overrides for subtests that now succeed and expected `FAIL`
entries for behavior still deferred to follow-up work.

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



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

Reply via email to