Skip to content

Commit

Permalink
Merge branch 'trunk' into circular-dep-bidi
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani authored Mar 13, 2024
2 parents cafbec2 + 77521cc commit 54a65a6
Show file tree
Hide file tree
Showing 93 changed files with 2,637 additions and 1,010 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ build:remote --remote_cache=grpcs://gypsum.cluster.engflow.com
build:remote -j 50

# Build Without The Bytes
build:remote --remote_download_outputs=minimal
build:remote --remote_download_minimal

build:remote --define=EXECUTOR=remote
build:remote --experimental_inmemory_dotd_files
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
distribution: 'temurin'
- name: Setup Bazel with caching
if: inputs.caching
uses: p0deje/setup-bazel@0.6.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelisk-cache: true
bazelrc: common --color=yes
Expand All @@ -110,7 +110,7 @@ jobs:
repository-cache: true
- name: Setup Bazel without caching
if: inputs.caching == false
uses: p0deje/setup-bazel@0.6.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelrc: common --color=yes
- name: Setup Fluxbox and Xvfb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
fetch-depth: 50
- name: Setup Bazel
uses: p0deje/setup-bazel@0.4.0
uses: bazel-contrib/setup-bazel@0.8.0
with:
bazelisk-cache: true
external-cache: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ jobs:
cache-key: python-nightly
run: |
./go "py:version[nightly]"
./go py:release
./go py:build
pip install twine
twine upload --repository testpypi bazel-bin/py/selenium-4*.whl bazel-bin/py/selenium-4*.tar.gz
secrets: inherit


Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ jobs:
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.'
stale-issue-label: 'I-stale'
days-before-stale: 280
days-before-close: 14
operations-per-run: 200
- uses: actions/stale@v9
with:
close-issue-message: 'This issue was closed because we did not receive any additional information after 14 days.'
stale-issue-label: 'R-awaiting answer'
days-before-stale: -1
days-before-close: 14
labels-to-add-when-unstale: 'needs-triaging'

3 changes: 3 additions & 0 deletions .skipped-tests
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_service_tests.py
-//py:test-chrome-test/selenium/webdriver/chrome/proxy_tests.py
-//py:unit-test/unit/selenium/webdriver/common/cdp_module_fallback_tests.py
-//rb/spec/integration/selenium/webdriver/chrome:service
-//rb/spec/integration/selenium/webdriver/edge:service
-//rb/spec/integration/selenium/webdriver/firefox:service
21 changes: 17 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,23 @@ namespace :py do
bump_nightly = arguments[:version] === 'nightly'
old_version = python_version
new_version = nil
if bump_nightly && old_version.include?('nightly')
new_version = old_version.gsub('nightly', "#{Time.now.strftime("%Y%m%d%H%M")}")

# There are three cases we want to deal with:
# 1. Switching from a release build to a nightly one
# 2. Updating a nightly build for the next nightly build
# 3. Switching from nightlies to a release build.

if bump_nightly && old_version.include?('.dev')
# This is the case where we are updating a nightly build to the next nightly build.
# This change is usually done by the CI system and never committed.
# The ".dev" is removed to have the pushed package in TestPyPi be shown as latest.
new_version = old_version.gsub(/\.dev\d+$/, '') + + ".#{Time.now.strftime("%Y%m%d%H%M")}"
elsif bump_nightly
# This is the case after a production release and the version number is configured
# to start doing nightly builds.
new_version = old_version + ".dev#{Time.now.strftime("%Y%m%d%H%M")}"
else
new_version = updated_version(old_version, arguments[:version])
new_version += '.nightly' unless old_version.include?('nightly')
new_version = updated_version(old_version.gsub(/\.dev\d+$/, ''), arguments[:version])
end

['py/setup.py',
Expand Down Expand Up @@ -1154,6 +1166,7 @@ task :create_release_notes do
end

def updated_version(current, desired = nil)
puts "Calculating "
version = desired ? desired.split('.') : current.split(/\.|-/)
if desired
# Allows user to pass in only major/minor versions
Expand Down
103 changes: 97 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ workspace(

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_java",
sha256 = "16bc94b1a3c64f2c36ceecddc9e09a643e80937076b97e934b96a8f715ed1eaa",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.5.2/rules_java-6.5.2.tar.gz",
],
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

http_archive(
name = "apple_rules_lint",
sha256 = "7c3cc45a95e3ef6fbc484a4234789a027e11519f454df63cbb963ac499f103f9",
Expand Down Expand Up @@ -51,9 +65,9 @@ aspect_bazel_lib_register_toolchains()

http_archive(
name = "rules_python",
sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036",
strip_prefix = "rules_python-0.25.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
strip_prefix = "rules_python-0.31.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains")
Expand Down Expand Up @@ -344,9 +358,9 @@ pin_browsers()

http_archive(
name = "rules_ruby",
sha256 = "9bfab76e1272dae72355c65cc858ede68b659716381485baa4c8e7a70ddc38a6",
strip_prefix = "rules_ruby-0.5.0",
url = "https://github.com/bazel-contrib/rules_ruby/releases/download/v0.5.0/rules_ruby-v0.5.0.tar.gz",
sha256 = "9ff781fd8180c2be8b3ab0f16d1d88d618c3b1bc4d502dcb914591886da40014",
strip_prefix = "rules_ruby-0.8.1",
url = "https://github.com/bazel-contrib/rules_ruby/releases/download/v0.8.1/rules_ruby-v0.8.1.tar.gz",
)

load(
Expand All @@ -367,6 +381,83 @@ rb_bundle_fetch(
"//:rb/selenium-devtools.gemspec",
"//:rb/selenium-webdriver.gemspec",
],
gem_checksums = {
"abbrev-0.1.2": "ad1b4eaaaed4cb722d5684d63949e4bde1d34f2a95e20db93aecfe7cbac74242",
"activesupport-7.1.3": "fbfc137f1ab0e3909bd3de3e2a965245abf0381a2a7e283fa766cee6f5e0f927",
"addressable-2.8.6": "798f6af3556641a7619bad1dce04cdb6eb44b0216a991b0396ea7339276f2b47",
"ast-2.4.2": "1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12",
"base64-0.2.0": "0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507",
"bigdecimal-3.1.6": "bcbc27d449cf8ed1b1814d21308f49c9d22ce73e33fff0d228e38799c02eab01",
"bigdecimal-3.1.6-java": "2ef0e13a578e2411123254273f8b34c47ff9d45de91a6f64465fb217de8d5d04",
"concurrent-ruby-1.2.3": "82fdd3f8a0816e28d513e637bb2b90a45d7b982bdf4f3a0511722d2e495801e2",
"connection_pool-2.4.1": "0f40cf997091f1f04ff66da67eabd61a9fe0d4928b9a3645228532512fab62f4",
"crack-1.0.0": "c83aefdb428cdc7b66c7f287e488c796f055c0839e6e545fec2c7047743c4a49",
"csv-3.2.8": "2f5e11e8897040b97baf2abfe8fa265b314efeb8a9b7f756db9ebcf79e7db9fe",
"debug-1.9.1": "86f1a6d4a299184f1a1f7ae4c2fe80f178beed55cdf608f83b49d7bdefa3ffda",
"diff-lcs-1.5.1": "273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe",
"drb-2.2.0": "e9e4af1cded3306cfe37e064a0086e302d5f40df9cb4d161d059a6bb3a75d40f",
"ffi-1.16.3": "6d3242ff10c87271b0675c58d68d3f10148fabc2ad6da52a18123f06078871fb",
"ffi-1.16.3-x64-mingw32": "6ec709011e3955e97033fa77907a8ab89a9150137d4c45c82c77399b909c9259",
"fileutils-1.7.2": "36a0fb324218263e52b486ad7408e9a295378fe8edc9fd343709e523c0980631",
"git-1.19.1": "b0a422d9f6517353c48a330d6114de4db9e0c82dbe7202964a1d9f1fbc827d70",
"hashdiff-1.1.0": "b5465f0e7375f1ee883f53a766ece4dbc764b7674a7c5ffd76e79b2f5f6fc9c9",
"i18n-1.14.1": "9d03698903547c060928e70a9bc8b6b87fda674453cda918fc7ab80235ae4a61",
"io-console-0.7.2": "f0dccff252f877a4f60d04a4dc6b442b185ebffb4b320ab69212a92b48a7a221",
"io-console-0.7.2-java": "73aa382f8832b116613ceaf57b8ff5bf73dfedcaf39f0aa5420e10f63a4543ed",
"irb-1.11.2": "a05f07e81d32dc79d78b0019283b9877463da0d40253774d1fe89f9586ae1cb9",
"jar-dependencies-0.4.1": "b2df2f1ecbff15334ce20ea7fdd5b8d8161faab67761ff72c7647d728e40d387",
"json-2.7.1": "187ea312fb58420ff0c40f40af1862651d4295c8675267c6a1c353f1a0ac3265",
"json-2.7.1-java": "bfd628c0f8357058c2cf848febfa6f140f70f94ec492693a31a0a1933038a61b",
"language_server-protocol-3.17.0.3": "3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f",
"listen-3.8.0": "9679040ac6e7845ad9f19cf59ecde60861c78e2fae57a5c20fe35e94959b2f8f",
"logger-1.6.0": "0ab7c120262dd8de2a18cb8d377f1f318cbe98535160a508af9e7710ff43ef3e",
"minitest-5.22.2": "c5a5003fc2114a3fde506e87f377f32a0882b41d944d7b90cf4cd1f781dbc718",
"mutex_m-0.2.0": "b6ef0c6c842ede846f2ec0ade9e266b1a9dac0bc151682b04835e8ebd54840d5",
"parallel-1.24.0": "5bf38efb9b37865f8e93d7a762727f8c5fc5deb19949f4040c76481d5eee9397",
"parser-3.3.0.5": "7748313e505ca87045dc0465c776c802043f777581796eb79b1654c5d19d2687",
"psych-5.1.2": "337322f58fc2bf24827d2b9bd5ab595f6a72971867d151bb39980060ea40a368",
"psych-5.1.2-java": "1dd68dc609eddbc884e6892e11da942e16f7256bd30ebde9d35449d43043a6fe",
"public_suffix-5.0.4": "35cd648e0d21d06b8dce9331d19619538d1d898ba6d56a6f2258409d2526d1ae",
"racc-1.7.3": "b785ab8a30ec43bce073c51dbbe791fd27000f68d1c996c95da98bf685316905",
"racc-1.7.3-java": "b2ad737e788cfa083263ce7c9290644bb0f2c691908249eb4f6eb48ed2815dbf",
"rack-2.2.8": "7b83a1f1304a8f5554c67bc83632d29ecd2ed1daeb88d276b7898533fde22d97",
"rainbow-3.1.1": "039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a",
"rake-13.1.0": "be6a3e1aa7f66e6c65fa57555234eb75ce4cf4ada077658449207205474199c6",
"rb-fsevent-0.11.2": "43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe",
"rb-inotify-0.10.1": "050062d4f31d307cca52c3f6a7f4b946df8de25fc4bd373e1a5142e41034a7ca",
"rbs-3.4.4": "1376d2604a00832641bb47521595e63a1c0d1cc241ded383ba48ddb4396de5a8",
"rchardet-1.8.0": "693acd5253d5ade81a51940697955f6dd4bb2f0d245bda76a8e23deec70a52c7",
"rdoc-6.6.2": "f763dbec81079236bcccded19d69680471bd55da8f731ea6f583d019dacd9693",
"regexp_parser-2.9.0": "81a00ba141cec0d4b4bf58cb80cd9193e5180836d3fa6ef623f7886d3ba8bdd9",
"reline-0.4.2": "14042962b71d4cf52cc7d348f411886e2df54fc9d434d69b0b0bff84786d1c3a",
"rexml-3.2.6": "e0669a2d4e9f109951cb1fde723d8acd285425d81594a2ea929304af50282816",
"rspec-3.13.0": "d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993",
"rspec-core-3.13.0": "557792b4e88da883d580342b263d9652b6a10a12d5bda9ef967b01a48f15454c",
"rspec-expectations-3.13.0": "621d48c62262f955421eaa418130744760802cad47e781df70dba4d9f897102e",
"rspec-mocks-3.13.0": "735a891215758d77cdb5f4721fffc21078793959d1f0ee4a961874311d9b7f66",
"rspec-support-3.13.0": "0e725f53b8c20ce75913a5da7bf06bf90698266951f3b1e3ae7bcd9612775257",
"rubocop-1.60.2": "000da0bffba2da48efdab233b13085afc3fabad2aa17ef0470cbaa0fd7cbc76c",
"rubocop-ast-1.30.0": "faad6452b1018fee0dd9e21a44445908e94ee2a4435932a9dae0e0740b6349b3",
"rubocop-capybara-2.20.0": "2a6844b942921f230ee3ab8c94fe77f41a9406096a140245270c0e11624bb938",
"rubocop-factory_bot-2.25.1": "62751bde7af789878b8a31cbd2a82e69515ce7b23a2ad1820cb0fcc3e0150134",
"rubocop-performance-1.20.2": "1bb1fa8c427fac7ba3c8dd2decb9860f23cb2d6c40350bedc88538de8875c731",
"rubocop-rspec-2.26.1": "da00a2794c35c6df9d013621fe9d8340ef9717dba746eb4aa69f414d86e74458",
"ruby-progressbar-1.13.0": "80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33",
"ruby2_keywords-0.0.5": "ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef",
"rubyzip-2.3.2": "3f57e3935dc2255c414484fbf8d673b4909d8a6a57007ed754dde39342d2373f",
"securerandom-0.3.1": "98f0450c0ea46d2f9a4b6db4f391dbd83dc08049592eada155739f40e0341bde",
"steep-1.5.3": "7c6302a4d5932d0a46176ebc79766e52b853c223a85525aa2f8911e345123b85",
"stringio-3.1.0": "c1f6263ae03a15025e51194ab19b06b15e06adcaaedb7f5f6c06ab60f5d67718",
"strscan-3.1.0": "01b8a81d214fbf7b5308c6fb51b5972bbfc4a6aa1f166fd3618ba97e0fcd5555",
"strscan-3.1.0-java": "8645aa76e017e21764c6df572d2d79fcc1672284014f5bdbd806278cdbcd11b0",
"terminal-table-3.0.2": "f951b6af5f3e00203fb290a669e0a85c5dd5b051b3b023392ccfd67ba5abae91",
"tzinfo-2.0.6": "8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b",
"unicode-display_width-2.5.0": "7e7681dcade1add70cb9fda20dd77f300b8587c81ebbd165d14fd93144ff0ab4",
"webmock-3.21.0": "6609ab365daa85d203fcc297d1fffdbc8fc4216308b7c77d620af7d1261e2fd2",
"webrick-1.8.1": "19411ec6912911fd3df13559110127ea2badd0c035f7762873f58afc803e158f",
"websocket-1.2.10": "2cc1a4a79b6e63637b326b4273e46adcddf7871caa5dc5711f2ca4061a629fa8",
"yard-0.9.36": "5505736c1b00c926f71053a606ab75f02070c5960d0778b901fe9d8b0a470be4",
},
gemfile = "//:rb/Gemfile",
gemfile_lock = "//:rb/Gemfile.lock",
)
Expand Down
1 change: 1 addition & 0 deletions common/src/web/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ filegroup(
"//java/test/org/openqa/selenium/environment:__pkg__",
"//javascript/node/selenium-webdriver:__pkg__",
"//py:__pkg__",
"//rb/spec:__subpackages__",
],
)
1 change: 1 addition & 0 deletions java/src/org/openqa/selenium/bidi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ java_library(
"browsingcontext/*.java",
"network/*.java",
"script/*.java",
"storage/*.java",
],
exclude = AUGMENTER_SRCS,
),
Expand Down
67 changes: 67 additions & 0 deletions java/src/org/openqa/selenium/bidi/Browser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.bidi;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.json.JsonInput;

public class Browser {
private final BiDi bidi;

private final Function<JsonInput, String> userContextInfoMapper =
jsonInput -> {
Map<String, Object> response = jsonInput.read(Map.class);
return (String) response.get("userContext");
};

private final Function<JsonInput, List<String>> userContextsInfoMapper =
jsonInput -> {
Map<String, Object> response = jsonInput.read(Map.class);
List<Map<String, String>> userContextsResponse =
(List<Map<String, String>>) response.get("userContexts");

List<String> userContexts = new ArrayList<>();
userContextsResponse.forEach(
map -> {
String userContext = map.get("userContext");
userContexts.add(userContext);
});

return userContexts;
};

public Browser(WebDriver driver) {
this.bidi = ((HasBiDi) driver).getBiDi();
}

public String createUserContext() {
return bidi.send(new Command<>("browser.createUserContext", Map.of(), userContextInfoMapper));
}

public List<String> getUserContexts() {
return bidi.send(new Command<>("browser.getUserContexts", Map.of(), userContextsInfoMapper));
}

public void removeUserContext(String userContext) {
bidi.send(new Command<>("browser.removeUserContext", Map.of("userContext", userContext)));
}
}
74 changes: 74 additions & 0 deletions java/src/org/openqa/selenium/bidi/Storage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.bidi;

import java.io.StringReader;
import java.util.Map;
import java.util.function.Function;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.bidi.storage.DeleteCookiesParameters;
import org.openqa.selenium.bidi.storage.GetCookiesParameters;
import org.openqa.selenium.bidi.storage.GetCookiesResult;
import org.openqa.selenium.bidi.storage.PartitionKey;
import org.openqa.selenium.bidi.storage.SetCookieParameters;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonInput;

public class Storage {
private static final Json JSON = new Json();

private final BiDi bidi;

private final Function<JsonInput, GetCookiesResult> getCookiesResultMapper =
jsonInput -> jsonInput.read(GetCookiesResult.class);

private final Function<JsonInput, PartitionKey> partitionKeyResultMapper =
jsonInput -> {
Map<String, Object> response = jsonInput.read(Map.class);
try (StringReader reader = new StringReader(JSON.toJson(response.get("partitionKey")));
JsonInput input = JSON.newInput(reader)) {
return input.read(PartitionKey.class);
}
};

public Storage(WebDriver driver) {
Require.nonNull("WebDriver", driver);

if (!(driver instanceof HasBiDi)) {
throw new IllegalArgumentException("WebDriver instance must support BiDi protocol");
}

this.bidi = ((HasBiDi) driver).getBiDi();
}

public GetCookiesResult getCookies(GetCookiesParameters params) {
return this.bidi.send(
new Command<>("storage.getCookies", params.toMap(), getCookiesResultMapper));
}

public PartitionKey setCookie(SetCookieParameters params) {
return this.bidi.send(
new Command<>("storage.setCookie", params.toMap(), partitionKeyResultMapper));
}

public PartitionKey deleteCookies(DeleteCookiesParameters params) {
return this.bidi.send(
new Command<>("storage.deleteCookies", params.toMap(), partitionKeyResultMapper));
}
}
Loading

0 comments on commit 54a65a6

Please sign in to comment.