Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] [bidi] Get tree from browsing context as root #14495

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Loading