@@ -29,15 +29,13 @@ namespace OpenQA.Selenium.BiDi;
2929
3030public sealed class BiDi : IAsyncDisposable
3131{
32- private readonly Broker _broker ;
33- private readonly JsonSerializerOptions _jsonOptions ;
32+ internal Broker Broker { get ; }
33+ internal JsonSerializerOptions JsonOptions { get ; }
3434 private readonly BiDiJsonSerializerContext _jsonContext ;
3535
36- private BiDi ( string url )
36+ public JsonSerializerOptions DefaultBiDiOptions ( )
3737 {
38- var uri = new Uri ( url ) ;
39-
40- _jsonOptions = new JsonSerializerOptions
38+ return new JsonSerializerOptions
4139 {
4240 PropertyNameCaseInsensitive = true ,
4341 PropertyNamingPolicy = JsonNamingPolicy . CamelCase ,
@@ -60,20 +58,27 @@ private BiDi(string url)
6058 new WebExtensionConverter ( this ) ,
6159 }
6260 } ;
61+ }
62+
63+ private BiDi ( string url )
64+ {
65+ var uri = new Uri ( url ) ;
6366
64- _jsonContext = new BiDiJsonSerializerContext ( _jsonOptions ) ;
65-
66- _broker = new Broker ( this , uri , _jsonOptions ) ;
67- SessionModule = Module . Create < Session . SessionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
68- BrowsingContext = Module . Create < BrowsingContext . BrowsingContextModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
69- Browser = Module . Create < Browser . BrowserModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
70- Network = Module . Create < Network . NetworkModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
71- InputModule = Module . Create < Input . InputModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
72- Script = Module . Create < Script . ScriptModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
73- Log = Module . Create < Log . LogModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
74- Storage = Module . Create < Storage . StorageModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
75- WebExtension = Module . Create < WebExtension . WebExtensionModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
76- Emulation = Module . Create < Emulation . EmulationModule > ( this , _broker , _jsonOptions , _jsonContext ) ;
67+ JsonOptions = DefaultBiDiOptions ( ) ;
68+
69+ _jsonContext = new BiDiJsonSerializerContext ( JsonOptions ) ;
70+
71+ Broker = new Broker ( this , uri , JsonOptions ) ;
72+ SessionModule = Module . Create < Session . SessionModule > ( this , JsonOptions , _jsonContext ) ;
73+ BrowsingContext = Module . Create < BrowsingContext . BrowsingContextModule > ( this , JsonOptions , _jsonContext ) ;
74+ Browser = Module . Create < Browser . BrowserModule > ( this , JsonOptions , _jsonContext ) ;
75+ Network = Module . Create < Network . NetworkModule > ( this , JsonOptions , _jsonContext ) ;
76+ InputModule = Module . Create < Input . InputModule > ( this , JsonOptions , _jsonContext ) ;
77+ Script = Module . Create < Script . ScriptModule > ( this , JsonOptions , _jsonContext ) ;
78+ Log = Module . Create < Log . LogModule > ( this , JsonOptions , _jsonContext ) ;
79+ Storage = Module . Create < Storage . StorageModule > ( this , JsonOptions , _jsonContext ) ;
80+ WebExtension = Module . Create < WebExtension . WebExtensionModule > ( this , JsonOptions , _jsonContext ) ;
81+ Emulation = Module . Create < Emulation . EmulationModule > ( this , JsonOptions , _jsonContext ) ;
7782 }
7883
7984 internal Session . SessionModule SessionModule { get ; }
@@ -105,7 +110,7 @@ public static async Task<BiDi> ConnectAsync(string url, BiDiOptions? options = n
105110 {
106111 var bidi = new BiDi ( url ) ;
107112
108- await bidi . _broker . ConnectAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
113+ await bidi . Broker . ConnectAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
109114
110115 return bidi ;
111116 }
@@ -117,7 +122,7 @@ public Task EndAsync(Session.EndOptions? options = null)
117122
118123 public async ValueTask DisposeAsync ( )
119124 {
120- await _broker . DisposeAsync ( ) . ConfigureAwait ( false ) ;
125+ await Broker . DisposeAsync ( ) . ConfigureAwait ( false ) ;
121126 GC . SuppressFinalize ( this ) ;
122127 }
123128}
0 commit comments