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
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Browser/ClientWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Browser;

[JsonConverter(typeof(BrowserClientWindowConverter))]
public sealed record ClientWindow
{
internal ClientWindow(string id)
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Browser;

Expand All @@ -28,6 +30,7 @@ internal sealed class GetClientWindowsCommand()

public sealed class GetClientWindowsOptions : CommandOptions;

[JsonConverter(typeof(GetClientWindowsResultConverter))]
public sealed record GetClientWindowsResult : EmptyResult, IReadOnlyList<ClientWindowInfo>
{
internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows)
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Browser;

Expand All @@ -28,6 +30,7 @@ internal sealed class GetUserContextsCommand()

public class GetUserContextsOptions : CommandOptions;

[JsonConverter(typeof(GetUserContextsResultConverter))]
public sealed record GetUserContextsResult : EmptyResult, IReadOnlyList<UserContextInfo>
{
internal GetUserContextsResult(IReadOnlyList<UserContextInfo> userContexts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
using System;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

// https://github.com/dotnet/runtime/issues/72604
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "status")]
//[JsonDerivedType(typeof(DownloadCanceledEventArgs), "canceled")]
//[JsonDerivedType(typeof(DownloadCompleteEventArgs), "complete")]
[JsonConverter(typeof(DownloadEndEventArgsConverter))]
public abstract record DownloadEndEventArgs(BiDi BiDi, BrowsingContext Context)
: BrowsingContextEventArgs(BiDi, Context);

Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand Down Expand Up @@ -47,6 +49,7 @@ public sealed record BrowsingContextGetTreeOptions
public long? MaxDepth { get; set; }
}

[JsonConverter(typeof(GetTreeResultConverter))]
public sealed record GetTreeResult : EmptyResult, IReadOnlyList<BrowsingContextInfo>
{
internal GetTreeResult(IReadOnlyList<BrowsingContextInfo> contexts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand All @@ -37,6 +39,7 @@ public sealed class LocateNodesOptions : CommandOptions
public IEnumerable<Script.ISharedReference>? StartNodes { get; set; }
}

[JsonConverter(typeof(LocateNodesResultConverter))]
public sealed record LocateNodesResult : EmptyResult, IReadOnlyList<Script.NodeRemoteValue>
{
internal LocateNodesResult(IReadOnlyList<Script.NodeRemoteValue> nodes)
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

[JsonConverter(typeof(NavigationConverter))]
public sealed record Navigation(string Id);
1 change: 1 addition & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public struct PrintPage
public double? Width { get; set; }
}

[JsonConverter(typeof(PrintPageRangeConverter))]
public readonly record struct PrintPageRange(int? Start, int? End)
{
public static implicit operator PrintPageRange(int index) { return new PrintPageRange(index, index); }
Expand Down
26 changes: 1 addition & 25 deletions dotnet/src/webdriver/BiDi/Communication/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,39 +72,15 @@ internal Broker(BiDi bidi, Uri url)
Converters =
{
new BrowsingContextConverter(_bidi),
new BrowserUserContextConverter(bidi),
new BrowserClientWindowConverter(),
new NavigationConverter(),
new BrowserUserContextConverter(_bidi),
new CollectorConverter(_bidi),
new InterceptConverter(_bidi),
new RequestConverter(),
new ChannelConverter(),
new HandleConverter(_bidi),
new InternalIdConverter(_bidi),
new PreloadScriptConverter(_bidi),
new RealmConverter(_bidi),
new DateTimeOffsetConverter(),
new PrintPageRangeConverter(),
new InputOriginConverter(),
new WebExtensionConverter(_bidi),
new SubscriptionConverter(),

// https://github.com/dotnet/runtime/issues/72604
new Json.Converters.Polymorphic.EvaluateResultConverter(),
new Json.Converters.Polymorphic.RemoteValueConverter(),
new Json.Converters.Polymorphic.RealmInfoConverter(),
new Json.Converters.Polymorphic.LogEntryConverter(),
new Json.Converters.Polymorphic.DownloadEndEventArgsConverter(),
//

// Enumerable
new Json.Converters.Enumerable.GetCookiesResultConverter(),
new Json.Converters.Enumerable.LocateNodesResultConverter(),
new Json.Converters.Enumerable.InputSourceActionsConverter(),
new Json.Converters.Enumerable.GetUserContextsResultConverter(),
new Json.Converters.Enumerable.GetClientWindowsResultConverter(),
new Json.Converters.Enumerable.GetRealmsResultConverter(),
new Json.Converters.Enumerable.GetTreeResultConverter(),
}
};

Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Input/Origin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Input;

[JsonConverter(typeof(InputOriginConverter))]
public abstract record Origin;

public sealed record ViewportOrigin() : Origin;
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Input/SourceActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Input;

[JsonConverter(typeof(InputSourceActionsConverter))]
public abstract record SourceActions
{
public string Id { get; } = Guid.NewGuid().ToString();
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Log/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
Expand All @@ -29,6 +30,7 @@ namespace OpenQA.Selenium.BiDi.Log;
//[JsonDerivedType(typeof(GenericLogEntry))]
//[JsonDerivedType(typeof(ConsoleLogEntry), "console")]
//[JsonDerivedType(typeof(JavascriptLogEntry), "javascript")]
[JsonConverter(typeof(LogEntryConverter))]
public abstract record LogEntry(BiDi BiDi, Level Level, Script.Source Source, string? Text, DateTimeOffset Timestamp)
: EventArgs(BiDi)
{
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Network/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Network;

[JsonConverter(typeof(RequestConverter))]
public sealed class Request
{
internal Request(string id)
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

[JsonConverter(typeof(ChannelConverter))]
public sealed record Channel(string Id);
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
using System;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

Expand All @@ -40,6 +42,7 @@ public sealed class EvaluateOptions : CommandOptions
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
//[JsonDerivedType(typeof(EvaluateResultSuccess), "success")]
//[JsonDerivedType(typeof(EvaluateResultException), "exception")]
[JsonConverter(typeof(EvaluateResultConverter))]
public abstract record EvaluateResult : EmptyResult
{
public RemoteValue AsSuccessResult()
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

Expand All @@ -35,6 +37,7 @@ public sealed class GetRealmsOptions : CommandOptions
public RealmType? Type { get; set; }
}

[JsonConverter(typeof(GetRealmsResultConverter))]
public sealed record GetRealmsResult : EmptyResult, IReadOnlyList<RealmInfo>
{
private readonly IReadOnlyList<RealmInfo> _realms;
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Script/RealmInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Script;

Expand All @@ -31,6 +33,7 @@ namespace OpenQA.Selenium.BiDi.Script;
//[JsonDerivedType(typeof(PaintWorkletRealmInfo), "paint-worklet")]
//[JsonDerivedType(typeof(AudioWorkletRealmInfo), "audio-worklet")]
//[JsonDerivedType(typeof(WorkletRealmInfo), "worklet")]
[JsonConverter(typeof(RealmInfoConverter))]
public abstract record RealmInfo(BiDi BiDi, Realm Realm, string Origin) : EventArgs(BiDi);

public sealed record WindowRealmInfo(BiDi BiDi, Realm Realm, string Origin, BrowsingContext.BrowsingContext Context) : RealmInfo(BiDi, Realm, Origin)
Expand Down
3 changes: 2 additions & 1 deletion dotnet/src/webdriver/BiDi/Script/RemoteValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text.Json;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;

namespace OpenQA.Selenium.BiDi.Script;

Expand Down Expand Up @@ -55,6 +55,7 @@ namespace OpenQA.Selenium.BiDi.Script;
//[JsonDerivedType(typeof(HtmlCollectionRemoteValue), "htmlcollection")]
//[JsonDerivedType(typeof(NodeRemoteValue), "node")]
//[JsonDerivedType(typeof(WindowProxyRemoteValue), "window")]
[JsonConverter(typeof(RemoteValueConverter))]
public abstract record RemoteValue
{
public static implicit operator double(RemoteValue remoteValue) => (double)((NumberRemoteValue)remoteValue).Value;
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Session/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Session;

[JsonConverter(typeof(SubscriptionConverter))]
public sealed class Subscription
{
internal Subscription(string id)
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -37,6 +38,7 @@ public sealed class GetCookiesOptions : CommandOptions
public PartitionDescriptor? Partition { get; set; }
}

[JsonConverter(typeof(GetCookiesResultConverter))]
public sealed record GetCookiesResult : EmptyResult, IReadOnlyList<Network.Cookie>
{
internal GetCookiesResult(IReadOnlyList<Network.Cookie> cookies, PartitionKey partitionKey)
Expand Down