Skip to content

[dotnet] [bidi] Add DisownData command in Network module#17436

Merged
nvborisenko merged 2 commits into
SeleniumHQ:trunkfrom
nvborisenko:bidi-disown-data
May 11, 2026
Merged

[dotnet] [bidi] Add DisownData command in Network module#17436
nvborisenko merged 2 commits into
SeleniumHQ:trunkfrom
nvborisenko:bidi-disown-data

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

https://w3c.github.io/webdriver-bidi/#command-network-disownData

💥 What does this PR do?

This pull request adds support for the network.disownData command to the BiDi Network module in the .NET WebDriver implementation. This allows users to explicitly disown network data that was previously collected, improving resource management and control over network data lifecycles. The changes include the introduction of new command parameter/result types, updates to the network module interface and implementation, serialization support, and a new test to verify the feature.

New BiDi Command Support:

  • Added DisownDataParameters, DisownDataOptions, and DisownDataResult record types in DisownData.cs to represent the parameters and results of the new command.
  • Registered the new DisownDataCommand in NetworkModule and implemented the DisownDataAsync method to execute the command. [1] [2]
  • Updated the INetworkModule interface to expose the new DisownDataAsync method.

Serialization and Testing:

  • Added DisownDataParameters and DisownDataResult to the list of types handled by source generation for serialization.
  • Added a new test CanDisownData to verify that the disown data command works as expected.

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • What was generated:
    • I reviewed all AI output and can explain the change

🔄 Types of changes

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

@selenium-ci selenium-ci added the C-dotnet .NET Bindings label May 11, 2026
@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add network.disownData BiDi command to .NET WebDriver

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds network.disownData BiDi command support to .NET WebDriver
• Implements DisownDataParameters, DisownDataOptions, DisownDataResult types
• Registers DisownDataCommand in NetworkModule with async execution method
• Adds JSON serialization support for new parameter and result types
• Includes test verifying disown data command functionality
Diagram
flowchart LR
  A["DisownData.cs<br/>New Types"] -->|Parameters & Result| B["NetworkModule.cs<br/>Command Registration"]
  B -->|Implements| C["INetworkModule.cs<br/>DisownDataAsync Method"]
  B -->|Serialization| D["NetworkModule.cs<br/>JsonSerializable Attributes"]
  C -->|Tested by| E["NetworkTests.cs<br/>CanDisownData Test"]
Loading

Grey Divider

File Changes

1. dotnet/src/webdriver/BiDi/Network/DisownData.cs ✨ Enhancement +26/-0

New DisownData command parameter and result types

• Created new file with three record types for the disown data command
• Defined DisownDataParameters with DataType, Collector, and Request fields
• Defined DisownDataOptions extending CommandOptions
• Defined DisownDataResult as EmptyResult type

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


2. dotnet/src/webdriver/BiDi/Network/INetworkModule.cs ✨ Enhancement +1/-0

Add DisownDataAsync method to interface

• Added DisownDataAsync method signature to the interface
• Method accepts DataType, Collector, Request parameters and optional DisownDataOptions
• Returns Task<DisownDataResult> with CancellationToken support

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


3. dotnet/src/webdriver/BiDi/Network/NetworkModule.cs ✨ Enhancement +12/-0

Implement DisownDataAsync command execution and serialization

• Registered DisownDataCommand static field with "network.disownData" command name
• Implemented DisownDataAsync method that creates parameters and executes command
• Added [JsonSerializable] attributes for DisownDataParameters and DisownDataResult
• Maintains consistent pattern with other network commands

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


View more (1)
4. dotnet/test/webdriver/BiDi/Network/NetworkTests.cs 🧪 Tests +16/-0

Add CanDisownData test for command verification

• Added new test method CanDisownData to verify command functionality
• Test creates data collector, navigates to page, retrieves request, and calls DisownDataAsync
• Verifies that DisownDataAsync executes without throwing exceptions
• Follows existing test patterns in the NetworkTests class

dotnet/test/webdriver/BiDi/Network/NetworkTests.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 11, 2026

Code Review by Qodo

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

Grey Divider


Action required

1. INetworkModule adds DisownDataAsync 📘 Rule violation ⚙ Maintainability
Description
A new method was added to the public INetworkModule interface, which is a breaking API change for
any downstream code implementing this interface (it will fail to compile until updated). This
violates the requirement to preserve backwards compatibility for user-facing APIs.
Code

dotnet/src/webdriver/BiDi/Network/INetworkModule.cs[26]

+    Task<DisownDataResult> DisownDataAsync(DataType dataType, Collector collector, Request request, DisownDataOptions? options = null, CancellationToken cancellationToken = default);
Evidence
The checklist forbids breaking changes to public APIs. The PR adds DisownDataAsync(...) to the
public INetworkModule interface, which is a source-breaking change for any existing third-party
implementation of INetworkModule.

AGENTS.md
dotnet/src/webdriver/BiDi/Network/INetworkModule.cs[22-31]

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

## Issue description
Adding `DisownDataAsync(...)` to the public `INetworkModule` interface is a breaking change for any external implementers of that interface.

## Issue Context
In .NET, adding a member to an interface requires all implementers to add the new member, breaking source compatibility.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Network/INetworkModule.cs[22-31]

## Suggested approaches
- Introduce a new interface (e.g., `INetworkModuleDisownData` / `INetworkModule2`) and have the concrete implementation implement both, while leaving `INetworkModule` unchanged.
- Alternatively, expose the new API via an extension method on `INetworkModule` (calling into the concrete type) to avoid changing the interface contract.
- If the project targets a language/runtime that supports default interface implementations and policy allows it, provide a default implementation (only if compatible with your supported TFMs and API guidelines).

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


2. Hanging stream LINQ query ✓ Resolved 🐞 Bug ☼ Reliability
Description
NetworkTests.CanDisownData awaits FirstAsync() on an event stream without any cancellation/timeout,
so if the matching ResponseCompleted event never arrives the test can hang indefinitely and stall
the suite.
Code

dotnet/test/webdriver/BiDi/Network/NetworkTests.cs[299]

+        var request = await stream.Where(e => e.Response.Url.Contains("simpleTest.html")).Select(e => e.Request.Request).FirstAsync();
Evidence
The new test uses FirstAsync() with no cancellation/timeout, unlike other tests which explicitly
bound waiting to prevent hangs.

dotnet/test/webdriver/BiDi/Network/NetworkTests.cs[290-304]
dotnet/test/webdriver/BiDi/Network/NetworkTests.cs[266-286]
dotnet/test/webdriver/BiDi/Session/SessionTests.cs[129-137]

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

### Issue description
`CanDisownData` awaits an async stream LINQ query ending in `FirstAsync()` without providing a `CancellationToken` or any timeout. If no matching event is produced, the test can hang indefinitely.

### Issue Context
Other tests in this repo bound async stream waits using a `CancellationTokenSource(TimeSpan...)` (e.g., `sub.FirstAsync(cts.Token)`) or `WaitAsync(TimeSpan...)` to avoid CI stalls.

### Fix Focus Areas
- dotnet/test/webdriver/BiDi/Network/NetworkTests.cs[290-304]

### Suggested change
Wrap the `FirstAsync` with a timeout, e.g.:
- create `using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));`
- call `await stream.Where(...).Select(...).FirstAsync(cts.Token);`
(or equivalently use `WaitAsync(TimeSpan.FromSeconds(5))` on the returned task/value-task).

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


Grey Divider

Qodo Logo

Comment thread dotnet/src/webdriver/BiDi/Network/INetworkModule.cs
Comment thread dotnet/test/webdriver/BiDi/Network/NetworkTests.cs Outdated
@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented May 11, 2026

Persistent review updated to latest commit bb03ed1

@nvborisenko nvborisenko merged commit 83ce01e into SeleniumHQ:trunk May 11, 2026
31 of 32 checks passed
@nvborisenko nvborisenko deleted the bidi-disown-data branch May 11, 2026 20:37
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.

2 participants