Skip to content

[dotnet] [bidi] Add SetScrollbarTypeOverride command in Emulation module#17171

Draft
nvborisenko wants to merge 1 commit intoSeleniumHQ:trunkfrom
nvborisenko:bidi-set-scrollbar-type
Draft

[dotnet] [bidi] Add SetScrollbarTypeOverride command in Emulation module#17171
nvborisenko wants to merge 1 commit intoSeleniumHQ:trunkfrom
nvborisenko:bidi-set-scrollbar-type

Conversation

@nvborisenko
Copy link
Member

https://w3c.github.io/webdriver-bidi/#command-emulation-setScrollbarTypeOverride

💥 What does this PR do?

Adds support for overriding the scrollbar type in the BiDi Emulation module. The main changes include the introduction of new command and result types, updates to the emulation interface and implementation, and new tests to verify the functionality.

🔄 Types of changes

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

Copilot AI review requested due to automatic review settings March 3, 2026 18:20
@nvborisenko nvborisenko marked this pull request as draft March 3, 2026 18:21
@selenium-ci selenium-ci added the C-dotnet .NET Bindings label Mar 3, 2026
@qodo-code-review
Copy link
Contributor

Review Summary by Qodo

Add SetScrollbarTypeOverride command to BiDi Emulation module

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds SetScrollbarTypeOverride command to BiDi Emulation module
• Introduces ScrollbarType enum with Classic and Overlay options
• Implements command, parameters, options, and result types
• Adds comprehensive unit tests for the new functionality

Grey Divider

File Changes

1. dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverrideCommand.cs ✨ Enhancement +44/-0

New SetScrollbarTypeOverride command implementation

• New file implementing SetScrollbarTypeOverrideCommand class
• Defines SetScrollbarTypeOverrideParameters record with ScrollbarType, Contexts, and UserContexts
• Introduces ScrollbarType enum with Classic and Overlay values
• Creates SetScrollbarTypeOverrideOptions and SetScrollbarTypeOverrideResult types

dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverrideCommand.cs


2. dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs ✨ Enhancement +9/-0

Add SetScrollbarTypeOverride method to module

• Adds SetScrollbarTypeOverrideAsync method to EmulationModule class
• Registers SetScrollbarTypeOverrideCommand and SetScrollbarTypeOverrideResult for JSON
 serialization
• Follows existing pattern for emulation command execution

dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs


3. dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs ✨ Enhancement +1/-0

Add SetScrollbarTypeOverride interface method

• Adds SetScrollbarTypeOverrideAsync method signature to IEmulationModule interface
• Maintains alphabetical ordering of interface methods

dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs


View more (1)
4. dotnet/test/common/BiDi/Emulation/EmulationTests.cs 🧪 Tests +20/-0

Add SetScrollbarTypeOverride unit tests

• Adds CanSetScrollbarTypeOverride test with Overlay scrollbar type
• Adds CanSetScrollbarTypeOverrideToDefault test with null parameter
• Tests both explicit and default override scenarios

dotnet/test/common/BiDi/Emulation/EmulationTests.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Mar 3, 2026

Code Review by Qodo

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

Grey Divider


Action required

1. New IEmulationModule method 📘 Rule violation ✓ Correctness
Description
A new member was added to the public IEmulationModule interface, which is a breaking API/ABI
change for any downstream implementations of that interface. Existing consumers implementing
IEmulationModule will fail to compile (and may fail at runtime depending on binding/dispatch).
Code

dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[32]

+    Task<SetScrollbarTypeOverrideResult> SetScrollbarTypeOverrideAsync(ScrollbarType? scrollbarType, SetScrollbarTypeOverrideOptions? options = null, CancellationToken cancellationToken = default);
Evidence
PR Compliance ID 1 requires preserving public API/ABI compatibility. The PR adds
SetScrollbarTypeOverrideAsync(...) to the public IEmulationModule interface, which breaks
downstream implementers by introducing a new required member.

AGENTS.md
dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[22-33]

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

## Issue description
A new method was added to the public `IEmulationModule` interface, which is a breaking change for downstream implementers and violates API/ABI compatibility expectations.

## Issue Context
Downstream projects may implement `IEmulationModule`. Adding a new interface member forces them to update implementations, meaning they cannot upgrade by changing only the version number.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[22-33]

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



Remediation recommended

2. Ungated new BiDi test 🐞 Bug ⛯ Reliability
Description
The new SetScrollbarTypeOverride tests run on all configured browsers without any feature-gating.
If a given browser/driver doesn’t implement emulation.setScrollbarTypeOverride yet, these tests
will fail and block CI even though the binding code is correct.
Code

dotnet/test/common/BiDi/Emulation/EmulationTests.cs[R134-152]

+    [Test]
+    public void CanSetScrollbarTypeOverride()
+    {
+        Assert.That(async () =>
+        {
+            await bidi.Emulation.SetScrollbarTypeOverrideAsync(ScrollbarType.Overlay, new() { Contexts = [context] });
+        },
+        Throws.Nothing);
+    }
+
+    [Test]
+    public void CanSetScrollbarTypeOverrideToDefault()
+    {
+        Assert.That(async () =>
+        {
+            await bidi.Emulation.SetScrollbarTypeOverrideAsync(null, new() { Contexts = [context] });
+        },
+        Throws.Nothing);
+    }
Evidence
The newly added tests are unconditional (no IgnoreBrowser) while other emulation override tests in
the same file explicitly use IgnoreBrowser when commands are not supported yet. The IgnoreBrowser
mechanism keys off EnvironmentManager.Instance.Browser, and the BiDi fixture creates a driver
based on that environment; therefore, without gating, the new tests will execute on whichever
browser is configured and fail if unsupported. Additionally, broker error responses are surfaced as
BiDiException, which could be used for feature-detection-based skipping if desired.

dotnet/test/common/BiDi/Emulation/EmulationTests.cs[134-152]
dotnet/test/common/BiDi/Emulation/EmulationTests.cs[86-110]
dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs[28-75]
dotnet/test/common/BiDi/BiDiFixture.cs[24-50]
dotnet/src/webdriver/BiDi/Broker.cs[224-230]

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

### Issue description
The new scrollbar override tests run unconditionally. In environments where the underlying browser/driver doesn’t support `emulation.setScrollbarTypeOverride` yet, they can fail CI even though the client binding is correct.

### Issue Context
This test suite already uses `IgnoreBrowser` to avoid running unsupported BiDi commands on specific browsers.

### Fix Focus Areas
- dotnet/test/common/BiDi/Emulation/EmulationTests.cs[134-152]
- dotnet/test/common/BiDi/Emulation/EmulationTests.cs[86-110]
- dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs[28-75]

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



Advisory comments

3. Scrollbar tests are smoke-only 🐞 Bug ⛯ Reliability
Description
The new tests only assert that the command doesn’t throw and don’t validate that scrollbar behavior
actually changed or was reset. This is consistent with other tests in this file, but it limits the
tests’ ability to catch no-op implementations/regressions.
Code

dotnet/test/common/BiDi/Emulation/EmulationTests.cs[R134-152]

+    [Test]
+    public void CanSetScrollbarTypeOverride()
+    {
+        Assert.That(async () =>
+        {
+            await bidi.Emulation.SetScrollbarTypeOverrideAsync(ScrollbarType.Overlay, new() { Contexts = [context] });
+        },
+        Throws.Nothing);
+    }
+
+    [Test]
+    public void CanSetScrollbarTypeOverrideToDefault()
+    {
+        Assert.That(async () =>
+        {
+            await bidi.Emulation.SetScrollbarTypeOverrideAsync(null, new() { Contexts = [context] });
+        },
+        Throws.Nothing);
+    }
Evidence
Both added tests only wrap the async call and assert Throws.Nothing; there are no post-conditions
asserted (e.g., computed style/visual behavior checks).

dotnet/test/common/BiDi/Emulation/EmulationTests.cs[134-152]

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

### Issue description
Current tests only verify that the command call does not throw, which may not detect cases where the command is accepted but has no effect.

### Issue Context
This file uses smoke-style assertions for multiple emulation commands; consider adding at least one higher-signal assertion specifically for scrollbar behavior if practical.

### Fix Focus Areas
- dotnet/test/common/BiDi/Emulation/EmulationTests.cs[134-152]

ⓘ 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
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 PR adds support for the emulation.setScrollbarTypeOverride WebDriver BiDi command, as defined in the W3C spec. It introduces new types and hooks them into the existing Emulation module infrastructure.

Changes:

  • Introduces ScrollbarType enum, SetScrollbarTypeOverrideCommand, SetScrollbarTypeOverrideParameters, SetScrollbarTypeOverrideOptions, and SetScrollbarTypeOverrideResult types
  • Wires up the new command in EmulationModule (implementation) and IEmulationModule (interface), including [JsonSerializable] context registration
  • Adds two integration tests covering setting an explicit scrollbar type and resetting to default

Reviewed changes

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

File Description
SetScrollbarTypeOverrideCommand.cs New file defining command, parameters, options, result, and ScrollbarType enum
EmulationModule.cs Adds SetScrollbarTypeOverrideAsync method and registers types in the JSON serializer context
IEmulationModule.cs Adds SetScrollbarTypeOverrideAsync to the public interface
EmulationTests.cs Adds CanSetScrollbarTypeOverride and CanSetScrollbarTypeOverrideToDefault integration tests

Task<SetNetworkConditionsResult> SetNetworkConditionsAsync(NetworkConditions? networkConditions, SetNetworkConditionsOptions? options = null, CancellationToken cancellationToken = default);
Task<SetScreenOrientationOverrideResult> SetScreenOrientationOverrideAsync(ScreenOrientation? screenOrientation, SetScreenOrientationOverrideOptions? options = null, CancellationToken cancellationToken = default);
Task<SetScreenSettingsOverrideResult> SetScreenSettingsOverrideAsync(ScreenArea? screenArea, SetScreenSettingsOverrideOptions? options = null, CancellationToken cancellationToken = default);
Task<SetScrollbarTypeOverrideResult> SetScrollbarTypeOverrideAsync(ScrollbarType? scrollbarType, SetScrollbarTypeOverrideOptions? options = null, CancellationToken cancellationToken = default);
Copy link
Contributor

Choose a reason for hiding this comment

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

Action required

1. New iemulationmodule method 📘 Rule violation ✓ Correctness

A new member was added to the public IEmulationModule interface, which is a breaking API/ABI
change for any downstream implementations of that interface. Existing consumers implementing
IEmulationModule will fail to compile (and may fail at runtime depending on binding/dispatch).
Agent Prompt
## Issue description
A new method was added to the public `IEmulationModule` interface, which is a breaking change for downstream implementers and violates API/ABI compatibility expectations.

## Issue Context
Downstream projects may implement `IEmulationModule`. Adding a new interface member forces them to update implementations, meaning they cannot upgrade by changing only the version number.

## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[22-33]

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

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