-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Possibility to reset viewport #16601
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
base: trunk
Are you sure you want to change the base?
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
| : Command<SetViewportParameters, SetViewportResult>(@params, "browsingContext.setViewport"); | ||
|
|
||
| internal sealed record SetViewportParameters(BrowsingContext Context, Viewport? Viewport, double? DevicePixelRatio) : Parameters; | ||
| internal sealed record SetViewportParameters(BrowsingContext Context, [property: JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] Viewport? Viewport, double? DevicePixelRatio) : Parameters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, we already started doing it in another places. Let's find all occurences of this type (property: type / null) and mark all with this attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting: WhenWritingNull or WhenWritingDefault. We want to send json null obly if user explicitly wrote SomeNullableProperty = null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified, in both cases WhenWritingNull and WhenWritingDefault it doesn't serializes to json null.
await context.SetViewportAsync(new() { Viewport = null });
await context.SetViewportAsync(); 19:40:02.793 TRACE WebSocketTransport: BiDi SND --> {"id":3,"method":"browsingContext.setViewport","params":{"context":"D0E4F713FD009541B7FADB9D86BC5D6C"}}
19:40:02.795 TRACE WebSocketTransport: BiDi RCV <-- {"id":3,"result":{},"type":"success"}
19:40:02.796 TRACE WebSocketTransport: BiDi SND --> {"id":4,"method":"browsingContext.setViewport","params":{"context":"D0E4F713FD009541B7FADB9D86BC5D6C"}}
19:40:02.798 TRACE WebSocketTransport: BiDi RCV <-- {"id":4,"result":{},"type":"success"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, we have used JsonIgnoreCondition.Never for these cases :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it always sends null:
19:46:18.576 TRACE WebSocketTransport: BiDi SND --> {"id":4,"method":"browsingContext.setViewport","params":{"context":"EAEFDFDBD3A2386DD196A128BE21FF1E","viewport":null}}
But I am more interesting whether it's possibly to send null only and only when user explicitly set it to null. Is it poossible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad news: if we send null then browser resets viewport, but user didn't want to do it.
So we really want to understand how to:
send null only and only when user explicitly set it to null
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
User description
New pattern detected.
https://w3c.github.io/webdriver-bidi/#command-browsingContext-setViewport
Here
viewportproperty is nullable. But if remote-end faces realnullinjson, then it behaves differently. So we just always sendnullif it isnull.🔧 Implementation Notes
Mark this special
nullablewith:🔄 Types of changes
PR Type
Bug fix, Enhancement
Description
Add JsonIgnore attribute to Viewport property for null serialization
Enable viewport reset capability via BiDi setViewport command
Ensure null viewport values are properly sent to remote endpoint
Diagram Walkthrough
File Walkthrough
SetViewportCommand.cs
Add JsonIgnore attribute for null viewport serializationdotnet/src/webdriver/BiDi/BrowsingContext/SetViewportCommand.cs
System.Text.Json.Serializationusing statement[property: JsonIgnore(Condition =JsonIgnoreCondition.WhenWritingNull)]attribute toViewport?propertyin
SetViewportParametersrecordvia BiDi protocol