Skip to content
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 @@ -18,13 +18,8 @@
// </copyright>

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed record BrowsingContextInfo(BiDi BiDi, IReadOnlyList<BrowsingContextInfo>? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, string Url, Browser.UserContext UserContext)
: BrowsingContextEventArgs(BiDi, Context)
{
[JsonInclude]
public BrowsingContext? Parent { get; internal set; }
}
public sealed record BrowsingContextInfo(BiDi BiDi, IReadOnlyList<BrowsingContextInfo>? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, string Url, Browser.UserContext UserContext, BrowsingContext? Parent)
: BrowsingContextEventArgs(BiDi, Context);
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<Intercept> InterceptRequestAsync(Func<InterceptedRequest, Task
var intercept = await networkModule.AddInterceptAsync([InterceptPhase.BeforeRequestSent], addInterceptOptions).ConfigureAwait(false);

await intercept.OnBeforeRequestSentAsync(
async req => await handler(new(req.BiDi, req.Context, req.IsBlocked, req.Navigation, req.RedirectCount, req.Request, req.Timestamp, req.Initiator)),
async req => await handler(new(req.BiDi, req.Context, req.IsBlocked, req.Navigation, req.RedirectCount, req.Request, req.Timestamp, req.Initiator, req.Intercepts)),
new BrowsingContextsSubscriptionOptions(null) { Contexts = [context] }).ConfigureAwait(false);

return intercept;
Expand All @@ -51,7 +51,7 @@ public async Task<Intercept> InterceptResponseAsync(Func<InterceptedResponse, Ta
var intercept = await networkModule.AddInterceptAsync([InterceptPhase.ResponseStarted], addInterceptOptions).ConfigureAwait(false);

await intercept.OnResponseStartedAsync(
async res => await handler(new(res.BiDi, res.Context, res.IsBlocked, res.Navigation, res.RedirectCount, res.Request, res.Timestamp, res.Response)),
async res => await handler(new(res.BiDi, res.Context, res.IsBlocked, res.Navigation, res.RedirectCount, res.Request, res.Timestamp, res.Response, res.Intercepts)),
new BrowsingContextsSubscriptionOptions(null) { Contexts = [context] }).ConfigureAwait(false);

return intercept;
Expand All @@ -67,7 +67,7 @@ public async Task<Intercept> InterceptAuthAsync(Func<InterceptedAuth, Task> hand
var intercept = await networkModule.AddInterceptAsync([InterceptPhase.AuthRequired], addInterceptOptions).ConfigureAwait(false);

await intercept.OnAuthRequiredAsync(
async auth => await handler(new(auth.BiDi, auth.Context, auth.IsBlocked, auth.Navigation, auth.RedirectCount, auth.Request, auth.Timestamp, auth.Response)),
async auth => await handler(new(auth.BiDi, auth.Context, auth.IsBlocked, auth.Navigation, auth.RedirectCount, auth.Request, auth.Timestamp, auth.Response, auth.Intercepts)),
new BrowsingContextsSubscriptionOptions(null) { Contexts = [context] }).ConfigureAwait(false);

return intercept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
// under the License.
// </copyright>

using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed record UserPromptClosedEventArgs(BiDi BiDi, BrowsingContext Context, bool Accepted)
: BrowsingContextEventArgs(BiDi, Context)
{
[JsonInclude]
public string? UserText { get; internal set; }
}
public sealed record UserPromptClosedEventArgs(BiDi BiDi, BrowsingContext Context, bool Accepted, string? UserText)
: BrowsingContextEventArgs(BiDi, Context);
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@

namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Context, Session.UserPromptHandlerType Handler, UserPromptType Type, string Message)
: BrowsingContextEventArgs(BiDi, Context)
{
[JsonInclude]
public string? DefaultValue { get; internal set; }
}
public sealed record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Context, Session.UserPromptHandlerType Handler, UserPromptType Type, string Message, string? DefaultValue)
: BrowsingContextEventArgs(BiDi, Context);

[JsonConverter(typeof(CamelCaseEnumConverter<UserPromptType>))]
public enum UserPromptType
Expand Down
5 changes: 3 additions & 2 deletions dotnet/src/webdriver/BiDi/Network/AuthRequiredEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
// </copyright>

using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Network;

public record AuthRequiredEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response) :
BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp);
public record AuthRequiredEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response, IReadOnlyList<Intercept>? Intercepts) :
BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Intercepts);
10 changes: 2 additions & 8 deletions dotnet/src/webdriver/BiDi/Network/BaseParametersEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@
// </copyright>

using System.Collections.Generic;
using System.Text.Json.Serialization;
using System;

namespace OpenQA.Selenium.BiDi.Network;

public abstract record BaseParametersEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp)
: BrowsingContextEventArgs(BiDi, Context)
{
[JsonInclude]
public IReadOnlyList<Intercept>? Intercepts { get; internal set; }
}

public abstract record BaseParametersEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, IReadOnlyList<Intercept>? Intercepts)
: BrowsingContextEventArgs(BiDi, Context);
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

using OpenQA.Selenium.BiDi.BrowsingContext;
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Network;

public record BeforeRequestSentEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, Initiator Initiator)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp);
public record BeforeRequestSentEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, Initiator Initiator, IReadOnlyList<Intercept>? Intercepts)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Intercepts);
5 changes: 3 additions & 2 deletions dotnet/src/webdriver/BiDi/Network/FetchErrorEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

using OpenQA.Selenium.BiDi.BrowsingContext;
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Network;

public sealed record FetchErrorEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, string ErrorText)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp);
public sealed record FetchErrorEventArgs(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, string ErrorText, IReadOnlyList<Intercept>? Intercepts)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Intercepts);
19 changes: 10 additions & 9 deletions dotnet/src/webdriver/BiDi/Network/NetworkModule.HighLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// </copyright>

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace OpenQA.Selenium.BiDi.Network;
Expand All @@ -28,7 +29,7 @@ public async Task<Intercept> InterceptRequestAsync(Func<InterceptedRequest, Task
{
var intercept = await AddInterceptAsync([InterceptPhase.BeforeRequestSent], options).ConfigureAwait(false);

await intercept.OnBeforeRequestSentAsync(async req => await handler(new(req.BiDi, req.Context, req.IsBlocked, req.Navigation, req.RedirectCount, req.Request, req.Timestamp, req.Initiator))).ConfigureAwait(false);
await intercept.OnBeforeRequestSentAsync(async req => await handler(new(req.BiDi, req.Context, req.IsBlocked, req.Navigation, req.RedirectCount, req.Request, req.Timestamp, req.Initiator, req.Intercepts))).ConfigureAwait(false);

return intercept;
}
Expand All @@ -37,7 +38,7 @@ public async Task<Intercept> InterceptResponseAsync(Func<InterceptedResponse, Ta
{
var intercept = await AddInterceptAsync([InterceptPhase.ResponseStarted], options).ConfigureAwait(false);

await intercept.OnResponseStartedAsync(async res => await handler(new(res.BiDi, res.Context, res.IsBlocked, res.Navigation, res.RedirectCount, res.Request, res.Timestamp, res.Response))).ConfigureAwait(false);
await intercept.OnResponseStartedAsync(async res => await handler(new(res.BiDi, res.Context, res.IsBlocked, res.Navigation, res.RedirectCount, res.Request, res.Timestamp, res.Response, res.Intercepts))).ConfigureAwait(false);

return intercept;
}
Expand All @@ -46,7 +47,7 @@ public async Task<Intercept> InterceptAuthAsync(Func<InterceptedAuth, Task> hand
{
var intercept = await AddInterceptAsync([InterceptPhase.AuthRequired], options).ConfigureAwait(false);

await intercept.OnAuthRequiredAsync(async auth => await handler(new(auth.BiDi, auth.Context, auth.IsBlocked, auth.Navigation, auth.RedirectCount, auth.Request, auth.Timestamp, auth.Response))).ConfigureAwait(false);
await intercept.OnAuthRequiredAsync(async auth => await handler(new(auth.BiDi, auth.Context, auth.IsBlocked, auth.Navigation, auth.RedirectCount, auth.Request, auth.Timestamp, auth.Response, auth.Intercepts))).ConfigureAwait(false);

return intercept;
}
Expand All @@ -58,8 +59,8 @@ public sealed class InterceptResponseOptions : AddInterceptOptions;

public sealed class InterceptAuthOptions : AddInterceptOptions;

public sealed record InterceptedRequest(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, Initiator Initiator)
: BeforeRequestSentEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Initiator)
public sealed record InterceptedRequest(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, Initiator Initiator, IReadOnlyList<Intercept>? Intercepts)
: BeforeRequestSentEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Initiator, Intercepts)
{
public Task ContinueAsync(ContinueRequestOptions? options = null)
{
Expand All @@ -77,17 +78,17 @@ public Task ProvideResponseAsync(ProvideResponseOptions? options = null)
}
}

public sealed record InterceptedResponse(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response)
: ResponseStartedEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Response)
public sealed record InterceptedResponse(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response, IReadOnlyList<Intercept>? Intercepts)
: ResponseStartedEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Response, Intercepts)
{
public Task ContinueAsync(ContinueResponseOptions? options = null)
{
return BiDi.Network.ContinueResponseAsync(Request.Request, options);
}
}

public sealed record InterceptedAuth(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response)
: AuthRequiredEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Response)
public sealed record InterceptedAuth(BiDi BiDi, BrowsingContext.BrowsingContext? Context, bool IsBlocked, BrowsingContext.Navigation? Navigation, long RedirectCount, RequestData Request, DateTimeOffset Timestamp, ResponseData Response, IReadOnlyList<Intercept>? Intercepts)
: AuthRequiredEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Response, Intercepts)
{
public Task ContinueAsync(AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using OpenQA.Selenium.BiDi.BrowsingContext;
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Network;

Expand All @@ -29,5 +30,6 @@ public sealed record ResponseCompletedEventArgs(BiDi BiDi,
long RedirectCount,
RequestData Request,
DateTimeOffset Timestamp,
ResponseData Response)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp);
ResponseData Response,
IReadOnlyList<Intercept>? Intercepts)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Intercepts);
8 changes: 2 additions & 6 deletions dotnet/src/webdriver/BiDi/Network/ResponseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// </copyright>

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

Expand All @@ -32,8 +31,5 @@ public record ResponseData(string Url,
long BytesReceived,
long? HeadersSize,
long? BodySize,
ResponseContent Content)
{
[JsonInclude]
public IReadOnlyList<AuthChallenge>? AuthChallenges { get; internal set; }
}
ResponseContent Content,
IReadOnlyList<AuthChallenge>? AuthChallenges);
6 changes: 4 additions & 2 deletions dotnet/src/webdriver/BiDi/Network/ResponseStartedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using OpenQA.Selenium.BiDi.BrowsingContext;
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Network;

Expand All @@ -29,5 +30,6 @@ public record ResponseStartedEventArgs(BiDi BiDi,
long RedirectCount,
RequestData Request,
DateTimeOffset Timestamp,
ResponseData Response)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp);
ResponseData Response,
IReadOnlyList<Intercept>? Intercepts)
: BaseParametersEventArgs(BiDi, Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, Intercepts);
25 changes: 1 addition & 24 deletions dotnet/src/webdriver/BiDi/Script/NodeProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,7 @@
// </copyright>

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

public sealed record NodeProperties(long NodeType, long ChildNodeCount)
{
[JsonInclude]
public IReadOnlyDictionary<string, string>? Attributes { get; internal set; }

[JsonInclude]
public IReadOnlyList<NodeRemoteValue>? Children { get; internal set; }

[JsonInclude]
public string? LocalName { get; internal set; }

[JsonInclude]
public Mode? Mode { get; internal set; }

[JsonInclude]
public string? NamespaceUri { get; internal set; }

[JsonInclude]
public string? NodeValue { get; internal set; }

[JsonInclude]
public NodeRemoteValue? ShadowRoot { get; internal set; }
}
public sealed record NodeProperties(long NodeType, long ChildNodeCount, IReadOnlyDictionary<string, string>? Attributes, IReadOnlyList<NodeRemoteValue>? Children, string? LocalName, Mode? Mode, string? NamespaceUri, string? NodeValue, NodeRemoteValue? ShadowRoot);
8 changes: 1 addition & 7 deletions dotnet/src/webdriver/BiDi/Script/RemoteValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,11 @@ public sealed record HtmlCollectionRemoteValue : RemoteValue
public IReadOnlyList<RemoteValue>? Value { get; set; }
}

public sealed record NodeRemoteValue : RemoteValue, ISharedReference
public sealed record NodeRemoteValue(string? SharedId, NodeProperties? Value) : RemoteValue, ISharedReference
{
[JsonInclude]
public string? SharedId { get; internal set; }

public Handle? Handle { get; set; }

public InternalId? InternalId { get; set; }

[JsonInclude]
public NodeProperties? Value { get; internal set; }
}

public sealed record WindowProxyRemoteValue(WindowProxyProperties Value) : RemoteValue
Expand Down