-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Support getting of client windows in browser module #15241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nvborisenko
merged 8 commits into
SeleniumHQ:trunk
from
nvborisenko:dotnet-bidi-getclientwindows
Feb 6, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
407d5c8
Get client windows
nvborisenko 452fe80
Fix file name
nvborisenko 097fcc8
Ignore test for specific browsers
nvborisenko 85fcf07
Client window as part of browsing context info
nvborisenko f8576e1
Merge branch 'trunk' into dotnet-bidi-getclientwindows
nvborisenko 1080a74
Dispose JsonDocument
nvborisenko 4dbe411
Use JsonNode instead of JsonDocument
nvborisenko 004fa39
Revert "Use JsonNode instead of JsonDocument"
nvborisenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dotnet/src/webdriver/BiDi/Communication/Json/Converters/BrowserClientWindowConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // <copyright file="BrowserClientWindowConverter.cs" company="Selenium 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 | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| using OpenQA.Selenium.BiDi.Modules.Browser; | ||
| using System; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace OpenQA.Selenium.BiDi.Communication.Json.Converters; | ||
|
|
||
| internal class BrowserClientWindowConverter : JsonConverter<ClientWindow> | ||
| { | ||
| public override ClientWindow? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
| { | ||
| var id = reader.GetString(); | ||
|
|
||
| return new ClientWindow(id!); | ||
| } | ||
|
|
||
| public override void Write(Utf8JsonWriter writer, ClientWindow value, JsonSerializerOptions options) | ||
| { | ||
| writer.WriteStringValue(value.Id); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
...ebdriver/BiDi/Communication/Json/Converters/Enumerable/GetClientWindowsResultConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // <copyright file="GetClientWindowsResultConverter.cs" company="Selenium 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 | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| using OpenQA.Selenium.BiDi.Modules.Browser; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable; | ||
|
|
||
| internal class GetClientWindowsResultConverter : JsonConverter<GetClientWindowsResult> | ||
| { | ||
| public override GetClientWindowsResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
| { | ||
| using var doc = JsonDocument.ParseValue(ref reader); | ||
| var clientWindows = doc.RootElement.GetProperty("clientWindows").Deserialize<IReadOnlyList<ClientWindowInfo>>(options); | ||
|
|
||
| return new GetClientWindowsResult(clientWindows!); | ||
| } | ||
|
|
||
| public override void Write(Utf8JsonWriter writer, GetClientWindowsResult value, JsonSerializerOptions options) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // <copyright file="ClientWindow.cs" company="Selenium 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 | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
|
||
| public record ClientWindow | ||
| { | ||
| internal ClientWindow(string id) | ||
| { | ||
| Id = id; | ||
| } | ||
|
|
||
| internal string Id { get; } | ||
| } | ||
34 changes: 34 additions & 0 deletions
34
dotnet/src/webdriver/BiDi/Modules/Browser/ClientWindowInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // <copyright file="ClientWindowInfo.cs" company="Selenium 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 | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| #nullable enable | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
|
||
| public record ClientWindowInfo([property: JsonPropertyName("active")] bool IsActive, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y); | ||
|
|
||
| public enum ClientWindowState | ||
| { | ||
| Fullscreen, | ||
| Maximized, | ||
| Minimized, | ||
| Normal | ||
| } |
49 changes: 49 additions & 0 deletions
49
dotnet/src/webdriver/BiDi/Modules/Browser/GetClientWindowsCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // <copyright file="GetClientWindowsCommand.cs" company="Selenium 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 | ||
| // regarding copyright ownership. The SFC licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| // </copyright> | ||
|
|
||
| using OpenQA.Selenium.BiDi.Communication; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace OpenQA.Selenium.BiDi.Modules.Browser; | ||
|
|
||
| internal class GetClientWindowsCommand() | ||
| : Command<CommandParameters>(CommandParameters.Empty, "browser.getClientWindows"); | ||
|
|
||
| public record GetClientWindowsOptions : CommandOptions; | ||
|
|
||
| public record GetClientWindowsResult : IReadOnlyList<ClientWindowInfo> | ||
| { | ||
| private readonly IReadOnlyList<ClientWindowInfo> _clientWindows; | ||
|
|
||
| internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows) | ||
| { | ||
| _clientWindows = clientWindows; | ||
| } | ||
|
|
||
| public ClientWindowInfo this[int index] => _clientWindows[index]; | ||
|
|
||
| public int Count => _clientWindows.Count; | ||
|
|
||
| public IEnumerator<ClientWindowInfo> GetEnumerator() => _clientWindows.GetEnumerator(); | ||
|
|
||
| IEnumerator IEnumerable.GetEnumerator() => (_clientWindows as IEnumerable).GetEnumerator(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.