Skip to content

Commit a901f4c

Browse files
committed
BrowsingContext
1 parent c4166c9 commit a901f4c

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2323

2424
internal sealed class ActivateCommand(ActivateParameters @params)
25-
: Command<ActivateParameters, EmptyResult>(@params, "browsingContext.activate");
25+
: Command<ActivateParameters, ActivateResult>(@params, "browsingContext.activate");
2626

2727
internal sealed record ActivateParameters(BrowsingContext Context) : Parameters;
2828

2929
public sealed class ActivateOptions : CommandOptions;
30+
31+
public sealed record ActivateResult : EmptyResult;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public async Task<NavigateResult> NavigateAsync(BrowsingContext context, string
4141
return await Broker.ExecuteCommandAsync(new NavigateCommand(@params), options, JsonContext.NavigateCommand, JsonContext.NavigateResult).ConfigureAwait(false);
4242
}
4343

44-
public async Task<EmptyResult> ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
44+
public async Task<ActivateResult> ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
4545
{
4646
var @params = new ActivateParameters(context);
4747

48-
return await Broker.ExecuteCommandAsync(new ActivateCommand(@params), options, JsonContext.ActivateCommand, JsonContext.EmptyResult).ConfigureAwait(false);
48+
return await Broker.ExecuteCommandAsync(new ActivateCommand(@params), options, JsonContext.ActivateCommand, JsonContext.ActivateResult).ConfigureAwait(false);
4949
}
5050

5151
public async Task<LocateNodesResult> LocateNodesAsync(BrowsingContext context, Locator locator, LocateNodesOptions? options = null)
@@ -62,11 +62,11 @@ public async Task<CaptureScreenshotResult> CaptureScreenshotAsync(BrowsingContex
6262
return await Broker.ExecuteCommandAsync(new CaptureScreenshotCommand(@params), options, JsonContext.CaptureScreenshotCommand, JsonContext.CaptureScreenshotResult).ConfigureAwait(false);
6363
}
6464

65-
public async Task<EmptyResult> CloseAsync(BrowsingContext context, CloseOptions? options = null)
65+
public async Task<CloseResult> CloseAsync(BrowsingContext context, CloseOptions? options = null)
6666
{
6767
var @params = new CloseParameters(context, options?.PromptUnload);
6868

69-
return await Broker.ExecuteCommandAsync(new CloseCommand(@params), options, JsonContext.BrowsingContext_CloseCommand, JsonContext.EmptyResult).ConfigureAwait(false);
69+
return await Broker.ExecuteCommandAsync(new CloseCommand(@params), options, JsonContext.BrowsingContext_CloseCommand, JsonContext.BrowsingContext_CloseResult).ConfigureAwait(false);
7070
}
7171

7272
public async Task<TraverseHistoryResult> TraverseHistoryAsync(BrowsingContext context, int delta, TraverseHistoryOptions? options = null)
@@ -76,18 +76,18 @@ public async Task<TraverseHistoryResult> TraverseHistoryAsync(BrowsingContext co
7676
return await Broker.ExecuteCommandAsync(new TraverseHistoryCommand(@params), options, JsonContext.TraverseHistoryCommand, JsonContext.TraverseHistoryResult).ConfigureAwait(false);
7777
}
7878

79-
public async Task<NavigateResult> ReloadAsync(BrowsingContext context, ReloadOptions? options = null)
79+
public async Task<ReloadResult> ReloadAsync(BrowsingContext context, ReloadOptions? options = null)
8080
{
8181
var @params = new ReloadParameters(context, options?.IgnoreCache, options?.Wait);
8282

83-
return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options, JsonContext.ReloadCommand, JsonContext.NavigateResult).ConfigureAwait(false);
83+
return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options, JsonContext.ReloadCommand, JsonContext.ReloadResult).ConfigureAwait(false);
8484
}
8585

86-
public async Task<EmptyResult> SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
86+
public async Task<SetViewportResult> SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
8787
{
8888
var @params = new SetViewportParameters(context, options?.Viewport, options?.DevicePixelRatio);
8989

90-
return await Broker.ExecuteCommandAsync(new SetViewportCommand(@params), options, JsonContext.SetViewportCommand, JsonContext.EmptyResult).ConfigureAwait(false);
90+
return await Broker.ExecuteCommandAsync(new SetViewportCommand(@params), options, JsonContext.SetViewportCommand, JsonContext.SetViewportResult).ConfigureAwait(false);
9191
}
9292

9393
public async Task<GetTreeResult> GetTreeAsync(GetTreeOptions? options = null)
@@ -104,11 +104,11 @@ public async Task<PrintResult> PrintAsync(BrowsingContext context, PrintOptions?
104104
return await Broker.ExecuteCommandAsync(new PrintCommand(@params), options, JsonContext.PrintCommand, JsonContext.PrintResult).ConfigureAwait(false);
105105
}
106106

107-
public async Task<EmptyResult> HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
107+
public async Task<HandleUserPromptResult> HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
108108
{
109109
var @params = new HandleUserPromptParameters(context, options?.Accept, options?.UserText);
110110

111-
return await Broker.ExecuteCommandAsync(new HandleUserPromptCommand(@params), options, JsonContext.HandleUserPromptCommand, JsonContext.EmptyResult).ConfigureAwait(false);
111+
return await Broker.ExecuteCommandAsync(new HandleUserPromptCommand(@params), options, JsonContext.HandleUserPromptCommand, JsonContext.HandleUserPromptResult).ConfigureAwait(false);
112112
}
113113

114114
public async Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2323

2424
internal sealed class CloseCommand(CloseParameters @params)
25-
: Command<CloseParameters, EmptyResult>(@params, "browsingContext.close");
25+
: Command<CloseParameters, CloseResult>(@params, "browsingContext.close");
2626

2727
internal sealed record CloseParameters(BrowsingContext Context, bool? PromptUnload) : Parameters;
2828

2929
public sealed class CloseOptions : CommandOptions
3030
{
3131
public bool? PromptUnload { get; set; }
3232
}
33+
34+
public sealed record CloseResult : EmptyResult;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2323

2424
internal sealed class HandleUserPromptCommand(HandleUserPromptParameters @params)
25-
: Command<HandleUserPromptParameters, EmptyResult>(@params, "browsingContext.handleUserPrompt");
25+
: Command<HandleUserPromptParameters, HandleUserPromptResult>(@params, "browsingContext.handleUserPrompt");
2626

2727
internal sealed record HandleUserPromptParameters(BrowsingContext Context, bool? Accept, string? UserText) : Parameters;
2828

@@ -32,3 +32,5 @@ public sealed class HandleUserPromptOptions : CommandOptions
3232

3333
public string? UserText { get; set; }
3434
}
35+
36+
public sealed record HandleUserPromptResult : EmptyResult;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ public enum ReadinessState
4141
Complete
4242
}
4343

44-
public sealed record NavigateResult(Navigation? Navigation, string Url) : EmptyResult;
44+
public record NavigateResult(Navigation? Navigation, string Url) : EmptyResult;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2323

2424
internal sealed class ReloadCommand(ReloadParameters @params)
25-
: Command<ReloadParameters, NavigateResult>(@params, "browsingContext.reload");
25+
: Command<ReloadParameters, ReloadResult>(@params, "browsingContext.reload");
2626

2727
internal sealed record ReloadParameters(BrowsingContext Context, bool? IgnoreCache, ReadinessState? Wait) : Parameters;
2828

@@ -32,3 +32,5 @@ public sealed class ReloadOptions : CommandOptions
3232

3333
public ReadinessState? Wait { get; set; }
3434
}
35+
36+
public sealed record ReloadResult(Navigation? Navigation, string Url) : NavigateResult(Navigation, Url);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2323

2424
internal sealed class SetViewportCommand(SetViewportParameters @params)
25-
: Command<SetViewportParameters, EmptyResult>(@params, "browsingContext.setViewport");
25+
: Command<SetViewportParameters, SetViewportResult>(@params, "browsingContext.setViewport");
2626

2727
internal sealed record SetViewportParameters(BrowsingContext Context, Viewport? Viewport, double? DevicePixelRatio) : Parameters;
2828

@@ -34,3 +34,5 @@ public sealed class SetViewportOptions : CommandOptions
3434
}
3535

3636
public readonly record struct Viewport(long Width, long Height);
37+
38+
public sealed record SetViewportResult : EmptyResult;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,27 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
9898

9999

100100
[JsonSerializable(typeof(BrowsingContext.ActivateCommand))]
101+
[JsonSerializable(typeof(BrowsingContext.ActivateResult))]
101102
[JsonSerializable(typeof(BrowsingContext.CaptureScreenshotCommand))]
102103
[JsonSerializable(typeof(BrowsingContext.CaptureScreenshotResult))]
103104
[JsonSerializable(typeof(BrowsingContext.CloseCommand), TypeInfoPropertyName = "BrowsingContext_CloseCommand")]
105+
[JsonSerializable(typeof(BrowsingContext.CloseResult), TypeInfoPropertyName = "BrowsingContext_CloseResult")]
104106
[JsonSerializable(typeof(BrowsingContext.CreateCommand))]
105107
[JsonSerializable(typeof(BrowsingContext.CreateResult))]
106108
[JsonSerializable(typeof(BrowsingContext.GetTreeCommand))]
107109
[JsonSerializable(typeof(BrowsingContext.GetTreeResult))]
108110
[JsonSerializable(typeof(BrowsingContext.HandleUserPromptCommand))]
111+
[JsonSerializable(typeof(BrowsingContext.HandleUserPromptResult))]
109112
[JsonSerializable(typeof(BrowsingContext.LocateNodesCommand))]
110113
[JsonSerializable(typeof(BrowsingContext.LocateNodesResult))]
111114
[JsonSerializable(typeof(BrowsingContext.NavigateCommand))]
112115
[JsonSerializable(typeof(BrowsingContext.NavigateResult))]
113116
[JsonSerializable(typeof(BrowsingContext.PrintCommand))]
114117
[JsonSerializable(typeof(BrowsingContext.PrintResult))]
115118
[JsonSerializable(typeof(BrowsingContext.ReloadCommand))]
119+
[JsonSerializable(typeof(BrowsingContext.ReloadResult))]
116120
[JsonSerializable(typeof(BrowsingContext.SetViewportCommand))]
121+
[JsonSerializable(typeof(BrowsingContext.SetViewportResult))]
117122
[JsonSerializable(typeof(BrowsingContext.TraverseHistoryCommand))]
118123
[JsonSerializable(typeof(BrowsingContext.TraverseHistoryResult))]
119124

0 commit comments

Comments
 (0)