Skip to content

Commit ae5c706

Browse files
authored
Merge branch 'trunk' into rb_bidi_add_request_handler
2 parents 8a5f8cc + 744e7d6 commit ae5c706

File tree

35 files changed

+5451
-5889
lines changed

35 files changed

+5451
-5889
lines changed

.bazelrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ build --tool_java_runtime_version=remotejdk_17
3030
build --javacopt="--release 11"
3131

3232
# Require java dependencies to be used and first-order
33-
3433
build --experimental_strict_java_deps=strict
3534
build --explicit_java_test_deps
3635

36+
# Avoid ErrorProne getting annoyed about "impossible null checks"
37+
build --javacopt="-Xep:ImpossibleNullComparison:OFF"
38+
3739
# Allow spaces in runfile paths
3840
build --nobuild_runfile_links
3941

@@ -55,6 +57,11 @@ query --@aspect_rules_ts//ts:default_to_tsc_transpiler
5557

5658
build --incompatible_strict_action_env
5759

60+
# Required to get `protobuf` compiling, which is required for `rules_closure`
61+
build --incompatible_enable_cc_toolchain_resolution
62+
build --cxxopt=-std=c++14
63+
build --host_cxxopt=-std=c++14
64+
5865
# For build stamping
5966

6067
build --enable_platform_specific_config

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bazel_dep(name = "contrib_rules_jvm", version = "0.27.0")
1212
bazel_dep(name = "platforms", version = "0.0.10")
1313

1414
# Required for the closure rules
15-
bazel_dep(name = "protobuf", version = "21.7", dev_dependency = True, repo_name = "com_google_protobuf")
15+
bazel_dep(name = "protobuf", version = "29.1", dev_dependency = True, repo_name = "com_google_protobuf")
1616

1717
# Required for rules_rust to import the crates properly
1818
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)

WORKSPACE

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
66

77
http_archive(
88
name = "io_bazel_rules_closure",
9-
patch_args = [
10-
"-p1",
11-
],
12-
patches = [
13-
"//javascript:rules_closure_shell.patch",
14-
],
15-
sha256 = "d66deed38a0bb20581c15664f0ab62270af5940786855c7adc3087b27168b529",
16-
strip_prefix = "rules_closure-0.11.0",
17-
urls = [
18-
"https://github.com/bazelbuild/rules_closure/archive/0.11.0.tar.gz",
19-
],
9+
strip_prefix = "rules_closure-0.12.0",
10+
url = "https://github.com/bazelbuild/rules_closure/archive/refs/tags/0.12.0.tar.gz",
2011
)
2112

2213
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
@@ -34,8 +25,8 @@ rules_closure_toolchains()
3425

3526
http_archive(
3627
name = "rules_rust",
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"],
28+
integrity = "sha256-eEXiHXSGUH6qD1bdI5KXZ/B04m0wIUeoyM7pmujzbbQ=",
29+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.55.5/rules_rust-0.55.5.tar.gz"],
3930
)
4031

4132
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

dotnet/src/webdriver/Alert.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
using System;
2121
using System.Collections.Generic;
2222

23+
#nullable enable
24+
2325
namespace OpenQA.Selenium
2426
{
2527
/// <summary>
2628
/// Defines the interface through which the user can manipulate JavaScript alerts.
2729
/// </summary>
2830
internal class Alert : IAlert
2931
{
30-
private WebDriver driver;
32+
private readonly WebDriver driver;
3133

3234
/// <summary>
3335
/// Initializes a new instance of the <see cref="Alert"/> class.
@@ -41,12 +43,12 @@ public Alert(WebDriver driver)
4143
/// <summary>
4244
/// Gets the text of the alert.
4345
/// </summary>
44-
public string Text
46+
public string? Text
4547
{
4648
get
4749
{
4850
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAlertText, null);
49-
return commandResponse.Value.ToString();
51+
return (string?)commandResponse.Value;
5052
}
5153
}
5254

@@ -70,9 +72,10 @@ public void Accept()
7072
/// Sends keys to the alert.
7173
/// </summary>
7274
/// <param name="keysToSend">The keystrokes to send.</param>
75+
/// <exception cref="ArgumentNullException">If <paramref name="keysToSend" /> is <see langword="null"/>.</exception>
7376
public void SendKeys(string keysToSend)
7477
{
75-
if (keysToSend == null)
78+
if (keysToSend is null)
7679
{
7780
throw new ArgumentNullException(nameof(keysToSend), "Keys to send must not be null.");
7881
}

dotnet/src/webdriver/Cookie.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,12 @@ public override string ToString()
351351
public override bool Equals(object obj)
352352
{
353353
// Two cookies are equal if the name and value match
354-
Cookie cookie = obj as Cookie;
355-
356354
if (this == obj)
357355
{
358356
return true;
359357
}
360358

361-
if (cookie == null)
359+
if (obj is not Cookie cookie)
362360
{
363361
return false;
364362
}
@@ -368,7 +366,7 @@ public override bool Equals(object obj)
368366
return false;
369367
}
370368

371-
return !(this.cookieValue != null ? !this.cookieValue.Equals(cookie.cookieValue) : cookie.Value != null);
369+
return string.Equals(this.cookieValue, cookie.cookieValue);
372370
}
373371

374372
/// <summary>

dotnet/src/webdriver/CookieJar.cs

Lines changed: 58 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,128 +21,125 @@
2121
using System.Collections.Generic;
2222
using System.Collections.ObjectModel;
2323

24+
#nullable enable
25+
2426
namespace OpenQA.Selenium
2527
{
26-
/// <summary>
27-
/// Defines an interface allowing the user to manipulate cookies on the current page.
28-
/// </summary>
29-
internal class CookieJar : ICookieJar
28+
internal sealed class CookieJar(WebDriver driver) : ICookieJar
3029
{
31-
private WebDriver driver;
32-
33-
/// <summary>
34-
/// Initializes a new instance of the <see cref="CookieJar"/> class.
35-
/// </summary>
36-
/// <param name="driver">The driver that is currently in use</param>
37-
public CookieJar(WebDriver driver)
38-
{
39-
this.driver = driver;
40-
}
41-
4230
/// <summary>
4331
/// Gets all cookies defined for the current page.
4432
/// </summary>
4533
public ReadOnlyCollection<Cookie> AllCookies
4634
{
47-
get { return this.GetAllCookies(); }
35+
get
36+
{
37+
Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary<string, object>());
38+
39+
try
40+
{
41+
List<Cookie> toReturn = new List<Cookie>();
42+
if (response.Value is object?[] cookies)
43+
{
44+
foreach (object? rawCookie in cookies)
45+
{
46+
if (rawCookie != null)
47+
{
48+
Cookie newCookie = Cookie.FromDictionary((Dictionary<string, object?>)rawCookie);
49+
toReturn.Add(newCookie);
50+
}
51+
}
52+
}
53+
54+
return new ReadOnlyCollection<Cookie>(toReturn);
55+
}
56+
catch (Exception e)
57+
{
58+
throw new WebDriverException("Unexpected problem getting cookies", e);
59+
}
60+
}
4861
}
4962

5063
/// <summary>
5164
/// Method for creating a cookie in the browser
5265
/// </summary>
5366
/// <param name="cookie"><see cref="Cookie"/> that represents a cookie in the browser</param>
67+
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
5468
public void AddCookie(Cookie cookie)
5569
{
70+
if (cookie is null)
71+
{
72+
throw new ArgumentNullException(nameof(cookie));
73+
}
74+
5675
Dictionary<string, object> parameters = new Dictionary<string, object>();
5776
parameters.Add("cookie", cookie);
58-
this.driver.InternalExecute(DriverCommand.AddCookie, parameters);
77+
driver.InternalExecute(DriverCommand.AddCookie, parameters);
5978
}
6079

6180
/// <summary>
6281
/// Delete the cookie by passing in the name of the cookie
6382
/// </summary>
6483
/// <param name="name">The name of the cookie that is in the browser</param>
84+
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
6585
public void DeleteCookieNamed(string name)
6686
{
87+
if (name is null)
88+
{
89+
throw new ArgumentNullException(nameof(name));
90+
}
91+
6792
Dictionary<string, object> parameters = new Dictionary<string, object>();
6893
parameters.Add("name", name);
69-
this.driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
94+
driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
7095
}
7196

7297
/// <summary>
7398
/// Delete a cookie in the browser by passing in a copy of a cookie
7499
/// </summary>
75100
/// <param name="cookie">An object that represents a copy of the cookie that needs to be deleted</param>
101+
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
76102
public void DeleteCookie(Cookie cookie)
77103
{
78-
if (cookie != null)
104+
if (cookie is null)
79105
{
80-
this.DeleteCookieNamed(cookie.Name);
106+
throw new ArgumentNullException(nameof(cookie));
81107
}
108+
109+
this.DeleteCookieNamed(cookie.Name);
82110
}
83111

84112
/// <summary>
85113
/// Delete All Cookies that are present in the browser
86114
/// </summary>
87115
public void DeleteAllCookies()
88116
{
89-
this.driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
117+
driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
90118
}
91119

92120
/// <summary>
93121
/// Method for returning a getting a cookie by name
94122
/// </summary>
95123
/// <param name="name">name of the cookie that needs to be returned</param>
96-
/// <returns>A Cookie from the name</returns>
97-
public Cookie GetCookieNamed(string name)
124+
/// <returns>A Cookie from the name; or <see langword="null"/> if not found.</returns>
125+
public Cookie? GetCookieNamed(string name)
98126
{
99-
Cookie cookieToReturn = null;
100-
if (name != null)
127+
if (name is null)
101128
{
102-
ReadOnlyCollection<Cookie> allCookies = this.AllCookies;
103-
foreach (Cookie currentCookie in allCookies)
104-
{
105-
if (name.Equals(currentCookie.Name))
106-
{
107-
cookieToReturn = currentCookie;
108-
break;
109-
}
110-
}
129+
throw new ArgumentNullException(nameof(name));
111130
}
112131

113-
return cookieToReturn;
114-
}
115132

116-
/// <summary>
117-
/// Method for getting a Collection of Cookies that are present in the browser
118-
/// </summary>
119-
/// <returns>ReadOnlyCollection of Cookies in the browser</returns>
120-
private ReadOnlyCollection<Cookie> GetAllCookies()
121-
{
122-
List<Cookie> toReturn = new List<Cookie>();
123-
object returned = this.driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary<string, object>()).Value;
124-
125-
try
133+
foreach (Cookie currentCookie in this.AllCookies)
126134
{
127-
object[] cookies = returned as object[];
128-
if (cookies != null)
135+
if (name.Equals(currentCookie.Name))
129136
{
130-
foreach (object rawCookie in cookies)
131-
{
132-
Dictionary<string, object> cookieDictionary = rawCookie as Dictionary<string, object>;
133-
if (rawCookie != null)
134-
{
135-
toReturn.Add(Cookie.FromDictionary(cookieDictionary));
136-
}
137-
}
137+
return currentCookie;
138138
}
139139

140-
return new ReadOnlyCollection<Cookie>(toReturn);
141-
}
142-
catch (Exception e)
143-
{
144-
throw new WebDriverException("Unexpected problem getting cookies", e);
145140
}
141+
142+
return null;
146143
}
147144
}
148145
}

dotnet/src/webdriver/IAlert.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using System;
21+
22+
#nullable enable
23+
2024
namespace OpenQA.Selenium
2125
{
2226
/// <summary>
@@ -27,7 +31,7 @@ public interface IAlert
2731
/// <summary>
2832
/// Gets the text of the alert.
2933
/// </summary>
30-
string Text { get; }
34+
string? Text { get; }
3135

3236
/// <summary>
3337
/// Dismisses the alert.
@@ -43,6 +47,7 @@ public interface IAlert
4347
/// Sends keys to the alert.
4448
/// </summary>
4549
/// <param name="keysToSend">The keystrokes to send.</param>
50+
/// <exception cref="ArgumentNullException">If <paramref name="keysToSend"/> is <see langword="null"/>.</exception>
4651
void SendKeys(string keysToSend);
4752
}
4853
}

dotnet/src/webdriver/ICookieJar.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using System;
2021
using System.Collections.ObjectModel;
2122

23+
#nullable enable
24+
2225
namespace OpenQA.Selenium
2326
{
2427
/// <summary>
@@ -35,6 +38,7 @@ public interface ICookieJar
3538
/// Adds a cookie to the current page.
3639
/// </summary>
3740
/// <param name="cookie">The <see cref="Cookie"/> object to be added.</param>
41+
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
3842
void AddCookie(Cookie cookie);
3943

4044
/// <summary>
@@ -43,18 +47,21 @@ public interface ICookieJar
4347
/// <param name="name">The name of the cookie to retrieve.</param>
4448
/// <returns>The <see cref="Cookie"/> containing the name. Returns <see langword="null"/>
4549
/// if no cookie with the specified name is found.</returns>
46-
Cookie GetCookieNamed(string name);
50+
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
51+
Cookie? GetCookieNamed(string name);
4752

4853
/// <summary>
4954
/// Deletes the specified cookie from the page.
5055
/// </summary>
5156
/// <param name="cookie">The <see cref="Cookie"/> to be deleted.</param>
57+
/// <exception cref="ArgumentNullException">If <paramref name="cookie"/> is <see langword="null"/>.</exception>
5258
void DeleteCookie(Cookie cookie);
5359

5460
/// <summary>
5561
/// Deletes the cookie with the specified name from the page.
5662
/// </summary>
5763
/// <param name="name">The name of the cookie to be deleted.</param>
64+
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
5865
void DeleteCookieNamed(string name);
5966

6067
/// <summary>

0 commit comments

Comments
 (0)