diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs index 70ca21320de23..81f03ffb59134 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs @@ -147,6 +147,16 @@ public Task OnFragmentNavigatedAsync(Action handle return BiDi.BrowsingContext.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] }); } + public Task OnHistoryUpdatedAsync(Func handler, SubscriptionOptions? options = null) + { + return BiDi.BrowsingContext.OnHistoryUpdatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] }); + } + + public Task OnHistoryUpdatedAsync(Action handler, SubscriptionOptions? options = null) + { + return BiDi.BrowsingContext.OnHistoryUpdatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] }); + } + public Task OnDomContentLoadedAsync(Func handler, SubscriptionOptions? options = null) { return BiDi.BrowsingContext.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] }); diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index e3c8ec83d87b3..4f966c4df46a8 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -134,6 +134,16 @@ public async Task OnFragmentNavigatedAsync(Action return await Broker.SubscribeAsync("browsingContext.fragmentNavigated", handler, options).ConfigureAwait(false); } + public async Task OnHistoryUpdatedAsync(Func handler, BrowsingContextsSubscriptionOptions? options = null) + { + return await Broker.SubscribeAsync("browsingContext.historyUpdated", handler, options).ConfigureAwait(false); + } + + public async Task OnHistoryUpdatedAsync(Action handler, BrowsingContextsSubscriptionOptions? options = null) + { + return await Broker.SubscribeAsync("browsingContext.historyUpdated", handler, options).ConfigureAwait(false); + } + public async Task OnDomContentLoadedAsync(Func handler, BrowsingContextsSubscriptionOptions? options = null) { return await Broker.SubscribeAsync("browsingContext.domContentLoaded", handler, options).ConfigureAwait(false); diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs new file mode 100644 index 0000000000000..6611f37bd684d --- /dev/null +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/HistoryUpdatedEventArgs.cs @@ -0,0 +1,25 @@ +// +// 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; + +namespace OpenQA.Selenium.BiDi.BrowsingContext; + +public record HistoryUpdatedEventArgs(BiDi BiDi, BrowsingContext Context, DateTimeOffset Timestamp, string Url) + : BrowsingContextEventArgs(BiDi, Context); diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 0803f13404c3c..5b2a0b803ff7a 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -111,9 +111,10 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(BrowsingContext.SetViewportCommand))] [JsonSerializable(typeof(BrowsingContext.TraverseHistoryCommand))] [JsonSerializable(typeof(BrowsingContext.TraverseHistoryResult))] + [JsonSerializable(typeof(BrowsingContext.BrowsingContextInfo))] +[JsonSerializable(typeof(BrowsingContext.HistoryUpdatedEventArgs))] [JsonSerializable(typeof(BrowsingContext.NavigationInfo))] - [JsonSerializable(typeof(BrowsingContext.UserPromptOpenedEventArgs))] [JsonSerializable(typeof(BrowsingContext.UserPromptClosedEventArgs))]