+321
-0
lines changedFilter options
+321
-0
lines changed Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ filegroup(
7
7
"**/*",
8
8
]),
9
9
visibility = [
10
+
"//dotnet/test/common:__pkg__",
10
11
"//java/test/org/openqa/selenium/chrome:__pkg__",
11
12
"//java/test/org/openqa/selenium/edge:__pkg__",
12
13
"//java/test/org/openqa/selenium/environment:__pkg__",
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ public sealed class BiDi : IAsyncDisposable
36
36
private Script.ScriptModule? _scriptModule;
37
37
private Log.LogModule? _logModule;
38
38
private Storage.StorageModule? _storageModule;
39
+
private WebExtension.WebExtensionModule? _webExtensionModule;
39
40
40
41
private readonly object _moduleLock = new();
41
42
@@ -150,6 +151,19 @@ public Storage.StorageModule Storage
150
151
}
151
152
}
152
153
154
+
public WebExtension.WebExtensionModule WebExtension
155
+
{
156
+
get
157
+
{
158
+
if (_webExtensionModule is not null) return _webExtensionModule;
159
+
lock (_moduleLock)
160
+
{
161
+
_webExtensionModule ??= new WebExtension.WebExtensionModule(_broker);
162
+
}
163
+
return _webExtensionModule;
164
+
}
165
+
}
166
+
153
167
public Task<Session.StatusResult> StatusAsync()
154
168
{
155
169
return SessionModule.StatusAsync();
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ internal Broker(BiDi bidi, Uri url)
86
86
new DateTimeOffsetConverter(),
87
87
new PrintPageRangeConverter(),
88
88
new InputOriginConverter(),
89
+
new WebExtensionConverter(_bidi),
89
90
new SubscriptionConverter(),
90
91
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase),
91
92
Original file line number Diff line number Diff line change
@@ -165,4 +165,8 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
165
165
[JsonSerializable(typeof(IEnumerable<Input.INoneSourceAction>))]
166
166
[JsonSerializable(typeof(IEnumerable<Input.IWheelSourceAction>))]
167
167
168
+
[JsonSerializable(typeof(WebExtension.InstallCommand))]
169
+
[JsonSerializable(typeof(WebExtension.InstallResult))]
170
+
[JsonSerializable(typeof(WebExtension.UninstallCommand))]
171
+
168
172
internal partial class BiDiJsonSerializerContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
1
+
// <copyright file="WebExtensionConverter.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.WebExtension;
21
+
using System;
22
+
using System.Text.Json;
23
+
using System.Text.Json.Serialization;
24
+
25
+
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;
26
+
27
+
internal class WebExtensionConverter : JsonConverter<Extension>
28
+
{
29
+
private readonly BiDi _bidi;
30
+
31
+
public WebExtensionConverter(BiDi bidi)
32
+
{
33
+
_bidi = bidi;
34
+
}
35
+
36
+
public override Extension? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
37
+
{
38
+
var id = reader.GetString();
39
+
40
+
return new Extension(_bidi, id!);
41
+
}
42
+
43
+
public override void Write(Utf8JsonWriter writer, Extension value, JsonSerializerOptions options)
44
+
{
45
+
writer.WriteStringValue(value.Id);
46
+
}
47
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
1
+
// <copyright file="Extension.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.Threading.Tasks;
21
+
22
+
namespace OpenQA.Selenium.BiDi.WebExtension;
23
+
24
+
public sealed class Extension
25
+
{
26
+
private readonly BiDi _bidi;
27
+
28
+
public Extension(BiDi bidi, string id)
29
+
{
30
+
_bidi = bidi;
31
+
Id = id;
32
+
}
33
+
34
+
internal string Id { get; }
35
+
36
+
public Task UninstallAsync(UninstallOptions? options = null)
37
+
{
38
+
return _bidi.WebExtension.UninstallAsync(this, options);
39
+
}
40
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
1
+
// <copyright file="InstallCommand.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.Text.Json.Serialization;
22
+
23
+
namespace OpenQA.Selenium.BiDi.WebExtension;
24
+
25
+
internal sealed class InstallCommand(InstallParameters @params)
26
+
: Command<InstallParameters, InstallResult>(@params, "webExtension.install");
27
+
28
+
internal sealed record InstallParameters(ExtensionData ExtensionData) : Parameters;
29
+
30
+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
31
+
[JsonDerivedType(typeof(ExtensionArchivePath), "archivePath")]
32
+
[JsonDerivedType(typeof(ExtensionBase64Encoded), "base64")]
33
+
[JsonDerivedType(typeof(ExtensionPath), "path")]
34
+
public abstract record ExtensionData;
35
+
36
+
public sealed record ExtensionArchivePath(string Path) : ExtensionData;
37
+
38
+
public sealed record ExtensionBase64Encoded(string Value) : ExtensionData;
39
+
40
+
public sealed record ExtensionPath(string Path) : ExtensionData;
41
+
42
+
public sealed class InstallOptions : CommandOptions;
43
+
44
+
public sealed record InstallResult(Extension Extension) : EmptyResult;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
1
+
// <copyright file="UninstallCommand.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
+
22
+
namespace OpenQA.Selenium.BiDi.WebExtension;
23
+
24
+
internal sealed class UninstallCommand(UninstallParameters @params)
25
+
: Command<UninstallParameters, EmptyResult>(@params, "webExtension.uninstall");
26
+
27
+
internal sealed record UninstallParameters(Extension Extension) : Parameters;
28
+
29
+
public sealed class UninstallOptions : CommandOptions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
1
+
// <copyright file="WebExtensionModule.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.Threading.Tasks;
22
+
23
+
namespace OpenQA.Selenium.BiDi.WebExtension;
24
+
25
+
public sealed class WebExtensionModule(Broker broker) : Module(broker)
26
+
{
27
+
public async Task<InstallResult> InstallAsync(ExtensionData extensionData, InstallOptions? options = null)
28
+
{
29
+
var @params = new InstallParameters(extensionData);
30
+
31
+
return await Broker.ExecuteCommandAsync<InstallCommand, InstallResult>(new InstallCommand(@params), options).ConfigureAwait(false);
32
+
}
33
+
34
+
public async Task<EmptyResult> UninstallAsync(Extension extension, UninstallOptions? options = null)
35
+
{
36
+
var @params = new UninstallParameters(extension);
37
+
38
+
return await Broker.ExecuteCommandAsync<UninstallCommand, EmptyResult>(new UninstallCommand(@params), options).ConfigureAwait(false);
39
+
}
40
+
}
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ filegroup(
17
17
srcs = [],
18
18
data = [
19
19
"appconfig.json",
20
+
"//common/extensions",
20
21
"//common/src/web",
21
22
"//dotnet/src/webdriver:manager-linux",
22
23
"//dotnet/src/webdriver:manager-macos",
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4