Skip to content

Commit 7416da6

Browse files
committed
Merge remote-tracking branch 'origin/trunk' into remote-image
2 parents 4a87a29 + 013ab47 commit 7416da6

File tree

9 files changed

+266
-44
lines changed

9 files changed

+266
-44
lines changed

.github/workflows/pre-release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,19 @@ jobs:
9797
**Warning: Manually update the changelogs before merging**
9898
9999
This PR:
100-
* Updates Rust version for Selenium Manager release
101100
* Updates Pinned browser version to coincide with new CDP release
102101
* Adds support for new CDP version and removes old CDP version
103102
* Selenium Manager references the new Selenium Manager release
104103
* Updates Maven Dependencies
105104
* Adds new authors to authors file
106105
* Updates all versions for all bindings
107106
* Generates *rough* change logs for each bindings (please tidy them up before merging this)
107+
* Not all commits need to be in the change log — users do not need to see anything about building or testing Selenium
108+
* Remove references to updating versions including nightly
109+
* The code now outputs the complete body of the commit message; make sure the changelog message is complete and correct
108110
109-
- Auto-generated by [create-pull-request][1]
111+
- This PR was auto-generated by workflow run: [release-preparation][1]
110112
111-
[1]: https://github.com/peter-evans/create-pull-request
113+
[1]: https://github.com/SeleniumHQ/selenium/actions/runs/${{ github.run_id }}
112114
labels: C-build
113115
draft: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ for Maven to use locally by deploying to your local maven repository (`~/.m2/rep
201201

202202
#### Updating Dependencies
203203

204-
Dependencies are defined in the file [maven_deps.bzl](https://github.com/SeleniumHQ/selenium/blob/trunk/java/maven_deps.bzl).
204+
Dependencies are defined in the file [MODULE.bazel](https://github.com/SeleniumHQ/selenium/blob/trunk/MODULE.bazel).
205205
To automatically update and pin new dependencies, run:
206206

207207
```shell

Rakefile

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def verify_java_release_targets
129129
current_targets = []
130130

131131
Bazel.execute('query', [], query) do |output|
132-
current_targets = output.lines.map(&:strip).reject(&:empty?)
132+
current_targets = output.lines.map(&:strip).reject(&:empty?).select { |line| line.start_with?('//') }
133133
end
134134

135135
missing_targets = current_targets - JAVA_RELEASE_TARGETS
@@ -1110,34 +1110,38 @@ namespace :all do
11101110
commit!('Update selenium manager version', ['common/selenium_manager.bzl'])
11111111

11121112
Rake::Task['java:update'].invoke
1113-
commit!('Update Maven Dependencies', ['java/maven_deps.bzl', 'java/maven_install.json'])
1113+
commit!('Update Maven Dependencies', ['MODULE.bazel', 'java/maven_install.json'])
11141114

11151115
Rake::Task['authors'].invoke
11161116
commit!('Update authors file', ['AUTHORS'])
11171117

11181118
# Note that this does not include Rust version changes that are handled in separate rake:version task
11191119
# TODO: These files are all defined in other tasks; remove duplication
11201120
Rake::Task['all:version'].invoke(version)
1121-
commit!("FIX CHANGELOGS BEFORE MERGING!\n\nUpdate versions and change logs to release Selenium #{java_version}",
1122-
['dotnet/CHANGELOG',
1123-
'dotnet/selenium-dotnet-version.bzl',
1124-
'java/CHANGELOG',
1121+
commit!("Update Version in all bindings to #{java_version}",
1122+
['dotnet/selenium-dotnet-version.bzl',
11251123
'java/version.bzl',
1126-
'javascript/node/selenium-webdriver/CHANGES.md',
1124+
'javascript/node/selenium-webdriver/BUILD.bazel',
11271125
'javascript/node/selenium-webdriver/package.json',
11281126
'py/docs/source/conf.py',
1127+
'py/pyproject.toml',
11291128
'py/selenium/__init__.py',
11301129
'py/selenium/webdriver/__init__.py',
11311130
'py/BUILD.bazel',
1132-
'py/CHANGES',
11331131
'rb/lib/selenium/webdriver/version.rb',
1134-
'rb/CHANGES',
11351132
'rb/Gemfile.lock',
1136-
'rust/CHANGELOG.md',
11371133
'rust/BUILD.bazel',
11381134
'rust/Cargo.Bazel.lock',
11391135
'rust/Cargo.toml',
11401136
'rust/Cargo.lock'])
1137+
1138+
commit!("FIX CHANGELOGS BEFORE MERGING! #{java_version}",
1139+
['dotnet/CHANGELOG',
1140+
'java/CHANGELOG',
1141+
'javascript/node/selenium-webdriver/CHANGES.md',
1142+
'py/CHANGES',
1143+
'rb/CHANGES',
1144+
'rust/CHANGELOG.md'])
11411145
end
11421146

11431147
desc 'Update all versions'
@@ -1214,16 +1218,25 @@ end
12141218

12151219
def update_changelog(version, language, path, changelog, header)
12161220
tag = previous_tag(version, language)
1217-
log = if language == 'javascript'
1218-
`git --no-pager log #{tag}...HEAD --pretty=format:"- %s" --reverse #{path}`
1219-
else
1220-
`git --no-pager log #{tag}...HEAD --pretty=format:"* %s" --reverse #{path}`
1221-
end
1222-
commits = log.split('>>>').map { |entry|
1223-
lines = entry.split("\n")
1224-
lines.reject! { |line| line.match?(/^(----|Co-authored|Signed-off)/) || line.empty? }
1225-
lines.join("\n")
1226-
}.join("\n>>>")
1221+
bullet = language == 'javascript' ? '- ' : '* '
1222+
commit_delimiter = '===DELIM==='
1223+
tags_to_remove = /\[(dotnet|rb|py|java|js|rust)\]:?\s?/
1224+
1225+
command = "git --no-pager log #{tag}...HEAD --pretty=format:\"%s%n%b#{commit_delimiter}\" --reverse #{path}"
1226+
puts "Executing git command: #{command}"
1227+
1228+
log = `#{command}`
1229+
1230+
commits = log.split(commit_delimiter).map { |commit|
1231+
lines = commit.gsub(tags_to_remove, '').strip.lines.map(&:chomp)
1232+
subject = "#{bullet}#{lines[0]}"
1233+
1234+
body = lines[1..]
1235+
.reject { |line| line.match?(/^(----|Co-authored|Signed-off)/) || line.empty? }
1236+
.map { |line| " > #{line}" }
1237+
.join("\n")
1238+
body.empty? ? subject : "#{subject}\n#{body}"
1239+
}.join("\n")
12271240

12281241
File.open(changelog, 'r+') do |file|
12291242
new_content = "#{header}\n#{commits}\n\n#{file.read}"

java/test/org/openqa/selenium/bidi/BiDiSessionCleanUpTest.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
2121
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType;
2222

23-
import java.util.Collections;
2423
import org.junit.jupiter.api.Test;
2524
import org.openqa.selenium.WebDriverException;
2625
import org.openqa.selenium.WindowType;
@@ -42,8 +41,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
4241

4342
BiDi biDi = driver.getBiDi();
4443

45-
BiDiSessionStatus status =
46-
biDi.send(new Command<>("session.status", Collections.emptyMap(), BiDiSessionStatus.class));
44+
BiDiSessionStatus status = biDi.getBidiSessionStatus();
4745
assertThat(status).isNotNull();
4846
assertThat(status.getMessage()).isEqualTo("Session already started");
4947

@@ -53,8 +51,7 @@ void shouldNotCloseBiDiSessionIfOneWindowIsClosed() {
5351

5452
driver.close();
5553

56-
BiDiSessionStatus statusAfterClosing =
57-
biDi.send(new Command<>("session.status", Collections.emptyMap(), BiDiSessionStatus.class));
54+
BiDiSessionStatus statusAfterClosing = biDi.getBidiSessionStatus();
5855
assertThat(statusAfterClosing).isNotNull();
5956
assertThat(status.getMessage()).isEqualTo("Session already started");
6057
driver.quit();
@@ -70,19 +67,14 @@ void shouldCloseBiDiSessionIfLastWindowIsClosed() {
7067

7168
BiDi biDi = driver.getBiDi();
7269

73-
BiDiSessionStatus status =
74-
biDi.send(new Command<>("session.status", Collections.emptyMap(), BiDiSessionStatus.class));
70+
BiDiSessionStatus status = biDi.getBidiSessionStatus();
7571
assertThat(status).isNotNull();
7672
assertThat(status.getMessage()).isEqualTo("Session already started");
7773

7874
driver.close();
7975

8076
// Closing the last top-level browsing context, closes the WebDriver and BiDi session
8177
assertThatExceptionOfType(WebDriverException.class)
82-
.isThrownBy(
83-
() ->
84-
biDi.send(
85-
new Command<>(
86-
"session.status", Collections.emptyMap(), BiDiSessionStatus.class)));
78+
.isThrownBy(() -> biDi.getBidiSessionStatus());
8779
}
8880
}

java/test/org/openqa/selenium/bidi/BiDiSessionTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
2121

22-
import java.util.Collections;
2322
import org.junit.jupiter.api.Test;
2423
import org.openqa.selenium.testing.JupiterTestBase;
2524

@@ -29,8 +28,7 @@ class BiDiSessionTest extends JupiterTestBase {
2928
void shouldBeAbleToCreateABiDiSession() {
3029
BiDi biDi = ((HasBiDi) driver).getBiDi();
3130

32-
BiDiSessionStatus status =
33-
biDi.send(new Command<>("session.status", Collections.emptyMap(), BiDiSessionStatus.class));
31+
BiDiSessionStatus status = biDi.getBidiSessionStatus();
3432
assertThat(status).isNotNull();
3533
assertThat(status.getMessage()).isNotEmpty();
3634
}

java/test/org/openqa/selenium/grid/router/RemoteWebDriverBiDiTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static org.openqa.selenium.testing.drivers.Browser.*;
2222

2323
import java.io.StringReader;
24-
import java.util.Collections;
2524
import java.util.Objects;
2625
import java.util.concurrent.CompletableFuture;
2726
import java.util.concurrent.ExecutionException;
@@ -37,7 +36,6 @@
3736
import org.openqa.selenium.WindowType;
3837
import org.openqa.selenium.bidi.BiDi;
3938
import org.openqa.selenium.bidi.BiDiSessionStatus;
40-
import org.openqa.selenium.bidi.Command;
4139
import org.openqa.selenium.bidi.HasBiDi;
4240
import org.openqa.selenium.bidi.browsingcontext.BrowsingContext;
4341
import org.openqa.selenium.bidi.browsingcontext.NavigationResult;
@@ -89,9 +87,7 @@ void setup() {
8987
@NotYetImplemented(EDGE)
9088
void ensureBiDiSessionCreation() {
9189
try (BiDi biDi = ((HasBiDi) driver).getBiDi()) {
92-
BiDiSessionStatus status =
93-
biDi.send(
94-
new Command<>("session.status", Collections.emptyMap(), BiDiSessionStatus.class));
90+
BiDiSessionStatus status = biDi.getBidiSessionStatus();
9591
assertThat(status).isNotNull();
9692
assertThat(status.getMessage()).isNotEmpty();
9793
}

javascript/node/selenium-webdriver/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ js_library(
3838
"devtools/*.js",
3939
"common/*.js",
4040
"bidi/*.js",
41+
"bidi/external/*.js",
4142
]),
4243
deps = [
4344
":node_modules/@bazel/runfiles",
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
const PermissionState = Object.freeze({
19+
GRANTED: 'granted',
20+
DENIED: 'denied',
21+
PROMPT: 'prompt',
22+
})
23+
24+
class Permission {
25+
constructor(driver) {
26+
this._driver = driver
27+
}
28+
29+
async init() {
30+
if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
31+
throw Error('WebDriver instance must support BiDi protocol')
32+
}
33+
34+
this.bidi = await this._driver.getBidi()
35+
}
36+
37+
/**
38+
* Sets a permission state for a given permission descriptor.
39+
* @param {Object} permissionDescriptor The permission descriptor.
40+
* @param {string} state The permission state (granted, denied, prompt).
41+
* @param {string} origin The origin for which the permission is set.
42+
* @param {string} [userContext] The user context id (optional).
43+
* @returns {Promise<void>}
44+
*/
45+
async setPermission(permissionDescriptor, state, origin, userContext = null) {
46+
if (!Object.values(PermissionState).includes(state)) {
47+
throw new Error(`Invalid permission state. Must be one of: ${Object.values(PermissionState).join(', ')}`)
48+
}
49+
50+
const command = {
51+
method: 'permissions.setPermission',
52+
params: {
53+
descriptor: permissionDescriptor,
54+
state: state,
55+
origin: origin,
56+
},
57+
}
58+
59+
if (userContext) {
60+
command.params.userContext = userContext
61+
}
62+
63+
await this.bidi.send(command)
64+
}
65+
}
66+
67+
async function getPermissionInstance(driver) {
68+
let instance = new Permission(driver)
69+
await instance.init()
70+
return instance
71+
}
72+
73+
module.exports = { getPermissionInstance, PermissionState }

0 commit comments

Comments
 (0)