diff --git a/dotnet/src/webdriver/BiDi/Communication/Command.cs b/dotnet/src/webdriver/BiDi/Communication/Command.cs index 9c3fb09d3d58f..782992d513fe8 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Command.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Command.cs @@ -56,6 +56,7 @@ namespace OpenQA.Selenium.BiDi.Communication; [JsonDerivedType(typeof(Modules.Network.ProvideResponseCommand), "network.provideResponse")] [JsonDerivedType(typeof(Modules.Network.ContinueWithAuthCommand), "network.continueWithAuth")] [JsonDerivedType(typeof(Modules.Network.RemoveInterceptCommand), "network.removeIntercept")] +[JsonDerivedType(typeof(Modules.Network.SetCacheBehaviorCommand), "network.setCacheBehavior")] [JsonDerivedType(typeof(Modules.Script.AddPreloadScriptCommand), "script.addPreloadScript")] [JsonDerivedType(typeof(Modules.Script.RemovePreloadScriptCommand), "script.removePreloadScript")] diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs index da6bb2838ce3a..117e662a208b4 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs @@ -69,6 +69,16 @@ public async Task InterceptAuthAsync(Func OnBeforeRequestSentAsync(Func handler, SubscriptionOptions? options = null) { return networkModule.OnBeforeRequestSentAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [context] }); diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs index c90dfa20a4df9..257da7c27daf8 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs @@ -68,6 +68,18 @@ public async Task InterceptResponseAsync(Func InterceptAuthAsync(Func handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { var intercept = await AddInterceptAsync([InterceptPhase.AuthRequired], interceptOptions).ConfigureAwait(false); diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs new file mode 100644 index 0000000000000..c6b29b3ba6769 --- /dev/null +++ b/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs @@ -0,0 +1,58 @@ +// +// 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 System.Collections.Generic; +using OpenQA.Selenium.BiDi.Communication; + +#nullable enable + +namespace OpenQA.Selenium.BiDi.Modules.Network; + +internal class SetCacheBehaviorCommand(SetCacheBehaviorCommandParameters @params) : Command(@params); + +internal record SetCacheBehaviorCommandParameters(CacheBehavior CacheBehavior) : CommandParameters +{ + public IEnumerable? Contexts { get; set; } +} + +public record SetCacheBehaviorOptions : CommandOptions +{ + public SetCacheBehaviorOptions() + { + + } + + internal SetCacheBehaviorOptions(BrowsingContextSetCacheBehaviorOptions? options) + { + + } + + public IEnumerable? Contexts { get; set; } +} + +public record BrowsingContextSetCacheBehaviorOptions +{ + +} + +public enum CacheBehavior +{ + Default, + Bypass +} diff --git a/dotnet/test/common/BiDi/Network/NetworkTest.cs b/dotnet/test/common/BiDi/Network/NetworkTest.cs index b3340edcd942d..3ffc72e551a83 100644 --- a/dotnet/test/common/BiDi/Network/NetworkTest.cs +++ b/dotnet/test/common/BiDi/Network/NetworkTest.cs @@ -211,4 +211,11 @@ public async Task CanFailRequest() Assert.That(action, Throws.TypeOf().With.Message.Contain("net::ERR_FAILED").Or.Message.Contain("NS_ERROR_ABORT")); } + + [Test] + public void CanSetCacheBehavior() + { + Assert.That(async () => await bidi.Network.SetCacheBehaviorAsync(CacheBehavior.Default), Throws.Nothing); + Assert.That(async () => await context.Network.SetCacheBehaviorAsync(CacheBehavior.Default), Throws.Nothing); + } }