Skip to content

Commit 710b986

Browse files
Merge branch 'trunk' into bidi-negative-zero
2 parents 21d1539 + 3ce647f commit 710b986

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+508
-133
lines changed

.github/workflows/ci-python.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ jobs:
5454
env:
5555
TOXENV: mypy
5656

57+
unit-tests:
58+
name: Unit Tests
59+
needs: build
60+
uses: ./.github/workflows/bazel.yml
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
include:
65+
- os: ubuntu
66+
- os: macos
67+
with:
68+
name: Unit Tests (${{ matrix.os }})
69+
os: ${{ matrix.os }}
70+
cache-key: python-unit-test-${{ matrix.os }}
71+
run: bazel test //py:unit
72+
5773
remote-tests:
5874
name: Remote Tests
5975
needs: build
@@ -83,6 +99,10 @@ jobs:
8399
os: ubuntu
84100
- browser: firefox
85101
os: ubuntu
102+
- browser: chrome
103+
os: windows
104+
- browser: edge
105+
os: windows
86106
with:
87107
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
88108
browser: ${{ matrix.browser }}
@@ -108,4 +128,5 @@ jobs:
108128
os: ${{ matrix.os }}
109129
cache-key: py-browser-${{ matrix.browser }}
110130
run: |
131+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}
111132
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,25 @@ public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindows
5252
{
5353
return await Broker.ExecuteCommandAsync<GetClientWindowsCommand, GetClientWindowsResult>(new(), options).ConfigureAwait(false);
5454
}
55+
56+
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
57+
{
58+
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts);
59+
60+
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
61+
}
62+
63+
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
64+
{
65+
var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts);
66+
67+
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
68+
}
69+
70+
public async Task<EmptyResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
71+
{
72+
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts);
73+
74+
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
75+
}
5576
}

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

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

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
21+
using System.Text.Json.Serialization;
22+
2023
namespace OpenQA.Selenium.BiDi.Browser;
2124

2225
public sealed record ClientWindowInfo(bool Active, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y);
2326

27+
[JsonConverter(typeof(CamelCaseEnumConverter<ClientWindowState>))]
2428
public enum ClientWindowState
2529
{
2630
Fullscreen,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// <copyright file="SetDownloadBehaviorCommand.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+
using OpenQA.Selenium.BiDi.Communication;
21+
using System.Collections.Generic;
22+
using System.Text.Json.Serialization;
23+
24+
namespace OpenQA.Selenium.BiDi.Browser;
25+
26+
internal sealed class SetDownloadBehaviorCommand(SetDownloadBehaviorParameters @params)
27+
: Command<SetDownloadBehaviorParameters, EmptyResult>(@params, "browser.setDownloadBehavior");
28+
29+
internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, IEnumerable<UserContext>? UserContexts) : Parameters;
30+
31+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
32+
[JsonDerivedType(typeof(DownloadBehaviorAllowed), "allowed")]
33+
[JsonDerivedType(typeof(DownloadBehaviorDenied), "denied")]
34+
internal abstract record DownloadBehavior;
35+
36+
internal sealed record DownloadBehaviorAllowed(string DestinationFolder) : DownloadBehavior;
37+
38+
internal sealed record DownloadBehaviorDenied : DownloadBehavior;
39+
40+
public sealed class SetDownloadBehaviorOptions : CommandOptions
41+
{
42+
public IEnumerable<UserContext>? UserContexts { get; set; }
43+
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,26 @@ public Task<Subscription> OnLoadAsync(Func<NavigationInfo, Task> handler, Subscr
167167
return BiDi.BrowsingContext.OnLoadAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
168168
}
169169

170-
public Task<Subscription> OnDownloadWillBeginAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
170+
public Task<Subscription> OnDownloadWillBeginAsync(Action<DownloadWillBeginEventArgs> handler, SubscriptionOptions? options = null)
171171
{
172172
return BiDi.BrowsingContext.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
173173
}
174174

175-
public Task<Subscription> OnDownloadWillBeginAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
175+
public Task<Subscription> OnDownloadWillBeginAsync(Func<DownloadWillBeginEventArgs, Task> handler, SubscriptionOptions? options = null)
176176
{
177177
return BiDi.BrowsingContext.OnDownloadWillBeginAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
178178
}
179179

180+
public Task<Subscription> OnDownloadEndAsync(Action<DownloadEndEventArgs> handler, SubscriptionOptions? options = null)
181+
{
182+
return BiDi.BrowsingContext.OnDownloadEndAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
183+
}
184+
185+
public Task<Subscription> OnDownloadEndAsync(Func<DownloadEndEventArgs, Task> handler, SubscriptionOptions? options = null)
186+
{
187+
return BiDi.BrowsingContext.OnDownloadEndAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });
188+
}
189+
180190
public Task<Subscription> OnNavigationAbortedAsync(Action<NavigationInfo> handler, SubscriptionOptions? options = null)
181191
{
182192
return BiDi.BrowsingContext.OnNavigationAbortedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,26 @@ public async Task<Subscription> OnLoadAsync(Action<NavigationInfo> handler, Brow
161161
return await Broker.SubscribeAsync("browsingContext.load", handler, options).ConfigureAwait(false);
162162
}
163163

164-
public async Task<Subscription> OnDownloadWillBeginAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
164+
public async Task<Subscription> OnDownloadWillBeginAsync(Func<DownloadWillBeginEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
165165
{
166166
return await Broker.SubscribeAsync("browsingContext.downloadWillBegin", handler, options).ConfigureAwait(false);
167167
}
168168

169-
public async Task<Subscription> OnDownloadWillBeginAsync(Action<NavigationInfo> handler, BrowsingContextsSubscriptionOptions? options = null)
169+
public async Task<Subscription> OnDownloadWillBeginAsync(Action<DownloadWillBeginEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null)
170170
{
171171
return await Broker.SubscribeAsync("browsingContext.downloadWillBegin", handler, options).ConfigureAwait(false);
172172
}
173173

174+
public async Task<Subscription> OnDownloadEndAsync(Func<DownloadEndEventArgs, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
175+
{
176+
return await Broker.SubscribeAsync("browsingContext.downloadEnd", handler, options).ConfigureAwait(false);
177+
}
178+
179+
public async Task<Subscription> OnDownloadEndAsync(Action<DownloadEndEventArgs> handler, BrowsingContextsSubscriptionOptions? options = null)
180+
{
181+
return await Broker.SubscribeAsync("browsingContext.downloadEnd", handler, options).ConfigureAwait(false);
182+
}
183+
174184
public async Task<Subscription> OnNavigationAbortedAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
175185
{
176186
return await Broker.SubscribeAsync("browsingContext.navigationAborted", handler, options).ConfigureAwait(false);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System;
2223
using System.Text.Json.Serialization;
2324

@@ -37,6 +38,7 @@ public sealed class CaptureScreenshotOptions : CommandOptions
3738
public ClipRectangle? Clip { get; set; }
3839
}
3940

41+
[JsonConverter(typeof(CamelCaseEnumConverter<ScreenshotOrigin>))]
4042
public enum ScreenshotOrigin
4143
{
4244
Viewport,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
22+
using System.Text.Json.Serialization;
2123

2224
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2325

@@ -35,6 +37,7 @@ public sealed class CreateOptions : CommandOptions
3537
public Browser.UserContext? UserContext { get; set; }
3638
}
3739

40+
[JsonConverter(typeof(CamelCaseEnumConverter<ContextType>))]
3841
public enum ContextType
3942
{
4043
Tab,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// <copyright file="DownloadEndEventArgs.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+
using System;
21+
22+
namespace OpenQA.Selenium.BiDi.BrowsingContext;
23+
24+
// https://github.com/dotnet/runtime/issues/72604
25+
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "status")]
26+
//[JsonDerivedType(typeof(DownloadCanceledEventArgs), "canceled")]
27+
//[JsonDerivedType(typeof(DownloadCompleteEventArgs), "complete")]
28+
public abstract record DownloadEndEventArgs(BiDi BiDi, BrowsingContext Context)
29+
: BrowsingContextEventArgs(BiDi, Context);
30+
31+
public sealed record DownloadCanceledEventArgs(BiDi BiDi, BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url)
32+
: DownloadEndEventArgs(BiDi, Context), IBaseNavigationInfo;
33+
34+
public sealed record DownloadCompleteEventArgs(BiDi BiDi, string? Filepath, BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url)
35+
: DownloadEndEventArgs(BiDi, Context), IBaseNavigationInfo;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// <copyright file="DownloadWillBeginEventArgs.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+
using System;
21+
22+
namespace OpenQA.Selenium.BiDi.BrowsingContext;
23+
24+
public sealed record DownloadWillBeginEventArgs(BiDi BiDi, string SuggestedFilename, BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url)
25+
: BrowsingContextEventArgs(BiDi, Context), IBaseNavigationInfo;

0 commit comments

Comments
 (0)