Skip to content

Commit f783dd5

Browse files
authored
Merge branch 'trunk' into java-bidi-getClientWindows
2 parents c776bf7 + 445ba70 commit f783dd5

27 files changed

+390
-204
lines changed

dotnet/src/webdriver/DevTools/DevToolsDomains.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class DevToolsDomains
8282
/// Initializes the supplied DevTools session's domains for the specified browser version.
8383
/// </summary>
8484
/// <param name="protocolVersion">The version of the DevTools Protocol to use.</param>
85-
/// <param name="session">The <see cref="DevToolsSession"/> for which to initialiize the domains.</param>
85+
/// <param name="session">The <see cref="DevToolsSession"/> for which to initialize the domains.</param>
8686
/// <returns>The <see cref="DevToolsDomains"/> object containing the version-specific domains.</returns>
8787
/// <exception cref="ArgumentException">If <paramref name="protocolVersion"/> is negative.</exception>
8888
/// <exception cref="WebDriverException">If the desired protocol version is not supported.</exception>
@@ -95,7 +95,7 @@ public static DevToolsDomains InitializeDomains(int protocolVersion, DevToolsSes
9595
/// Initializes the supplied DevTools session's domains for the specified browser version within the specified number of versions.
9696
/// </summary>
9797
/// <param name="protocolVersion">The version of the DevTools Protocol to use.</param>
98-
/// <param name="session">The <see cref="DevToolsSession"/> for which to initialiize the domains.</param>
98+
/// <param name="session">The <see cref="DevToolsSession"/> for which to initialize the domains.</param>
9999
/// <param name="versionRange">The range of versions within which to match the provided version number. Defaults to 5 versions.</param>
100100
/// <returns>The <see cref="DevToolsDomains"/> object containing the version-specific domains.</returns>
101101
/// <exception cref="ArgumentException">If <paramref name="protocolVersion"/> is negative.</exception>

dotnet/src/webdriver/DevTools/JavaScript.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using System;
2121
using System.Threading.Tasks;
2222

23+
#nullable enable
24+
2325
namespace OpenQA.Selenium.DevTools
2426
{
2527
/// <summary>
@@ -30,17 +32,17 @@ public abstract class JavaScript
3032
/// <summary>
3133
/// Occurs when a JavaScript script binding is called.
3234
/// </summary>
33-
public event EventHandler<BindingCalledEventArgs> BindingCalled;
35+
public event EventHandler<BindingCalledEventArgs>? BindingCalled;
3436

3537
/// <summary>
3638
/// Occurs when the browser's JavaScript console API is called.
3739
/// </summary>
38-
public event EventHandler<ConsoleApiCalledEventArgs> ConsoleApiCalled;
40+
public event EventHandler<ConsoleApiCalledEventArgs>? ConsoleApiCalled;
3941

4042
/// <summary>
4143
/// Occurs when a JavaScript exception is thrown.
4244
/// </summary>
43-
public event EventHandler<ExceptionThrownEventArgs> ExceptionThrown;
45+
public event EventHandler<ExceptionThrownEventArgs>? ExceptionThrown;
4446

4547
/// <summary>
4648
/// Asynchronously enables the Runtime domain in the DevTools Protocol.

dotnet/src/webdriver/DevTools/Log.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using System;
2121
using System.Threading.Tasks;
2222

23+
#nullable enable
24+
2325
namespace OpenQA.Selenium.DevTools
2426
{
2527
/// <summary>
@@ -30,7 +32,7 @@ public abstract class Log
3032
/// <summary>
3133
/// Occurs when an entry is added to the browser's log.
3234
/// </summary>
33-
public event EventHandler<EntryAddedEventArgs> EntryAdded;
35+
public event EventHandler<EntryAddedEventArgs>? EntryAdded;
3436

3537
/// <summary>
3638
/// Asynchronously enables manipulation of the browser's log.

dotnet/src/webdriver/DevTools/Target.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using System.Collections.ObjectModel;
2222
using System.Threading.Tasks;
2323

24+
#nullable enable
25+
2426
namespace OpenQA.Selenium.DevTools
2527
{
2628
/// <summary>
@@ -31,12 +33,12 @@ public abstract class Target
3133
/// <summary>
3234
/// Occurs when a target is detached.
3335
/// </summary>
34-
public event EventHandler<TargetDetachedEventArgs> TargetDetached;
36+
public event EventHandler<TargetDetachedEventArgs>? TargetDetached;
3537

3638
/// <summary>
3739
/// Occurs when a target is attached.
3840
/// </summary>
39-
public event EventHandler<TargetAttachedEventArgs> TargetAttached;
41+
public event EventHandler<TargetAttachedEventArgs>? TargetAttached;
4042

4143
/// <summary>
4244
/// Asynchronously gets the targets available for this session.
@@ -46,7 +48,7 @@ public abstract class Target
4648
/// contains the list of <see cref="TargetInfo"/> objects describing the
4749
/// targets available for this session.
4850
/// </returns>
49-
public abstract Task<ReadOnlyCollection<TargetInfo>> GetTargets(Object settings = null);
51+
public abstract Task<ReadOnlyCollection<TargetInfo>> GetTargets(object? settings = null);
5052

5153
/// <summary>
5254
/// Asynchronously attaches to a target.
@@ -66,7 +68,7 @@ public abstract class Target
6668
/// <returns>
6769
/// A task representing the asynchronous detach operation.
6870
/// </returns>
69-
public abstract Task DetachFromTarget(string sessionId = null, string targetId = null);
71+
public abstract Task DetachFromTarget(string? sessionId = null, string? targetId = null);
7072

7173
/// <summary>
7274
/// Asynchronously sets the DevTools Protocol connection to automatically attach to new targets.

dotnet/src/webdriver/DevTools/TargetInfo.cs

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

20+
#nullable enable
21+
2022
namespace OpenQA.Selenium.DevTools
2123
{
2224
/// <summary>
2325
/// Represents information about the target of a DevTools Protocol command
2426
/// </summary>
2527
public class TargetInfo
2628
{
29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="TargetInfo"/> type.
31+
/// </summary>
32+
/// <param name="targetId">The ID of the target.</param>
33+
/// <param name="type">The type of target.</param>
34+
/// <param name="title">The title of the target.</param>
35+
/// <param name="url">The URL of the target.</param>
36+
/// <param name="isAttached">Whether the protocol is attached to the target.</param>
37+
/// <param name="openerId">The ID of the opener of the target.</param>
38+
/// <param name="browserContextId">The browser context ID.</param>
39+
public TargetInfo(string targetId, string type, string title, string url, bool isAttached, string? openerId, string? browserContextId)
40+
{
41+
this.TargetId = targetId;
42+
this.Type = type;
43+
this.Title = title;
44+
this.Url = url;
45+
this.IsAttached = isAttached;
46+
this.OpenerId = openerId;
47+
this.BrowserContextId = browserContextId;
48+
}
49+
2750
/// <summary>
2851
/// Gets the ID of the target.
2952
/// </summary>
30-
public string TargetId { get; internal set; }
53+
public string TargetId { get; }
3154

3255
/// <summary>
3356
/// Gets the type of target.
3457
/// </summary>
35-
public string Type { get; internal set; }
58+
public string Type { get; }
3659

3760
/// <summary>
3861
/// Gets the title of the target.
3962
/// </summary>
40-
public string Title { get; internal set; }
63+
public string Title { get; }
4164

4265
/// <summary>
4366
/// Gets the URL of the target.
4467
/// </summary>
45-
public string Url { get; internal set; }
68+
public string Url { get; }
4669

4770
/// <summary>
4871
/// Gets a value indicating if the protocol is attached to the target.
4972
/// </summary>
50-
public bool IsAttached { get; internal set; }
73+
public bool IsAttached { get; }
5174

5275
/// <summary>
5376
/// Gets the ID of the opener of the target.
5477
/// </summary>
55-
public string OpenerId { get; internal set; }
78+
public string? OpenerId { get; }
5679

5780
/// <summary>
5881
/// Gets the browser context ID.
5982
/// </summary>
60-
public string BrowserContextId { get; internal set; }
83+
public string? BrowserContextId { get; }
6184
}
6285
}

dotnet/src/webdriver/DevTools/v130/V130Domains.cs

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

20+
using System;
21+
22+
#nullable enable
23+
2024
namespace OpenQA.Selenium.DevTools.V130
2125
{
2226
/// <summary>
2327
/// Class containing the domain implementation for version 130 of the DevTools Protocol.
2428
/// </summary>
2529
public class V130Domains : DevToolsDomains
2630
{
27-
private DevToolsSessionDomains domains;
31+
private readonly DevToolsSessionDomains domains;
2832

2933
/// <summary>
3034
/// Initializes a new instance of the V130Domains class.
3135
/// </summary>
3236
/// <param name="session">The DevToolsSession to use with this set of domains.</param>
37+
/// <exception cref="ArgumentNullException">If <paramref name="session"/> is <see langword="null"/>.</exception>
3338
public V130Domains(DevToolsSession session)
3439
{
35-
this.domains = new DevToolsSessionDomains(session);
40+
this.domains = new DevToolsSessionDomains(session ?? throw new ArgumentNullException(nameof(session)));
3641
}
3742

3843
/// <summary>

dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,28 @@
2323
using System.Collections.Generic;
2424
using System.Threading.Tasks;
2525

26+
#nullable enable
27+
2628
namespace OpenQA.Selenium.DevTools.V130
2729
{
2830
/// <summary>
2931
/// Class containing the JavaScript implementation for version 130 of the DevTools Protocol.
3032
/// </summary>
3133
public class V130JavaScript : JavaScript
3234
{
33-
private RuntimeAdapter runtime;
34-
private PageAdapter page;
35+
private readonly RuntimeAdapter runtime;
36+
private readonly PageAdapter page;
3537

3638
/// <summary>
3739
/// Initializes a new instance of the <see cref="V130JavaScript"/> class.
3840
/// </summary>
3941
/// <param name="runtime">The DevTools Protocol adapter for the Runtime domain.</param>
4042
/// <param name="page">The DevTools Protocol adapter for the Page domain.</param>
43+
/// <exception cref="ArgumentNullException">If <paramref name="runtime"/> or <paramref name="page"/> are <see langword="null"/>.</exception>
4144
public V130JavaScript(RuntimeAdapter runtime, PageAdapter page)
4245
{
43-
this.runtime = runtime;
44-
this.page = page;
46+
this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime));
47+
this.page = page ?? throw new ArgumentNullException(nameof(page));
4548
this.runtime.BindingCalled += OnRuntimeBindingCalled;
4649
this.runtime.ConsoleAPICalled += OnRuntimeConsoleApiCalled;
4750
this.runtime.ExceptionThrown += OnRuntimeExceptionThrown;
@@ -138,7 +141,7 @@ internal override async Task Evaluate(string script)
138141
await runtime.Evaluate(new EvaluateCommandSettings { Expression = script }).ConfigureAwait(false);
139142
}
140143

141-
private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArgs e)
144+
private void OnRuntimeBindingCalled(object? sender, Runtime.BindingCalledEventArgs e)
142145
{
143146
BindingCalledEventArgs wrapped = new BindingCalledEventArgs
144147
(
@@ -150,7 +153,7 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg
150153
this.OnBindingCalled(wrapped);
151154
}
152155

153-
private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEventArgs e)
156+
private void OnRuntimeExceptionThrown(object? sender, Runtime.ExceptionThrownEventArgs e)
154157
{
155158
// TODO: Collect stack trace elements
156159
var wrapped = new ExceptionThrownEventArgs
@@ -162,12 +165,12 @@ private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEven
162165
this.OnExceptionThrown(wrapped);
163166
}
164167

165-
private void OnRuntimeConsoleApiCalled(object sender, ConsoleAPICalledEventArgs e)
168+
private void OnRuntimeConsoleApiCalled(object? sender, ConsoleAPICalledEventArgs e)
166169
{
167-
List<ConsoleApiArgument> args = new List<ConsoleApiArgument>();
170+
List<ConsoleApiArgument> args = new List<ConsoleApiArgument>(e.Args.Length);
168171
foreach (var arg in e.Args)
169172
{
170-
string argValue = arg.Value?.ToString();
173+
string? argValue = arg.Value?.ToString();
171174
args.Add(new ConsoleApiArgument(arg.Type.ToString(), argValue));
172175
}
173176

dotnet/src/webdriver/DevTools/v130/V130Log.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,28 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.DevTools.V130.Log;
21+
using System;
2122
using System.Threading.Tasks;
2223

24+
#nullable enable
25+
2326
namespace OpenQA.Selenium.DevTools.V130
2427
{
2528
/// <summary>
2629
/// Class containing the browser's log as referenced by version 130 of the DevTools Protocol.
2730
/// </summary>
2831
public class V130Log : DevTools.Log
2932
{
30-
private LogAdapter adapter;
33+
private readonly LogAdapter adapter;
3134

3235
/// <summary>
3336
/// Initializes a new instance of the <see cref="V130Log"/> class.
3437
/// </summary>
3538
/// <param name="adapter">The adapter for the Log domain.</param>
39+
/// <exception cref="ArgumentNullException">If <paramref name="adapter"/> is <see langword="null"/>.</exception>
3640
public V130Log(LogAdapter adapter)
3741
{
38-
this.adapter = adapter;
42+
this.adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
3943
this.adapter.EntryAdded += OnAdapterEntryAdded;
4044
}
4145

@@ -66,14 +70,14 @@ public override async Task Clear()
6670
await adapter.Clear().ConfigureAwait(false);
6771
}
6872

69-
private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e)
73+
private void OnAdapterEntryAdded(object? sender, Log.EntryAddedEventArgs e)
7074
{
7175
var entry = new LogEntry(
7276
kind: e.Entry.Source.ToString(),
7377
message: e.Entry.Text
7478
);
75-
EntryAddedEventArgs propagated = new EntryAddedEventArgs(entry);
76-
this.OnEntryAdded(propagated);
79+
80+
this.OnEntryAdded(new EntryAddedEventArgs(entry));
7781
}
7882
}
7983
}

0 commit comments

Comments
 (0)