Skip to content

Commit 34c7694

Browse files
authored
Merge branch 'trunk' into browser
2 parents c5de223 + 8e46f06 commit 34c7694

File tree

20 files changed

+358
-287
lines changed

20 files changed

+358
-287
lines changed

MODULE.bazel

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,12 @@ maven.install(
181181
"com.google.code.findbugs:jsr305:3.0.2",
182182
"com.google.code.gson:gson:2.13.1",
183183
"com.google.guava:guava:33.4.8-jre",
184+
"com.github.ben-manes.caffeine:caffeine:3.2.2",
184185
"com.google.auto:auto-common:1.2.2",
185186
"com.google.auto.service:auto-service:1.1.1",
186187
"com.google.auto.service:auto-service-annotations:1.1.1",
187-
"com.google.googlejavaformat:google-java-format:1.27.0",
188-
"com.graphql-java:graphql-java:22.3",
188+
"com.google.googlejavaformat:google-java-format:1.28.0",
189+
"com.graphql-java:graphql-java:24.1",
189190
"dev.failsafe:failsafe:3.3.2",
190191
"io.grpc:grpc-context:1.73.0",
191192
"io.lettuce:lettuce-core:6.7.1.RELEASE",
@@ -209,7 +210,7 @@ maven.install(
209210
"net.bytebuddy:byte-buddy:1.17.6",
210211
"org.htmlunit:htmlunit-core-js:4.13.0",
211212
"org.apache.commons:commons-exec:1.5.0",
212-
"org.apache.logging.log4j:log4j-core:2.25.0",
213+
"org.apache.logging.log4j:log4j-core:2.25.1",
213214
"org.assertj:assertj-core:3.27.3",
214215
"org.bouncycastle:bcpkix-jdk18on:1.81",
215216
"org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5",
@@ -232,9 +233,9 @@ maven.install(
232233
"uk.org.webcompere:system-stubs-core:2.1.8",
233234
],
234235
boms = [
235-
"io.opentelemetry:opentelemetry-bom:1.51.0",
236+
"io.opentelemetry:opentelemetry-bom:1.52.0",
236237
"io.netty:netty-bom:4.1.121.Final",
237-
"org.junit:junit-bom:5.13.2",
238+
"org.junit:junit-bom:5.13.4",
238239
],
239240
excluded_artifacts = [
240241
"org.hamcrest:hamcrest-all", # Replaced by hamcrest 2

dotnet/src/webdriver/BiDi/BiDi.cs

Lines changed: 29 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
// </copyright>
1919

2020
using System;
21+
using System.Threading;
2122
using System.Threading.Tasks;
2223
using OpenQA.Selenium.BiDi.Communication;
2324

2425
namespace OpenQA.Selenium.BiDi;
2526

26-
public class BiDi : IAsyncDisposable
27+
public sealed class BiDi : IAsyncDisposable
2728
{
2829
private readonly Broker _broker;
2930

@@ -38,7 +39,7 @@ public class BiDi : IAsyncDisposable
3839

3940
private readonly object _moduleLock = new();
4041

41-
internal BiDi(string url)
42+
private BiDi(string url)
4243
{
4344
var uri = new Uri(url);
4445

@@ -49,15 +50,10 @@ internal Session.SessionModule SessionModule
4950
{
5051
get
5152
{
52-
if (_sessionModule is null)
53+
if (_sessionModule is not null) return _sessionModule;
54+
lock (_moduleLock)
5355
{
54-
lock (_moduleLock)
55-
{
56-
if (_sessionModule is null)
57-
{
58-
_sessionModule = new Session.SessionModule(_broker);
59-
}
60-
}
56+
_sessionModule ??= new Session.SessionModule(_broker);
6157
}
6258
return _sessionModule;
6359
}
@@ -67,15 +63,10 @@ public BrowsingContext.BrowsingContextModule BrowsingContext
6763
{
6864
get
6965
{
70-
if (_browsingContextModule is null)
66+
if (_browsingContextModule is not null) return _browsingContextModule;
67+
lock (_moduleLock)
7168
{
72-
lock (_moduleLock)
73-
{
74-
if (_browsingContextModule is null)
75-
{
76-
_browsingContextModule = new BrowsingContext.BrowsingContextModule(_broker);
77-
}
78-
}
69+
_browsingContextModule ??= new BrowsingContext.BrowsingContextModule(_broker);
7970
}
8071
return _browsingContextModule;
8172
}
@@ -85,15 +76,10 @@ public Browser.BrowserModule Browser
8576
{
8677
get
8778
{
88-
if (_browserModule is null)
79+
if (_browserModule is not null) return _browserModule;
80+
lock (_moduleLock)
8981
{
90-
lock (_moduleLock)
91-
{
92-
if (_browserModule is null)
93-
{
94-
_browserModule = new Browser.BrowserModule(_broker);
95-
}
96-
}
82+
_browserModule ??= new Browser.BrowserModule(_broker);
9783
}
9884
return _browserModule;
9985
}
@@ -103,15 +89,10 @@ public Network.NetworkModule Network
10389
{
10490
get
10591
{
106-
if (_networkModule is null)
92+
if (_networkModule is not null) return _networkModule;
93+
lock (_moduleLock)
10794
{
108-
lock (_moduleLock)
109-
{
110-
if (_networkModule is null)
111-
{
112-
_networkModule = new Network.NetworkModule(_broker);
113-
}
114-
}
95+
_networkModule ??= new Network.NetworkModule(_broker);
11596
}
11697
return _networkModule;
11798
}
@@ -121,15 +102,10 @@ internal Input.InputModule InputModule
121102
{
122103
get
123104
{
124-
if (_inputModule is null)
105+
if (_inputModule is not null) return _inputModule;
106+
lock (_moduleLock)
125107
{
126-
lock (_moduleLock)
127-
{
128-
if (_inputModule is null)
129-
{
130-
_inputModule = new Input.InputModule(_broker);
131-
}
132-
}
108+
_inputModule ??= new Input.InputModule(_broker);
133109
}
134110
return _inputModule;
135111
}
@@ -139,15 +115,10 @@ public Script.ScriptModule Script
139115
{
140116
get
141117
{
142-
if (_scriptModule is null)
118+
if (_scriptModule is not null) return _scriptModule;
119+
lock (_moduleLock)
143120
{
144-
lock (_moduleLock)
145-
{
146-
if (_scriptModule is null)
147-
{
148-
_scriptModule = new Script.ScriptModule(_broker);
149-
}
150-
}
121+
_scriptModule ??= new Script.ScriptModule(_broker);
151122
}
152123
return _scriptModule;
153124
}
@@ -157,15 +128,10 @@ public Log.LogModule Log
157128
{
158129
get
159130
{
160-
if (_logModule is null)
131+
if (_logModule is not null) return _logModule;
132+
lock (_moduleLock)
161133
{
162-
lock (_moduleLock)
163-
{
164-
if (_logModule is null)
165-
{
166-
_logModule = new Log.LogModule(_broker);
167-
}
168-
}
134+
_logModule ??= new Log.LogModule(_broker);
169135
}
170136
return _logModule;
171137
}
@@ -175,15 +141,10 @@ public Storage.StorageModule Storage
175141
{
176142
get
177143
{
178-
if (_storageModule is null)
144+
if (_storageModule is not null) return _storageModule;
145+
lock (_moduleLock)
179146
{
180-
lock (_moduleLock)
181-
{
182-
if (_storageModule is null)
183-
{
184-
_storageModule = new Storage.StorageModule(_broker);
185-
}
186-
}
147+
_storageModule ??= new Storage.StorageModule(_broker);
187148
}
188149
return _storageModule;
189150
}
@@ -198,7 +159,7 @@ public static async Task<BiDi> ConnectAsync(string url)
198159
{
199160
var bidi = new BiDi(url);
200161

201-
await bidi._broker.ConnectAsync(default).ConfigureAwait(false);
162+
await bidi._broker.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
202163

203164
return bidi;
204165
}
@@ -209,13 +170,8 @@ public Task EndAsync(Session.EndOptions? options = null)
209170
}
210171

211172
public async ValueTask DisposeAsync()
212-
{
213-
await DisposeAsyncCore();
214-
GC.SuppressFinalize(this);
215-
}
216-
217-
protected virtual async ValueTask DisposeAsyncCore()
218173
{
219174
await _broker.DisposeAsync().ConfigureAwait(false);
175+
GC.SuppressFinalize(this);
220176
}
221177
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// <copyright file="BiDiOptions.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
namespace OpenQA.Selenium.BiDi;
21+
22+
public sealed class BiDiOptions
23+
{
24+
}

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace OpenQA.Selenium.BiDi.Browser;
2424

2525
public sealed class BrowserModule(Broker broker) : Module(broker)
2626
{
27-
public async Task CloseAsync(CloseOptions? options = null)
27+
public async Task<EmptyResult> CloseAsync(CloseOptions? options = null)
2828
{
29-
await Broker.ExecuteCommandAsync(new CloseCommand(), options).ConfigureAwait(false);
29+
return await Broker.ExecuteCommandAsync<CloseCommand, EmptyResult>(new CloseCommand(), options).ConfigureAwait(false);
3030
}
3131

3232
public async Task<UserContextInfo> CreateUserContextAsync(CreateUserContextOptions? options = null)
@@ -41,11 +41,11 @@ public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOpt
4141
return await Broker.ExecuteCommandAsync<GetUserContextsCommand, GetUserContextsResult>(new GetUserContextsCommand(), options).ConfigureAwait(false);
4242
}
4343

44-
public async Task RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
44+
public async Task<EmptyResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
4545
{
4646
var @params = new RemoveUserContextCommandParameters(userContext);
4747

48-
await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options).ConfigureAwait(false);
48+
return await Broker.ExecuteCommandAsync<RemoveUserContextCommand, EmptyResult>(new RemoveUserContextCommand(@params), options).ConfigureAwait(false);
4949
}
5050

5151
public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
using System.Threading.Tasks;
2121
using System;
22+
using OpenQA.Selenium.BiDi.Communication;
2223

2324
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2425

@@ -66,7 +67,7 @@ public Task<NavigateResult> ReloadAsync(ReloadOptions? options = null)
6667
return BiDi.BrowsingContext.ReloadAsync(this, options);
6768
}
6869

69-
public Task ActivateAsync(ActivateOptions? options = null)
70+
public Task<EmptyResult> ActivateAsync(ActivateOptions? options = null)
7071
{
7172
return BiDi.BrowsingContext.ActivateAsync(this, options);
7273
}
@@ -81,17 +82,17 @@ public Task<CaptureScreenshotResult> CaptureScreenshotAsync(CaptureScreenshotOpt
8182
return BiDi.BrowsingContext.CaptureScreenshotAsync(this, options);
8283
}
8384

84-
public Task CloseAsync(CloseOptions? options = null)
85+
public Task<EmptyResult> CloseAsync(CloseOptions? options = null)
8586
{
8687
return BiDi.BrowsingContext.CloseAsync(this, options);
8788
}
8889

89-
public Task TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
90+
public Task<TraverseHistoryResult> TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
9091
{
9192
return BiDi.BrowsingContext.TraverseHistoryAsync(this, delta, options);
9293
}
9394

94-
public Task SetViewportAsync(SetViewportOptions? options = null)
95+
public Task<EmptyResult> SetViewportAsync(SetViewportOptions? options = null)
9596
{
9697
return BiDi.BrowsingContext.SetViewportAsync(this, options);
9798
}
@@ -101,7 +102,7 @@ public Task<PrintResult> PrintAsync(PrintOptions? options = null)
101102
return BiDi.BrowsingContext.PrintAsync(this, options);
102103
}
103104

104-
public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
105+
public Task<EmptyResult> HandleUserPromptAsync(HandleUserPromptOptions? options = null)
105106
{
106107
return BiDi.BrowsingContext.HandleUserPromptAsync(this, options);
107108
}

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@
2020
using System.Threading.Tasks;
2121
using OpenQA.Selenium.BiDi.Input;
2222
using System.Collections.Generic;
23+
using OpenQA.Selenium.BiDi.Communication;
2324

2425
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2526

2627
public sealed class BrowsingContextInputModule(BrowsingContext context, InputModule inputModule)
2728
{
28-
public Task PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
29+
public Task<EmptyResult> PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
2930
{
3031
return inputModule.PerformActionsAsync(context, actions, options);
3132
}
3233

33-
public Task ReleaseActionsAsync(ReleaseActionsOptions? options = null)
34+
public Task<EmptyResult> ReleaseActionsAsync(ReleaseActionsOptions? options = null)
3435
{
3536
return inputModule.ReleaseActionsAsync(context, options);
3637
}
3738

38-
public Task SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
39+
public Task<EmptyResult> SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
3940
{
4041
return inputModule.SetFilesAsync(context, element, files, options);
4142
}

0 commit comments

Comments
 (0)