Skip to content

Commit 47992c9

Browse files
authored
Merge branch 'trunk' into chrome_enable_logging
2 parents c166199 + d3cef1a commit 47992c9

File tree

16 files changed

+79
-96
lines changed

16 files changed

+79
-96
lines changed

common/repositories.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ js_library(
123123

124124
pkg_archive(
125125
name = "mac_edge",
126-
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/017e25fc-2906-45b2-958c-1c71c4667dc1/MicrosoftEdge-139.0.3405.111.pkg",
127-
sha256 = "1aa42cbaaf38b035e17d43fbbe0a293ceb286c5fd298d463b1a369ed900a03ac",
126+
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/95344cbf-d116-4494-8485-b96014e98901/MicrosoftEdge-139.0.3405.119.pkg",
127+
sha256 = "31b3ddce353180a706179d64086ed01b53cfd20a7daea45597a7e9e405fc553f",
128128
move = {
129-
"MicrosoftEdge-139.0.3405.111.pkg/Payload/Microsoft Edge.app": "Edge.app",
129+
"MicrosoftEdge-139.0.3405.119.pkg/Payload/Microsoft Edge.app": "Edge.app",
130130
},
131131
build_file_content = """
132132
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -143,8 +143,8 @@ js_library(
143143

144144
deb_archive(
145145
name = "linux_edge",
146-
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_139.0.3405.111-1_amd64.deb",
147-
sha256 = "d61b2fcef695083496184a6a323b2bcfb57d45af8fb6867ffe54974a5992dc52",
146+
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_139.0.3405.119-1_amd64.deb",
147+
sha256 = "e51e4e36cde5e7be2031fd9145ac9bf26444f734a88ff43858e05c7782e60c7b",
148148
build_file_content = """
149149
load("@aspect_rules_js//js:defs.bzl", "js_library")
150150
package(default_visibility = ["//visibility:public"])

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ internal Broker(BiDi bidi, Uri url)
8484
new RealmConverter(_bidi),
8585
new RealmTypeConverter(),
8686
new DateTimeOffsetConverter(),
87-
new TimeSpanConverter(),
8887
new PrintPageRangeConverter(),
8988
new InputOriginConverter(),
9089
new WebExtensionConverter(_bidi),

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,24 @@ internal class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
2727
{
2828
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
2929
{
30-
return DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64());
30+
return DateTimeOffset.FromUnixTimeMilliseconds((long)reader.GetDouble()); // still might get a double
3131
}
3232

3333
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
3434
{
3535
writer.WriteNumberValue(value.ToUnixTimeMilliseconds());
3636
}
3737
}
38+
39+
internal class DateTimeOffsetSecondsConverter : JsonConverter<DateTimeOffset>
40+
{
41+
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
42+
{
43+
return DateTimeOffset.FromUnixTimeSeconds((long)reader.GetDouble()); // still might get a double
44+
}
45+
46+
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
47+
{
48+
writer.WriteNumberValue(value.ToUnixTimeSeconds());
49+
}
50+
}

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System;
22+
using System.Text.Json.Serialization;
2123

2224
namespace OpenQA.Selenium.BiDi.Network;
2325

24-
public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite, TimeSpan? Expiry);
26+
public sealed record Cookie(string Name, BytesValue Value, string Domain, string Path, long Size, bool HttpOnly, bool Secure, SameSite SameSite, [property: JsonConverter(typeof(DateTimeOffsetSecondsConverter))] DateTimeOffset? Expiry);
2527

2628
public enum SameSite
2729
{

dotnet/src/webdriver/BiDi/Storage/SetCookieCommand.cs

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

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System;
23+
using System.Text.Json.Serialization;
2224

2325
namespace OpenQA.Selenium.BiDi.Storage;
2426

@@ -37,6 +39,7 @@ public sealed record PartialCookie(string Name, Network.BytesValue Value, string
3739

3840
public Network.SameSite? SameSite { get; set; }
3941

42+
[JsonConverter(typeof(DateTimeOffsetSecondsConverter))]
4043
public DateTimeOffset? Expiry { get; set; }
4144
}
4245

dotnet/src/webdriver/Internal/PortUtilities.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,23 @@ public static class PortUtilities
3030
/// <summary>
3131
/// Finds a random, free port to be listened on.
3232
/// </summary>
33+
/// <remarks>
34+
/// Prefers IPv4, but falls back to IPv6 if necessary.
35+
/// </remarks>
3336
/// <returns>A random, free port to be listened on.</returns>
3437
public static int FindFreePort()
3538
{
36-
using var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
37-
socket.DualMode = true;
38-
socket.Bind(new IPEndPoint(IPAddress.IPv6Loopback, 0));
39-
return (socket.LocalEndPoint as IPEndPoint)!.Port;
40-
39+
try
40+
{
41+
using var ipV4socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
42+
ipV4socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
43+
return ((IPEndPoint)ipV4socket.LocalEndPoint!).Port;
44+
}
45+
catch (SocketException)
46+
{
47+
using var ipV6socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
48+
ipV6socket.Bind(new IPEndPoint(IPAddress.IPv6Loopback, 0));
49+
return ((IPEndPoint)ipV6socket.LocalEndPoint!).Port;
50+
}
4151
}
4252
}

dotnet/test/common/BiDi/Storage/StorageTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public async Task CanAddAndGetCookie()
8181
{
8282
driver.Url = UrlBuilder.WhereIs("animals");
8383

84-
var expiry = DateTime.Now.AddDays(1);
84+
var expiry = DateTimeOffset.Now.AddDays(1);
8585

8686
await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName)
8787
{
@@ -106,7 +106,7 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName)
106106
Assert.That(cookie.Secure, Is.False);
107107
Assert.That(cookie.SameSite, Is.EqualTo(SameSite.Lax));
108108
Assert.That(cookie.Size, Is.EqualTo(7));
109-
// Assert.That(cookie.Expiry, Is.EqualTo(expiry)); // chrome issue
109+
Assert.That(cookie.Expiry, Is.EqualTo(expiry).Within(1).Seconds);
110110
}
111111

112112
[Test]

java/src/org/openqa/selenium/grid/node/Node.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ protected Node(
199199
.to(() -> new Drain(this, json))
200200
.with(spanDecorator("node.drain").andThen(requiresSecret)),
201201
get("/se/grid/node/status")
202-
.to(
203-
() ->
204-
req -> new HttpResponse().setContent(asJson(Map.of("value", getStatus()))))
202+
.to(() -> req -> new HttpResponse().setContent(asJson(getStatus())))
205203
.with(spanDecorator("node.node_status")),
206204
get("/status").to(() -> new StatusHandler(this)).with(spanDecorator("node.status")));
207205
}

java/src/org/openqa/selenium/grid/router/HandleSession.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
2222
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
2323
import static org.openqa.selenium.remote.http.Contents.asJson;
24+
import static org.openqa.selenium.remote.http.Contents.string;
2425
import static org.openqa.selenium.remote.http.HttpMethod.GET;
2526
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
2627
import static org.openqa.selenium.remote.tracing.Tags.HTTP_REQUEST;
@@ -48,8 +49,8 @@
4849
import org.openqa.selenium.grid.data.NodeStatus;
4950
import org.openqa.selenium.grid.sessionmap.SessionMap;
5051
import org.openqa.selenium.grid.web.ReverseProxyHandler;
51-
import org.openqa.selenium.grid.web.Values;
5252
import org.openqa.selenium.internal.Require;
53+
import org.openqa.selenium.json.Json;
5354
import org.openqa.selenium.remote.ErrorCodec;
5455
import org.openqa.selenium.remote.SessionId;
5556
import org.openqa.selenium.remote.http.ClientConfig;
@@ -256,10 +257,13 @@ private ClientConfig fetchNodeSessionTimeout(URI uri) {
256257
try (HttpClient httpClient = httpClientFactory.createClient(config)) {
257258
HttpRequest statusRequest = new HttpRequest(GET, "/se/grid/node/status");
258259
HttpResponse res = httpClient.execute(statusRequest);
259-
NodeStatus nodeStatus = Values.get(res, NodeStatus.class);
260+
Json json = new Json();
261+
NodeStatus nodeStatus = json.toType(string(res), NodeStatus.class);
260262
if (nodeStatus != null) {
261263
sessionTimeout = nodeStatus.getSessionTimeout();
262264
}
265+
} catch (Exception e) {
266+
LOG.fine("Unable to fetch status for " + uri);
263267
}
264268
LOG.fine("Set read timeout: " + sessionTimeout.toSeconds() + " seconds for " + uri);
265269
config = config.readTimeout(sessionTimeout);

0 commit comments

Comments
 (0)