Skip to content

Commit cb4269d

Browse files
authored
Merge branch 'trunk' into py_dl_files
2 parents 24ab6e4 + fd9fbaa commit cb4269d

21 files changed

+1638
-634
lines changed
+70-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
11
name: Build selenium-manager
22

3-
on: workflow_dispatch
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
debug:
7+
description: 'Include debug symbols in binaries'
8+
required: false
9+
type: boolean
410

511
jobs:
612
win32:
713
name: "[Windows x32] Build selenium-manager"
814
runs-on: windows-latest
9-
env:
10-
RUSTFLAGS: '-Ctarget-feature=+crt-static'
1115
steps:
1216
- name: "Checkout project"
1317
uses: actions/checkout@v4
1418
- name: "Update Rust"
1519
run: |
1620
rustup update
17-
rustup toolchain install stable-i686-pc-windows-msvc
18-
rustup default stable-i686-pc-windows-msvc
21+
rustup toolchain install stable-i686-pc-windows-gnu
22+
rustup default stable-i686-pc-windows-gnu
1923
rustc -vV
20-
- name: "Build release"
24+
- name: "Build release binary"
25+
if: ${{ inputs.debug == false }}
2126
run: |
2227
cd rust
2328
cargo build --release
24-
- name: "Upload binary"
29+
- name: "Upload release binary"
30+
if: ${{ inputs.debug == false }}
2531
uses: actions/upload-artifact@v3
2632
with:
2733
name: selenium-manager_windows-x32
2834
path: rust/target/release/selenium-manager.exe
2935
retention-days: 6
36+
- name: "Build debug binary"
37+
if: ${{ inputs.debug == true }}
38+
run: |
39+
cd rust
40+
cargo build --profile dev
41+
- name: "Upload debug binary"
42+
if: ${{ inputs.debug == true }}
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: selenium-manager_windows-x32-debug
46+
path: rust/target/debug/selenium-manager.exe
47+
retention-days: 6
3048

3149
linux64:
3250
name: "[Linux x64] Build selenium-manager"
@@ -42,26 +60,38 @@ jobs:
4260
run: |
4361
cargo install cross --git https://github.com/cross-rs/cross
4462
cross -V
45-
- name: "Build release"
63+
- name: "Build release binary"
64+
if: ${{ inputs.debug == false }}
4665
run: |
4766
cd rust
4867
cross build --target x86_64-unknown-linux-musl --release
49-
- name: "Tar binary (to keep executable permission)"
50-
run: |
51-
cd rust/target/x86_64-unknown-linux-musl/release
68+
cd target/x86_64-unknown-linux-musl/release
5269
tar -cvf ../../../../selenium-manager.tar selenium-manager
53-
- name: "Upload binary"
70+
- name: "Upload release binary"
71+
if: ${{ inputs.debug == false }}
5472
uses: actions/upload-artifact@v3
5573
with:
5674
name: selenium-manager_linux-x64
5775
path: selenium-manager.tar
5876
retention-days: 6
77+
- name: "Build debug binary"
78+
if: ${{ inputs.debug == true }}
79+
run: |
80+
cd rust
81+
cross build --target x86_64-unknown-linux-musl --profile dev
82+
cd target/x86_64-unknown-linux-musl/debug
83+
tar -cvf ../../../../selenium-manager.tar selenium-manager
84+
- name: "Upload debug binary"
85+
if: ${{ inputs.debug == true }}
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: selenium-manager_linux-x64-debug
89+
path: selenium-manager.tar
90+
retention-days: 6
5991

6092
macos64:
6193
name: "[macOS x64/arm64] Build selenium-manager"
6294
runs-on: macos-latest
63-
env:
64-
RUSTFLAGS: '-Ctarget-feature=+crt-static'
6595
steps:
6696
- name: "Checkout project"
6797
uses: actions/checkout@v4
@@ -70,28 +100,39 @@ jobs:
70100
rustup update
71101
rustup target add aarch64-apple-darwin
72102
rustc -vV
73-
- name: "Build x64"
74-
run: |
75-
cd rust
76-
cargo build --release --target x86_64-apple-darwin
77-
- name: "Build arm64"
103+
- name: "Build release binary"
104+
if: ${{ inputs.debug == false }}
78105
run: |
79106
cd rust
80-
cargo build --release --target aarch64-apple-darwin
81-
- name: "Build universal"
82-
run: |
83-
cd rust
84-
lipo -create \
85-
-output target/selenium-manager \
107+
cargo build --target x86_64-apple-darwin --release
108+
cargo build --target aarch64-apple-darwin --release
109+
lipo -create -output target/selenium-manager \
86110
target/aarch64-apple-darwin/release/selenium-manager \
87111
target/x86_64-apple-darwin/release/selenium-manager
88-
- name: "Tar binary (to keep executable permission)"
89-
run: |
90-
cd rust/target
112+
cd target
91113
tar -cvf ../../selenium-manager.tar selenium-manager
92-
- name: "Upload binary"
114+
- name: "Upload release binary"
115+
if: ${{ inputs.debug == false }}
93116
uses: actions/upload-artifact@v3
94117
with:
95118
name: selenium-manager_macos-universal
96119
path: selenium-manager.tar
97120
retention-days: 6
121+
- name: "Build debug binary"
122+
if: ${{ inputs.debug == true }}
123+
run: |
124+
cd rust
125+
cargo build --target x86_64-apple-darwin --profile dev
126+
cargo build --target aarch64-apple-darwin --profile dev
127+
lipo -create -output target/selenium-manager \
128+
target/aarch64-apple-darwin/debug/selenium-manager \
129+
target/x86_64-apple-darwin/debug/selenium-manager
130+
cd target
131+
tar -cvf ../../selenium-manager.tar selenium-manager
132+
- name: "Upload debug binary"
133+
if: ${{ inputs.debug == true }}
134+
uses: actions/upload-artifact@v3
135+
with:
136+
name: selenium-manager_macos-universal-debug
137+
path: selenium-manager.tar
138+
retention-days: 6

java/src/org/openqa/selenium/bidi/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ java_library(
2626
"*.java",
2727
"log/*.java",
2828
"browsingcontext/*.java",
29+
"network/*.java",
2930
],
3031
exclude = AUGMENTER_SRCS,
3132
),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.bidi;
19+
20+
import java.util.Collections;
21+
import java.util.HashSet;
22+
import java.util.Set;
23+
import java.util.function.Consumer;
24+
import org.openqa.selenium.WebDriver;
25+
import org.openqa.selenium.bidi.network.BeforeRequestSent;
26+
import org.openqa.selenium.internal.Require;
27+
28+
public class Network implements AutoCloseable {
29+
30+
private final Set<String> browsingContextIds;
31+
32+
private final BiDi bidi;
33+
34+
private final Event<BeforeRequestSent> beforeRequestSentEvent =
35+
new Event<>("network.beforeRequestSent", BeforeRequestSent::fromJsonMap);
36+
37+
public Network(WebDriver driver) {
38+
this(new HashSet<>(), driver);
39+
}
40+
41+
public Network(String browsingContextId, WebDriver driver) {
42+
this(Collections.singleton(Require.nonNull("Browsing context id", browsingContextId)), driver);
43+
}
44+
45+
public Network(Set<String> browsingContextIds, WebDriver driver) {
46+
Require.nonNull("WebDriver", driver);
47+
Require.nonNull("Browsing context id list", browsingContextIds);
48+
49+
if (!(driver instanceof HasBiDi)) {
50+
throw new IllegalArgumentException("WebDriver instance must support BiDi protocol");
51+
}
52+
53+
this.bidi = ((HasBiDi) driver).getBiDi();
54+
this.browsingContextIds = browsingContextIds;
55+
}
56+
57+
public void onBeforeRequestSent(Consumer<BeforeRequestSent> consumer) {
58+
if (browsingContextIds.isEmpty()) {
59+
this.bidi.addListener(beforeRequestSentEvent, consumer);
60+
} else {
61+
this.bidi.addListener(browsingContextIds, beforeRequestSentEvent, consumer);
62+
}
63+
}
64+
65+
@Override
66+
public void close() {
67+
this.bidi.clearListener(beforeRequestSentEvent);
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.bidi.network;
19+
20+
import org.openqa.selenium.json.JsonInput;
21+
22+
public class AuthChallenge {
23+
24+
private final String scheme;
25+
private final String realm;
26+
27+
private AuthChallenge(String scheme, String realm) {
28+
this.scheme = scheme;
29+
this.realm = realm;
30+
}
31+
32+
public static AuthChallenge fromJson(JsonInput input) {
33+
String scheme = null;
34+
String realm = null;
35+
36+
input.beginObject();
37+
while (input.hasNext()) {
38+
switch (input.nextName()) {
39+
case "scheme":
40+
scheme = input.read(String.class);
41+
break;
42+
case "realm":
43+
realm = input.read(String.class);
44+
break;
45+
default:
46+
input.skipValue();
47+
}
48+
}
49+
50+
input.endObject();
51+
52+
return new AuthChallenge(scheme, realm);
53+
}
54+
55+
public String getScheme() {
56+
return scheme;
57+
}
58+
59+
public String getRealm() {
60+
return realm;
61+
}
62+
}

java/src/org/openqa/selenium/bidi/network/NetworkBaseParameters.java renamed to java/src/org/openqa/selenium/bidi/network/BaseParameters.java

+27-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.openqa.selenium.json.JsonInput;
2323
import org.openqa.selenium.json.TypeToken;
2424

25-
public class NetworkBaseParameters {
25+
public class BaseParameters {
2626

2727
private final String browsingContextId;
2828

@@ -38,7 +38,7 @@ public class NetworkBaseParameters {
3838

3939
private final List<String> intercepts;
4040

41-
private NetworkBaseParameters(
41+
BaseParameters(
4242
String browsingContextId,
4343
boolean isBlocked,
4444
String navigation,
@@ -55,7 +55,7 @@ private NetworkBaseParameters(
5555
this.intercepts = intercepts;
5656
}
5757

58-
public static NetworkBaseParameters fromJson(JsonInput input) {
58+
public static BaseParameters fromJson(JsonInput input) {
5959
String browsingContextId = null;
6060

6161
boolean isBlocked = false;
@@ -73,20 +73,35 @@ public static NetworkBaseParameters fromJson(JsonInput input) {
7373
input.beginObject();
7474
while (input.hasNext()) {
7575
switch (input.nextName()) {
76-
case "context" -> browsingContextId = input.read(String.class);
77-
case "isBlocked" -> isBlocked = input.read(Boolean.class);
78-
case "navigation" -> navigationId = input.read(String.class);
79-
case "redirectCount" -> redirectCount = input.read(Long.class);
80-
case "request" -> request = input.read(RequestData.class);
81-
case "timestamp" -> timestamp = input.read(Long.class);
82-
case "intercepts" -> intercepts = input.read(new TypeToken<List<String>>() {}.getType());
83-
default -> input.skipValue();
76+
case "context":
77+
browsingContextId = input.read(String.class);
78+
break;
79+
case "isBlocked":
80+
isBlocked = input.read(Boolean.class);
81+
break;
82+
case "navigation":
83+
navigationId = input.read(String.class);
84+
break;
85+
case "redirectCount":
86+
redirectCount = input.read(Long.class);
87+
break;
88+
case "request":
89+
request = input.read(RequestData.class);
90+
break;
91+
case "timestamp":
92+
timestamp = input.read(Long.class);
93+
break;
94+
case "intercepts":
95+
intercepts = input.read(new TypeToken<List<String>>() {}.getType());
96+
break;
97+
default:
98+
input.skipValue();
8499
}
85100
}
86101

87102
input.endObject();
88103

89-
return new NetworkBaseParameters(
104+
return new BaseParameters(
90105
browsingContextId, isBlocked, navigationId, redirectCount, request, timestamp, intercepts);
91106
}
92107

0 commit comments

Comments
 (0)