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] Second round of BiDi implementation #14566

Merged
merged 69 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1278557
Refactor
nvborisenko Sep 24, 2024
f6eb03d
Auth
nvborisenko Sep 25, 2024
2c32a8e
Log tests
nvborisenko Sep 25, 2024
27583a2
Auth tests
nvborisenko Sep 25, 2024
b4a92c5
Intercept options
nvborisenko Sep 25, 2024
c525507
Stabilize tests
nvborisenko Sep 25, 2024
c41f567
Finish network tests
nvborisenko Sep 25, 2024
f3c93cb
Stabilize
nvborisenko Sep 25, 2024
0fdd4c4
Browser tests
nvborisenko Sep 25, 2024
e55f10a
Update InputModule.cs
nvborisenko Sep 25, 2024
2a88779
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Sep 26, 2024
6557ff2
Parallelize
nvborisenko Sep 26, 2024
5498d8c
Storage tests
nvborisenko Sep 26, 2024
b8be96d
Stabilize
nvborisenko Sep 26, 2024
25f1c79
Enumerable cookies
nvborisenko Sep 26, 2024
c26d213
Update Subscription.cs
nvborisenko Sep 26, 2024
42f4150
Script tests
nvborisenko Sep 26, 2024
e96b546
Evaluate tests
nvborisenko Sep 27, 2024
2d70508
Script events
nvborisenko Sep 27, 2024
61d7fe2
Script commands
nvborisenko Sep 27, 2024
dd5eac5
Temp input
nvborisenko Sep 27, 2024
e80ea94
Temp input tests
nvborisenko Sep 28, 2024
96b7f3c
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Sep 28, 2024
6f68c21
Experimenting input via paint
nvborisenko Sep 29, 2024
d711bd8
Update DefaultMouseTest.cs
nvborisenko Oct 1, 2024
4c8e10c
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Oct 4, 2024
88be355
Make actions required
nvborisenko Oct 4, 2024
de74098
Don't introduce any helpers
nvborisenko Oct 4, 2024
2124ef8
Input wheel
nvborisenko Oct 4, 2024
91325ce
Simplify hierarchy
nvborisenko Oct 4, 2024
a93b2b5
Better
nvborisenko Oct 4, 2024
33a88b6
GetUserContextsResult as enumerable
nvborisenko Oct 4, 2024
3853119
LocateNodesResult as enumerable
nvborisenko Oct 4, 2024
5bc7a3c
GetRealmsResult as Enumerable
nvborisenko Oct 4, 2024
68fd7c4
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Oct 4, 2024
497a265
Better?
nvborisenko Oct 4, 2024
54daefa
Should be TestFixture?
nvborisenko Oct 5, 2024
0135519
And make fixture public magically
nvborisenko Oct 5, 2024
2ff0b5c
Fix CanListenToFetchError test
nvborisenko Oct 5, 2024
4065342
Fix CanListenToOnAuthRequiredEvent test
nvborisenko Oct 5, 2024
042fd7c
Remove demo test
nvborisenko Oct 5, 2024
a295033
Fix CanFailRequest test
nvborisenko Oct 5, 2024
19edb16
Update ScriptCommandsTest.cs
nvborisenko Oct 5, 2024
7b7552a
Fix CanFailRequest test
nvborisenko Oct 5, 2024
8705113
Ignore auth req continue for firefox
nvborisenko Oct 5, 2024
c760369
Don't output command length in logs
nvborisenko Oct 5, 2024
e4d91ca
Hide transport
nvborisenko Oct 5, 2024
b64ea04
Enable nullable context for bidi namespace
nvborisenko Oct 5, 2024
3557645
Even more warnings
nvborisenko Oct 5, 2024
661c52e
Intercept is cls compliant
nvborisenko Oct 5, 2024
15ef32f
String remote value not null?
nvborisenko Oct 5, 2024
8eb4cb4
Merge branch 'trunk' into dotnet-bidi-second-round
nvborisenko Oct 5, 2024
1add679
Merge branch 'trunk' into dotnet-bidi-second-round
nvborisenko Oct 5, 2024
e142fe9
Options in browsing context log as optional
nvborisenko Oct 5, 2024
b777ead
Fix warnings for UrlPattern and Locator
nvborisenko Oct 6, 2024
25f1a5b
Remove extra experiment
nvborisenko Oct 6, 2024
39f233a
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Oct 6, 2024
588e358
Make sure unions don't contain extra nested classes
nvborisenko Oct 6, 2024
a3aa07e
None input action
nvborisenko Oct 6, 2024
55afa4f
Source input actions as interface
nvborisenko Oct 6, 2024
013d2b3
Update SourceActions.cs
nvborisenko Oct 6, 2024
3cd459c
Open door to sequential input actions
nvborisenko Oct 6, 2024
762648c
Pause as ISourceAction
nvborisenko Oct 10, 2024
9b1b6d0
TODO Node as shared reference
nvborisenko Oct 11, 2024
7681685
Add input tests
nvborisenko Oct 13, 2024
eb0ac57
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-second…
nvborisenko Oct 24, 2024
de2075f
Simplified required properties dto
nvborisenko Oct 24, 2024
a6ca10a
Tests for Input module temporary are out
nvborisenko Oct 26, 2024
56c8e42
Merge branch 'trunk' into dotnet-bidi-second-round
nvborisenko Oct 26, 2024
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
57 changes: 4 additions & 53 deletions dotnet/src/webdriver/BiDi/BiDi.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Transport;

#nullable enable

namespace OpenQA.Selenium.BiDi;

public class BiDi : IAsyncDisposable
Expand Down Expand Up @@ -38,11 +39,11 @@ internal BiDi(string url)
}

internal Modules.Session.SessionModule SessionModule => _sessionModule.Value;
internal Modules.BrowsingContext.BrowsingContextModule BrowsingContextModule => _browsingContextModule.Value;
internal Modules.BrowsingContext.BrowsingContextModule BrowsingContext => _browsingContextModule.Value;
public Modules.Browser.BrowserModule Browser => _browserModule.Value;
public Modules.Network.NetworkModule Network => _networkModule.Value;
internal Modules.Input.InputModule InputModule => _inputModule.Value;
internal Modules.Script.ScriptModule ScriptModule => _scriptModule.Value;
public Modules.Script.ScriptModule Script => _scriptModule.Value;
public Modules.Log.LogModule Log => _logModule.Value;
public Modules.Storage.StorageModule Storage => _storageModule.Value;

Expand All @@ -60,16 +61,6 @@ public static async Task<BiDi> ConnectAsync(string url)
return bidi;
}

public Task<Modules.BrowsingContext.BrowsingContext> CreateContextAsync(Modules.BrowsingContext.ContextType type, Modules.BrowsingContext.CreateOptions? options = null)
{
return BrowsingContextModule.CreateAsync(type, options);
}

public Task<IReadOnlyList<Modules.BrowsingContext.BrowsingContextInfo>> GetTreeAsync(Modules.BrowsingContext.GetTreeOptions? options = null)
{
return BrowsingContextModule.GetTreeAsync(options);
}

public Task EndAsync(Modules.Session.EndOptions? options = null)
{
return SessionModule.EndAsync(options);
Expand All @@ -81,44 +72,4 @@ public async ValueTask DisposeAsync()

_transport?.Dispose();
}

public Task<Subscription> OnContextCreatedAsync(Func<Modules.BrowsingContext.BrowsingContextInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnContextCreatedAsync(handler, options);
}

public Task<Subscription> OnContextCreatedAsync(Action<Modules.BrowsingContext.BrowsingContextInfo> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnContextCreatedAsync(handler, options);
}

public Task<Subscription> OnContextDestroyedAsync(Func<Modules.BrowsingContext.BrowsingContextInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnContextDestroyedAsync(handler, options);
}

public Task<Subscription> OnContextDestroyedAsync(Action<Modules.BrowsingContext.BrowsingContextInfo> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnContextDestroyedAsync(handler, options);
}

public Task<Subscription> OnUserPromptOpenedAsync(Func<Modules.BrowsingContext.UserPromptOpenedEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnUserPromptOpenedAsync(handler, options);
}

public Task<Subscription> OnUserPromptOpenedAsync(Action<Modules.BrowsingContext.UserPromptOpenedEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnUserPromptOpenedAsync(handler, options);
}

public Task<Subscription> OnUserPromptClosedAsync(Func<Modules.BrowsingContext.UserPromptClosedEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnUserPromptClosedAsync(handler, options);
}

public Task<Subscription> OnUserPromptClosedAsync(Action<Modules.BrowsingContext.UserPromptClosedEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null)
{
return BrowsingContextModule.OnUserPromptClosedAsync(handler, options);
}
}
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/BiDiException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;

#nullable enable

namespace OpenQA.Selenium.BiDi;

public class BiDiException : Exception
Expand Down
14 changes: 12 additions & 2 deletions dotnet/src/webdriver/BiDi/Communication/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Threading;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication;

public class Broker : IAsyncDisposable
Expand All @@ -34,7 +36,7 @@ public class Broker : IAsyncDisposable

private readonly JsonSerializerOptions _jsonSerializerOptions;

public Broker(BiDi bidi, ITransport transport)
internal Broker(BiDi bidi, ITransport transport)
{
_bidi = bidi;
_transport = transport;
Expand All @@ -51,14 +53,15 @@ public Broker(BiDi bidi, ITransport transport)
new NavigationConverter(),
new InterceptConverter(_bidi),
new RequestConverter(_bidi),
new ChannelConverter(_bidi),
new ChannelConverter(),
new HandleConverter(_bidi),
new InternalIdConverter(_bidi),
new PreloadScriptConverter(_bidi),
new RealmConverter(_bidi),
new RealmTypeConverter(),
new DateTimeOffsetConverter(),
new PrintPageRangeConverter(),
new InputOriginConverter(),
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase),

// https://github.com/dotnet/runtime/issues/72604
Expand All @@ -68,6 +71,13 @@ public Broker(BiDi bidi, ITransport transport)
new Json.Converters.Polymorphic.RealmInfoConverter(),
new Json.Converters.Polymorphic.LogEntryConverter(),
//

// 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.GetRealmsResultConverter(),
}
};
}
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Communication/Command.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication;

[JsonPolymorphic(TypeDiscriminatorPropertyName = "method")]
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Communication/CommandOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication;

public record CommandOptions
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Communication/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication;

public abstract class EventHandler(string eventName, Type eventArgsType, IEnumerable<BrowsingContext>? contexts = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

internal class BrowserUserContextConverter : JsonConverter<UserContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

internal class BrowsingContextConverter : JsonConverter<BrowsingContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,17 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

internal class ChannelConverter : JsonConverter<Channel>
{
private readonly BiDi _bidi;

public ChannelConverter(BiDi bidi)
{
_bidi = bidi;
}

public override Channel? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var id = reader.GetString();

return new Channel(_bidi, id!);
return new Channel(id!);
}

public override void Write(Utf8JsonWriter writer, Channel value, JsonSerializerOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

internal class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using OpenQA.Selenium.BiDi.Modules.Storage;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;

internal class GetCookiesResultConverter : JsonConverter<GetCookiesResult>
{
public override GetCookiesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var doc = JsonDocument.ParseValue(ref reader);
var cookies = doc.RootElement.GetProperty("cookies").Deserialize<IReadOnlyList<Modules.Network.Cookie>>(options);
var partitionKey = doc.RootElement.GetProperty("partitionKey").Deserialize<PartitionKey>(options);

return new GetCookiesResult(cookies!, partitionKey!);
}

public override void Write(Utf8JsonWriter writer, GetCookiesResult value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenQA.Selenium.BiDi.Modules.Script;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;

internal class GetRealmsResultConverter : JsonConverter<GetRealmsResult>
{
public override GetRealmsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var doc = JsonDocument.ParseValue(ref reader);
var realms = doc.RootElement.GetProperty("realms").Deserialize<IReadOnlyList<RealmInfo>>(options);

return new GetRealmsResult(realms!);
}

public override void Write(Utf8JsonWriter writer, GetRealmsResult value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenQA.Selenium.BiDi.Modules.Browser;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;

internal class GetUserContextsResultConverter : JsonConverter<GetUserContextsResult>
{
public override GetUserContextsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var doc = JsonDocument.ParseValue(ref reader);
var userContexts = doc.RootElement.GetProperty("userContexts").Deserialize<IReadOnlyList<UserContextInfo>>(options);

return new GetUserContextsResult(userContexts!);
}

public override void Write(Utf8JsonWriter writer, GetUserContextsResult value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using OpenQA.Selenium.BiDi.Modules.Input;
using System;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;

internal class InputSourceActionsConverter : JsonConverter<SourceActions>
{
public override SourceActions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}

public override void Write(Utf8JsonWriter writer, SourceActions value, JsonSerializerOptions options)
{
writer.WriteStartObject();

writer.WriteString("id", value.Id);

switch (value)
{
case KeyActions keys:
writer.WriteString("type", "key");
writer.WritePropertyName("actions");
JsonSerializer.Serialize(writer, keys.Actions.Select(a => a as IKeySourceAction), options);

break;
case PointerActions pointers:
writer.WriteString("type", "pointer");
if (pointers.Options is not null)
{
writer.WritePropertyName("parameters");
JsonSerializer.Serialize(writer, pointers.Options, options);
}

writer.WritePropertyName("actions");
JsonSerializer.Serialize(writer, pointers.Actions.Select(a => a as IPointerSourceAction), options);

break;
case WheelActions wheels:
writer.WriteString("type", "wheel");
writer.WritePropertyName("actions");
JsonSerializer.Serialize(writer, wheels.Actions.Select(a => a as IWheelSourceAction), options);

break;
case NoneActions none:
writer.WriteString("type", "none");
writer.WritePropertyName("actions");
JsonSerializer.Serialize(writer, none.Actions.Select(a => a as INoneSourceAction), options);

break;
}

writer.WriteEndObject();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using OpenQA.Selenium.BiDi.Modules.BrowsingContext;
using OpenQA.Selenium.BiDi.Modules.Script;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;

internal class LocateNodesResultConverter : JsonConverter<LocateNodesResult>
{
public override LocateNodesResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var doc = JsonDocument.ParseValue(ref reader);
var nodes = doc.RootElement.GetProperty("nodes").Deserialize<IReadOnlyList<RemoteValue.Node>>(options);

return new LocateNodesResult(nodes!);
}

public override void Write(Utf8JsonWriter writer, LocateNodesResult value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

internal class HandleConverter : JsonConverter<Handle>
Expand Down
Loading
Loading