Skip to content

Commit a7a53fb

Browse files
committed
[dotnet] [bidi] Expose BiDi associated reference in browsing context
1 parent 35dd34a commit a7a53fb

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

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

+33-33
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ public class BrowsingContext
88
{
99
internal BrowsingContext(BiDi bidi, string id)
1010
{
11-
_bidi = bidi;
11+
BiDi = bidi;
1212
Id = id;
1313

14-
_logModule = new Lazy<BrowsingContextLogModule>(() => new BrowsingContextLogModule(this, _bidi.Log));
15-
_networkModule = new Lazy<BrowsingContextNetworkModule>(() => new BrowsingContextNetworkModule(this, _bidi.Network));
16-
_scriptModule = new Lazy<BrowsingContextScriptModule>(() => new BrowsingContextScriptModule(this, _bidi.ScriptModule));
17-
_storageModule = new Lazy<BrowsingContextStorageModule>(() => new BrowsingContextStorageModule(this, _bidi.Storage));
18-
_inputModule = new Lazy<BrowsingContextInputModule>(() => new BrowsingContextInputModule(this, _bidi.InputModule));
14+
_logModule = new Lazy<BrowsingContextLogModule>(() => new BrowsingContextLogModule(this, BiDi.Log));
15+
_networkModule = new Lazy<BrowsingContextNetworkModule>(() => new BrowsingContextNetworkModule(this, BiDi.Network));
16+
_scriptModule = new Lazy<BrowsingContextScriptModule>(() => new BrowsingContextScriptModule(this, BiDi.ScriptModule));
17+
_storageModule = new Lazy<BrowsingContextStorageModule>(() => new BrowsingContextStorageModule(this, BiDi.Storage));
18+
_inputModule = new Lazy<BrowsingContextInputModule>(() => new BrowsingContextInputModule(this, BiDi.InputModule));
1919
}
2020

21-
private readonly BiDi _bidi;
22-
2321
private readonly Lazy<BrowsingContextLogModule> _logModule;
2422
private readonly Lazy<BrowsingContextNetworkModule> _networkModule;
2523
private readonly Lazy<BrowsingContextScriptModule> _scriptModule;
@@ -28,6 +26,8 @@ internal BrowsingContext(BiDi bidi, string id)
2826

2927
internal string Id { get; }
3028

29+
public BiDi BiDi { get; }
30+
3131
public BrowsingContextLogModule Log => _logModule.Value;
3232

3333
public BrowsingContextNetworkModule Network => _networkModule.Value;
@@ -40,37 +40,37 @@ internal BrowsingContext(BiDi bidi, string id)
4040

4141
public Task<NavigateResult> NavigateAsync(string url, NavigateOptions? options = null)
4242
{
43-
return _bidi.BrowsingContextModule.NavigateAsync(this, url, options);
43+
return BiDi.BrowsingContextModule.NavigateAsync(this, url, options);
4444
}
4545

4646
public Task<NavigateResult> ReloadAsync(ReloadOptions? options = null)
4747
{
48-
return _bidi.BrowsingContextModule.ReloadAsync(this, options);
48+
return BiDi.BrowsingContextModule.ReloadAsync(this, options);
4949
}
5050

5151
public Task ActivateAsync(ActivateOptions? options = null)
5252
{
53-
return _bidi.BrowsingContextModule.ActivateAsync(this, options);
53+
return BiDi.BrowsingContextModule.ActivateAsync(this, options);
5454
}
5555

5656
public Task<IReadOnlyList<Script.NodeRemoteValue>> LocateNodesAsync(Locator locator, LocateNodesOptions? options = null)
5757
{
58-
return _bidi.BrowsingContextModule.LocateNodesAsync(this, locator, options);
58+
return BiDi.BrowsingContextModule.LocateNodesAsync(this, locator, options);
5959
}
6060

6161
public Task<CaptureScreenshotResult> CaptureScreenshotAsync(CaptureScreenshotOptions? options = null)
6262
{
63-
return _bidi.BrowsingContextModule.CaptureScreenshotAsync(this, options);
63+
return BiDi.BrowsingContextModule.CaptureScreenshotAsync(this, options);
6464
}
6565

6666
public Task CloseAsync(CloseOptions? options = null)
6767
{
68-
return _bidi.BrowsingContextModule.CloseAsync(this, options);
68+
return BiDi.BrowsingContextModule.CloseAsync(this, options);
6969
}
7070

7171
public Task TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
7272
{
73-
return _bidi.BrowsingContextModule.TraverseHistoryAsync(this, delta, options);
73+
return BiDi.BrowsingContextModule.TraverseHistoryAsync(this, delta, options);
7474
}
7575

7676
public Task NavigateBackAsync(TraverseHistoryOptions? options = null)
@@ -85,17 +85,17 @@ public Task NavigateForwardAsync(TraverseHistoryOptions? options = null)
8585

8686
public Task SetViewportAsync(SetViewportOptions? options = null)
8787
{
88-
return _bidi.BrowsingContextModule.SetViewportAsync(this, options);
88+
return BiDi.BrowsingContextModule.SetViewportAsync(this, options);
8989
}
9090

9191
public Task<PrintResult> PrintAsync(PrintOptions? options = null)
9292
{
93-
return _bidi.BrowsingContextModule.PrintAsync(this, options);
93+
return BiDi.BrowsingContextModule.PrintAsync(this, options);
9494
}
9595

9696
public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
9797
{
98-
return _bidi.BrowsingContextModule.HandleUserPromptAsync(this, options);
98+
return BiDi.BrowsingContextModule.HandleUserPromptAsync(this, options);
9999
}
100100

101101
public Task<IReadOnlyList<BrowsingContextInfo>> GetTreeAsync(BrowsingContextGetTreeOptions? options = null)
@@ -105,77 +105,77 @@ public Task<IReadOnlyList<BrowsingContextInfo>> GetTreeAsync(BrowsingContextGetT
105105
Root = this
106106
};
107107

108-
return _bidi.BrowsingContextModule.GetTreeAsync(getTreeOptions);
108+
return BiDi.BrowsingContextModule.GetTreeAsync(getTreeOptions);
109109
}
110110

111111
public Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
112112
{
113-
return _bidi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
113+
return BiDi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
114114
}
115115

116116
public Task<Subscription> OnNavigationStartedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
117117
{
118-
return _bidi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
118+
return BiDi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
119119
}
120120

121121
public Task<Subscription> OnFragmentNavigatedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
122122
{
123-
return _bidi.BrowsingContextModule.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
123+
return BiDi.BrowsingContextModule.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
124124
}
125125

126126
public Task<Subscription> OnFragmentNavigatedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
127127
{
128-
return _bidi.BrowsingContextModule.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
128+
return BiDi.BrowsingContextModule.OnFragmentNavigatedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
129129
}
130130

131131
public Task<Subscription> OnDomContentLoadedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
132132
{
133-
return _bidi.BrowsingContextModule.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
133+
return BiDi.BrowsingContextModule.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
134134
}
135135

136136
public Task<Subscription> OnLoadAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
137137
{
138-
return _bidi.BrowsingContextModule.OnLoadAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
138+
return BiDi.BrowsingContextModule.OnLoadAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
139139
}
140140

141141
public Task<Subscription> OnLoadAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
142142
{
143-
return _bidi.BrowsingContextModule.OnLoadAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
143+
return BiDi.BrowsingContextModule.OnLoadAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
144144
}
145145

146146
public Task<Subscription> OnDownloadWillBeginAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
147147
{
148-
return _bidi.BrowsingContextModule.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
148+
return BiDi.BrowsingContextModule.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
149149
}
150150

151151
public Task<Subscription> OnDownloadWillBeginAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
152152
{
153-
return _bidi.BrowsingContextModule.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
153+
return BiDi.BrowsingContextModule.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
154154
}
155155

156156
public Task<Subscription> OnNavigationAbortedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
157157
{
158-
return _bidi.BrowsingContextModule.OnNavigationAbortedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
158+
return BiDi.BrowsingContextModule.OnNavigationAbortedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
159159
}
160160

161161
public Task<Subscription> OnNavigationAbortedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
162162
{
163-
return _bidi.BrowsingContextModule.OnNavigationAbortedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
163+
return BiDi.BrowsingContextModule.OnNavigationAbortedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
164164
}
165165

166166
public Task<Subscription> OnNavigationFailedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
167167
{
168-
return _bidi.BrowsingContextModule.OnNavigationFailedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
168+
return BiDi.BrowsingContextModule.OnNavigationFailedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
169169
}
170170

171171
public Task<Subscription> OnNavigationFailedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
172172
{
173-
return _bidi.BrowsingContextModule.OnNavigationFailedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
173+
return BiDi.BrowsingContextModule.OnNavigationFailedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
174174
}
175175

176176
public Task<Subscription> OnDomContentLoadedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
177177
{
178-
return _bidi.BrowsingContextModule.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
178+
return BiDi.BrowsingContextModule.OnDomContentLoadedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
179179
}
180180

181181
public override bool Equals(object? obj)

0 commit comments

Comments
 (0)