Skip to content

Commit 6659ec5

Browse files
authored
Merge branch 'trunk' into dotnet-deprecated-getattribute
2 parents de4b9f2 + 965f6b1 commit 6659ec5

File tree

18 files changed

+202
-50
lines changed

18 files changed

+202
-50
lines changed

common/mirror/selenium

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"tag_name": "nightly",
2424
"assets": [
2525
{
26-
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.26.0-SNAPSHOT.zip"
26+
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-java-4.27.0-SNAPSHOT.zip"
2727
},
2828
{
29-
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.26.0-SNAPSHOT.jar"
29+
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.27.0-SNAPSHOT.jar"
3030
},
3131
{
32-
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.26.0-SNAPSHOT.zip"
32+
"browser_download_url": "https://github.com/SeleniumHQ/selenium/releases/download/nightly/selenium-server-4.27.0-SNAPSHOT.zip"
3333
}
3434
]
3535
},

dotnet/CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v4.26.1
2+
======
3+
* [bidi] Reveal browsing context module in bidi instance (#14684)
4+
* Fix adding cookies when ReturnedCookie class is used (#14697)
5+
16
v4.26.0
27
======
38
* [bidi] Fix web socket communication for .net framework

dotnet/selenium-dotnet-version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BUILD FILE SYNTAX: STARLARK
22

3-
SE_VERSION = "4.27.0-nightly202410301443"
3+
SE_VERSION = "4.27.0-nightly202410311906"
44
ASSEMBLY_VERSION = "4.0.0.0"
55
SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0"]
66

dotnet/src/webdriver/BiDi/BiDi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal BiDi(string url)
3939
}
4040

4141
internal Modules.Session.SessionModule SessionModule => _sessionModule.Value;
42-
internal Modules.BrowsingContext.BrowsingContextModule BrowsingContext => _browsingContextModule.Value;
42+
public Modules.BrowsingContext.BrowsingContextModule BrowsingContext => _browsingContextModule.Value;
4343
public Modules.Browser.BrowserModule Browser => _browserModule.Value;
4444
public Modules.Network.NetworkModule Network => _networkModule.Value;
4545
internal Modules.Input.InputModule InputModule => _inputModule.Value;

dotnet/src/webdriver/Command.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private static Dictionary<string, object> ConvertParametersFromJson(string value
159159
[JsonSerializable(typeof(byte[]))]
160160
[JsonSerializable(typeof(Dictionary<string, object>))]
161161
[JsonSerializable(typeof(Cookie))]
162+
[JsonSerializable(typeof(ReturnedCookie))]
162163
[JsonSerializable(typeof(Proxy))]
163164
internal partial class CommandJsonSerializerContext : JsonSerializerContext
164165
{

java/src/org/openqa/selenium/bidi/script/NodeProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class NodeProperties {
2626
private enum Mode {
2727
OPEN("open"),
28-
CLOSE("close");
28+
CLOSED("closed");
2929

3030
private final String value;
3131

java/src/org/openqa/selenium/netty/server/SeleniumHandler.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
import io.netty.channel.ChannelHandlerContext;
2121
import io.netty.channel.SimpleChannelInboundHandler;
22+
import java.util.concurrent.CompletableFuture;
2223
import java.util.concurrent.ExecutorService;
2324
import java.util.concurrent.Executors;
25+
import java.util.concurrent.Future;
2426
import org.openqa.selenium.internal.Require;
2527
import org.openqa.selenium.remote.ErrorFilter;
2628
import org.openqa.selenium.remote.http.HttpHandler;
@@ -31,18 +33,27 @@ class SeleniumHandler extends SimpleChannelInboundHandler<HttpRequest> {
3133

3234
private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool();
3335
private final HttpHandler seleniumHandler;
36+
private Future<?> lastOne;
3437

3538
public SeleniumHandler(HttpHandler seleniumHandler) {
3639
super(HttpRequest.class);
3740
this.seleniumHandler = Require.nonNull("HTTP handler", seleniumHandler).with(new ErrorFilter());
41+
this.lastOne = CompletableFuture.completedFuture(null);
3842
}
3943

4044
@Override
4145
protected void channelRead0(ChannelHandlerContext ctx, HttpRequest msg) {
42-
EXECUTOR.submit(
43-
() -> {
44-
HttpResponse res = seleniumHandler.execute(msg);
45-
ctx.writeAndFlush(res);
46-
});
46+
lastOne =
47+
EXECUTOR.submit(
48+
() -> {
49+
HttpResponse res = seleniumHandler.execute(msg);
50+
ctx.writeAndFlush(res);
51+
});
52+
}
53+
54+
@Override
55+
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
56+
lastOne.cancel(true);
57+
super.channelInactive(ctx);
4758
}
4859
}

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpClient.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,16 @@ public CompletableFuture<HttpResponse> executeAsync(HttpRequest request) {
388388
}
389389
});
390390

391-
// try to interrupt the http request in case of a timeout, to avoid
392-
// https://bugs.openjdk.org/browse/JDK-8258397
393-
cf.exceptionally(
394-
(throwable) -> {
395-
if (throwable instanceof java.util.concurrent.TimeoutException) {
396-
// interrupts the thread
391+
cf.whenComplete(
392+
(result, throwable) -> {
393+
if (throwable instanceof java.util.concurrent.CancellationException) {
394+
// try to interrupt the http request in case someone canceled the future returned
395+
future.cancel(true);
396+
} else if (throwable instanceof java.util.concurrent.TimeoutException) {
397+
// try to interrupt the http request in case of a timeout, to avoid
398+
// https://bugs.openjdk.org/browse/JDK-8258397
397399
future.cancel(true);
398400
}
399-
400-
// nobody will read this result
401-
return null;
402401
});
403402

404403
// will complete exceptionally with a java.util.concurrent.TimeoutException
@@ -407,13 +406,15 @@ public CompletableFuture<HttpResponse> executeAsync(HttpRequest request) {
407406

408407
@Override
409408
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
409+
Future<HttpResponse> async = executeAsync(req);
410410
try {
411411
// executeAsync does define a timeout, no need to use a timeout here
412-
return executeAsync(req).get();
412+
return async.get();
413413
} catch (CancellationException e) {
414414
throw new WebDriverException(e.getMessage(), e);
415415
} catch (InterruptedException e) {
416416
Thread.currentThread().interrupt();
417+
async.cancel(true);
417418
throw new WebDriverException(e.getMessage(), e);
418419
} catch (ExecutionException e) {
419420
Throwable cause = e.getCause();
@@ -495,7 +496,7 @@ private HttpResponse execute0(HttpRequest req) throws UncheckedIOException {
495496
throw new UncheckedIOException(e);
496497
} catch (InterruptedException e) {
497498
Thread.currentThread().interrupt();
498-
throw new RuntimeException(e);
499+
throw new WebDriverException(e.getMessage(), e);
499500
} finally {
500501
LOG.log(
501502
Level.FINE,

java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ void canLocateNodesWithMaxNodeCount() {
162162
}
163163

164164
@Test
165-
@NotYetImplemented(CHROME)
166-
@NotYetImplemented(EDGE)
167165
void canLocateNodesGivenStartNodes() {
168166
String handle = driver.getWindowHandle();
169167
BrowsingContext browsingContext = new BrowsingContext(driver, handle);

java/test/org/openqa/selenium/netty/server/NettyServerTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@
2828

2929
import com.google.common.collect.ImmutableMap;
3030
import java.net.URL;
31+
import java.time.Duration;
32+
import java.util.concurrent.CountDownLatch;
33+
import java.util.concurrent.TimeUnit;
3134
import java.util.concurrent.atomic.AtomicInteger;
35+
import org.junit.jupiter.api.Assertions;
3236
import org.junit.jupiter.api.Test;
37+
import org.openqa.selenium.TimeoutException;
3338
import org.openqa.selenium.grid.config.CompoundConfig;
3439
import org.openqa.selenium.grid.config.Config;
3540
import org.openqa.selenium.grid.config.MapConfig;
3641
import org.openqa.selenium.grid.server.BaseServerOptions;
3742
import org.openqa.selenium.grid.server.Server;
3843
import org.openqa.selenium.net.PortProber;
44+
import org.openqa.selenium.remote.http.ClientConfig;
3945
import org.openqa.selenium.remote.http.HttpClient;
4046
import org.openqa.selenium.remote.http.HttpRequest;
4147
import org.openqa.selenium.remote.http.HttpResponse;
@@ -141,6 +147,43 @@ void shouldNotBindToHost() {
141147
assertEquals("anyRandomHost", server.getUrl().getHost());
142148
}
143149

150+
@Test
151+
void doesInterruptPending() throws Exception {
152+
CountDownLatch interrupted = new CountDownLatch(1);
153+
Config cfg = new MapConfig(ImmutableMap.of());
154+
BaseServerOptions options = new BaseServerOptions(cfg);
155+
156+
Server<?> server =
157+
new NettyServer(
158+
options,
159+
req -> {
160+
try {
161+
Thread.sleep(800);
162+
} catch (InterruptedException ex) {
163+
interrupted.countDown();
164+
}
165+
return new HttpResponse();
166+
})
167+
.start();
168+
ClientConfig config =
169+
ClientConfig.defaultConfig()
170+
.readTimeout(Duration.ofMillis(400))
171+
.baseUri(server.getUrl().toURI());
172+
173+
// provoke a client timeout
174+
Assertions.assertThrows(
175+
TimeoutException.class,
176+
() -> {
177+
try (HttpClient client = HttpClient.Factory.createDefault().createClient(config)) {
178+
HttpRequest request = new HttpRequest(DELETE, "/session");
179+
request.setHeader("Accept", "*/*");
180+
client.execute(request);
181+
}
182+
});
183+
184+
assertTrue(interrupted.await(1000, TimeUnit.MILLISECONDS), "The handling was interrupted");
185+
}
186+
144187
private void outputHeaders(HttpResponse res) {
145188
res.forEachHeader((name, value) -> System.out.printf("%s -> %s\n", name, value));
146189
}

0 commit comments

Comments
 (0)