Skip to content

Commit

Permalink
[dotnet] [bidi] Expose BiDi associated reference in browsing context
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Sep 15, 2024
1 parent 35dd34a commit a7a53fb
Showing 1 changed file with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ public class BrowsingContext
{
internal BrowsingContext(BiDi bidi, string id)
{
_bidi = bidi;
BiDi = bidi;
Id = id;

_logModule = new Lazy<BrowsingContextLogModule>(() => new BrowsingContextLogModule(this, _bidi.Log));
_networkModule = new Lazy<BrowsingContextNetworkModule>(() => new BrowsingContextNetworkModule(this, _bidi.Network));
_scriptModule = new Lazy<BrowsingContextScriptModule>(() => new BrowsingContextScriptModule(this, _bidi.ScriptModule));
_storageModule = new Lazy<BrowsingContextStorageModule>(() => new BrowsingContextStorageModule(this, _bidi.Storage));
_inputModule = new Lazy<BrowsingContextInputModule>(() => new BrowsingContextInputModule(this, _bidi.InputModule));
_logModule = new Lazy<BrowsingContextLogModule>(() => new BrowsingContextLogModule(this, BiDi.Log));
_networkModule = new Lazy<BrowsingContextNetworkModule>(() => new BrowsingContextNetworkModule(this, BiDi.Network));
_scriptModule = new Lazy<BrowsingContextScriptModule>(() => new BrowsingContextScriptModule(this, BiDi.ScriptModule));
_storageModule = new Lazy<BrowsingContextStorageModule>(() => new BrowsingContextStorageModule(this, BiDi.Storage));
_inputModule = new Lazy<BrowsingContextInputModule>(() => new BrowsingContextInputModule(this, BiDi.InputModule));
}

private readonly BiDi _bidi;

private readonly Lazy<BrowsingContextLogModule> _logModule;
private readonly Lazy<BrowsingContextNetworkModule> _networkModule;
private readonly Lazy<BrowsingContextScriptModule> _scriptModule;
Expand All @@ -28,6 +26,8 @@ internal BrowsingContext(BiDi bidi, string id)

internal string Id { get; }

public BiDi BiDi { get; }

public BrowsingContextLogModule Log => _logModule.Value;

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

public Task<NavigateResult> NavigateAsync(string url, NavigateOptions? options = null)
{
return _bidi.BrowsingContextModule.NavigateAsync(this, url, options);
return BiDi.BrowsingContextModule.NavigateAsync(this, url, options);
}

public Task<NavigateResult> ReloadAsync(ReloadOptions? options = null)
{
return _bidi.BrowsingContextModule.ReloadAsync(this, options);
return BiDi.BrowsingContextModule.ReloadAsync(this, options);
}

public Task ActivateAsync(ActivateOptions? options = null)
{
return _bidi.BrowsingContextModule.ActivateAsync(this, options);
return BiDi.BrowsingContextModule.ActivateAsync(this, options);
}

public Task<IReadOnlyList<Script.NodeRemoteValue>> LocateNodesAsync(Locator locator, LocateNodesOptions? options = null)
{
return _bidi.BrowsingContextModule.LocateNodesAsync(this, locator, options);
return BiDi.BrowsingContextModule.LocateNodesAsync(this, locator, options);
}

public Task<CaptureScreenshotResult> CaptureScreenshotAsync(CaptureScreenshotOptions? options = null)
{
return _bidi.BrowsingContextModule.CaptureScreenshotAsync(this, options);
return BiDi.BrowsingContextModule.CaptureScreenshotAsync(this, options);
}

public Task CloseAsync(CloseOptions? options = null)
{
return _bidi.BrowsingContextModule.CloseAsync(this, options);
return BiDi.BrowsingContextModule.CloseAsync(this, options);
}

public Task TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
{
return _bidi.BrowsingContextModule.TraverseHistoryAsync(this, delta, options);
return BiDi.BrowsingContextModule.TraverseHistoryAsync(this, delta, options);
}

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

public Task SetViewportAsync(SetViewportOptions? options = null)
{
return _bidi.BrowsingContextModule.SetViewportAsync(this, options);
return BiDi.BrowsingContextModule.SetViewportAsync(this, options);
}

public Task<PrintResult> PrintAsync(PrintOptions? options = null)
{
return _bidi.BrowsingContextModule.PrintAsync(this, options);
return BiDi.BrowsingContextModule.PrintAsync(this, options);
}

public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
{
return _bidi.BrowsingContextModule.HandleUserPromptAsync(this, options);
return BiDi.BrowsingContextModule.HandleUserPromptAsync(this, options);
}

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

return _bidi.BrowsingContextModule.GetTreeAsync(getTreeOptions);
return BiDi.BrowsingContextModule.GetTreeAsync(getTreeOptions);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

public override bool Equals(object? obj)
Expand Down

0 comments on commit a7a53fb

Please sign in to comment.