Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public async Task<SetScreenSettingsOverrideResult> SetScreenSettingsOverrideAsyn
return await ExecuteCommandAsync(new SetScreenSettingsOverrideCommand(@params), options, _jsonContext.SetScreenSettingsOverrideCommand, _jsonContext.SetScreenSettingsOverrideResult, cancellationToken).ConfigureAwait(false);
}

public async Task<SetScrollbarTypeOverrideResult> SetScrollbarTypeOverrideAsync(ScrollbarType? scrollbarType, SetScrollbarTypeOverrideOptions? options = null, CancellationToken cancellationToken = default)
{
var @params = new SetScrollbarTypeOverrideParameters(scrollbarType, options?.Contexts, options?.UserContexts);

return await ExecuteCommandAsync(new SetScrollbarTypeOverrideCommand(@params), options, _jsonContext.SetScrollbarTypeOverrideCommand, _jsonContext.SetScrollbarTypeOverrideResult, cancellationToken).ConfigureAwait(false);
}

public async Task<SetGeolocationOverrideResult> SetGeolocationCoordinatesOverrideAsync(double latitude, double longitude, SetGeolocationCoordinatesOverrideOptions? options = null, CancellationToken cancellationToken = default)
{
var coordinates = new GeolocationCoordinates(latitude, longitude, options?.Accuracy, options?.Altitude, options?.AltitudeAccuracy, options?.Heading, options?.Speed);
Expand Down Expand Up @@ -136,6 +143,8 @@ protected override void Initialize(IBiDi bidi, JsonSerializerOptions jsonSeriali
[JsonSerializable(typeof(SetScreenOrientationOverrideResult))]
[JsonSerializable(typeof(SetScreenSettingsOverrideCommand))]
[JsonSerializable(typeof(SetScreenSettingsOverrideResult))]
[JsonSerializable(typeof(SetScrollbarTypeOverrideCommand))]
[JsonSerializable(typeof(SetScrollbarTypeOverrideResult))]
[JsonSerializable(typeof(SetGeolocationOverrideCommand))]
[JsonSerializable(typeof(SetGeolocationOverrideResult))]
[JsonSerializable(typeof(SetTouchOverrideCommand))]
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface IEmulationModule
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

Task<SetScriptingEnabledResult> SetScriptingEnabledAsync(bool? enabled, SetScriptingEnabledOptions? options = null, CancellationToken cancellationToken = default);
Task<SetTimezoneOverrideResult> SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default);
Task<SetTouchOverrideResult> SetTouchOverrideAsync(long? maxTouchPoints, SetTouchOverrideOptions? options = null, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <copyright file="SetScrollbarTypeOverrideCommand.cs" company="Selenium Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// </copyright>

using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Json.Converters;

namespace OpenQA.Selenium.BiDi.Emulation;

internal sealed class SetScrollbarTypeOverrideCommand(SetScrollbarTypeOverrideParameters @params)
: Command<SetScrollbarTypeOverrideParameters, SetScrollbarTypeOverrideResult>(@params, "emulation.setScrollbarTypeOverride");

internal sealed record SetScrollbarTypeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScrollbarType? ScrollbarType, IEnumerable<BrowsingContext.BrowsingContext>? Contexts, IEnumerable<Browser.UserContext>? UserContexts) : Parameters;

public sealed record SetScrollbarTypeOverrideOptions : CommandOptions
{
public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; init; }

public IEnumerable<Browser.UserContext>? UserContexts { get; init; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ScrollbarType>))]
public enum ScrollbarType
{
Classic,
Overlay
}

public sealed record SetScrollbarTypeOverrideResult : EmptyResult;
20 changes: 20 additions & 0 deletions dotnet/test/common/BiDi/Emulation/EmulationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ public void CanSetScriptingEnabledToDefault()
Throws.Nothing);
}

[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);
}

[Test]
public void CanSetScreenOrientationOverride()
{
Expand Down
Loading