Skip to content

Commit 15a7a10

Browse files
authored
[dotnet] [bidi] Add OnHistoryUpdated event (#15916)
1 parent 2cc031c commit 15a7a10

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ public Task<Subscription> OnFragmentNavigatedAsync(Action<NavigationInfo> handle
147147
return BiDi.BrowsingContext.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
148148
}
149149

150+
public Task<Subscription> OnHistoryUpdatedAsync(Func<HistoryUpdatedEventArgs, Task> handler, SubscriptionOptions? options = null)
151+
{
152+
return BiDi.BrowsingContext.OnHistoryUpdatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
153+
}
154+
155+
public Task<Subscription> OnHistoryUpdatedAsync(Action<HistoryUpdatedEventArgs> handler, SubscriptionOptions? options = null)
156+
{
157+
return BiDi.BrowsingContext.OnHistoryUpdatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
158+
}
159+
150160
public Task<Subscription> OnDomContentLoadedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
151161
{
152162
return BiDi.BrowsingContext.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ public async Task<Subscription> OnFragmentNavigatedAsync(Action<NavigationInfo>
134134
return await Broker.SubscribeAsync("browsingContext.fragmentNavigated", handler, options).ConfigureAwait(false);
135135
}
136136

137+
public async Task<Subscription> OnHistoryUpdatedAsync(Func<HistoryUpdatedEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
138+
{
139+
return await Broker.SubscribeAsync("browsingContext.historyUpdated", handler, options).ConfigureAwait(false);
140+
}
141+
142+
public async Task<Subscription> OnHistoryUpdatedAsync(Action<HistoryUpdatedEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null)
143+
{
144+
return await Broker.SubscribeAsync("browsingContext.historyUpdated", handler, options).ConfigureAwait(false);
145+
}
146+
137147
public async Task<Subscription> OnDomContentLoadedAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
138148
{
139149
return await Broker.SubscribeAsync("browsingContext.domContentLoaded", handler, options).ConfigureAwait(false);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// <copyright file="HistoryUpdatedEventArgs.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
using System;
21+
22+
namespace OpenQA.Selenium.BiDi.BrowsingContext;
23+
24+
public record HistoryUpdatedEventArgs(BiDi BiDi, BrowsingContext Context, DateTimeOffset Timestamp, string Url)
25+
: BrowsingContextEventArgs(BiDi, Context);

dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
111111
[JsonSerializable(typeof(BrowsingContext.SetViewportCommand))]
112112
[JsonSerializable(typeof(BrowsingContext.TraverseHistoryCommand))]
113113
[JsonSerializable(typeof(BrowsingContext.TraverseHistoryResult))]
114+
114115
[JsonSerializable(typeof(BrowsingContext.BrowsingContextInfo))]
116+
[JsonSerializable(typeof(BrowsingContext.HistoryUpdatedEventArgs))]
115117
[JsonSerializable(typeof(BrowsingContext.NavigationInfo))]
116-
117118
[JsonSerializable(typeof(BrowsingContext.UserPromptOpenedEventArgs))]
118119
[JsonSerializable(typeof(BrowsingContext.UserPromptClosedEventArgs))]
119120

0 commit comments

Comments
 (0)