diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs index cbee35ab8f5c1..ea139766238b2 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs @@ -100,11 +100,12 @@ public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null) public Task> GetTreeAsync(BrowsingContextGetTreeOptions? options = null) { - options ??= new(); + GetTreeOptions getTreeOptions = new(options) + { + Root = this + }; - options.Root = this; - - return _bidi.BrowsingContextModule.GetTreeAsync(options); + return _bidi.BrowsingContextModule.GetTreeAsync(getTreeOptions); } public Task OnNavigationStartedAsync(Func handler, SubscriptionOptions? options = null) diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs index 4c1d260740488..4b4d805eb3041 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs @@ -8,11 +8,12 @@ public class BrowsingContextNetworkModule(BrowsingContext context, NetworkModule { public async Task InterceptRequestAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { - interceptOptions ??= new(); + AddInterceptOptions addInterceptOptions = new(interceptOptions) + { + Contexts = [context] + }; - interceptOptions.Contexts = [context]; - - var intercept = await networkModule.AddInterceptAsync([InterceptPhase.BeforeRequestSent], interceptOptions).ConfigureAwait(false); + var intercept = await networkModule.AddInterceptAsync([InterceptPhase.BeforeRequestSent], addInterceptOptions).ConfigureAwait(false); await intercept.OnBeforeRequestSentAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [context] }).ConfigureAwait(false); @@ -21,11 +22,12 @@ public async Task InterceptRequestAsync(Func InterceptResponseAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { - interceptOptions ??= new(); - - interceptOptions.Contexts = [context]; + AddInterceptOptions addInterceptOptions = new(interceptOptions) + { + Contexts = [context] + }; - var intercept = await networkModule.AddInterceptAsync([InterceptPhase.ResponseStarted], interceptOptions).ConfigureAwait(false); + var intercept = await networkModule.AddInterceptAsync([InterceptPhase.ResponseStarted], addInterceptOptions).ConfigureAwait(false); await intercept.OnResponseStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [context] }).ConfigureAwait(false); @@ -34,11 +36,12 @@ public async Task InterceptResponseAsync(Func InterceptAuthenticationAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { - interceptOptions ??= new(); - - interceptOptions.Contexts = [context]; + AddInterceptOptions addInterceptOptions = new(interceptOptions) + { + Contexts = [context] + }; - var intercept = await networkModule.AddInterceptAsync([InterceptPhase.AuthRequired], interceptOptions).ConfigureAwait(false); + var intercept = await networkModule.AddInterceptAsync([InterceptPhase.AuthRequired], addInterceptOptions).ConfigureAwait(false); await intercept.OnAuthRequiredAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [context] }).ConfigureAwait(false); diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs index 81cf545112599..d2756ecc503cc 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs @@ -8,11 +8,12 @@ public class BrowsingContextScriptModule(BrowsingContext context, ScriptModule s { public async Task AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null) { - options ??= new(); - - options.Contexts = [context]; + AddPreloadScriptOptions addPreloadScriptOptions = new(options) + { + Contexts = [context] + }; - return await scriptModule.AddPreloadScriptAsync(functionDeclaration, options).ConfigureAwait(false); + return await scriptModule.AddPreloadScriptAsync(functionDeclaration, addPreloadScriptOptions).ConfigureAwait(false); } public async Task> GetRealmsAsync(GetRealmsOptions? options = null) diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs index d5a43d612b6c4..fe6a38c1fe0bc 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs @@ -14,18 +14,21 @@ internal record GetTreeCommandParameters : CommandParameters public record GetTreeOptions : CommandOptions { + public GetTreeOptions() { } + + internal GetTreeOptions(BrowsingContextGetTreeOptions? options) + { + MaxDepth = options?.MaxDepth; + } + public long? MaxDepth { get; set; } public BrowsingContext? Root { get; set; } } -public record BrowsingContextGetTreeOptions : GetTreeOptions +public record BrowsingContextGetTreeOptions { - internal new BrowsingContext? Root - { - get => base.Root; - set => base.Root = value; - } + public long? MaxDepth { get; set; } } public record GetTreeResult(IReadOnlyList Contexts); diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs index bb94c16d5d91b..4856193d512d9 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs @@ -14,18 +14,21 @@ internal record AddInterceptCommandParameters(IEnumerable Phases public record AddInterceptOptions : CommandOptions { + public AddInterceptOptions() { } + + internal AddInterceptOptions(BrowsingContextAddInterceptOptions? options) + { + UrlPatterns = options?.UrlPatterns; + } + public IEnumerable? Contexts { get; set; } public IEnumerable? UrlPatterns { get; set; } } -public record BrowsingContextAddInterceptOptions : AddInterceptOptions +public record BrowsingContextAddInterceptOptions { - internal new IEnumerable? Contexts - { - get => base.Contexts; - set => base.Contexts = value; - } + public IEnumerable? UrlPatterns { get; set; } } public record AddInterceptResult(Intercept Intercept); diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs index eeefc9563e0b6..516e65b10f45c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs @@ -16,6 +16,14 @@ internal record AddPreloadScriptCommandParameters(string FunctionDeclaration) : public record AddPreloadScriptOptions : CommandOptions { + public AddPreloadScriptOptions() { } + + internal AddPreloadScriptOptions(BrowsingContextAddPreloadScriptOptions? options) + { + Arguments = options?.Arguments; + Sandbox = options?.Sandbox; + } + public IEnumerable? Arguments { get; set; } public IEnumerable? Contexts { get; set; } @@ -23,13 +31,11 @@ public record AddPreloadScriptOptions : CommandOptions public string? Sandbox { get; set; } } -public record BrowsingContextAddPreloadScriptOptions : AddPreloadScriptOptions +public record BrowsingContextAddPreloadScriptOptions { - internal new IEnumerable? Contexts - { - get => base.Contexts; - set => base.Contexts = value; - } + public IEnumerable? Arguments { get; set; } + + public string? Sandbox { get; set; } } internal record AddPreloadScriptResult(PreloadScript Script);