Skip to content

Commit c4166c9

Browse files
committed
Browser
1 parent 3f15056 commit c4166c9

File tree

8 files changed

+29
-20
lines changed

8 files changed

+29
-20
lines changed

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ namespace OpenQA.Selenium.BiDi.Browser;
2424

2525
public sealed class BrowserModule : Module
2626
{
27-
public async Task<EmptyResult> CloseAsync(CloseOptions? options = null)
27+
public async Task<CloseResult> CloseAsync(CloseOptions? options = null)
2828
{
29-
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.EmptyResult).ConfigureAwait(false);
29+
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.Browser_CloseResult).ConfigureAwait(false);
3030
}
3131

32-
public async Task<UserContextInfo> CreateUserContextAsync(CreateUserContextOptions? options = null)
32+
public async Task<CreateUserContextResult> CreateUserContextAsync(CreateUserContextOptions? options = null)
3333
{
3434
var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior);
3535

36-
return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.UserContextInfo).ConfigureAwait(false);
36+
return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.CreateUserContextResult).ConfigureAwait(false);
3737
}
3838

3939
public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOptions? options = null)
4040
{
4141
return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options, JsonContext.GetUserContextsCommand, JsonContext.GetUserContextsResult).ConfigureAwait(false);
4242
}
4343

44-
public async Task<EmptyResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
44+
public async Task<RemoveUserContextResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
4545
{
4646
var @params = new RemoveUserContextParameters(userContext);
4747

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

5151
public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)
@@ -54,24 +54,24 @@ public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindows
5454
).ConfigureAwait(false);
5555
}
5656

57-
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
57+
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
5858
{
5959
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts);
6060

61-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
61+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
6262
}
6363

64-
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
64+
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
6565
{
6666
var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts);
6767

68-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
68+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
6969
}
7070

71-
public async Task<EmptyResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
71+
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
7272
{
7373
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts);
7474

75-
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
75+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
7676
}
7777
}

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

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

2424
internal sealed class CloseCommand()
25-
: Command<Parameters, EmptyResult>(Parameters.Empty, "browser.close");
25+
: Command<Parameters, CloseResult>(Parameters.Empty, "browser.close");
2626

2727
public sealed class CloseOptions : CommandOptions;
28+
29+
public sealed record CloseResult : EmptyResult;

dotnet/src/webdriver/BiDi/Browser/CreateUserContextCommand.cs

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

2424
internal sealed class CreateUserContextCommand(CreateUserContextParameters @params)
25-
: Command<CreateUserContextParameters, UserContextInfo>(@params, "browser.createUserContext");
25+
: Command<CreateUserContextParameters, CreateUserContextResult>(@params, "browser.createUserContext");
2626

2727
internal sealed record CreateUserContextParameters(bool? AcceptInsecureCerts, Session.ProxyConfiguration? Proxy, Session.UserPromptHandler? UnhandledPromptBehavior) : Parameters;
2828

@@ -34,3 +34,5 @@ public sealed class CreateUserContextOptions : CommandOptions
3434

3535
public Session.UserPromptHandler? UnhandledPromptBehavior { get; set; }
3636
}
37+
38+
public sealed record CreateUserContextResult(UserContext UserContext) : UserContextInfo(UserContext);

dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows)
4444

4545
public int Count => ClientWindows.Count;
4646

47-
48-
4947
public IEnumerator<ClientWindowInfo> GetEnumerator() => ClientWindows.GetEnumerator();
5048

5149
IEnumerator IEnumerable.GetEnumerator() => (ClientWindows as IEnumerable).GetEnumerator();

dotnet/src/webdriver/BiDi/Browser/RemoveUserContextCommand.cs

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

2424
internal sealed class RemoveUserContextCommand(RemoveUserContextParameters @params)
25-
: Command<RemoveUserContextParameters, EmptyResult>(@params, "browser.removeUserContext");
25+
: Command<RemoveUserContextParameters, RemoveUserContextResult>(@params, "browser.removeUserContext");
2626

2727
internal sealed record RemoveUserContextParameters(UserContext UserContext) : Parameters;
2828

2929
public sealed class RemoveUserContextOptions : CommandOptions;
30+
31+
public sealed record RemoveUserContextResult : EmptyResult;

dotnet/src/webdriver/BiDi/Browser/SetDownloadBehaviorCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace OpenQA.Selenium.BiDi.Browser;
2525

2626
internal sealed class SetDownloadBehaviorCommand(SetDownloadBehaviorParameters @params)
27-
: Command<SetDownloadBehaviorParameters, EmptyResult>(@params, "browser.setDownloadBehavior");
27+
: Command<SetDownloadBehaviorParameters, SetDownloadBehaviorResult>(@params, "browser.setDownloadBehavior");
2828

2929
internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, IEnumerable<UserContext>? UserContexts) : Parameters;
3030

@@ -41,3 +41,5 @@ public sealed class SetDownloadBehaviorOptions : CommandOptions
4141
{
4242
public IEnumerable<UserContext>? UserContexts { get; set; }
4343
}
44+
45+
public sealed record SetDownloadBehaviorResult : EmptyResult;

dotnet/src/webdriver/BiDi/Browser/UserContextInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
namespace OpenQA.Selenium.BiDi.Browser;
2323

24-
public sealed record UserContextInfo(UserContext UserContext) : EmptyResult;
24+
public record UserContextInfo(UserContext UserContext) : EmptyResult;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,17 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
8282
[JsonSerializable(typeof(Session.UnsubscribeResult))]
8383

8484
[JsonSerializable(typeof(Browser.CloseCommand), TypeInfoPropertyName = "Browser_CloseCommand")]
85+
[JsonSerializable(typeof(Browser.CloseResult), TypeInfoPropertyName = "Browser_CloseResult")]
8586
[JsonSerializable(typeof(Browser.CreateUserContextCommand))]
87+
[JsonSerializable(typeof(Browser.CreateUserContextResult))]
8688
[JsonSerializable(typeof(Browser.GetUserContextsCommand))]
8789
[JsonSerializable(typeof(Browser.GetUserContextsResult))]
8890
[JsonSerializable(typeof(Browser.RemoveUserContextCommand))]
91+
[JsonSerializable(typeof(Browser.RemoveUserContextResult))]
8992
[JsonSerializable(typeof(Browser.GetClientWindowsCommand))]
9093
[JsonSerializable(typeof(Browser.GetClientWindowsResult))]
9194
[JsonSerializable(typeof(Browser.SetDownloadBehaviorCommand))]
92-
[JsonSerializable(typeof(Browser.UserContextInfo))]
95+
[JsonSerializable(typeof(Browser.SetDownloadBehaviorResult))]
9396
[JsonSerializable(typeof(IReadOnlyList<Browser.UserContextInfo>))]
9497
[JsonSerializable(typeof(IReadOnlyList<Browser.ClientWindowInfo>))]
9598

0 commit comments

Comments
 (0)