Skip to content

Commit

Permalink
[dotnet] [bidi] Get tree from browsing context as root (#14495)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko authored Sep 13, 2024
1 parent 6b4c39c commit 6c0df70
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
return _bidi.BrowsingContextModule.HandleUserPromptAsync(this, options);
}

public Task<IReadOnlyList<BrowsingContextInfo>> GetTreeAsync(BrowsingContextGetTreeOptions? options = null)
{
options ??= new();

options.Root = this;

return _bidi.BrowsingContextModule.GetTreeAsync(options);
}

public Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
{
return _bidi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using System;
using OpenQA.Selenium.BiDi.Modules.Network;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;

public class BrowsingContextNetworkModule(BrowsingContext context, NetworkModule networkModule)
{
public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
{
interceptOptions ??= new();

Expand All @@ -19,7 +19,7 @@ public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventAr
return intercept;
}

public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
{
interceptOptions ??= new();

Expand All @@ -32,7 +32,7 @@ public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArg
return intercept;
}

public async Task<Intercept> InterceptAuthenticationAsync(Func<AuthRequiredEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
public async Task<Intercept> InterceptAuthenticationAsync(Func<AuthRequiredEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
{
interceptOptions ??= new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;

public class BrowsingContextScriptModule(BrowsingContext context, ScriptModule scriptModule)
{
public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaration, AddPreloadScriptOptions? options = null)
public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null)
{
options ??= new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ public record GetTreeOptions : CommandOptions
public BrowsingContext? Root { get; set; }
}

public record BrowsingContextGetTreeOptions : GetTreeOptions
{
internal new BrowsingContext? Root
{
get => base.Root;
set => base.Root = value;
}
}

public record GetTreeResult(IReadOnlyList<BrowsingContextInfo> Contexts);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public record AddInterceptOptions : CommandOptions
public IEnumerable<UrlPattern>? UrlPatterns { get; set; }
}

public record BrowsingContextAddInterceptOptions : AddInterceptOptions
{
internal new IEnumerable<BrowsingContext.BrowsingContext>? Contexts
{
get => base.Contexts;
set => base.Contexts = value;
}
}

public record AddInterceptResult(Intercept Intercept);

public enum InterceptPhase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ public record AddPreloadScriptOptions : CommandOptions
public string? Sandbox { get; set; }
}

public record BrowsingContextAddPreloadScriptOptions : AddPreloadScriptOptions
{
internal new IEnumerable<BrowsingContext.BrowsingContext>? Contexts
{
get => base.Contexts;
set => base.Contexts = value;
}
}

internal record AddPreloadScriptResult(PreloadScript Script);

0 comments on commit 6c0df70

Please sign in to comment.