@@ -30,15 +30,13 @@ namespace OpenQA.Selenium.BiDi;
3030
3131public sealed class BiDi : IAsyncDisposable
3232{
33- private readonly Broker _broker ;
34- private readonly JsonSerializerOptions _jsonOptions ;
33+ internal Broker Broker { get ; }
34+ internal JsonSerializerOptions JsonOptions { get ; }
3535 private readonly BiDiJsonSerializerContext _jsonContext ;
3636
37- private BiDi ( string url )
37+ public JsonSerializerOptions DefaultBiDiOptions ( )
3838 {
39- var uri = new Uri ( url ) ;
40-
41- _jsonOptions = new JsonSerializerOptions
39+ return new JsonSerializerOptions
4240 {
4341 PropertyNameCaseInsensitive = true ,
4442 PropertyNamingPolicy = JsonNamingPolicy . CamelCase ,
@@ -61,20 +59,27 @@ private BiDi(string url)
6159 new WebExtensionConverter ( this ) ,
6260 }
6361 } ;
62+ }
63+
64+ private BiDi ( string url )
65+ {
66+ var uri = new Uri ( url ) ;
6467
65- _jsonContext = new BiDiJsonSerializerContext ( _jsonOptions ) ;
66-
67- _broker = new Broker ( this , uri , _jsonOptions ) ;
68- SessionModule = Module . Create < Session . SessionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
69- BrowsingContext = Module . Create < BrowsingContext . BrowsingContextModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
70- Browser = Module . Create < Browser . BrowserModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
71- Network = Module . Create < Network . NetworkModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
72- InputModule = Module . Create < Input . InputModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
73- Script = Module . Create < Script . ScriptModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
74- Log = Module . Create < Log . LogModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
75- Storage = Module . Create < Storage . StorageModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
76- WebExtension = Module . Create < WebExtension . WebExtensionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
77- Emulation = Module . Create < Emulation . EmulationModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
68+ JsonOptions = DefaultBiDiOptions ( ) ;
69+
70+ _jsonContext = new BiDiJsonSerializerContext ( JsonOptions ) ;
71+
72+ Broker = new Broker ( this , uri , JsonOptions ) ;
73+ SessionModule = Module . Create < Session . SessionModule > ( this , JsonOptions , _jsonContext ) ;
74+ BrowsingContext = Module . Create < BrowsingContext . BrowsingContextModule > ( this , JsonOptions , _jsonContext ) ;
75+ Browser = Module . Create < Browser . BrowserModule > ( this , JsonOptions , _jsonContext ) ;
76+ Network = Module . Create < Network . NetworkModule > ( this , JsonOptions , _jsonContext ) ;
77+ InputModule = Module . Create < Input . InputModule > ( this , JsonOptions , _jsonContext ) ;
78+ Script = Module . Create < Script . ScriptModule > ( this , JsonOptions , _jsonContext ) ;
79+ Log = Module . Create < Log . LogModule > ( this , JsonOptions , _jsonContext ) ;
80+ Storage = Module . Create < Storage . StorageModule > ( this , JsonOptions , _jsonContext ) ;
81+ WebExtension = Module . Create < WebExtension . WebExtensionModule > ( this , JsonOptions , _jsonContext ) ;
82+ Emulation = Module . Create < Emulation . EmulationModule > ( this , JsonOptions , _jsonContext ) ;
7883 }
7984
8085 internal Session . SessionModule SessionModule { get ; }
@@ -106,7 +111,7 @@ public static async Task<BiDi> ConnectAsync(string url, BiDiOptions? options = n
106111 {
107112 var bidi = new BiDi ( url ) ;
108113
109- await bidi . _broker . ConnectAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
114+ await bidi . Broker . ConnectAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
110115
111116 return bidi ;
112117 }
@@ -118,7 +123,7 @@ public Task EndAsync(Session.EndOptions? options = null)
118123
119124 public async ValueTask DisposeAsync ( )
120125 {
121- await _broker . DisposeAsync ( ) . ConfigureAwait ( false ) ;
126+ await Broker . DisposeAsync ( ) . ConfigureAwait ( false ) ;
122127 GC . SuppressFinalize ( this ) ;
123128 }
124129}
0 commit comments