Skip to content

Commit eeae5a8

Browse files
committed
Merge remote-tracking branch 'upstream/trunk' into dotnet-bidi-getdata
2 parents b9ea380 + ab9733c commit eeae5a8

File tree

19 files changed

+224
-55
lines changed

19 files changed

+224
-55
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ the defect. If the issue can't be reproduced it will be closed.
1414
Please provide [concise reproducible test cases](http://sscce.org/)
1515
and describe what results you are seeing and what results you expect.
1616

17-
Issues shouldn't be used for support. Please address questions to the
18-
[`selenium-users@` mailing list](https://groups.google.com/forum/#!forum/selenium-users).
17+
Issues shouldn't be used for support. To raise a bug, please go to the
18+
[Issue tracker](https://github.com/SeleniumHQ/selenium/issues).
1919
Discussion of high level project ideas or non-technical topics should
20-
move to the
21-
[`selenium-developers@` mailing list](https://groups.google.com/forum/#!forum/selenium-developers)
22-
instead.
20+
move to the Selenium [Slack channel](https://inviter.co/seleniumhq).
2321

2422
We also need help with triaging
2523
[issues that needs investigation](https://github.com/SeleniumHQ/selenium/labels/I-needs%20investigation).
@@ -34,7 +32,6 @@ with details describing what feature(s) you'd like added or changed.
3432

3533
If you'd like a hand at trying to implement the feature yourself, please refer to the [Code Contributions](#code-contributions) section of the document.
3634

37-
3835
## Documentation
3936

4037
Selenium is a big software project and documentation is key to

common/repositories.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ js_library(
165165

166166
http_archive(
167167
name = "linux_edgedriver",
168-
url = "https://msedgedriver.microsoft.com/139.0.3405.86/edgedriver_linux64.zip",
169-
sha256 = "49ce29de50f9ac418a3a2416708a5563215b8412b27d3e505f3c859fc6ffba12",
168+
url = "https://msedgedriver.microsoft.com/139.0.3405.102/edgedriver_linux64.zip",
169+
sha256 = "e092178901c011ccfddc0556193742a01f206d71b5bb1a12cc1ba7a243262fc2",
170170
build_file_content = """
171171
load("@aspect_rules_js//js:defs.bzl", "js_library")
172172
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
182182

183183
http_archive(
184184
name = "mac_edgedriver",
185-
url = "https://msedgedriver.microsoft.com/139.0.3405.86/edgedriver_mac64.zip",
186-
sha256 = "b6c8244dfb7b8a223d3ac8fd569533f0a307eadaca2b8cbc884ce7f69294682e",
185+
url = "https://msedgedriver.microsoft.com/139.0.3405.102/edgedriver_mac64.zip",
186+
sha256 = "98aa637081061ea610c1f70be09fdea6b5f5b3a46c94a87ca291e2285bad1328",
187187
build_file_content = """
188188
load("@aspect_rules_js//js:defs.bzl", "js_library")
189189
package(default_visibility = ["//visibility:public"])

dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using System;
2122
using System.Text.Json.Serialization;
2223

2324
namespace OpenQA.Selenium.BiDi.BrowsingContext;
@@ -56,9 +57,9 @@ public sealed record BoxClipRectangle(double X, double Y, double Width, double H
5657

5758
public sealed record ElementClipRectangle(Script.ISharedReference Element) : ClipRectangle;
5859

59-
public sealed record CaptureScreenshotResult(string Data) : EmptyResult
60+
public sealed record CaptureScreenshotResult(ReadOnlyMemory<byte> Data) : EmptyResult
6061
{
6162
public static implicit operator byte[](CaptureScreenshotResult captureScreenshotResult) => captureScreenshotResult.ToByteArray();
6263

63-
public byte[] ToByteArray() => System.Convert.FromBase64String(Data);
64+
public byte[] ToByteArray() => Data.ToArray();
6465
}

dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static implicit operator PrintPageRange(Range range)
112112
#endif
113113
}
114114

115-
public sealed record PrintResult(string Data) : EmptyResult
115+
public sealed record PrintResult(ReadOnlyMemory<byte> Data) : EmptyResult
116116
{
117-
public byte[] ToByteArray() => Convert.FromBase64String(Data);
117+
public byte[] ToByteArray() => Data.ToArray();
118118
}

dotnet/src/webdriver/BiDi/Communication/Broker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ internal Broker(BiDi bidi, Uri url)
8585
new RealmConverter(_bidi),
8686
new RealmTypeConverter(),
8787
new DateTimeOffsetConverter(),
88+
new TimeSpanConverter(),
8889
new PrintPageRangeConverter(),
8990
new InputOriginConverter(),
9091
new WebExtensionConverter(_bidi),

dotnet/src/webdriver/BiDi/Communication/Json/Converters/DateTimeOffsetConverter.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ internal class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
2727
{
2828
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
2929
{
30-
// Workaround: it should be Int64, chrome uses double for `expiry` like "expiry":1737379944.308351
31-
32-
if (reader.TryGetInt64(out long unixTime) is false)
33-
{
34-
var doubleValue = reader.GetDouble();
35-
36-
unixTime = Convert.ToInt64(doubleValue);
37-
}
38-
39-
return DateTimeOffset.FromUnixTimeMilliseconds(unixTime);
30+
return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64());
4031
}
4132

4233
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// <copyright file="TimeSpanConverter.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
using System;
21+
using System.Text.Json;
22+
using System.Text.Json.Serialization;
23+
24+
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;
25+
26+
internal class TimeSpanConverter : JsonConverter<TimeSpan>
27+
{
28+
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
29+
{
30+
if (reader.TryGetInt64(out long milliseconds) is false)
31+
{
32+
var doubleValue = reader.GetDouble();
33+
34+
milliseconds = Convert.ToInt64(doubleValue);
35+
}
36+
37+
return TimeSpan.FromMilliseconds(milliseconds);
38+
}
39+
40+
public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
41+
{
42+
writer.WriteNumberValue(value.TotalMilliseconds);
43+
}
44+
}

dotnet/src/webdriver/BiDi/Network/BytesValue.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,9 @@ namespace OpenQA.Selenium.BiDi.Network;
2828
public abstract record BytesValue
2929
{
3030
public static implicit operator BytesValue(string value) => new StringBytesValue(value);
31-
public static implicit operator BytesValue(byte[] value) => new Base64BytesValue(Convert.ToBase64String(value));
32-
33-
public static explicit operator string(BytesValue value)
34-
{
35-
if (value is StringBytesValue stringBytesValue)
36-
{
37-
return stringBytesValue.Value;
38-
}
39-
40-
throw new InvalidCastException($"Cannot cast '{value.GetType()}' to '{typeof(string)}'.");
41-
}
31+
public static implicit operator BytesValue(byte[] value) => new Base64BytesValue(value);
4232
}
4333

4434
public sealed record StringBytesValue(string Value) : BytesValue;
4535

46-
public sealed record Base64BytesValue(string Value) : BytesValue;
36+
public sealed record Base64BytesValue(ReadOnlyMemory<byte> Value) : BytesValue;

dotnet/src/webdriver/BiDi/Network/Cookie.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@
1818
// </copyright>
1919

2020
using System;
21-
using System.Text.Json.Serialization;
2221

2322
namespace OpenQA.Selenium.BiDi.Network;
2423

25-
public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite)
26-
{
27-
[JsonInclude]
28-
public DateTimeOffset? Expiry { get; internal set; }
29-
}
24+
public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite, TimeSpan? Expiry);
3025

3126
public enum SameSite
3227
{

dotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using System;
2122
using System.Text.Json.Serialization;
2223

2324
namespace OpenQA.Selenium.BiDi.WebExtension;
@@ -35,7 +36,7 @@ public abstract record ExtensionData;
3536

3637
public sealed record ExtensionArchivePath(string Path) : ExtensionData;
3738

38-
public sealed record ExtensionBase64Encoded(string Value) : ExtensionData;
39+
public sealed record ExtensionBase64Encoded(ReadOnlyMemory<byte> Value) : ExtensionData;
3940

4041
public sealed record ExtensionPath(string Path) : ExtensionData;
4142

0 commit comments

Comments
 (0)