@@ -27,59 +27,61 @@ namespace OpenQA.Selenium.BiDi.Browser;
2727
2828public sealed class BrowserModule : Module
2929{
30+ private BrowserModuleJsonSerializerContext _jsonContext = null ! ;
31+
3032 public async Task < EmptyResult > CloseAsync ( CloseOptions ? options = null )
3133 {
32- return await Broker . ExecuteCommandAsync < CloseCommand , EmptyResult > ( new CloseCommand ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
34+ return await Broker . ExecuteCommandAsync < CloseCommand , EmptyResult > ( new CloseCommand ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
3335 }
3436
3537 public async Task < UserContextInfo > CreateUserContextAsync ( CreateUserContextOptions ? options = null )
3638 {
3739 var @params = new CreateUserContextParameters ( options ? . AcceptInsecureCerts , options ? . Proxy , options ? . UnhandledPromptBehavior ) ;
3840
39- return await Broker . ExecuteCommandAsync < CreateUserContextCommand , UserContextInfo > ( new CreateUserContextCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
41+ return await Broker . ExecuteCommandAsync < CreateUserContextCommand , UserContextInfo > ( new CreateUserContextCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
4042 }
4143
4244 public async Task < GetUserContextsResult > GetUserContextsAsync ( GetUserContextsOptions ? options = null )
4345 {
44- return await Broker . ExecuteCommandAsync < GetUserContextsCommand , GetUserContextsResult > ( new GetUserContextsCommand ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
46+ return await Broker . ExecuteCommandAsync < GetUserContextsCommand , GetUserContextsResult > ( new GetUserContextsCommand ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
4547 }
4648
4749 public async Task < EmptyResult > RemoveUserContextAsync ( UserContext userContext , RemoveUserContextOptions ? options = null )
4850 {
4951 var @params = new RemoveUserContextParameters ( userContext ) ;
5052
51- return await Broker . ExecuteCommandAsync < RemoveUserContextCommand , EmptyResult > ( new RemoveUserContextCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
53+ return await Broker . ExecuteCommandAsync < RemoveUserContextCommand , EmptyResult > ( new RemoveUserContextCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
5254 }
5355
5456 public async Task < GetClientWindowsResult > GetClientWindowsAsync ( GetClientWindowsOptions ? options = null )
5557 {
56- return await Broker . ExecuteCommandAsync < GetClientWindowsCommand , GetClientWindowsResult > ( new ( ) , options , JsonContext ) . ConfigureAwait ( false ) ;
58+ return await Broker . ExecuteCommandAsync < GetClientWindowsCommand , GetClientWindowsResult > ( new ( ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
5759 }
5860
5961 public async Task < EmptyResult > SetDownloadBehaviorAllowedAsync ( string destinationFolder , SetDownloadBehaviorOptions ? options = null )
6062 {
6163 var @params = new SetDownloadBehaviorParameters ( new DownloadBehaviorAllowed ( destinationFolder ) , options ? . UserContexts ) ;
6264
63- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
65+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
6466 }
6567
6668 public async Task < EmptyResult > SetDownloadBehaviorAllowedAsync ( SetDownloadBehaviorOptions ? options = null )
6769 {
6870 var @params = new SetDownloadBehaviorParameters ( null , options ? . UserContexts ) ;
6971
70- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
72+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
7173 }
7274
7375 public async Task < EmptyResult > SetDownloadBehaviorDeniedAsync ( SetDownloadBehaviorOptions ? options = null )
7476 {
7577 var @params = new SetDownloadBehaviorParameters ( new DownloadBehaviorDenied ( ) , options ? . UserContexts ) ;
7678
77- return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , JsonContext ) . ConfigureAwait ( false ) ;
79+ return await Broker . ExecuteCommandAsync < SetDownloadBehaviorCommand , EmptyResult > ( new SetDownloadBehaviorCommand ( @params ) , options , _jsonContext ) . ConfigureAwait ( false ) ;
7880 }
7981
80- protected internal override JsonSerializerContext ConfigureJson ( JsonSerializerOptions options )
82+ protected internal override void Initialize ( JsonSerializerOptions options )
8183 {
82- return new BrowserModuleJsonSerializerContext ( options ) ;
84+ _jsonContext = new ( options ) ;
8385 }
8486}
8587
0 commit comments