Skip to content

Commit

Permalink
[dotnet][cdp] add support Chrome 102 and remove for Chrome 99
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed May 25, 2022
1 parent 3b0eef2 commit d685665
Show file tree
Hide file tree
Showing 17 changed files with 198 additions and 196 deletions.
2 changes: 1 addition & 1 deletion dotnet/selenium-dotnet-version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ SUPPORTED_NET_STANDARD_VERSIONS = ["netstandard2.0", "netstandard2.1", "net5.0"]

SUPPORTED_DEVTOOLS_VERSIONS = [
"v85",
"v99",
"v100",
"v101",
"v102",
]

ASSEMBLY_COMPANY = "Selenium Committers"
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/DevToolsDomains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public abstract class DevToolsDomains
// added to this dictionary.
private static readonly Dictionary<int, Type> SupportedDevToolsVersions = new Dictionary<int, Type>()
{
{ 102, typeof(V102.V102Domains) },
{ 101, typeof(V101.V101Domains) },
{ 100, typeof(V100.V100Domains) },
{ 99, typeof(V99.V99Domains) },
{ 85, typeof(V85.V85Domains) }
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V99Domains.cs" company="WebDriver Committers">
// <copyright file="V102Domains.cs" company="WebDriver Committers">
// 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
Expand All @@ -19,24 +19,24 @@
using System.Collections.Generic;
using System.Text;

namespace OpenQA.Selenium.DevTools.V99
namespace OpenQA.Selenium.DevTools.V102
{
/// <summary>
/// Class containing the domain implementation for version 99 of the DevTools Protocol.
/// Class containing the domain implementation for version 102 of the DevTools Protocol.
/// </summary>
public class V99Domains : DevToolsDomains
public class V102Domains : DevToolsDomains
{
private DevToolsSessionDomains domains;

public V99Domains(DevToolsSession session)
public V102Domains(DevToolsSession session)
{
this.domains = new DevToolsSessionDomains(session);
}

/// <summary>
/// Gets the DevTools Protocol version for which this class is valid.
/// </summary>
public static int DevToolsVersion => 99;
public static int DevToolsVersion => 102;

/// <summary>
/// Gets the version-specific domains for the DevTools session. This value must be cast to a version specific type to be at all useful.
Expand All @@ -46,21 +46,21 @@ public V99Domains(DevToolsSession session)
/// <summary>
/// Gets the object used for manipulating network information in the browser.
/// </summary>
public override DevTools.Network Network => new V99Network(domains.Network, domains.Fetch);
public override DevTools.Network Network => new V102Network(domains.Network, domains.Fetch);

/// <summary>
/// Gets the object used for manipulating the browser's JavaScript execution.
/// </summary>
public override JavaScript JavaScript => new V99JavaScript(domains.Runtime, domains.Page);
public override JavaScript JavaScript => new V102JavaScript(domains.Runtime, domains.Page);

/// <summary>
/// Gets the object used for manipulating DevTools Protocol targets.
/// </summary>
public override DevTools.Target Target => new V99Target(domains.Target);
public override DevTools.Target Target => new V102Target(domains.Target);

/// <summary>
/// Gets the object used for manipulating the browser's logs.
/// </summary>
public override DevTools.Log Log => new V99Log(domains.Log);
public override DevTools.Log Log => new V102Log(domains.Log);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V99JavaScript.cs" company="WebDriver Committers">
// <copyright file="V102JavaScript.cs" company="WebDriver Committers">
// 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
Expand All @@ -18,25 +18,25 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V99.Page;
using OpenQA.Selenium.DevTools.V99.Runtime;
using OpenQA.Selenium.DevTools.V102.Page;
using OpenQA.Selenium.DevTools.V102.Runtime;

namespace OpenQA.Selenium.DevTools.V99
namespace OpenQA.Selenium.DevTools.V102
{
/// <summary>
/// Class containing the JavaScript implementation for version 99 of the DevTools Protocol.
/// Class containing the JavaScript implementation for version 102 of the DevTools Protocol.
/// </summary>
public class V99JavaScript : JavaScript
public class V102JavaScript : JavaScript
{
private RuntimeAdapter runtime;
private PageAdapter page;

/// <summary>
/// Initializes a new instance of the <see cref="V99JavaScript"/> class.
/// Initializes a new instance of the <see cref="V102JavaScript"/> class.
/// </summary>
/// <param name="runtime">The DevTools Protocol adapter for the Runtime domain.</param>
/// <param name="page">The DevTools Protocol adapter for the Page domain.</param>
public V99JavaScript(RuntimeAdapter runtime, PageAdapter page)
public V102JavaScript(RuntimeAdapter runtime, PageAdapter page)
{
this.runtime = runtime;
this.page = page;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V99Log.cs" company="WebDriver Committers">
// <copyright file="V102Log.cs" company="WebDriver Committers">
// 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
Expand All @@ -20,22 +20,22 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V99.Log;
using OpenQA.Selenium.DevTools.V102.Log;

namespace OpenQA.Selenium.DevTools.V99
namespace OpenQA.Selenium.DevTools.V102
{
/// <summary>
/// Class containing the browser's log as referenced by version 99 of the DevTools Protocol.
/// Class containing the browser's log as referenced by version 102 of the DevTools Protocol.
/// </summary>
public class V99Log : DevTools.Log
public class V102Log : DevTools.Log
{
private LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V99Log"/> class.
/// Initializes a new instance of the <see cref="V102Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
public V99Log(LogAdapter adapter)
public V102Log(LogAdapter adapter)
{
this.adapter = adapter;
this.adapter.EntryAdded += OnAdapterEntryAdded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V99Network.cs" company="WebDriver Committers">
// <copyright file="V102Network.cs" company="WebDriver Committers">
// 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
Expand All @@ -20,25 +20,25 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V99.Fetch;
using OpenQA.Selenium.DevTools.V99.Network;
using OpenQA.Selenium.DevTools.V102.Fetch;
using OpenQA.Selenium.DevTools.V102.Network;

namespace OpenQA.Selenium.DevTools.V99
namespace OpenQA.Selenium.DevTools.V102
{
/// <summary>
/// Class providing functionality for manipulating network calls using version 99 of the DevTools Protocol
/// Class providing functionality for manipulating network calls using version 102 of the DevTools Protocol
/// </summary>
public class V99Network : DevTools.Network
public class V102Network : DevTools.Network
{
private FetchAdapter fetch;
private NetworkAdapter network;

/// <summary>
/// Initializes a new instance of the <see cref="V99Network"/> class.
/// Initializes a new instance of the <see cref="V102Network"/> class.
/// </summary>
/// <param name="network">The adapter for the Network domain.</param>
/// <param name="fetch">The adapter for the Fetch domain.</param>
public V99Network(NetworkAdapter network, FetchAdapter fetch)
public V102Network(NetworkAdapter network, FetchAdapter fetch)
{
this.network = network;
this.fetch = fetch;
Expand Down Expand Up @@ -80,12 +80,12 @@ public override async Task DisableNetwork()
/// <returns>A task that represents the asynchronous operation.</returns>
public override async Task EnableFetchForAllPatterns()
{
await fetch.Enable(new OpenQA.Selenium.DevTools.V99.Fetch.EnableCommandSettings()
await fetch.Enable(new OpenQA.Selenium.DevTools.V102.Fetch.EnableCommandSettings()
{
Patterns = new OpenQA.Selenium.DevTools.V99.Fetch.RequestPattern[]
Patterns = new OpenQA.Selenium.DevTools.V102.Fetch.RequestPattern[]
{
new OpenQA.Selenium.DevTools.V99.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V99.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response }
new OpenQA.Selenium.DevTools.V102.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Request },
new OpenQA.Selenium.DevTools.V102.Fetch.RequestPattern() { UrlPattern = "*", RequestStage = RequestStage.Response }
},
HandleAuthRequests = true
});
Expand Down Expand Up @@ -208,9 +208,9 @@ public override async Task ContinueWithAuth(string requestId, string userName, s
await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
{
RequestId = requestId,
AuthChallengeResponse = new V99.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new V102.Fetch.AuthChallengeResponse()
{
Response = V99.Fetch.AuthChallengeResponseResponseValues.ProvideCredentials,
Response = V102.Fetch.AuthChallengeResponseResponseValues.ProvideCredentials,
Username = userName,
Password = password
}
Expand All @@ -227,9 +227,9 @@ public override async Task CancelAuth(string requestId)
await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
{
RequestId = requestId,
AuthChallengeResponse = new OpenQA.Selenium.DevTools.V99.Fetch.AuthChallengeResponse()
AuthChallengeResponse = new OpenQA.Selenium.DevTools.V102.Fetch.AuthChallengeResponse()
{
Response = V99.Fetch.AuthChallengeResponseResponseValues.CancelAuth
Response = V102.Fetch.AuthChallengeResponseResponseValues.CancelAuth
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="V99Target.cs" company="WebDriver Committers">
// <copyright file="V102Target.cs" company="WebDriver Committers">
// 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
Expand All @@ -21,22 +21,22 @@
using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.DevTools.V99.Target;
using OpenQA.Selenium.DevTools.V102.Target;

namespace OpenQA.Selenium.DevTools.V99
namespace OpenQA.Selenium.DevTools.V102
{
/// <summary>
/// Class providing functionality for manipulating targets for version 99 of the DevTools Protocol
/// Class providing functionality for manipulating targets for version 102 of the DevTools Protocol
/// </summary>
public class V99Target : DevTools.Target
public class V102Target : DevTools.Target
{
private TargetAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V99Target"/> class.
/// Initializes a new instance of the <see cref="V102Target"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Target domain.</param>
public V99Target(TargetAdapter adapter)
public V102Target(TargetAdapter adapter)
{
this.adapter = adapter;
adapter.DetachedFromTarget += OnDetachedFromTarget;
Expand Down
14 changes: 7 additions & 7 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v85\DevToolsSession
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v99\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 99
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v99
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v100\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 100
pushd "%1..\..\.."
Expand All @@ -47,3 +40,10 @@ if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v101\DevToolsSessio
bazel build //dotnet/src/webdriver/cdp:generate-v101
popd
)

if not exist "%1..\..\..\bazel-bin\dotnet\src\webdriver\cdp\v102\DevToolsSessionDomains.cs" (
echo Generating CDP code for version 102
pushd "%1..\..\.."
bazel build //dotnet/src/webdriver/cdp:generate-v102
popd
)
12 changes: 6 additions & 6 deletions dotnet/src/webdriver/WebDriver.csproj.prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ then
bazel build //dotnet/src/webdriver/cdp:generate-v85
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v99/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 99"
bazel build //dotnet/src/webdriver/cdp:generate-v99
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v100/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 100"
Expand All @@ -40,3 +34,9 @@ then
echo "Generating CDP code for version 101"
bazel build //dotnet/src/webdriver/cdp:generate-v101
fi

if [[ ! -f "$1../../../bazel-bin/dotnet/src/webdriver/cdp/v102/DevToolsSessionDomains.cs" ]]
then
echo "Generating CDP code for version 102"
bazel build //dotnet/src/webdriver/cdp:generate-v102
fi
6 changes: 4 additions & 2 deletions dotnet/src/webdriver/cdp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contents of the `//dotnet/src/webdriver/DevTools/v<N-1>` directory into it.
3. Rename each of the `*.cs` files in `//dotnet/src/webdriver/DevTools/v<N>` so that
the file names start with `V<N>` instead of `V<N-1>`.
4. In each of the `*.cs` files in `//dotnet/src/webdriver/DevTools/v<N>`, update all
occurances of `V<N-1>` to `V<N>`. **IMPORTANT:** Do _not_ change the case of `V<N>` in
occurrences of `V<N-1>` to `V<N>`. **IMPORTANT:** Do _not_ change the case of `V<N>` in
each `.cs` file.
5. In [`//dotnet/src/webdriver/DevTools/DevToolsDomains.cs`](https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsDomains.cs),
add an entry for version `<N>` to the `SupportedDevToolsVersions` dictionary initialization.
Expand All @@ -37,7 +37,9 @@ then
fi
```

8. Commit the changes.
8. In each of the `*.cs` files in `//dotnet/test/common/DevTools/`, update all
occurrences of `V<N-1>` to `V<N>`.
9. Commit the changes.

### Removing support for a version of Chromium DevTools Protocol from the .NET bindings

Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/common/DevTools/DevToolsConsoleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class DevToolsConsoleTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyMessageAdded()
{
var domains = session.GetVersionSpecificDomains<V101.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V102.DevToolsSessionDomains>();
string consoleMessage = "Hello Selenium";

ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V101.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
EventHandler<V102.Console.MessageAddedEventArgs> messageAddedHandler = (sender, e) =>
{
Assert.That(e.Message.Text, Is.EqualTo(consoleMessage));
sync.Set();
Expand Down
6 changes: 3 additions & 3 deletions dotnet/test/common/DevTools/DevToolsLogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public class DevToolsLogTest : DevToolsTestFixture
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
public async Task VerifyEntryAddedAndClearLog()
{
var domains = session.GetVersionSpecificDomains<V101.DevToolsSessionDomains>();
var domains = session.GetVersionSpecificDomains<V102.DevToolsSessionDomains>();
ManualResetEventSlim sync = new ManualResetEventSlim(false);
EventHandler<V101.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
EventHandler<V102.Log.EntryAddedEventArgs> entryAddedHandler = (sender, e) =>
{
Assert.That(e.Entry.Text.Contains("404"));
Assert.That(e.Entry.Level == V101.Log.LogEntryLevelValues.Error);
Assert.That(e.Entry.Level == V102.Log.LogEntryLevelValues.Error);
sync.Set();
};

Expand Down

0 comments on commit d685665

Please sign in to comment.