Skip to content

[dotnet] [bidi] Revise event args#17304

Merged
nvborisenko merged 28 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-event-args-up
Apr 5, 2026
Merged

[dotnet] [bidi] Revise event args#17304
nvborisenko merged 28 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-event-args-up

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

@nvborisenko nvborisenko commented Apr 5, 2026

New pattern detected

browsingContext.ContextCreated = (
 method: "browsingContext.contextCreated",
 params: browsingContext.Info
)

Transforms to:

  • ContextCreatedEventArgs - non-serializable top-level public type.
  • Info serializable, might be internal - doesn't matter.

Why

Normalizes all event args, name is the same as its declaration. Still safe at compilation level, any change in high/low level shows affected areas.

🔗 Related Issues

Contributes to #16095

💥 What does this PR do?

This pull request refactors the event subscription and dispatching mechanism in the BiDi (Bidirectional) WebDriver implementation, focusing on improving type safety, extensibility, and maintainability. The main changes include updating event handler signatures to use more specific event argument types, overhauling the Broker class's subscription methods, and introducing a new event metadata management approach.

Event Subscription and Dispatching Improvements:

  • The Broker class now manages event metadata using a new EventMetadata record, enabling more flexible and type-safe event argument creation. Subscription methods have been refactored to support generic event argument and parameter types, and to simplify handler registration and unregistration. [1] [2] [3] [4] [5]

  • The EventDispatcher is now instantiated without a session provider, reflecting the new event handling structure. [1] [2]

Event Handler Type Safety:

  • All event handler methods in BrowsingContext.cs have been updated to use specific event argument types (e.g., NavigationStartedEventArgs, FragmentNavigatedEventArgs, DomContentLoadedEventArgs, etc.) instead of the generic NavigationEventArgs. This improves type safety and clarity for consumers of these APIs. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

  • The corresponding private handler methods in BrowsingContext.cs have also been updated to accept and process the new specific event argument types. [1] [2]

These changes collectively make the event subscription API more robust, easier to use, and less error-prone by leveraging strong typing and modern C# features.

🔧 Implementation Notes

This is good new abstraction for .NET world. Moreover in future we can easily introduce [JsonAdditionalData] IReadOnly.

I should mention:

  • reverted events deserialization to message processing loop in Broker (performance downgrade, but it is ok). We will think about it in details later.
  • fixed strange BiDi hydration for event args

🔄 Types of changes

  • Cleanup (formatting, renaming)

@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

[dotnet] [BiDi] Refactor event subscription with type-safe event arguments and factory pattern

✨ Enhancement

Grey Divider

Walkthroughs

Description
  Comprehensive refactoring of the BiDi event subscription and dispatching mechanism to improve type
  safety, extensibility, and maintainability:
  * **Event Subscription Architecture**: Refactored Broker class to use a new EventMetadata record
  pattern, enabling flexible and type-safe event argument creation through factory functions instead
  of direct type references.
  * **Type-Safe Event Arguments**: Introduced specific, non-serializable public event argument types
  for all BiDi events (e.g., ContextCreatedEventArgs, NavigationStartedEventArgs,
  FragmentNavigatedEventArgs, EntryAddedEventArgs, RealmCreatedEventArgs,
  FileDialogOpenedEventArgs), replacing generic base types and preventing future breaking changes.
  * **Polymorphic Deserialization**: Implemented custom JSON converters (LogEntryConverter,
  DownloadEndParamsConverter, RealmInfoConverter, RemoteValueConverter,
  EvaluateResultConverter) for proper handling of polymorphic event parameter types during
  deserialization.
  * **Constructor-Based Dependency Injection**: Updated all event argument types to accept IBiDi
  parameter through constructor injection, simplifying the event args base class and removing lazy
  initialization logic.
  * **Simplified EventDispatcher**: Removed subscription logic and session provider dependency from
  EventDispatcher, delegating to Broker for metadata management and using `Func<EventArgs,
  ValueTask>` delegates for handler management.
  * **Factory Method Pattern**: Added factory methods in all module classes (BrowsingContextModule,
  NetworkModule, ScriptModule, LogModule, InputModule, SpeculationModule) to construct typed
  event arguments from deserialized parameters.
  * **Consistent Naming**: Renamed event argument types to match their event names (e.g.,
  LogEntryEventArgsEntryAddedEventArgs, FileDialogEventArgsFileDialogOpenedEventArgs,
  RealmInfoEventArgsRealmCreatedEventArgs).
  * **Test Updates**: Updated all BiDi tests to use new event argument types and verify correct event
  handling with the refactored architecture.

Grey Divider

File Changes

1. dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs ✨ Enhancement +87/-55

Refactor event handlers with specific typed event arguments

• Updated event handler signatures to use specific event argument types instead of generic
 NavigationEventArgs and BrowsingContextEventArgs
• Added factory methods (CreateNavigationStartedEventArgs, CreateFragmentNavigatedEventArgs,
 etc.) to construct typed event args from parameters
• Modified SubscribeAsync calls to pass factory methods and parameter types instead of event args
 types
• Updated JsonSerializable attributes to reference parameter types instead of event args types

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs


2. dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs ✨ Enhancement +28/-28

Update event handler signatures with specific event types

• Updated event handler method signatures to use specific event argument types
 (NavigationStartedEventArgs, FragmentNavigatedEventArgs, etc.)
• Updated internal handler methods to accept and process specific event argument types
• Maintained context filtering logic for event routing

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs


3. dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs ✨ Enhancement +18/-18

Update interface signatures with specific event types

• Updated interface method signatures to use specific event argument types instead of generic base
 types
• Changed NavigationEventArgs to NavigationStartedEventArgs, FragmentNavigatedEventArgs,
 DomContentLoadedEventArgs, LoadEventArgs, etc.
• Changed BrowsingContextEventArgs to ContextCreatedEventArgs and ContextDestroyedEventArgs

dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs


View more (64)
4. dotnet/src/webdriver/BiDi/Broker.cs ✨ Enhancement +40/-9

Implement event metadata and factory pattern for event args

• Refactored SubscribeAsync methods to accept factory functions for creating typed event args from
 parameters
• Introduced EventMetadata record to store JSON type info and event args factory functions
• Removed dependency on IBiDi interface, changed to concrete BiDi type
• Simplified EventDispatcher instantiation by removing session provider parameter
• Updated event processing to use metadata-based factory pattern for creating event args

dotnet/src/webdriver/BiDi/Broker.cs


5. dotnet/src/webdriver/BiDi/Network/NetworkModule.cs ✨ Enhancement +30/-15

Add factory methods for network event args creation

• Updated event subscription methods to use factory methods for creating typed event args
• Added factory methods (CreateBeforeRequestSentEventArgs, CreateResponseStartedEventArgs, etc.)
• Updated JsonSerializable attributes to reference parameter types instead of event args types

dotnet/src/webdriver/BiDi/Network/NetworkModule.cs


6. dotnet/src/webdriver/BiDi/EventDispatcher.cs ✨ Enhancement +19/-46

Simplify EventDispatcher by removing subscription logic

• Removed session provider dependency and subscription logic from dispatcher
• Simplified handler management with AddHandler and RemoveHandler methods
• Changed from EventHandler objects to Func<EventArgs, ValueTask> delegates
• Removed TryGetJsonTypeInfo method as metadata is now managed in Broker
• Renamed EventRegistration to HandlerRegistration and simplified its structure

dotnet/src/webdriver/BiDi/EventDispatcher.cs


7. dotnet/src/webdriver/BiDi/Script/ScriptModule.cs ✨ Enhancement +29/-21

Add factory methods for script event args creation

• Updated event subscription methods to use factory methods for creating typed event args
• Changed RealmInfoEventArgs to RealmCreatedEventArgs with specific subtype factories
• Added factory method for RealmCreatedEventArgs with polymorphic type handling
• Updated JsonSerializable attributes to reference parameter types

dotnet/src/webdriver/BiDi/Script/ScriptModule.cs


8. dotnet/src/webdriver/BiDi/Log/EntryAddedEventArgs.cs ✨ Enhancement +131/-0

Create typed log entry event args with polymorphic support

• Created new abstract base record EntryAddedEventArgs with specific subclasses for different log
 entry types
• Added LogEntry internal record hierarchy for deserialization
• Implemented LogEntryConverter for polymorphic JSON deserialization

dotnet/src/webdriver/BiDi/Log/EntryAddedEventArgs.cs


9. dotnet/src/webdriver/BiDi/Script/RealmInfo.cs ✨ Enhancement +56/-10

Add polymorphic converter for RealmInfo deserialization

• Added RealmInfoConverter class for polymorphic JSON deserialization based on type
 discriminator
• Improved formatting of record declarations with multi-line parameters

dotnet/src/webdriver/BiDi/Script/RealmInfo.cs


10. dotnet/src/webdriver/BiDi/Script/RealmInfoEventArgs.cs ✨ Enhancement +40/-23

Rename and refactor realm event args with BiDi parameter

• Renamed RealmInfoEventArgs to RealmCreatedEventArgs with IBiDi parameter
• Renamed all subclasses from *RealmInfoEventArgs to *RealmCreatedEventArgs
• Updated all subclasses to include IBiDi parameter in constructors

dotnet/src/webdriver/BiDi/Script/RealmInfoEventArgs.cs


11. dotnet/src/webdriver/BiDi/BrowsingContext/DownloadEndEventArgs.cs ✨ Enhancement +60/-10

Create typed download event args with polymorphic support

• Created public abstract DownloadEndEventArgs base class with IBiDi parameter
• Created public DownloadCanceledEventArgs and DownloadCompleteEventArgs subclasses
• Created internal DownloadEndParams hierarchy for deserialization
• Implemented DownloadEndParamsConverter for polymorphic JSON deserialization

dotnet/src/webdriver/BiDi/BrowsingContext/DownloadEndEventArgs.cs


12. dotnet/src/webdriver/BiDi/Script/RemoteValue.cs ✨ Enhancement +51/-1

Add polymorphic converter for RemoteValue deserialization

• Added RemoteValueConverter class for polymorphic JSON deserialization of remote values
• Handles all remote value types with type discriminator pattern

dotnet/src/webdriver/BiDi/Script/RemoteValue.cs


13. dotnet/src/webdriver/BiDi/Log/LogModule.cs ✨ Enhancement +17/-11

Add factory method for log entry event args creation

• Updated event subscription methods to use factory methods for creating typed event args
• Changed LogEntryEventArgs to EntryAddedEventArgs with polymorphic factory
• Updated JsonSerializable attributes to reference internal parameter types

dotnet/src/webdriver/BiDi/Log/LogModule.cs


14. dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs ✨ Enhancement +42/-8

Add polymorphic converter for EvaluateResult deserialization

• Added EvaluateResultConverter for polymorphic JSON deserialization of evaluate results
• Improved formatting of record declarations with multi-line parameters
• Removed StringSyntax attribute from Expression parameter

dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs


15. dotnet/src/webdriver/BiDi/Input/InputModule.cs ✨ Enhancement +11/-5

Add factory method for file dialog event args creation

• Updated event subscription methods to use factory method for creating typed event args
• Changed FileDialogEventArgs to FileDialogOpenedEventArgs with IBiDi parameter
• Updated JsonSerializable attributes to reference parameter types

dotnet/src/webdriver/BiDi/Input/InputModule.cs


16. dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs ✨ Enhancement +4/-4

Update file dialog event handler signatures

• Updated event handler signatures to use FileDialogOpenedEventArgs instead of
 FileDialogEventArgs
• Updated internal handler methods to accept the new event args type

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs


17. dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs ✨ Enhancement +4/-4

Update log entry event handler signatures

• Updated event handler signatures to use EntryAddedEventArgs instead of LogEntryEventArgs
• Updated internal handler methods to accept the new event args type

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs


18. dotnet/src/webdriver/BiDi/Module.cs ✨ Enhancement +4/-6

Refactor Module subscription methods with factory pattern

• Updated SubscribeAsync method signatures to accept factory functions for creating typed event
 args
• Removed SyncEventHandler and AsyncEventHandler wrapper objects
• Simplified subscription logic by delegating to Broker with factory functions

dotnet/src/webdriver/BiDi/Module.cs


19. dotnet/test/webdriver/BiDi/Log/LogTests.cs 🧪 Tests +6/-6

Update log tests with new event args types

• Updated test assertions to use EntryAddedEventArgs instead of LogEntryEventArgs
• Updated type checks to use ConsoleEntryAddedEventArgs and JavascriptEntryAddedEventArgs

dotnet/test/webdriver/BiDi/Log/LogTests.cs


20. dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs ✨ Enhancement +6/-3

Add factory method for speculation event args creation

• Updated event subscription methods to use factory method for creating typed event args
• Added factory method CreatePrefetchStatusUpdatedEventArgs
• Updated JsonSerializable attributes to reference parameter types

dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs


21. dotnet/src/webdriver/BiDi/Network/AuthRequiredEventArgs.cs ✨ Enhancement +24/-2

Update AuthRequiredEventArgs with BiDi and UserContext

• Updated AuthRequiredEventArgs to include IBiDi and UserContext parameters
• Created internal AuthRequiredParameters record for deserialization
• Changed base class from BaseParametersEventArgs to EventArgs

dotnet/src/webdriver/BiDi/Network/AuthRequiredEventArgs.cs


22. dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptOpenedEventArgs.cs ✨ Enhancement +16/-13

Update UserPromptOpenedEventArgs with BiDi parameter

• Updated UserPromptOpenedEventArgs to include IBiDi parameter and inherit from
 EventArgs(BiDi)
• Created internal UserPromptOpenedParameters record for deserialization
• Moved UserPromptType enum to separate file

dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptOpenedEventArgs.cs


23. dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEventArgs.cs ✨ Enhancement +23/-2

Update BeforeRequestSentEventArgs with BiDi and UserContext

• Updated BeforeRequestSentEventArgs to include IBiDi and UserContext parameters
• Created internal BeforeRequestSentParameters record for deserialization
• Changed base class from BaseParametersEventArgs to EventArgs

dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEventArgs.cs


24. dotnet/src/webdriver/BiDi/Network/FetchErrorEventArgs.cs ✨ Enhancement +24/-2

Update FetchErrorEventArgs with BiDi and UserContext

• Updated FetchErrorEventArgs to include IBiDi and UserContext parameters
• Created internal FetchErrorParameters record for deserialization
• Changed base class from BaseParametersEventArgs to EventArgs

dotnet/src/webdriver/BiDi/Network/FetchErrorEventArgs.cs


25. dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptType.cs Refactoring +13/-4

Extract UserPromptType enum to separate file

• Moved UserPromptType enum from UserPromptOpenedEventArgs.cs to dedicated file
• Added CamelCaseEnumConverter attribute for JSON serialization

dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptType.cs


26. dotnet/src/webdriver/BiDi/BrowsingContext/DomContentLoadedEventArgs.cs ✨ Enhancement +3/-3

Create DomContentLoadedEventArgs event type

• Created new DomContentLoadedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/DomContentLoadedEventArgs.cs


27. dotnet/src/webdriver/BiDi/Network/BaseParameters.cs Refactoring +10/-3

Rename and refactor BaseParameters record

• Renamed from BaseParametersEventArgs to BaseParameters
• Added UserContext parameter to the record
• Changed from public to internal visibility

dotnet/src/webdriver/BiDi/Network/BaseParameters.cs


28. dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs Refactoring +9/-2

Rename BrowsingContextInfo to Info

• Renamed from BrowsingContextInfo to Info
• Updated record to use self-referential type for Children property

dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs


29. dotnet/src/webdriver/BiDi/Input/FileDialogOpenedEventArgs.cs ✨ Enhancement +34/-0

Create FileDialogOpenedEventArgs event type

• Created new FileDialogOpenedEventArgs record with IBiDi parameter
• Created internal FileDialogInfo record for deserialization

dotnet/src/webdriver/BiDi/Input/FileDialogOpenedEventArgs.cs


30. dotnet/src/webdriver/BiDi/Script/IScriptModule.cs ✨ Enhancement +2/-2

Update IScriptModule interface with RealmCreatedEventArgs

• Updated interface method signatures to use RealmCreatedEventArgs instead of RealmInfoEventArgs

dotnet/src/webdriver/BiDi/Script/IScriptModule.cs


31. dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEventArgs.cs ✨ Enhancement +30/-0

Create ContextCreatedEventArgs event type

• Created new ContextCreatedEventArgs record with IBiDi parameter
• Includes browsing context information properties

dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEventArgs.cs


32. dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEventArgs.cs ✨ Enhancement +28/-0

Create ContextDestroyedEventArgs event type

• Created new ContextDestroyedEventArgs record with IBiDi parameter
• Includes browsing context information properties

dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEventArgs.cs


33. dotnet/src/webdriver/BiDi/BrowsingContext/FragmentNavigatedEventArgs.cs ✨ Enhancement +23/-0

Create FragmentNavigatedEventArgs event type

• Created new FragmentNavigatedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/FragmentNavigatedEventArgs.cs


34. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationAbortedEventArgs.cs ✨ Enhancement +23/-0

Create NavigationAbortedEventArgs event type

• Created new NavigationAbortedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationAbortedEventArgs.cs


35. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationCommittedEventArgs.cs ✨ Enhancement +23/-0

Create NavigationCommittedEventArgs event type

• Created new NavigationCommittedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationCommittedEventArgs.cs


36. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationFailedEventArgs.cs ✨ Enhancement +23/-0

Create NavigationFailedEventArgs event type

• Created new NavigationFailedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationFailedEventArgs.cs


37. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationStartedEventArgs.cs ✨ Enhancement +23/-0

Create NavigationStartedEventArgs event type

• Created new NavigationStartedEventArgs record inheriting from NavigationEventArgs
• Includes IBiDi parameter and navigation-related properties

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationStartedEventArgs.cs


38. dotnet/src/webdriver/BiDi/BrowsingContext/DownloadWillBeginEventArgs.cs ✨ Enhancement +16/-2

Update DownloadWillBeginEventArgs with BiDi parameter

• Updated DownloadWillBeginEventArgs to include IBiDi parameter
• Created internal DownloadWillBeginParams record for deserialization

dotnet/src/webdriver/BiDi/BrowsingContext/DownloadWillBeginEventArgs.cs


39. dotnet/src/webdriver/BiDi/EventArgs.cs ✨ Enhancement +1/-13

Refactor EventArgs to use constructor-based IBiDi injection

• Simplified EventArgs base class from property-based to constructor-based pattern
• Removed JsonIgnore attribute and lazy initialization logic
• Changed to accept IBiDi parameter directly in constructor
• Removed System.Text.Json.Serialization using statement

dotnet/src/webdriver/BiDi/EventArgs.cs


40. dotnet/src/webdriver/BiDi/BrowsingContext/LoadEventArgs.cs ✨ Enhancement +23/-0

Add LoadEventArgs event argument type

• Created new LoadEventArgs sealed record inheriting from NavigationEventArgs
• Includes IBiDi, BrowsingContext, Navigation, Timestamp, Url, and UserContext
 parameters
• Follows new event args pattern with constructor-based IBiDi injection

dotnet/src/webdriver/BiDi/BrowsingContext/LoadEventArgs.cs


41. dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptClosedEventArgs.cs ✨ Enhancement +15/-2

Update UserPromptClosedEventArgs with IBiDi parameter

• Added IBiDi parameter to UserPromptClosedEventArgs record
• Changed base class from EventArgs to EventArgs(BiDi) with constructor injection
• Created internal UserPromptClosedParameters record for deserialization
• Reformatted parameters across multiple lines for readability

dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptClosedEventArgs.cs


42. dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs ✨ Enhancement +13/-2

Update HistoryUpdatedEventArgs with IBiDi parameter

• Added IBiDi parameter to HistoryUpdatedEventArgs record
• Changed base class to EventArgs(BiDi) with constructor injection
• Created internal HistoryUpdatedParameters record for deserialization
• Reformatted parameters across multiple lines

dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs


43. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationEventArgs.cs ✨ Enhancement +2/-2

Update NavigationEventArgs with IBiDi parameter

• Changed from sealed to non-sealed record to allow inheritance
• Added IBiDi parameter as first parameter
• Updated base class to EventArgs(BiDi) with constructor injection

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationEventArgs.cs


44. dotnet/src/webdriver/BiDi/Network/ResponseCompletedEventArgs.cs ✨ Enhancement +15/-1

Refactor ResponseCompletedEventArgs with IBiDi and UserContext

• Added IBiDi parameter to ResponseCompletedEventArgs record
• Added UserContext parameter to event args
• Changed base class from BaseParametersEventArgs to EventArgs(BiDi)
• Created internal ResponseCompletedParameters record for deserialization

dotnet/src/webdriver/BiDi/Network/ResponseCompletedEventArgs.cs


45. dotnet/src/webdriver/BiDi/Network/ResponseStartedEventArgs.cs ✨ Enhancement +15/-1

Refactor ResponseStartedEventArgs with IBiDi and UserContext

• Added IBiDi parameter to ResponseStartedEventArgs record
• Added UserContext parameter to event args
• Changed base class from BaseParametersEventArgs to EventArgs(BiDi)
• Created internal ResponseStartedParameters record for deserialization

dotnet/src/webdriver/BiDi/Network/ResponseStartedEventArgs.cs


46. dotnet/src/webdriver/BiDi/Script/MessageEventArgs.cs ✨ Enhancement +10/-1

Update MessageEventArgs with IBiDi parameter

• Added IBiDi parameter to MessageEventArgs record
• Updated base class to EventArgs(BiDi) with constructor injection
• Created internal MessageParameters record for deserialization
• Reformatted parameters across multiple lines

dotnet/src/webdriver/BiDi/Script/MessageEventArgs.cs


47. dotnet/src/webdriver/BiDi/Script/RealmDestroyedEventArgs.cs ✨ Enhancement +5/-1

Update RealmDestroyedEventArgs with IBiDi parameter

• Added IBiDi parameter to RealmDestroyedEventArgs record
• Updated base class to EventArgs(BiDi) with constructor injection
• Created internal RealmDestroyedParameters record for deserialization
• Reformatted parameters across multiple lines

dotnet/src/webdriver/BiDi/Script/RealmDestroyedEventArgs.cs


48. dotnet/src/webdriver/BiDi/Speculation/PrefetchStatusUpdatedEventArgs.cs ✨ Enhancement +11/-2

Update PrefetchStatusUpdatedEventArgs with IBiDi parameter

• Added IBiDi parameter to PrefetchStatusUpdatedEventArgs record
• Updated base class to EventArgs(BiDi) with constructor injection
• Created internal PrefetchStatusUpdatedParameters record for deserialization
• Reformatted parameters across multiple lines

dotnet/src/webdriver/BiDi/Speculation/PrefetchStatusUpdatedEventArgs.cs


49. dotnet/src/webdriver/BiDi/Subscription.cs ✨ Enhancement +8/-6

Refactor Subscription to use Broker pattern

• Changed internal field from _eventDispatcher to _broker
• Updated constructor to accept Broker and eventName instead of EventDispatcher and
 EventHandler
• Replaced EventHandler property with EventName string property
• Added Handler property of type Func<EventArgs, ValueTask>
• Updated UnsubscribeAsync to call _broker.UnsubscribeAsync

dotnet/src/webdriver/BiDi/Subscription.cs


50. dotnet/src/webdriver/BiDi/BiDi.cs ✨ Enhancement +1/-1

Simplify Broker instantiation in BiDi class

• Removed session provider lambda from Broker constructor
• Changed from new Broker(transport, bidi, () => bidi.Session) to new Broker(transport, bidi)

dotnet/src/webdriver/BiDi/BiDi.cs


51. dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs ✨ Enhancement +1/-1

Update GetTreeResult to use Info type

• Changed GetTreeResult record to use Info type instead of BrowsingContextInfo
• Maintains same parameter structure with updated type name

dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs


52. dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs Formatting +6/-1

Reformat NavigationInfo parameters

• Reformatted NavigationInfo record parameters across multiple lines
• No functional changes to the record definition

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs


53. dotnet/src/webdriver/BiDi/Input/IInputModule.cs ✨ Enhancement +2/-2

Rename FileDialogEventArgs to FileDialogOpenedEventArgs

• Renamed event argument type from FileDialogEventArgs to FileDialogOpenedEventArgs
• Updated both async overloads (Func and Action variants)

dotnet/src/webdriver/BiDi/Input/IInputModule.cs


54. dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs ✨ Enhancement +2/-2

Rename FileDialogEventArgs to FileDialogOpenedEventArgs

• Renamed event argument type from FileDialogEventArgs to FileDialogOpenedEventArgs
• Updated both async overloads (Func and Action variants)

dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs


55. dotnet/src/webdriver/BiDi/Log/ILogModule.cs ✨ Enhancement +2/-2

Rename LogEntryEventArgs to EntryAddedEventArgs

• Renamed event argument type from LogEntryEventArgs to EntryAddedEventArgs
• Updated both async overloads (Func and Action variants)

dotnet/src/webdriver/BiDi/Log/ILogModule.cs


56. dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextLogModule.cs ✨ Enhancement +2/-2

Rename LogEntryEventArgs to EntryAddedEventArgs

• Renamed event argument type from LogEntryEventArgs to EntryAddedEventArgs
• Updated both async overloads (Func and Action variants)

dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextLogModule.cs


57. dotnet/test/webdriver/BiDi/Script/ScriptEventsTests.cs 🧪 Tests +2/-2

Update test to use RealmCreatedEventArgs type

• Changed TaskCompletionSource type from RealmInfoEventArgs to RealmCreatedEventArgs
• Updated assertion to check for WindowRealmCreatedEventArgs instead of WindowRealmInfoEventArgs

dotnet/test/webdriver/BiDi/Script/ScriptEventsTests.cs


58. dotnet/test/webdriver/BiDi/Input/InputEventsTests.cs 🧪 Tests +1/-1

Update test to use FileDialogOpenedEventArgs type

• Changed TaskCompletionSource type from FileDialogEventArgs to FileDialogOpenedEventArgs

dotnet/test/webdriver/BiDi/Input/InputEventsTests.cs


59. dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs 🧪 Tests +1/-1

Update test to use EntryAddedEventArgs type

• Changed TaskCompletionSource type from LogEntryEventArgs to EntryAddedEventArgs

dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs


60. dotnet/src/webdriver/BiDi/EventHandler.cs Additional files +0/-51

...

dotnet/src/webdriver/BiDi/EventHandler.cs


61. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/DownloadEndEventArgsConverter.cs Additional files +0/-43

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/DownloadEndEventArgsConverter.cs


62. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/EvaluateResultConverter.cs Additional files +0/-43

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/EvaluateResultConverter.cs


63. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/LogEntryEventArgsConverter.cs Additional files +0/-43

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/LogEntryEventArgsConverter.cs


64. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoConverter.cs Additional files +0/-49

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoConverter.cs


65. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoEventArgsConverter.cs Additional files +0/-49

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoEventArgsConverter.cs


66. dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RemoteValueConverter.cs Additional files +0/-72

...

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RemoteValueConverter.cs


67. dotnet/src/webdriver/BiDi/Log/LogEntryEventArgs.cs Additional files +0/-54

...

dotnet/src/webdriver/BiDi/Log/LogEntryEventArgs.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 5, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Action required

1. IBrowsingContextModule handler types changed 📘 Rule violation ≡ Correctness
Description
Multiple public interfaces changed event subscription method signatures (e.g., NavigationEventArgs
to NavigationStartedEventArgs, LogEntryEventArgs to EntryAddedEventArgs), which is a breaking
API/ABI change for consumers. These removals/renames were not deprecated and no compatibility
overloads are provided.
Code

dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs[R32-55]

+    Task<Subscription> OnContextCreatedAsync(Func<ContextCreatedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnContextCreatedAsync(Action<ContextCreatedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnContextDestroyedAsync(Func<ContextDestroyedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnContextDestroyedAsync(Action<ContextDestroyedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnDomContentLoadedAsync(Func<DomContentLoadedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnDomContentLoadedAsync(Action<DomContentLoadedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnDownloadEndAsync(Func<DownloadEndEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnDownloadEndAsync(Action<DownloadEndEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnDownloadWillBeginAsync(Func<DownloadWillBeginEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnDownloadWillBeginAsync(Action<DownloadWillBeginEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnFragmentNavigatedAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnFragmentNavigatedAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnFragmentNavigatedAsync(Func<FragmentNavigatedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnFragmentNavigatedAsync(Action<FragmentNavigatedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnHistoryUpdatedAsync(Func<HistoryUpdatedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
    Task<Subscription> OnHistoryUpdatedAsync(Action<HistoryUpdatedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnLoadAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnLoadAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationAbortedAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationAbortedAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationCommittedAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationCommittedAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationFailedAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationFailedAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationStartedAsync(Func<NavigationEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
-    Task<Subscription> OnNavigationStartedAsync(Action<NavigationEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnLoadAsync(Func<LoadEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnLoadAsync(Action<LoadEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationAbortedAsync(Func<NavigationAbortedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationAbortedAsync(Action<NavigationAbortedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationCommittedAsync(Func<NavigationCommittedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationCommittedAsync(Action<NavigationCommittedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationFailedAsync(Func<NavigationFailedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationFailedAsync(Action<NavigationFailedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationStartedAsync(Func<NavigationStartedEventArgs, Task> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
+    Task<Subscription> OnNavigationStartedAsync(Action<NavigationStartedEventArgs> handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default);
Evidence
The checklist requires maintaining backward-compatible public APIs (ID 15) and deprecating before
removal (ID 22). The diff shows direct signature replacements in public interfaces (breaking change)
and there are no [Obsolete] attributes anywhere under dotnet/src/webdriver/BiDi to provide a
deprecation/migration path.

AGENTS.md
AGENTS.md
dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs[32-55]
dotnet/src/webdriver/BiDi/Input/IInputModule.cs[24-25]
dotnet/src/webdriver/BiDi/Log/ILogModule.cs[24-25]
dotnet/src/webdriver/BiDi/Script/IScriptModule.cs[35-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Public BiDi interfaces changed event subscription signatures (e.g., `NavigationEventArgs` -> `NavigationStartedEventArgs`, `LogEntryEventArgs` -> `EntryAddedEventArgs`) without keeping backward-compatible overloads or marking the old surface as deprecated.

## Issue Context
These are public interfaces; changing method parameter types is a breaking change for downstream consumers. Compliance requires backward compatibility or a deprecation-based migration path.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs[32-55]
- dotnet/src/webdriver/BiDi/Input/IInputModule.cs[24-25]
- dotnet/src/webdriver/BiDi/Log/ILogModule.cs[24-25]
- dotnet/src/webdriver/BiDi/Script/IScriptModule.cs[35-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Handler persists after subscribe failure🐞 Bug ☼ Reliability
Description
Broker.SubscribeAsync registers the handler in EventDispatcher before awaiting
Session.SubscribeAsync, but does not roll it back if the remote subscribe fails/cancels. This can
leak handlers and also trigger unexpected callbacks later because dispatch is keyed only by event
name, not by subscription id.
Code

dotnet/src/webdriver/BiDi/Broker.cs[R88-95]

+        _eventMetadata.GetOrAdd(eventName, _ => new EventMetadata(jsonTypeInfo, argsFactory));
+
+        _eventDispatcher.AddHandler(eventName, handler);
+
+        var subscribeResult = await _bidi.Session.SubscribeAsync([eventName], new() { Contexts = options?.Contexts, UserContexts = options?.UserContexts }, cancellationToken).ConfigureAwait(false);
+
+        return new Subscription(subscribeResult.Subscription, this, eventName) { Handler = handler };
+    }
Evidence
The handler is added before the remote subscribe completes and there is no try/catch cleanup path,
so an exception prevents returning a Subscription (no way to call Unsubscribe) while the handler
stays registered. Since events are dispatched solely by event name (no subscription id routing), any
later event for that method will invoke all registered handlers, including the leaked one.

dotnet/src/webdriver/BiDi/Broker.cs[86-101]
dotnet/src/webdriver/BiDi/EventDispatcher.cs[47-64]
dotnet/src/webdriver/BiDi/Broker.cs[300-319]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`Broker.SubscribeAsync(...)` adds the handler to `EventDispatcher` before awaiting the remote `Session.SubscribeAsync(...)`. If the remote subscribe throws (transport error, cancellation, protocol error), no `Subscription` object is returned, and the handler remains registered locally.

Because event dispatching is keyed only by `eventName` (method string), that leaked handler can later be invoked by any subsequent event for that method (e.g., from another successful subscription to the same eventName), causing unexpected callbacks and memory leaks.

## Issue Context
This is in the refactored subscription path where `Broker` now owns subscription/unsubscription and `EventDispatcher` only manages local handlers.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Broker.cs[86-101]

## Suggested fix
1. Keep the current ordering (register handler before remote subscribe) to avoid missing events, but add a rollback on failure:
  - Wrap the `Session.SubscribeAsync(...)` call in `try/catch`.
  - In `catch`, call `_eventDispatcher.RemoveHandler(eventName, handler);` and then rethrow.
2. Optionally (if desired) also roll back `_eventMetadata` when the subscription attempt was the one that created the metadata entry (requires tracking whether this call created it, and/or reference counting).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Subscription timeout ignored 🐞 Bug ≡ Correctness
Description
Broker.SubscribeAsync accepts SubscriptionOptions.Timeout but never propagates it to the
SubscribeOptions passed into Session.SubscribeAsync, so callers cannot customize the subscribe
command timeout via SubscriptionOptions. This makes ContextSubscriptionOptions.Timeout and
SubscriptionOptions.Timeout effectively dead API knobs.
Code

dotnet/src/webdriver/BiDi/Broker.cs[R92-94]

+        var subscribeResult = await _bidi.Session.SubscribeAsync([eventName], new() { Contexts = options?.Contexts, UserContexts = options?.UserContexts }, cancellationToken).ConfigureAwait(false);
+
+        return new Subscription(subscribeResult.Subscription, this, eventName) { Handler = handler };
Evidence
SubscriptionOptions defines a Timeout property, but Broker.SubscribeAsync builds a new
Session.SubscribeOptions with only Contexts/UserContexts populated and does not set Timeout.
Session.SubscribeOptions derives from CommandOptions, where Timeout is what
Broker.ExecuteCommandAsync uses to cancel long-running commands, so omission means the
caller-provided timeout is ignored.

dotnet/src/webdriver/BiDi/Subscription.cs[51-58]
dotnet/src/webdriver/BiDi/Broker.cs[86-95]
dotnet/src/webdriver/BiDi/Session/SubscribeCommand.cs[27-32]
dotnet/src/webdriver/BiDi/CommandOptions.cs[22-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`SubscriptionOptions.Timeout` (and `ContextSubscriptionOptions.Timeout`) is currently not used by `Broker.SubscribeAsync(...)`. As a result, consumers cannot control the timeout used for the underlying `session.subscribe` command via the public subscription options.

## Issue Context
`Session.SubscribeOptions` inherits `CommandOptions` and supports `Timeout`, which is honored by `Broker.ExecuteCommandAsync`. `Broker.SubscribeAsync` constructs a new `SubscribeOptions` but does not populate `Timeout`.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Broker.cs[86-95]

## Suggested fix
When creating the options object for `_bidi.Session.SubscribeAsync(...)`, include `Timeout = options?.Timeout`:

```csharp
var subscribeResult = await _bidi.Session.SubscribeAsync(
   [eventName],
   new Session.SubscribeOptions
   {
       Contexts = options?.Contexts,
       UserContexts = options?.UserContexts,
       Timeout = options?.Timeout,
   },
   cancellationToken).ConfigureAwait(false);
```

(Adjust the type name/namespace if needed; the key is mapping `SubscriptionOptions.Timeout` into the command options used by `Session.SubscribeAsync`.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Copy Markdown
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

Refactors the .NET BiDi event subscription/dispatch pipeline to construct non-serializable public *EventArgs types from spec-serializable parameter models, improving type safety and reducing future breaking changes.

Changes:

  • Reworks Broker/EventDispatcher subscription handling to use event metadata + factories for event-args creation.
  • Splits event payloads into internal *Parameters/*Info models and public *EventArgs (carrying IBiDi) across modules.
  • Updates BiDi tests and module interfaces to use the new strongly-typed event args.

Reviewed changes

Copilot reviewed 67 out of 67 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
dotnet/test/webdriver/BiDi/Script/ScriptEventsTests.cs Updates Script event tests for RealmCreatedEventArgs types.
dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs Updates log event test wiring to EntryAddedEventArgs.
dotnet/test/webdriver/BiDi/Log/LogTests.cs Updates Log module tests to new EntryAddedEventArgs hierarchy.
dotnet/test/webdriver/BiDi/Input/InputEventsTests.cs Updates Input event test to FileDialogOpenedEventArgs.
dotnet/src/webdriver/BiDi/Subscription.cs Subscription now tracks broker + event name + handler delegate.
dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs Subscribes using params model + event-args factory.
dotnet/src/webdriver/BiDi/Speculation/PrefetchStatusUpdatedEventArgs.cs Splits event args vs serializable parameters model.
dotnet/src/webdriver/BiDi/Script/ScriptModule.cs Updates Script subscriptions and adds event-args factories.
dotnet/src/webdriver/BiDi/Script/RemoteValue.cs Moves polymorphic RemoteValue converter into Script namespace/file.
dotnet/src/webdriver/BiDi/Script/RealmInfoEventArgs.cs Replaces RealmInfoEventArgs with RealmCreatedEventArgs hierarchy.
dotnet/src/webdriver/BiDi/Script/RealmInfo.cs Adds internal RealmInfoConverter for polymorphic realm shapes.
dotnet/src/webdriver/BiDi/Script/RealmDestroyedEventArgs.cs Adds IBiDi to event args; adds parameters record.
dotnet/src/webdriver/BiDi/Script/MessageEventArgs.cs Adds IBiDi to event args; adds parameters record.
dotnet/src/webdriver/BiDi/Script/IScriptModule.cs Updates public interface to new event-args types.
dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs Adds in-file EvaluateResultConverter; reshapes parameters record.
dotnet/src/webdriver/BiDi/Network/ResponseStartedEventArgs.cs Splits public args from internal params; adds IBiDi and UserContext.
dotnet/src/webdriver/BiDi/Network/ResponseCompletedEventArgs.cs Splits public args from internal params; adds IBiDi and UserContext.
dotnet/src/webdriver/BiDi/Network/NetworkModule.cs Switches network subscriptions to params + factories.
dotnet/src/webdriver/BiDi/Network/FetchErrorEventArgs.cs Splits public args from internal params; adds IBiDi and UserContext.
dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEventArgs.cs Splits public args from internal params; adds IBiDi and UserContext.
dotnet/src/webdriver/BiDi/Network/BaseParameters.cs Replaces BaseParametersEventArgs with internal BaseParameters record.
dotnet/src/webdriver/BiDi/Network/AuthRequiredEventArgs.cs Splits public args from internal params; adds IBiDi and UserContext.
dotnet/src/webdriver/BiDi/Module.cs Updates SubscribeAsync helpers to accept params + factory.
dotnet/src/webdriver/BiDi/Log/LogModule.cs Switches log subscription to deserialize LogEntry + factory to event args.
dotnet/src/webdriver/BiDi/Log/LogEntryEventArgs.cs Removes old serializable event-args model.
dotnet/src/webdriver/BiDi/Log/ILogModule.cs Updates interface to EntryAddedEventArgs.
dotnet/src/webdriver/BiDi/Log/EntryAddedEventArgs.cs Introduces new public EntryAddedEventArgs + internal LogEntry models + converter.
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RemoteValueConverter.cs Removes old converter location (moved into Script).
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoEventArgsConverter.cs Removes old converter for now-removed RealmInfoEventArgs.
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/RealmInfoConverter.cs Removes old converter location (moved into Script).
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/LogEntryEventArgsConverter.cs Removes old converter for removed LogEntryEventArgs.
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/EvaluateResultConverter.cs Removes old converter location (moved into Script).
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/DownloadEndEventArgsConverter.cs Removes old converter (replaced with params converter in BrowsingContext).
dotnet/src/webdriver/BiDi/Input/InputModule.cs Switches input subscription to params + factory and new event args.
dotnet/src/webdriver/BiDi/Input/IInputModule.cs Updates interface to FileDialogOpenedEventArgs.
dotnet/src/webdriver/BiDi/Input/FileDialogOpenedEventArgs.cs Adds new public event args + internal FileDialogInfo params model.
dotnet/src/webdriver/BiDi/EventHandler.cs Removes old EventHandler abstraction (replaced with delegates).
dotnet/src/webdriver/BiDi/EventDispatcher.cs Reworks dispatcher to store delegate handlers per event name.
dotnet/src/webdriver/BiDi/EventArgs.cs Changes base EventArgs to carry IBiDi via constructor.
dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptType.cs Fixes file contents/namespace; defines UserPromptType enum.
dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptOpenedEventArgs.cs Adds IBiDi + internal parameters record.
dotnet/src/webdriver/BiDi/BrowsingContext/UserPromptClosedEventArgs.cs Adds IBiDi + internal parameters record.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationStartedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs Formats navigation payload model.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationFailedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationEventArgs.cs Makes navigation base args carry IBiDi.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationCommittedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationAbortedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/LoadEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs Renames browsing context info model to Info.
dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs Updates interface event signatures to typed event args.
dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextLogModule.cs Updates interface to EntryAddedEventArgs.
dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs Updates interface to FileDialogOpenedEventArgs.
dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs Adds IBiDi; introduces separate parameters record.
dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs Updates GetTree result model to use Info.
dotnet/src/webdriver/BiDi/BrowsingContext/FragmentNavigatedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/DownloadWillBeginEventArgs.cs Adds IBiDi; introduces internal params model.
dotnet/src/webdriver/BiDi/BrowsingContext/DownloadEndEventArgs.cs Splits public args from internal params + params converter.
dotnet/src/webdriver/BiDi/BrowsingContext/DomContentLoadedEventArgs.cs Replaces old args with typed navigation event args.
dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEventArgs.cs Adds dedicated typed event args class.
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs Updates all event subscriptions to params + factories + typed args.
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs Updates context-scoped log event handling to new args type.
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs Updates context-scoped input event handling to new args type.
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs Updates context instance event helpers to typed event args.
dotnet/src/webdriver/BiDi/Broker.cs Adds event metadata + args factories; moves unsubscribe into broker.
dotnet/src/webdriver/BiDi/BiDi.cs Updates broker construction to new signature.

Comment thread dotnet/src/webdriver/BiDi/Broker.cs
Comment thread dotnet/src/webdriver/BiDi/Broker.cs Outdated
Comment thread dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs Outdated
Comment thread dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs
Comment thread dotnet/src/webdriver/BiDi/Script/ScriptModule.cs
Comment thread dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextModule.cs
Comment thread dotnet/src/webdriver/BiDi/Broker.cs Outdated
Copilot AI review requested due to automatic review settings April 5, 2026 21:23
Copy link
Copy Markdown
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

Copilot reviewed 67 out of 67 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs:29

  • Renaming the public BrowsingContextInfo type to a very generic public type name Info is a source-breaking change for consumers and also reduces API clarity/discoverability (e.g., BrowsingContext.Info is hard to search for and can collide with other Info types). If the intent is to keep the wire/serialization shape internal, consider keeping BrowsingContextInfo as the public type (or providing a backwards-compatible shim/obsolete alias) and using a separate internal parameters type for serialization.

Comment thread dotnet/src/webdriver/BiDi/Broker.cs
Comment thread dotnet/src/webdriver/BiDi/Script/RealmInfo.cs
Comment thread dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEventArgs.cs
Comment thread dotnet/src/webdriver/BiDi/Script/ScriptModule.cs
Comment thread dotnet/src/webdriver/BiDi/EventArgs.cs
Copilot AI review requested due to automatic review settings April 5, 2026 21:47
Copy link
Copy Markdown
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

Copilot reviewed 67 out of 67 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs:29

  • Info is a very generic public type name for a user-facing API (it’s now used in GetTreeResult and context-created/destroyed event args). Consider using a more specific name (e.g., BrowsingContextInfo or BrowsingContextTreeInfo) to avoid ambiguity and improve discoverability.

Comment thread dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs
Comment thread dotnet/src/webdriver/BiDi/Script/ScriptModule.cs
Comment thread dotnet/src/webdriver/BiDi/Broker.cs
@nvborisenko nvborisenko changed the title [dotnet] [bidi] Revise event args preventing further breaking changes [dotnet] [bidi] Revise event args Apr 5, 2026
@nvborisenko
Copy link
Copy Markdown
Member Author

CI fails:

22:18:35.435  WARN DevToolsSession: CDP VNT ^^ Unhandled error occurred in event handler of 'Fetch.authRequired' method. OpenQA.Selenium.DevTools.CommandResponseException: Fetch.continueWithAuth: authChallengeResponse not expected.

This is because tests are not isolated. We have item in backlog how to improve and fix all flaky tests. Merging this one.

@nvborisenko nvborisenko merged commit e78c390 into SeleniumHQ:trunk Apr 5, 2026
18 of 19 checks passed
@nvborisenko nvborisenko deleted the bidi-event-args-up branch April 5, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants