Skip to content

[dotnet] [bidi] Add UserContext in event args#17100

Merged
nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-usercontext-events
Feb 18, 2026
Merged

[dotnet] [bidi] Add UserContext in event args#17100
nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-usercontext-events

Conversation

@nvborisenko
Copy link
Member

Adds support for tracking and handling UserContext information across various BiDi (Browser Automation) event argument and info classes. The main focus is on ensuring that user context data is available in relevant event records, improving context-awareness throughout the WebDriver BiDi implementation.

💡 Additional Considerations

Optional for now, tracking w3c/webdriver-bidi#1071

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

Copilot AI review requested due to automatic review settings February 17, 2026 21:52
@selenium-ci selenium-ci added the C-dotnet .NET Bindings label Feb 17, 2026
@qodo-code-review
Copy link
Contributor

PR Type

Enhancement


Description

  • Add UserContext property to BiDi event args and info classes

  • Update browsing context, input, and script modules with user context support

  • Enhance event tracking with user context information across multiple event types

  • Reorder parameters in user prompt event args for consistency


File Walkthrough

Relevant files
Enhancement
10 files
CreateCommand.cs
Add UserContext to CreateResult record                                     
+1/-1     
HistoryUpdatedEventArgs.cs
Add UserContext parameter to event args                                   
+1/-1     
NavigationInfo.cs
Add UserContext parameter to navigation info                         
+1/-1     
UserPromptClosedEventArgs.cs
Add UserContext and Type to event args                                     
+1/-1     
UserPromptOpenedEventArgs.cs
Add UserContext and reorder parameters                                     
+1/-1     
FileDialogInfo.cs
Add UserContext parameter to file dialog info                       
+1/-1     
InputModule.cs
Register BrowserUserContextConverter for deserialization 
+1/-0     
LogModule.cs
Register BrowserUserContextConverter for deserialization 
+1/-0     
RealmInfo.cs
Add UserContext property to WindowRealmInfo                           
+2/-0     
Source.cs
Add UserContext property to Source record                               
+2/-0     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 17, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #1071
🔴 Remove the deprecation of Actions.pause() (i.e., stop marking it as deprecated / stop
emitting deprecation warnings).
Change the deprecation warning/note into normal documentation (e.g., JavaDoc) that
explains the concerns without deprecating the API.
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 17, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect parameter order in constructor

Restore the original parameter order for Message and Type in the
UserPromptOpenedEventArgs constructor to prevent a breaking change and align
with the specification.

dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptOpenedEventArgs.cs [25-26]

-public sealed record UserPromptOpenedEventArgs(BrowsingContext Context, Session.UserPromptHandlerType Handler, string Message, UserPromptType Type, Browser.UserContext? UserContext, string? DefaultValue)
+public sealed record UserPromptOpenedEventArgs(BrowsingContext Context, Session.UserPromptHandlerType Handler, UserPromptType Type, string Message, Browser.UserContext? UserContext, string? DefaultValue)
     : EventArgs;
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that the PR introduces a breaking change by swapping constructor parameters, and the proposed fix restores the correct order, preventing potential bugs for consumers of this record.

Medium
Move property to primary constructor

Move the UserContext property into the primary constructor of the
WindowRealmInfo record to ensure consistent and reliable JSON deserialization.

dotnet/src/webdriver/BiDi/Script/RealmInfo.cs [39-44]

-public sealed record WindowRealmInfo(Realm Realm, string Origin, BrowsingContext.BrowsingContext Context) : RealmInfo(Realm, Origin)
+public sealed record WindowRealmInfo(Realm Realm, string Origin, BrowsingContext.BrowsingContext Context, Browser.UserContext? UserContext) : RealmInfo(Realm, Origin)
 {
-    public Browser.UserContext? UserContext { get; init; }
-    
     public string? Sandbox { get; init; }
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: This is a good suggestion that improves code consistency and serialization robustness by moving the new UserContext property into the primary constructor, which is a best practice for C# records.

Low
Move properties to primary constructor

Move the Context and UserContext properties into the primary constructor of the
Source record for improved consistency and reliable JSON deserialization.

dotnet/src/webdriver/BiDi/Script/Source.cs [22-27]

-public sealed record Source(Realm Realm)
-{
-    public BrowsingContext.BrowsingContext? Context { get; init; }
+public sealed record Source(Realm Realm, BrowsingContext.BrowsingContext? Context, Browser.UserContext? UserContext);
 
-    public Browser.UserContext? UserContext { get; init; }
-}
-
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: This suggestion correctly points out an inconsistency and potential serialization issue, proposing to move properties to the primary constructor, which improves code quality and robustness.

Low
  • Update

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds UserContext support across various BiDi event arguments and information classes to improve context-awareness throughout the WebDriver BiDi implementation. The changes track an optional W3C WebDriver BiDi specification evolution (issue #1071).

Changes:

  • Added UserContext property to Script module classes (Source, WindowRealmInfo)
  • Added UserContext parameter to BrowsingContext event args (UserPromptOpened, UserPromptClosed, NavigationInfo, HistoryUpdatedEventArgs)
  • Added UserContext to Input module (FileDialogInfo)
  • Added UserContext to CreateCommand result
  • Registered BrowserUserContextConverter in LogModule and InputModule for JSON deserialization

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dotnet/src/webdriver/BiDi/Script/Source.cs Added optional UserContext property as init-only
dotnet/src/webdriver/BiDi/Script/RealmInfo.cs Added optional UserContext property to WindowRealmInfo
dotnet/src/webdriver/BiDi/Log/LogModule.cs Registered BrowserUserContextConverter for deserialization
dotnet/src/webdriver/BiDi/Input/InputModule.cs Registered BrowserUserContextConverter for deserialization
dotnet/src/webdriver/BiDi/Input/FileDialogInfo.cs Added UserContext as constructor parameter (breaking change)
dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptOpenedEventArgs.cs Added UserContext and reordered parameters (breaking change)
dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptClosedEventArgs.cs Added UserContext and Type parameters mid-list (breaking change)
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs Added UserContext at end of parameter list
dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs Added UserContext at end of parameter list
dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs Added UserContext to CreateResult

@nvborisenko nvborisenko merged commit 6d0c57e into SeleniumHQ:trunk Feb 18, 2026
19 checks passed
@nvborisenko nvborisenko deleted the bidi-usercontext-events branch February 18, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments