Skip to content

Commit 06966d4

Browse files
Merge branch 'trunk' into exception-test
2 parents 0fa4291 + d9149ac commit 06966d4

File tree

13 files changed

+130
-65
lines changed

13 files changed

+130
-65
lines changed

common/repositories.bzl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def pin_browsers():
1111

1212
http_archive(
1313
name = "linux_firefox",
14-
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.1/linux-x86_64/en-US/firefox-132.0.1.tar.bz2",
15-
sha256 = "ecdcb4787263cacd31aa3a1b62c14f1d3b69af44a0b40f9eb040852f401097c1",
14+
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/linux-x86_64/en-US/firefox-132.0.2.tar.bz2",
15+
sha256 = "777d47f8b8710ab450582dc0dc0cdf8f43c2291249b3eaf740ee28ee34cda139",
1616
build_file_content = """
1717
load("@aspect_rules_js//js:defs.bzl", "js_library")
1818
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
3333

3434
dmg_archive(
3535
name = "mac_firefox",
36-
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.1/mac/en-US/Firefox%20132.0.1.dmg",
37-
sha256 = "409c0bdb4e434c1191b71504626f8165b01e2582e561a870591940186614be2e",
36+
url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/mac/en-US/Firefox%20132.0.2.dmg",
37+
sha256 = "233251c46eb4964868d815a9233cab855ac6160736310771a67af93a9b78224d",
3838
build_file_content = """
3939
load("@aspect_rules_js//js:defs.bzl", "js_library")
4040
package(default_visibility = ["//visibility:public"])
@@ -50,8 +50,8 @@ js_library(
5050

5151
http_archive(
5252
name = "linux_beta_firefox",
53-
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b6/linux-x86_64/en-US/firefox-133.0b6.tar.bz2",
54-
sha256 = "0f600dd3225ca6824004d28449e94d3768012f49eaea5506c618a199f234486e",
53+
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/linux-x86_64/en-US/firefox-133.0b9.tar.bz2",
54+
sha256 = "5c9f79912bfbf892d2b676973a26ffc078ee9b8fd9b791bfa856db030e657750",
5555
build_file_content = """
5656
load("@aspect_rules_js//js:defs.bzl", "js_library")
5757
package(default_visibility = ["//visibility:public"])
@@ -72,8 +72,8 @@ js_library(
7272

7373
dmg_archive(
7474
name = "mac_beta_firefox",
75-
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b6/mac/en-US/Firefox%20133.0b6.dmg",
76-
sha256 = "a6be00e4471d07eefc149a73e564232f2051fa8a39c1e12385550c8822f128b5",
75+
url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/mac/en-US/Firefox%20133.0b9.dmg",
76+
sha256 = "0eb0fabe9216dc80c2ca403dd2eba935d71f2bdc1dea1d1cc37f03666ef094d1",
7777
build_file_content = """
7878
load("@aspect_rules_js//js:defs.bzl", "js_library")
7979
package(default_visibility = ["//visibility:public"])
@@ -123,10 +123,10 @@ js_library(
123123

124124
pkg_archive(
125125
name = "mac_edge",
126-
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/1225faee-37ac-4c03-8f2b-153353d900c6/MicrosoftEdge-130.0.2849.80.pkg",
127-
sha256 = "a0f3353555a7057158fd0335ecc783a45e1ed5bf38da9975396b63008591af80",
126+
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/08b226c9-fbe8-43c0-94fe-ed9c3eeb8f59/MicrosoftEdge-131.0.2903.51.pkg",
127+
sha256 = "5bc1eab86bb315aa9f2cd2b7d9afe072df35280f6e6d1a9ca9c108d95bda8acd",
128128
move = {
129-
"MicrosoftEdge-130.0.2849.80.pkg/Payload/Microsoft Edge.app": "Edge.app",
129+
"MicrosoftEdge-131.0.2903.51.pkg/Payload/Microsoft Edge.app": "Edge.app",
130130
},
131131
build_file_content = """
132132
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -143,8 +143,8 @@ js_library(
143143

144144
deb_archive(
145145
name = "linux_edge",
146-
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_130.0.2849.80-1_amd64.deb",
147-
sha256 = "1b6f5743703e6da81c65c28dbcfd949d605466e226acc7cde9efbd4beabfa05d",
146+
url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.51-1_amd64.deb",
147+
sha256 = "8aad12c97bcae417ff9cc4251b75211eeda7f1513312dc57b2f744e824e028c0",
148148
build_file_content = """
149149
load("@aspect_rules_js//js:defs.bzl", "js_library")
150150
package(default_visibility = ["//visibility:public"])
@@ -165,8 +165,8 @@ js_library(
165165

166166
http_archive(
167167
name = "linux_edgedriver",
168-
url = "https://msedgedriver.azureedge.net/130.0.2849.78/edgedriver_linux64.zip",
169-
sha256 = "aec868f31bd714a5c12405f6fd6e0e7bfb3d0d06ae79690ecffde4af73da2075",
168+
url = "https://msedgedriver.azureedge.net/131.0.2903.52/edgedriver_linux64.zip",
169+
sha256 = "ddbeda7cec5ed16b96c3cf0f6759de30e4f3726da9da31bfba1371ccd8fcfd14",
170170
build_file_content = """
171171
load("@aspect_rules_js//js:defs.bzl", "js_library")
172172
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
182182

183183
http_archive(
184184
name = "mac_edgedriver",
185-
url = "https://msedgedriver.azureedge.net/130.0.2849.81/edgedriver_mac64.zip",
186-
sha256 = "da719a1170c2e93a88186dd9dabe485dda816280539522af03535d6c02eb1943",
185+
url = "https://msedgedriver.azureedge.net/131.0.2903.52/edgedriver_mac64.zip",
186+
sha256 = "719f54eb9376df5963e80da727c8ab8bacf6a1f57b785602a53a22fe330bb160",
187187
build_file_content = """
188188
load("@aspect_rules_js//js:defs.bzl", "js_library")
189189
package(default_visibility = ["//visibility:public"])
@@ -199,8 +199,8 @@ js_library(
199199

200200
http_archive(
201201
name = "linux_chrome",
202-
url = "https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip",
203-
sha256 = "3e71b99204dc191a8692048526a4ad41803b8b9035ea4ef14eb9b1d37331e1f1",
202+
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.69/linux64/chrome-linux64.zip",
203+
sha256 = "3e33f61511e5e9dabac0d7a57b4bb975555ed1d4dababa7898205c030f82e4e3",
204204
build_file_content = """
205205
load("@aspect_rules_js//js:defs.bzl", "js_library")
206206
package(default_visibility = ["//visibility:public"])
@@ -221,8 +221,8 @@ js_library(
221221

222222
http_archive(
223223
name = "mac_chrome",
224-
url = "https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/mac-x64/chrome-mac-x64.zip",
225-
sha256 = "2f535efa4d92c9aa3c7a1fd896ae4088d6a306150649bb7c1e6ef20f7d536476",
224+
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.69/mac-x64/chrome-mac-x64.zip",
225+
sha256 = "72a52967c80f9f145856d08d91052eaa27f6b951f9a4d8ab279f192b98784e41",
226226
strip_prefix = "chrome-mac-x64",
227227
patch_cmds = [
228228
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -243,8 +243,8 @@ js_library(
243243

244244
http_archive(
245245
name = "linux_chromedriver",
246-
url = "https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chromedriver-linux64.zip",
247-
sha256 = "35b6751942cb589e8bde4733cf6dc7a1484693a56004e5dc8d994beede19e847",
246+
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.69/linux64/chromedriver-linux64.zip",
247+
sha256 = "afc7b41aa0e1606e8cc177c776287d836635690964e39eab1ed94d63a0c96be2",
248248
strip_prefix = "chromedriver-linux64",
249249
build_file_content = """
250250
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -261,8 +261,8 @@ js_library(
261261

262262
http_archive(
263263
name = "mac_chromedriver",
264-
url = "https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/mac-x64/chromedriver-mac-x64.zip",
265-
sha256 = "f8f71dfbed7dfe7255b2a1abda3cf28cc4d661f6f653dc1282735c703c86b865",
264+
url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.69/mac-x64/chromedriver-mac-x64.zip",
265+
sha256 = "92583e52f601951d3e0849891239bb2f6ff00dd8f8fd6c908473cc21c0533dd2",
266266
strip_prefix = "chromedriver-mac-x64",
267267
build_file_content = """
268268
load("@aspect_rules_js//js:defs.bzl", "js_library")

dotnet/src/support/Events/EventFiringWebDriver.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ public object ExecuteScript(string script, params object[] args)
478478
/// <param name="script">A <see cref="PinnedScript"/> object containing the code to execute.</param>
479479
/// <param name="args">The arguments to the script.</param>
480480
/// <returns>The value returned by the script.</returns>
481+
/// <exception cref="ArgumentNullException">If <paramref name="script"/> is <see langword="null"/>.</exception>
481482
/// <remarks>
482483
/// <para>
483484
/// The ExecuteScript method executes JavaScript in the context of
@@ -509,6 +510,11 @@ public object ExecuteScript(string script, params object[] args)
509510
/// </remarks>
510511
public object ExecuteScript(PinnedScript script, params object[] args)
511512
{
513+
if (script == null)
514+
{
515+
throw new ArgumentNullException(nameof(script));
516+
}
517+
512518
IJavaScriptExecutor javascriptDriver = this.driver as IJavaScriptExecutor;
513519
if (javascriptDriver == null)
514520
{

dotnet/src/webdriver/IJavaScriptEngine.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ public interface IJavaScriptEngine : IDisposable
8787
/// <param name="scriptName">The friendly name by which to refer to this initialization script.</param>
8888
/// <param name="script">The JavaScript to be loaded on every page.</param>
8989
/// <returns>A task containing an <see cref="InitializationScript"/> object representing the script to be loaded on each page.</returns>
90+
/// <exception cref="ArgumentNullException">If <paramref name="scriptName"/> is <see langword="null"/>.</exception>
9091
Task<InitializationScript> AddInitializationScript(string scriptName, string script);
9192

9293
/// <summary>
9394
/// Asynchronously removes JavaScript from being loaded on every document load.
9495
/// </summary>
9596
/// <param name="scriptName">The friendly name of the initialization script to be removed.</param>
9697
/// <returns>A task that represents the asynchronous operation.</returns>
98+
/// <exception cref="ArgumentNullException">If <paramref name="scriptName"/> is <see langword="null"/>.</exception>
9799
Task RemoveInitializationScript(string scriptName);
98100

99101
/// <summary>
@@ -109,13 +111,15 @@ public interface IJavaScriptEngine : IDisposable
109111
/// </summary>
110112
/// <param name="script">The JavaScript to pin</param>
111113
/// <returns>A task containing a <see cref="PinnedScript"/> object to use to execute the script.</returns>
114+
/// <exception cref="ArgumentNullException">If <paramref name="script"/> is <see langword="null"/>.</exception>
112115
Task<PinnedScript> PinScript(string script);
113116

114117
/// <summary>
115118
/// Unpins a previously pinned script from the browser.
116119
/// </summary>
117120
/// <param name="script">The <see cref="PinnedScript"/> object to unpin.</param>
118121
/// <returns>A task that represents the asynchronous operation.</returns>
122+
/// <exception cref="ArgumentNullException">If <paramref name="script"/> is <see langword="null"/>.</exception>
119123
Task UnpinScript(PinnedScript script);
120124

121125
/// <summary>

dotnet/src/webdriver/IJavascriptExecutor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

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

2223
namespace OpenQA.Selenium
@@ -98,6 +99,7 @@ public interface IJavaScriptExecutor
9899
/// variable, as if the function were called via "Function.apply"
99100
/// </para>
100101
/// </remarks>
102+
/// <exception cref="ArgumentNullException">If <paramref name="script" /> is <see langword="null"/>.</exception>
101103
object ExecuteScript(PinnedScript script, params object[] args);
102104

103105
/// <summary>

dotnet/src/webdriver/ISearchContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

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

2223
namespace OpenQA.Selenium
@@ -31,6 +32,7 @@ public interface ISearchContext
3132
/// </summary>
3233
/// <param name="by">The locating mechanism to use.</param>
3334
/// <returns>The first matching <see cref="IWebElement"/> on the current context.</returns>
35+
/// <exception cref="ArgumentNullException">If <paramref name="by" /> is <see langword="null"/>.</exception>
3436
/// <exception cref="NoSuchElementException">If no element matches the criteria.</exception>
3537
IWebElement FindElement(By by);
3638

dotnet/src/webdriver/JavaScriptEngine.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,25 @@ public async Task ClearInitializationScripts()
219219
/// </summary>
220220
/// <param name="script">The JavaScript to pin</param>
221221
/// <returns>A task containing a <see cref="PinnedScript"/> object to use to execute the script.</returns>
222+
/// <exception cref="ArgumentNullException">If <paramref name="script"/> is <see langword="null"/>.</exception>
222223
public async Task<PinnedScript> PinScript(string script)
223224
{
225+
if (script == null)
226+
{
227+
throw new ArgumentNullException(nameof(script));
228+
}
229+
230+
string newScriptHandle = Guid.NewGuid().ToString("N");
231+
224232
// We do an "Evaluate" first so as to immediately create the script on the loaded
225233
// page, then will add it to the initialization of future pages.
226-
PinnedScript pinnedScript = new PinnedScript(script);
227234
await this.EnableDomains().ConfigureAwait(false);
228-
await this.session.Value.Domains.JavaScript.Evaluate(pinnedScript.CreationScript).ConfigureAwait(false);
229-
pinnedScript.ScriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(pinnedScript.CreationScript).ConfigureAwait(false);
235+
236+
string creationScript = PinnedScript.MakeCreationScript(newScriptHandle, script);
237+
await this.session.Value.Domains.JavaScript.Evaluate(creationScript).ConfigureAwait(false);
238+
string scriptId = await this.session.Value.Domains.JavaScript.AddScriptToEvaluateOnNewDocument(creationScript).ConfigureAwait(false);
239+
240+
PinnedScript pinnedScript = new PinnedScript(script, newScriptHandle, scriptId);
230241
this.pinnedScripts[pinnedScript.Handle] = pinnedScript;
231242
return pinnedScript;
232243
}
@@ -236,11 +247,17 @@ public async Task<PinnedScript> PinScript(string script)
236247
/// </summary>
237248
/// <param name="script">The <see cref="PinnedScript"/> object to unpin.</param>
238249
/// <returns>A task that represents the asynchronous operation.</returns>
250+
/// <exception cref="ArgumentNullException">If <paramref name="script"/> is <see langword="null"/>.</exception>
239251
public async Task UnpinScript(PinnedScript script)
240252
{
253+
if (script == null)
254+
{
255+
throw new ArgumentNullException(nameof(script));
256+
}
257+
241258
if (this.pinnedScripts.ContainsKey(script.Handle))
242259
{
243-
await this.session.Value.Domains.JavaScript.Evaluate(script.RemovalScript).ConfigureAwait(false);
260+
await this.session.Value.Domains.JavaScript.Evaluate(script.MakeRemovalScript()).ConfigureAwait(false);
244261
await this.session.Value.Domains.JavaScript.RemoveScriptToEvaluateOnNewDocument(script.ScriptId).ConfigureAwait(false);
245262
this.pinnedScripts.Remove(script.Handle);
246263
}

dotnet/src/webdriver/PinnedScript.cs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,83 +17,70 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using System;
2120
using System.Globalization;
2221

22+
#nullable enable
23+
2324
namespace OpenQA.Selenium
2425
{
2526
/// <summary>
2627
/// A class representing a pinned JavaScript function that can be repeatedly called
2728
/// without sending the entire script across the wire for every execution.
2829
/// </summary>
29-
public class PinnedScript
30+
public sealed class PinnedScript
3031
{
31-
private string scriptSource;
32-
private string scriptHandle;
33-
private string scriptId;
34-
3532
/// <summary>
3633
/// Initializes a new instance of the <see cref="PinnedScript"/> class.
3734
/// </summary>
3835
/// <param name="script">The body of the JavaScript function to pin.</param>
36+
/// <param name="stringHandle">The unique handle for this pinned script.</param>
37+
/// <param name="scriptId">The internal ID of this script.</param>
3938
/// <remarks>
4039
/// This constructor is explicitly internal. Creation of pinned script objects
4140
/// is strictly the perview of Selenium, and should not be required by external
4241
/// libraries.
4342
/// </remarks>
44-
internal PinnedScript(string script)
43+
internal PinnedScript(string script, string stringHandle, string scriptId)
4544
{
46-
this.scriptSource = script;
47-
this.scriptHandle = Guid.NewGuid().ToString("N");
45+
this.Source = script;
46+
this.Handle = stringHandle;
47+
this.ScriptId = scriptId;
4848
}
4949

5050
/// <summary>
5151
/// Gets the unique handle for this pinned script.
5252
/// </summary>
53-
public string Handle
54-
{
55-
get { return this.scriptHandle; }
56-
}
53+
public string Handle { get; }
5754

5855
/// <summary>
5956
/// Gets the source representing the body of the function in the pinned script.
6057
/// </summary>
61-
public string Source
62-
{
63-
get { return this.scriptSource; }
64-
}
58+
public string Source { get; }
6559

66-
/// <summary>
67-
/// Gets the script to create the pinned script in the browser.
68-
/// </summary>
69-
internal string CreationScript
60+
internal static string MakeCreationScript(string scriptHandle, string scriptSource)
7061
{
71-
get { return string.Format(CultureInfo.InvariantCulture, "function __webdriver_{0}(arguments) {{ {1} }}", this.scriptHandle, this.scriptSource); }
62+
return string.Format(CultureInfo.InvariantCulture, "function __webdriver_{0}(arguments) {{ {1} }}", scriptHandle, scriptSource);
7263
}
7364

7465
/// <summary>
7566
/// Gets the script used to execute the pinned script in the browser.
7667
/// </summary>
77-
internal string ExecutionScript
68+
internal string MakeExecutionScript()
7869
{
79-
get { return string.Format(CultureInfo.InvariantCulture, "return __webdriver_{0}(arguments)", this.scriptHandle); }
70+
return string.Format(CultureInfo.InvariantCulture, "return __webdriver_{0}(arguments)", this.Handle);
8071
}
8172

8273
/// <summary>
8374
/// Gets the script used to remove the pinned script from the browser.
8475
/// </summary>
85-
internal string RemovalScript
76+
internal string MakeRemovalScript()
8677
{
87-
get { return string.Format(CultureInfo.InvariantCulture, "__webdriver_{0} = undefined", this.scriptHandle); }
78+
return string.Format(CultureInfo.InvariantCulture, "__webdriver_{0} = undefined", this.Handle);
8879
}
8980

9081
/// <summary>
9182
/// Gets or sets the ID of this script.
9283
/// </summary>
93-
internal string ScriptId
94-
{
95-
get { return this.scriptId; }
96-
set { this.scriptId = value; }
97-
}
84+
internal string ScriptId { get; }
9885
}
9986
}

dotnet/src/webdriver/WebDriver.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,23 @@ public object ExecuteScript(string script, params object[] args)
280280
/// <param name="script">A <see cref="PinnedScript"/> object containing the JavaScript code to execute.</param>
281281
/// <param name="args">The arguments to the script.</param>
282282
/// <returns>The value returned by the script.</returns>
283+
/// <exception cref="ArgumentNullException">If <paramref name="script" /> is <see langword="null"/>.</exception>
283284
public object ExecuteScript(PinnedScript script, params object[] args)
284285
{
285-
return this.ExecuteScript(script.ExecutionScript, args);
286+
if (script == null)
287+
{
288+
throw new ArgumentNullException(nameof(script));
289+
}
290+
291+
return this.ExecuteScript(script.MakeExecutionScript(), args);
286292
}
287293

288294
/// <summary>
289295
/// Finds the first element in the page that matches the <see cref="By"/> object
290296
/// </summary>
291297
/// <param name="by">By mechanism to find the object</param>
292298
/// <returns>IWebElement object so that you can interact with that object</returns>
299+
/// <exception cref="ArgumentNullException">If <paramref name="by" /> is <see langword="null"/>.</exception>
293300
/// <example>
294301
/// <code>
295302
/// IWebDriver driver = new InternetExplorerDriver();

0 commit comments

Comments
 (0)