Skip to content

Commit dbe23c5

Browse files
committed
Merge remote-tracking branch 'origin/trunk' into py_client_config_new
Signed-off-by: Viet Nguyen Duc <[email protected]> # Conflicts: # py/selenium/webdriver/remote/remote_connection.py # py/selenium/webdriver/remote/webdriver.py
2 parents 9f21342 + 833efa9 commit dbe23c5

File tree

36 files changed

+4889
-1251
lines changed

36 files changed

+4889
-1251
lines changed

.github/workflows/ci-dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ jobs:
2323
java-version: 17
2424
os: windows
2525
run: |
26+
fsutil 8dot3name set 0
2627
bazel test //dotnet/test/common:ElementFindingTest-firefox //dotnet/test/common:ElementFindingTest-chrome --pin_browsers=true

.github/workflows/ci-java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
# https://github.com/bazelbuild/rules_jvm_external/issues/1046
2323
java-version: 17
2424
run: |
25+
fsutil 8dot3name set 0
2526
bazel test --flaky_test_attempts 3 //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest `
2627
//java/test/org/openqa/selenium/federatedcredentialmanagement:FederatedCredentialManagementTest `
2728
//java/test/org/openqa/selenium/firefox:FirefoxDriverBuilderTest `

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ rules_closure_toolchains()
3434

3535
http_archive(
3636
name = "rules_rust",
37-
integrity = "sha256-JLN47ZcAbx9wEr5Jiib4HduZATGLiDgK7oUi/fvotzU=",
38-
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.42.1/rules_rust-v0.42.1.tar.gz"],
37+
integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
38+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
3939
)
4040

4141
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
89 Bytes
Binary file not shown.

common/extensions/webextensions-selenium-example/manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
]
1515
}
1616
],
17+
"permissions": [
18+
"storage",
19+
"scripting"
20+
],
21+
"host_permissions": [
22+
"https://*/*",
23+
"http://*/*"
24+
],
1725
"browser_specific_settings": {
1826
"gecko": {
1927

dotnet/src/webdriver/WebDriver.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
</Target>
107107

108108
<Target Name="GenerateCdp" BeforeTargets="CoreCompile">
109-
<Exec Command="bazel build //dotnet/src/webdriver/cdp:generate-v85 //dotnet/src/webdriver/cdp:generate-v127 //dotnet/src/webdriver/cdp:generate-v128 //dotnet/src/webdriver/cdp:generate-v129" WorkingDirectory="../../.." />
109+
<Exec Command="bazel build //dotnet/src/webdriver/cdp/..." WorkingDirectory="../../.." />
110110

111111
<ItemGroup>
112112
<Compile Include="..\..\..\bazel-bin\dotnet\src\webdriver\cdp\**\*.cs" LinkBase="DevTools\generated" />

dotnet/src/webdriver/cdp/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,4 @@ perform the following steps, where `<N>` is the major version of the protocol:
5252
remove the entry for version `<N>` from the `SupportedDevToolsVersions` dictionary initialization.
5353
3. Remove the version string (`v<N>`) from the `SUPPORTED_DEVTOOLS_VERSIONS` list in
5454
[`//dotnet:selenium-dotnet-version.bzl`](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/selenium-dotnet-version.bzl).
55-
4. In [`//dotnet/src/webdriver:WebDriver.csproj.prebuild.cmd`](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/WebDriver.csproj.prebuild.cmd),
56-
remove the `if not exist` block for version `<N>`.
57-
5. In [`//dotnet/src/webdriver:WebDriver.csproj.prebuild.sh`](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/WebDriver.csproj.prebuild.sh),
58-
remove the `if-fi` block for version `<N>`.
59-
6. Commit the changes.
60-
55+
4. Commit the changes.

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717

1818
package org.openqa.selenium.grid.node;
1919

20+
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR;
21+
import static org.openqa.selenium.remote.HttpSessionId.getSessionId;
22+
import static org.openqa.selenium.remote.http.Contents.asJson;
23+
24+
import com.google.common.collect.ImmutableMap;
2025
import org.openqa.selenium.internal.Require;
26+
import org.openqa.selenium.remote.SessionId;
2127
import org.openqa.selenium.remote.http.HttpHandler;
2228
import org.openqa.selenium.remote.http.HttpRequest;
2329
import org.openqa.selenium.remote.http.HttpResponse;
@@ -30,8 +36,22 @@ class ForwardWebDriverCommand implements HttpHandler {
3036
this.node = Require.nonNull("Node", node);
3137
}
3238

39+
public boolean matches(HttpRequest req) {
40+
return getSessionId(req.getUri())
41+
.map(id -> node.isSessionOwner(new SessionId(id)))
42+
.orElse(false);
43+
}
44+
3345
@Override
3446
public HttpResponse execute(HttpRequest req) {
35-
return node.executeWebDriverCommand(req);
47+
if (matches(req)) {
48+
return node.executeWebDriverCommand(req);
49+
}
50+
return new HttpResponse()
51+
.setStatus(HTTP_INTERNAL_ERROR)
52+
.setContent(
53+
asJson(
54+
ImmutableMap.of(
55+
"error", String.format("Session not found in node %s", node.getId()))));
3656
}
3757
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected Node(
152152
req ->
153153
getSessionId(req.getUri())
154154
.map(SessionId::new)
155-
.map(this::isSessionOwner)
155+
.map(sessionId -> this.getSession(sessionId) != null)
156156
.orElse(false))
157157
.to(() -> new ForwardWebDriverCommand(this))
158158
.with(spanDecorator("node.forward_command")),

java/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,13 @@ protected LocalNode(
297297
heartbeatPeriod.getSeconds(),
298298
TimeUnit.SECONDS);
299299

300-
Runtime.getRuntime().addShutdownHook(new Thread(this::stopAllSessions));
300+
Runtime.getRuntime()
301+
.addShutdownHook(
302+
new Thread(
303+
() -> {
304+
stopAllSessions();
305+
drain();
306+
}));
301307
new JMXHelper().register(this);
302308
}
303309

@@ -316,7 +322,6 @@ private void stopTimedOutSession(RemovalNotification<SessionId, SessionSlot> not
316322
}
317323
// Attempt to stop the session
318324
slot.stop();
319-
this.sessionToDownloadsDir.invalidate(id);
320325
// Decrement pending sessions if Node is draining
321326
if (this.isDraining()) {
322327
int done = pendingSessions.decrementAndGet();
@@ -473,8 +478,6 @@ public Either<WebDriverException, CreateSessionResponse> newSession(
473478
sessionToDownloadsDir.put(session.getId(), uuidForSessionDownloads);
474479
currentSessions.put(session.getId(), slotToUse);
475480

476-
checkSessionCount();
477-
478481
SessionId sessionId = session.getId();
479482
Capabilities caps = session.getCapabilities();
480483
SESSION_ID.accept(span, sessionId);
@@ -513,6 +516,8 @@ public Either<WebDriverException, CreateSessionResponse> newSession(
513516
span.addEvent("Unable to create session with the driver", attributeMap);
514517
return Either.left(possibleSession.left());
515518
}
519+
} finally {
520+
checkSessionCount();
516521
}
517522
}
518523

@@ -765,6 +770,10 @@ public HttpResponse uploadFile(HttpRequest req, SessionId id) {
765770
public void stop(SessionId id) throws NoSuchSessionException {
766771
Require.nonNull("Session ID", id);
767772

773+
if (sessionToDownloadsDir.getIfPresent(id) != null) {
774+
sessionToDownloadsDir.invalidate(id);
775+
}
776+
768777
SessionSlot slot = currentSessions.getIfPresent(id);
769778
if (slot == null) {
770779
throw new NoSuchSessionException("Cannot find session with id: " + id);

0 commit comments

Comments
 (0)