From b595dfc343af8b3df900d084db390ac82b9500f7 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 17:04:00 -0400 Subject: [PATCH 01/12] [dotnet] Enable external BiDi modules --- dotnet/src/webdriver/BiDi/BiDi.cs | 47 ++++++++++--------- .../webdriver/BiDi/Browser/BrowserModule.cs | 2 +- .../BrowsingContext/BrowsingContextModule.cs | 2 +- .../BiDi/Emulation/EmulationModule.cs | 2 +- .../src/webdriver/BiDi/Input/InputModule.cs | 2 +- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 2 +- dotnet/src/webdriver/BiDi/Module.cs | 13 +++-- .../webdriver/BiDi/Network/NetworkModule.cs | 2 +- .../src/webdriver/BiDi/Script/ScriptModule.cs | 2 +- .../webdriver/BiDi/Session/SessionModule.cs | 2 +- .../webdriver/BiDi/Storage/StorageModule.cs | 2 +- .../BiDi/WebExtension/WebExtensionModule.cs | 2 +- 12 files changed, 42 insertions(+), 38 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/BiDi.cs b/dotnet/src/webdriver/BiDi/BiDi.cs index 448e0ea85bf48..d88105b7ca9a2 100644 --- a/dotnet/src/webdriver/BiDi/BiDi.cs +++ b/dotnet/src/webdriver/BiDi/BiDi.cs @@ -30,15 +30,13 @@ namespace OpenQA.Selenium.BiDi; public sealed class BiDi : IAsyncDisposable { - private readonly Broker _broker; - private readonly JsonSerializerOptions _jsonOptions; + internal Broker Broker { get; } + internal JsonSerializerOptions JsonOptions { get; } private readonly BiDiJsonSerializerContext _jsonContext; - private BiDi(string url) + public JsonSerializerOptions DefaultBiDiOptions() { - var uri = new Uri(url); - - _jsonOptions = new JsonSerializerOptions + return new JsonSerializerOptions { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, @@ -61,20 +59,27 @@ private BiDi(string url) new WebExtensionConverter(this), } }; + } + + private BiDi(string url) + { + var uri = new Uri(url); - _jsonContext = new BiDiJsonSerializerContext(_jsonOptions); - - _broker = new Broker(this, uri, _jsonOptions); - SessionModule = Module.Create(this, _broker, _jsonOptions, _jsonContext); - BrowsingContext = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Browser = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Network = Module.Create(this, _broker, _jsonOptions, _jsonContext); - InputModule = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Script = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Log = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Storage = Module.Create(this, _broker, _jsonOptions, _jsonContext); - WebExtension = Module.Create(this, _broker, _jsonOptions, _jsonContext); - Emulation = Module.Create(this, _broker, _jsonOptions, _jsonContext); + JsonOptions = DefaultBiDiOptions(); + + _jsonContext = new BiDiJsonSerializerContext(JsonOptions); + + Broker = new Broker(this, uri, JsonOptions); + SessionModule = Module.Create(this, JsonOptions, _jsonContext); + BrowsingContext = Module.Create(this, JsonOptions, _jsonContext); + Browser = Module.Create(this, JsonOptions, _jsonContext); + Network = Module.Create(this, JsonOptions, _jsonContext); + InputModule = Module.Create(this, JsonOptions, _jsonContext); + Script = Module.Create(this, JsonOptions, _jsonContext); + Log = Module.Create(this, JsonOptions, _jsonContext); + Storage = Module.Create(this, JsonOptions, _jsonContext); + WebExtension = Module.Create(this, JsonOptions, _jsonContext); + Emulation = Module.Create(this, JsonOptions, _jsonContext); } internal Session.SessionModule SessionModule { get; } @@ -106,7 +111,7 @@ public static async Task ConnectAsync(string url, BiDiOptions? options = n { var bidi = new BiDi(url); - await bidi._broker.ConnectAsync(CancellationToken.None).ConfigureAwait(false); + await bidi.Broker.ConnectAsync(CancellationToken.None).ConfigureAwait(false); return bidi; } @@ -118,7 +123,7 @@ public Task EndAsync(Session.EndOptions? options = null) public async ValueTask DisposeAsync() { - await _broker.DisposeAsync().ConfigureAwait(false); + await Broker.DisposeAsync().ConfigureAwait(false); GC.SuppressFinalize(this); } } diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 61c5ce4008f05..5fe96636381a1 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Browser; -public sealed class BrowserModule : Module +public sealed class BrowserModule : InternalModule { public async Task CloseAsync(CloseOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index f50d23085da40..ab9a888d288d1 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextModule : Module +public sealed class BrowsingContextModule : InternalModule { public async Task CreateAsync(ContextType type, CreateOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 6be60f7769c60..fba3edb71ed16 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Emulation; -public sealed class EmulationModule : Module +public sealed class EmulationModule : InternalModule { public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 8d2662caa035a..9a1d79c266fa9 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Input; -public sealed class InputModule : Module +public sealed class InputModule : InternalModule { public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index a3887d7f052cf..b5e175827ce5e 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Log; -public sealed class LogModule : Module +public sealed class LogModule : InternalModule { public async Task OnEntryAddedAsync(Func handler, SubscriptionOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index 202bc30bbcd75..70a2b829d5019 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -18,8 +18,8 @@ // using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json; using System.Text.Json; +using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi; @@ -27,20 +27,19 @@ public abstract class Module { protected Broker Broker { get; private set; } - internal BiDiJsonSerializerContext JsonContext { get; private set; } + internal JsonSerializerContext JsonContext { get; private set; } - protected virtual void Initialize(JsonSerializerOptions options) { } + protected abstract JsonSerializerContext Initialize(JsonSerializerOptions options); - internal static TModule Create(BiDi bidi, Broker broker, JsonSerializerOptions jsonOptions, BiDiJsonSerializerContext context) + public static TModule Create(BiDi bidi, JsonSerializerOptions jsonOptions, JsonSerializerContext? cachedContext = null) where TModule : Module, new() { TModule module = new() { - Broker = broker, - JsonContext = context + Broker = bidi.Broker, }; - module.Initialize(jsonOptions); + module.JsonContext = cachedContext ?? module.Initialize(jsonOptions); return module; } diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 4242f8515bab9..6bf18aba01ec2 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Network; -public sealed partial class NetworkModule : Module +public sealed partial class NetworkModule : InternalModule { public async Task AddDataCollectorAsync(IEnumerable DataTypes, int MaxEncodedDataSize, AddDataCollectorOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 6867941312362..0c4f0e42ea217 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Script; -public sealed class ScriptModule : Module +public sealed class ScriptModule : InternalModule { public async Task EvaluateAsync(string expression, bool awaitPromise, Target target, EvaluateOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index b545d51f6d441..40b404fbabafc 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class SessionModule : Module +internal sealed class SessionModule : InternalModule { public async Task StatusAsync(StatusOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 3e71db576c760..b5bbfe1b7d640 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Storage; -public sealed class StorageModule : Module +public sealed class StorageModule : InternalModule { public async Task GetCookiesAsync(GetCookiesOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 8432ccc36bd01..948c6f0eb4510 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.WebExtension; -public sealed class WebExtensionModule : Module +public sealed class WebExtensionModule : InternalModule { public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null) { From eaa3d5c353fbb68d50de78b1037e3fe36b2a9ba3 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 17:04:17 -0400 Subject: [PATCH 02/12] Add InternalModule --- dotnet/src/webdriver/BiDi/InternalModule.cs | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/InternalModule.cs diff --git a/dotnet/src/webdriver/BiDi/InternalModule.cs b/dotnet/src/webdriver/BiDi/InternalModule.cs new file mode 100644 index 0000000000000..dbc2f3a079bf2 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/InternalModule.cs @@ -0,0 +1,34 @@ +// +// 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. +// + +using OpenQA.Selenium.BiDi.Communication.Json; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace OpenQA.Selenium.BiDi; + +public abstract class InternalModule : Module +{ + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } +} From 71a748936f530e7cdea41eb279a2931ad208ff45 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 17:22:52 -0400 Subject: [PATCH 03/12] Rename InternalModule to CoreModule --- dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs | 2 +- .../webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs | 2 +- .../src/webdriver/BiDi/{InternalModule.cs => CoreModule.cs} | 4 ++-- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs | 2 +- dotnet/src/webdriver/BiDi/Input/InputModule.cs | 2 +- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 2 +- dotnet/src/webdriver/BiDi/Network/NetworkModule.cs | 2 +- dotnet/src/webdriver/BiDi/Script/ScriptModule.cs | 2 +- dotnet/src/webdriver/BiDi/Session/SessionModule.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/StorageModule.cs | 2 +- dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) rename dotnet/src/webdriver/BiDi/{InternalModule.cs => CoreModule.cs} (91%) diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 5fe96636381a1..e418122dc443b 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Browser; -public sealed class BrowserModule : InternalModule +public sealed class BrowserModule : CoreModule { public async Task CloseAsync(CloseOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index ab9a888d288d1..60f24a0ecfc95 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextModule : InternalModule +public sealed class BrowsingContextModule : CoreModule { public async Task CreateAsync(ContextType type, CreateOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/InternalModule.cs b/dotnet/src/webdriver/BiDi/CoreModule.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/InternalModule.cs rename to dotnet/src/webdriver/BiDi/CoreModule.cs index dbc2f3a079bf2..32d2d23bc702c 100644 --- a/dotnet/src/webdriver/BiDi/InternalModule.cs +++ b/dotnet/src/webdriver/BiDi/CoreModule.cs @@ -1,4 +1,4 @@ -// +// // 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 @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi; -public abstract class InternalModule : Module +public abstract class CoreModule : Module { internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index fba3edb71ed16..29c87fdb47586 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Emulation; -public sealed class EmulationModule : InternalModule +public sealed class EmulationModule : CoreModule { public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 9a1d79c266fa9..ec31bbf1fd35d 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Input; -public sealed class InputModule : InternalModule +public sealed class InputModule : CoreModule { public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index b5e175827ce5e..3d5a37d430bee 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Log; -public sealed class LogModule : InternalModule +public sealed class LogModule : CoreModule { public async Task OnEntryAddedAsync(Func handler, SubscriptionOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 6bf18aba01ec2..0c3d2641e7f1e 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Network; -public sealed partial class NetworkModule : InternalModule +public sealed partial class NetworkModule : CoreModule { public async Task AddDataCollectorAsync(IEnumerable DataTypes, int MaxEncodedDataSize, AddDataCollectorOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 0c4f0e42ea217..d8494f5b08a09 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Script; -public sealed class ScriptModule : InternalModule +public sealed class ScriptModule : CoreModule { public async Task EvaluateAsync(string expression, bool awaitPromise, Target target, EvaluateOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 40b404fbabafc..44f37a5399c30 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class SessionModule : InternalModule +internal sealed class SessionModule : CoreModule { public async Task StatusAsync(StatusOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index b5bbfe1b7d640..32fc59f5f1352 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Storage; -public sealed class StorageModule : InternalModule +public sealed class StorageModule : CoreModule { public async Task GetCookiesAsync(GetCookiesOptions? options = null) { diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 948c6f0eb4510..b5a5526430a44 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.WebExtension; -public sealed class WebExtensionModule : InternalModule +public sealed class WebExtensionModule : CoreModule { public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null) { From 1fbf4c6ac4f6d10336be94ad9ccbd12b5a0487e8 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 18:45:39 -0400 Subject: [PATCH 04/12] [dotnet] Implement Permissions module --- .../Permissions/PermissionDescriptor.cs | 22 ++++++++++ .../Extensions/Permissions/PermissionState.cs | 31 ++++++++++++++ .../Permissions/PermissionsModule.cs | 29 +++++++++++++ .../Permissions/SetPermissionCommand.cs | 17 ++++++++ .../webdriver/BiDi/WebDriver.Extensions.cs | 6 +++ .../Permissions/PermissionsTests.cs | 42 +++++++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs create mode 100644 dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs create mode 100644 dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs create mode 100644 dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs create mode 100644 dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs new file mode 100644 index 0000000000000..8523515a8a748 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs @@ -0,0 +1,22 @@ +// +// 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. +// + +namespace OpenQA.Selenium.BiDi.Extensions.Permissions; + +internal record PermissionDescriptor(string Name); diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs new file mode 100644 index 0000000000000..3707011bdec22 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs @@ -0,0 +1,31 @@ +// +// 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. +// + +using OpenQA.Selenium.BiDi.Communication.Json.Converters; +using System.Text.Json.Serialization; + +namespace OpenQA.Selenium.BiDi.Extensions.Permissions; + +[JsonConverter(typeof(CamelCaseEnumConverter))] +public enum PermissionState +{ + Granted, + Denied, + Prompt +} diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs new file mode 100644 index 0000000000000..2bcea8262d379 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs @@ -0,0 +1,29 @@ +using OpenQA.Selenium.BiDi.Browser; +using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json.Converters; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace OpenQA.Selenium.BiDi.Extensions.Permissions; + +public class PermissionsModule : Module +{ + private PermissionsJsonSerializerContext JsonContext => (PermissionsJsonSerializerContext)base.JsonContext; + + public async Task SetPermissionAsync(string permissionName, PermissionState state, string origin, UserContext? userContext, SetPermissionOptions? options = null) + { + var @params = new SetPermissionCommandParameters(new PermissionDescriptor(permissionName), state, origin, userContext); + + await Broker.ExecuteCommandAsync(new SetPermissionCommand(@params), options, JsonContext.Permissions_SetPermissionCommand, JsonContext.Permissions_SetPermissionResult).ConfigureAwait(false); + } + + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new PermissionsJsonSerializerContext(options); + } +} + +[JsonSerializable(typeof(SetPermissionCommand), TypeInfoPropertyName = "Permissions_SetPermissionCommand")] +[JsonSerializable(typeof(SetPermissionResult), TypeInfoPropertyName = "Permissions_SetPermissionResult")] +internal partial class PermissionsJsonSerializerContext : JsonSerializerContext; diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs b/dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs new file mode 100644 index 0000000000000..dac45688cc8c5 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs @@ -0,0 +1,17 @@ +using OpenQA.Selenium.BiDi.Browser; +using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json.Converters; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace OpenQA.Selenium.BiDi.Extensions.Permissions; + +internal class SetPermissionCommand(SetPermissionCommandParameters @params) + : Command(@params, "permissions.setPermission"); + +public class SetPermissionOptions : CommandOptions; +public sealed record SetPermissionResult : EmptyResult; + +internal record SetPermissionCommandParameters(PermissionDescriptor Descriptor, PermissionState State, string Origin, UserContext? UserContext) : Parameters; diff --git a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs b/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs index 2aedc80a2c092..84c3b7eec9bbb 100644 --- a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs +++ b/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs @@ -17,6 +17,7 @@ // under the License. // +using OpenQA.Selenium.BiDi.Extensions.Permissions; using System; using System.Threading.Tasks; @@ -41,4 +42,9 @@ public static async Task AsBiDiAsync(this IWebDriver webDriver, BiDiOption return bidi; } + + public static PermissionsModule AsPermissionsAsync(this BiDi bidi) + { + return Module.Create(bidi, bidi.DefaultBiDiOptions()); + } } diff --git a/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs b/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs new file mode 100644 index 0000000000000..1f9e43ae4ad34 --- /dev/null +++ b/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs @@ -0,0 +1,42 @@ +using NUnit.Framework; +using OpenQA.Selenium.BiDi.BrowsingContext; +using OpenQA.Selenium.BiDi.Script; +using OpenQA.Selenium.Environment; +using System.Threading.Tasks; + +namespace OpenQA.Selenium.BiDi.Extensions.Permissions; + +internal class PermissionsTests : BiDiTestFixture +{ + [Test] + public async Task SettingPermissionsTest() + { + var userContext = await bidi.Browser.CreateUserContextAsync(); + var window = (await bidi.BrowsingContext.CreateAsync(ContextType.Window, new() + { + ReferenceContext = context, + UserContext = userContext.UserContext, + Background = true + })).Context; + + var newPage = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage() + .WithBody("
new page
")); + + await window.NavigateAsync(newPage); + + var before = await window.Script.CallFunctionAsync(""" + async () => (await navigator.permissions.query({ name: "geolocation" })).state + """, awaitPromise: true, new() { UserActivation = true, }); + + Assert.That(before.AsSuccessResult(), Is.EqualTo(new StringRemoteValue("prompt"))); + + var permissions = bidi.AsPermissionsAsync(); + await permissions.SetPermissionAsync("geolocation", PermissionState.Denied, newPage, userContext.UserContext); + + var after = await window.Script.CallFunctionAsync(""" + async () => (await navigator.permissions.query({ name: "geolocation" })).state + """, awaitPromise: true, new() { UserActivation = true }); + + Assert.That(after.AsSuccessResult(), Is.EqualTo(new StringRemoteValue("denied"))); + } +} From 9a26d1e129a745cdba16793fd820a122ef65de90 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 18:46:35 -0400 Subject: [PATCH 05/12] Rename type --- dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs | 2 +- .../test/common/BiDi/Extensions/Permissions/PermissionsTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs b/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs index 84c3b7eec9bbb..fc270b7b58839 100644 --- a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs +++ b/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs @@ -43,7 +43,7 @@ public static async Task AsBiDiAsync(this IWebDriver webDriver, BiDiOption return bidi; } - public static PermissionsModule AsPermissionsAsync(this BiDi bidi) + public static PermissionsModule AsPermissions(this BiDi bidi) { return Module.Create(bidi, bidi.DefaultBiDiOptions()); } diff --git a/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs b/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs index 1f9e43ae4ad34..26cf1648680bc 100644 --- a/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs +++ b/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs @@ -30,7 +30,7 @@ public async Task SettingPermissionsTest() Assert.That(before.AsSuccessResult(), Is.EqualTo(new StringRemoteValue("prompt"))); - var permissions = bidi.AsPermissionsAsync(); + var permissions = bidi.AsPermissions(); await permissions.SetPermissionAsync("geolocation", PermissionState.Denied, newPage, userContext.UserContext); var after = await window.Script.CallFunctionAsync(""" From dbe8e0b05a1172e9ce729541c10dd13d55c4fd71 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Sat, 11 Oct 2025 19:09:10 -0400 Subject: [PATCH 06/12] Remove CoreModule --- .../webdriver/BiDi/Browser/BrowserModule.cs | 11 +++++- .../BrowsingContext/BrowsingContextModule.cs | 13 +++++-- dotnet/src/webdriver/BiDi/CoreModule.cs | 34 ------------------- .../BiDi/Emulation/EmulationModule.cs | 13 +++++-- .../src/webdriver/BiDi/Input/InputModule.cs | 11 +++++- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 15 ++++++-- .../webdriver/BiDi/Network/NetworkModule.cs | 13 +++++-- .../src/webdriver/BiDi/Script/ScriptModule.cs | 11 +++++- .../webdriver/BiDi/Session/SessionModule.cs | 11 +++++- .../webdriver/BiDi/Storage/StorageModule.cs | 11 +++++- .../BiDi/WebExtension/WebExtensionModule.cs | 11 +++++- 11 files changed, 105 insertions(+), 49 deletions(-) delete mode 100644 dotnet/src/webdriver/BiDi/CoreModule.cs diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index e418122dc443b..c41ab1426dd7e 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -18,12 +18,17 @@ //
using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Browser; -public sealed class BrowserModule : CoreModule +public sealed class BrowserModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task CloseAsync(CloseOptions? options = null) { return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.Browser_CloseResult).ConfigureAwait(false); @@ -74,4 +79,8 @@ public async Task SetDownloadBehaviorDeniedAsync(SetD return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index 60f24a0ecfc95..c2c609738061e 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -17,14 +17,19 @@ // under the License. // +using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; using System; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; -using OpenQA.Selenium.BiDi.Communication; namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextModule : CoreModule +public sealed class BrowsingContextModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task CreateAsync(ContextType type, CreateOptions? options = null) { var @params = new CreateParameters(type, options?.ReferenceContext, options?.Background, options?.UserContext); @@ -248,4 +253,8 @@ public async Task OnUserPromptClosedAsync(Action -// 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. -// - -using OpenQA.Selenium.BiDi.Communication.Json; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace OpenQA.Selenium.BiDi; - -public abstract class CoreModule : Module -{ - internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; - - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) - { - return new BiDiJsonSerializerContext(options); - } -} diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 29c87fdb47586..19076e139b8f0 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -17,13 +17,18 @@ // under the License. // -using System.Threading.Tasks; using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Emulation; -public sealed class EmulationModule : CoreModule +public sealed class EmulationModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null) { var @params = new SetTimezoneOverrideParameters(timezone, options?.Contexts, options?.UserContexts); @@ -88,4 +93,8 @@ public async Task SetGeolocationPositionErrorOverr return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index ec31bbf1fd35d..73fe2e124bc97 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -18,13 +18,18 @@ // using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Input; -public sealed class InputModule : CoreModule +public sealed class InputModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null) { var @params = new PerformActionsParameters(context, actions); @@ -45,4 +50,8 @@ public async Task SetFilesAsync(BrowsingContext.BrowsingContext return await Broker.ExecuteCommandAsync(new SetFilesCommand(@params), options, JsonContext.SetFilesCommand, JsonContext.SetFilesResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index 3d5a37d430bee..90c6868b60a82 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -17,14 +17,19 @@ // under the License. // -using System.Threading.Tasks; -using System; using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Log; -public sealed class LogModule : CoreModule +public sealed class LogModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task OnEntryAddedAsync(Func handler, SubscriptionOptions? options = null) { return await Broker.SubscribeAsync("log.entryAdded", handler, options, JsonContext.LogEntry).ConfigureAwait(false); @@ -34,4 +39,8 @@ public async Task OnEntryAddedAsync(Action handler, Subs { return await Broker.SubscribeAsync("log.entryAdded", handler, options, JsonContext.LogEntry).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 0c3d2641e7f1e..599c4e6b8e2d4 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -17,15 +17,20 @@ // under the License. // +using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; using System; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; -using OpenQA.Selenium.BiDi.Communication; namespace OpenQA.Selenium.BiDi.Network; -public sealed partial class NetworkModule : CoreModule +public sealed partial class NetworkModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task AddDataCollectorAsync(IEnumerable DataTypes, int MaxEncodedDataSize, AddDataCollectorOptions? options = null) { var @params = new AddDataCollectorParameters(DataTypes, MaxEncodedDataSize, options?.CollectorType, options?.Contexts, options?.UserContexts); @@ -173,4 +178,8 @@ public async Task OnAuthRequiredAsync(Action using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; using System; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Script; -public sealed class ScriptModule : CoreModule +public sealed class ScriptModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task EvaluateAsync(string expression, bool awaitPromise, Target target, EvaluateOptions? options = null) { var @params = new EvaluateParameters(expression, target, awaitPromise, options?.ResultOwnership, options?.SerializationOptions, options?.UserActivation); @@ -111,4 +116,8 @@ public async Task OnRealmDestroyedAsync(Action using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Session; -internal sealed class SessionModule : CoreModule +internal sealed class SessionModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task StatusAsync(StatusOptions? options = null) { return await Broker.ExecuteCommandAsync(new StatusCommand(), options, JsonContext.StatusCommand, JsonContext.StatusResult).ConfigureAwait(false); @@ -55,4 +60,8 @@ public async Task EndAsync(EndOptions? options = null) { return await Broker.ExecuteCommandAsync(new EndCommand(), options, JsonContext.EndCommand, JsonContext.EndResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 32fc59f5f1352..29410895ce187 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -18,12 +18,17 @@ // using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.Storage; -public sealed class StorageModule : CoreModule +public sealed class StorageModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task GetCookiesAsync(GetCookiesOptions? options = null) { var @params = new GetCookiesParameters(options?.Filter, options?.Partition); @@ -44,4 +49,8 @@ public async Task SetCookieAsync(PartialCookie cookie, SetCooki return await Broker.ExecuteCommandAsync(new SetCookieCommand(@params), options, JsonContext.SetCookieCommand, JsonContext.SetCookieResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index b5a5526430a44..2a3d13e9e9064 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -18,12 +18,17 @@ // using OpenQA.Selenium.BiDi.Communication; +using OpenQA.Selenium.BiDi.Communication.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi.WebExtension; -public sealed class WebExtensionModule : CoreModule +public sealed class WebExtensionModule : Module { + internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext; + public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null) { var @params = new InstallParameters(extensionData); @@ -37,4 +42,8 @@ public async Task UninstallAsync(Extension extension, Uninstall return await Broker.ExecuteCommandAsync(new UninstallCommand(@params), options, JsonContext.UninstallCommand, JsonContext.UninstallResult).ConfigureAwait(false); } + protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + { + return new BiDiJsonSerializerContext(options); + } } From 6449944523ac91fadc4a93f855528b3bf54e68ff Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 20 Oct 2025 17:16:03 -0400 Subject: [PATCH 07/12] Move Permissions module out of a separate Extensions folder --- .../BiDi/{Extensions => }/Permissions/PermissionDescriptor.cs | 2 +- .../BiDi/{Extensions => }/Permissions/PermissionState.cs | 2 +- .../BiDi/{Extensions => }/Permissions/PermissionsModule.cs | 1 + .../BiDi/{Extensions => }/Permissions/SetPermissionCommand.cs | 2 +- .../BiDi/{Extensions => }/Permissions/PermissionsTests.cs | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) rename dotnet/src/webdriver/BiDi/{Extensions => }/Permissions/PermissionDescriptor.cs (94%) rename dotnet/src/webdriver/BiDi/{Extensions => }/Permissions/PermissionState.cs (95%) rename dotnet/src/webdriver/BiDi/{Extensions => }/Permissions/PermissionsModule.cs (97%) rename dotnet/src/webdriver/BiDi/{Extensions => }/Permissions/SetPermissionCommand.cs (92%) rename dotnet/test/common/BiDi/{Extensions => }/Permissions/PermissionsTests.cs (96%) diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionDescriptor.cs similarity index 94% rename from dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs rename to dotnet/src/webdriver/BiDi/Permissions/PermissionDescriptor.cs index 8523515a8a748..a418c4387b485 100644 --- a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionDescriptor.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionDescriptor.cs @@ -17,6 +17,6 @@ // under the License. // -namespace OpenQA.Selenium.BiDi.Extensions.Permissions; +namespace OpenQA.Selenium.BiDi.Permissions; internal record PermissionDescriptor(string Name); diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionState.cs similarity index 95% rename from dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs rename to dotnet/src/webdriver/BiDi/Permissions/PermissionState.cs index 3707011bdec22..1b3c9d3486655 100644 --- a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionState.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionState.cs @@ -20,7 +20,7 @@ using OpenQA.Selenium.BiDi.Communication.Json.Converters; using System.Text.Json.Serialization; -namespace OpenQA.Selenium.BiDi.Extensions.Permissions; +namespace OpenQA.Selenium.BiDi.Permissions; [JsonConverter(typeof(CamelCaseEnumConverter))] public enum PermissionState diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs similarity index 97% rename from dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs rename to dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 2bcea8262d379..7c75b6252a7ca 100644 --- a/dotnet/src/webdriver/BiDi/Extensions/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -1,6 +1,7 @@ using OpenQA.Selenium.BiDi.Browser; using OpenQA.Selenium.BiDi.Communication; using OpenQA.Selenium.BiDi.Communication.Json.Converters; +using OpenQA.Selenium.BiDi.Permissions; using System.Text.Json; using System.Text.Json.Serialization; using System.Threading.Tasks; diff --git a/dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs rename to dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs index dac45688cc8c5..6fe2d93712d15 100644 --- a/dotnet/src/webdriver/BiDi/Extensions/Permissions/SetPermissionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.Json.Serialization; -namespace OpenQA.Selenium.BiDi.Extensions.Permissions; +namespace OpenQA.Selenium.BiDi.Permissions; internal class SetPermissionCommand(SetPermissionCommandParameters @params) : Command(@params, "permissions.setPermission"); diff --git a/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs b/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs similarity index 96% rename from dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs rename to dotnet/test/common/BiDi/Permissions/PermissionsTests.cs index 26cf1648680bc..bb832b74828b6 100644 --- a/dotnet/test/common/BiDi/Extensions/Permissions/PermissionsTests.cs +++ b/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs @@ -4,7 +4,7 @@ using OpenQA.Selenium.Environment; using System.Threading.Tasks; -namespace OpenQA.Selenium.BiDi.Extensions.Permissions; +namespace OpenQA.Selenium.BiDi.Permissions; internal class PermissionsTests : BiDiTestFixture { From 43dd406df206c55544affdab910aad82eada780a Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 20 Oct 2025 17:17:13 -0400 Subject: [PATCH 08/12] Remove unused usings --- dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs | 1 - .../src/webdriver/BiDi/Permissions/SetPermissionCommand.cs | 5 ----- 2 files changed, 6 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 7c75b6252a7ca..78143a7db2a8d 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -1,6 +1,5 @@ using OpenQA.Selenium.BiDi.Browser; using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters; using OpenQA.Selenium.BiDi.Permissions; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs index 6fe2d93712d15..9e49f436e59c0 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs @@ -1,10 +1,5 @@ using OpenQA.Selenium.BiDi.Browser; using OpenQA.Selenium.BiDi.Communication; -using OpenQA.Selenium.BiDi.Communication.Json.Converters; -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.Json.Serialization; namespace OpenQA.Selenium.BiDi.Permissions; From 341338f948f590ebfb72c4c2843b6fed9534e8e8 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 20 Oct 2025 17:20:14 -0400 Subject: [PATCH 09/12] Rename Initialize to CreateJsonContext --- dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs | 2 +- .../webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs | 2 +- dotnet/src/webdriver/BiDi/Input/InputModule.cs | 2 +- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 2 +- dotnet/src/webdriver/BiDi/Module.cs | 4 ++-- dotnet/src/webdriver/BiDi/Network/NetworkModule.cs | 2 +- dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs | 2 +- dotnet/src/webdriver/BiDi/Script/ScriptModule.cs | 2 +- dotnet/src/webdriver/BiDi/Session/SessionModule.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/StorageModule.cs | 2 +- dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index c41ab1426dd7e..6ec20caa7e90e 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -79,7 +79,7 @@ public async Task SetDownloadBehaviorDeniedAsync(SetD return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index c2c609738061e..b2c4d3b2e8d50 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -253,7 +253,7 @@ public async Task OnUserPromptClosedAsync(Action SetGeolocationPositionErrorOverr return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 73fe2e124bc97..5a7765119629a 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -50,7 +50,7 @@ public async Task SetFilesAsync(BrowsingContext.BrowsingContext return await Broker.ExecuteCommandAsync(new SetFilesCommand(@params), options, JsonContext.SetFilesCommand, JsonContext.SetFilesResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index 90c6868b60a82..55b68c46e3a98 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -39,7 +39,7 @@ public async Task OnEntryAddedAsync(Action handler, Subs { return await Broker.SubscribeAsync("log.entryAdded", handler, options, JsonContext.LogEntry).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index 70a2b829d5019..fda2c5199dbe9 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -29,7 +29,7 @@ public abstract class Module internal JsonSerializerContext JsonContext { get; private set; } - protected abstract JsonSerializerContext Initialize(JsonSerializerOptions options); + protected abstract JsonSerializerContext CreateJsonContext(JsonSerializerOptions options); public static TModule Create(BiDi bidi, JsonSerializerOptions jsonOptions, JsonSerializerContext? cachedContext = null) where TModule : Module, new() @@ -39,7 +39,7 @@ public static TModule Create(BiDi bidi, JsonSerializerOptions jsonOptio Broker = bidi.Broker, }; - module.JsonContext = cachedContext ?? module.Initialize(jsonOptions); + module.JsonContext = cachedContext ?? module.CreateJsonContext(jsonOptions); return module; } diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 599c4e6b8e2d4..198d4698391e2 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -178,7 +178,7 @@ public async Task OnAuthRequiredAsync(Action OnRealmDestroyedAsync(Action EndAsync(EndOptions? options = null) { return await Broker.ExecuteCommandAsync(new EndCommand(), options, JsonContext.EndCommand, JsonContext.EndResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 29410895ce187..4890804a71328 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -49,7 +49,7 @@ public async Task SetCookieAsync(PartialCookie cookie, SetCooki return await Broker.ExecuteCommandAsync(new SetCookieCommand(@params), options, JsonContext.SetCookieCommand, JsonContext.SetCookieResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 2a3d13e9e9064..85db9f69da2f0 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -42,7 +42,7 @@ public async Task UninstallAsync(Extension extension, Uninstall return await Broker.ExecuteCommandAsync(new UninstallCommand(@params), options, JsonContext.UninstallCommand, JsonContext.UninstallResult).ConfigureAwait(false); } - protected override JsonSerializerContext Initialize(JsonSerializerOptions options) + protected override JsonSerializerContext CreateJsonContext(JsonSerializerOptions options) { return new BiDiJsonSerializerContext(options); } From 6bec7723bfcd9d1acfe4e2d086afbe5730e1b3c1 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 20 Oct 2025 18:55:29 -0400 Subject: [PATCH 10/12] Fix format --- .../BiDi/Permissions/PermissionsModule.cs | 19 +++++++++++++++++++ .../BiDi/Permissions/SetPermissionCommand.cs | 19 +++++++++++++++++++ .../BiDi/Permissions/PermissionsTests.cs | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 0d03bd0d382f8..52b3ac53c267e 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -1,3 +1,22 @@ +// +// 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. +// + using OpenQA.Selenium.BiDi.Browser; using OpenQA.Selenium.BiDi.Communication; using OpenQA.Selenium.BiDi.Permissions; diff --git a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs index 9e49f436e59c0..f41b0e5f16a20 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs @@ -1,3 +1,22 @@ +// +// 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. +// + using OpenQA.Selenium.BiDi.Browser; using OpenQA.Selenium.BiDi.Communication; diff --git a/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs b/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs index bb832b74828b6..c567326ac0a6d 100644 --- a/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs +++ b/dotnet/test/common/BiDi/Permissions/PermissionsTests.cs @@ -1,3 +1,22 @@ +// +// 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. +// + using NUnit.Framework; using OpenQA.Selenium.BiDi.BrowsingContext; using OpenQA.Selenium.BiDi.Script; From 875f5e48e019a574ca676093d1195f4f9d44fb41 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 22 Oct 2025 12:03:11 -0400 Subject: [PATCH 11/12] Rename extensions files, move Permissions into a separate file from general BiDi extensinos --- ...Driver.Extensions.cs => BiDiExtensions.cs} | 10 ++---- .../BiDi/Permissions/PermissionsExtensions.cs | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) rename dotnet/src/webdriver/BiDi/{WebDriver.Extensions.cs => BiDiExtensions.cs} (82%) create mode 100644 dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs diff --git a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs b/dotnet/src/webdriver/BiDi/BiDiExtensions.cs similarity index 82% rename from dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs rename to dotnet/src/webdriver/BiDi/BiDiExtensions.cs index fc270b7b58839..13d58b7ff0b0c 100644 --- a/dotnet/src/webdriver/BiDi/WebDriver.Extensions.cs +++ b/dotnet/src/webdriver/BiDi/BiDiExtensions.cs @@ -1,4 +1,4 @@ -// +// // 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 @@ -17,13 +17,12 @@ // under the License. // -using OpenQA.Selenium.BiDi.Extensions.Permissions; using System; using System.Threading.Tasks; namespace OpenQA.Selenium.BiDi; -public static class WebDriverExtensions +public static class BiDiExtensions { public static async Task AsBiDiAsync(this IWebDriver webDriver, BiDiOptions? options = null) { @@ -42,9 +41,4 @@ public static async Task AsBiDiAsync(this IWebDriver webDriver, BiDiOption return bidi; } - - public static PermissionsModule AsPermissions(this BiDi bidi) - { - return Module.Create(bidi, bidi.DefaultBiDiOptions()); - } } diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs new file mode 100644 index 0000000000000..d24c3f0238c11 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs @@ -0,0 +1,36 @@ +// +// 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. +// + +using OpenQA.Selenium.BiDi.Extensions.Permissions; +using System; + +namespace OpenQA.Selenium.BiDi.Permissions; + +public static class PermissionsExtensions +{ + public static PermissionsModule AsPermissions(this BiDi bidi) + { + if (bidi is null) + { + throw new ArgumentNullException(nameof(bidi)); + } + + return Module.Create(bidi, bidi.DefaultBiDiOptions()); + } +} From 3c6d2f7dfebe548f92a9890df35a5dfba2d2345f Mon Sep 17 00:00:00 2001 From: Michael Render Date: Fri, 24 Oct 2025 16:29:24 -0400 Subject: [PATCH 12/12] Rename PermissionsExtensions to PermissionsBiDiExtensions --- ...{PermissionsExtensions.cs => PermissionsBiDiExtensions.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename dotnet/src/webdriver/BiDi/Permissions/{PermissionsExtensions.cs => PermissionsBiDiExtensions.cs} (90%) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsBiDiExtensions.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs rename to dotnet/src/webdriver/BiDi/Permissions/PermissionsBiDiExtensions.cs index d24c3f0238c11..ff8dff47db1e6 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsExtensions.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsBiDiExtensions.cs @@ -1,4 +1,4 @@ -// +// // 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 @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Permissions; -public static class PermissionsExtensions +public static class PermissionsBiDiExtensions { public static PermissionsModule AsPermissions(this BiDi bidi) {