Skip to content

Conversation

@nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Dec 8, 2025

User description

https://w3c.github.io/webdriver-bidi/#command-emulation-setScreenSettingsOverride

💥 What does this PR do?

Adds SetScreenSettingsOverrideAsync method in Emulation module.

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

PR Type

Enhancement


Description

  • Adds SetScreenSettingsOverrideAsync method to Emulation module

  • Implements command, parameters, options, and result types

  • Includes comprehensive test coverage with browser compatibility checks


Diagram Walkthrough

flowchart LR
  A["EmulationModule"] -->|"adds method"| B["SetScreenSettingsOverrideAsync"]
  B -->|"uses"| C["SetScreenSettingsOverrideCommand"]
  C -->|"with parameters"| D["SetScreenSettingsOverrideParameters"]
  D -->|"contains"| E["ScreenArea"]
  C -->|"returns"| F["SetScreenSettingsOverrideResult"]
  G["EmulationTest"] -->|"tests"| B
Loading

File Walkthrough

Relevant files
Enhancement
EmulationModule.cs
Add SetScreenSettingsOverrideAsync method implementation 

dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs

  • Adds SetScreenSettingsOverrideAsync method following existing pattern
  • Registers SetScreenSettingsOverrideCommand and
    SetScreenSettingsOverrideResult for JSON serialization
  • Maintains consistency with other emulation override methods
+9/-0     
SetScreenSettingsOverrideCommand.cs
Implement SetScreenSettingsOverride command and related types

dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverrideCommand.cs

  • Creates new command class SetScreenSettingsOverrideCommand for BiDi
    communication
  • Defines SetScreenSettingsOverrideParameters record with ScreenArea
    property
  • Implements SetScreenSettingsOverrideOptions with context and user
    context support
  • Defines ScreenArea record with width and height properties
  • Creates SetScreenSettingsOverrideResult as empty result type
+39/-0   
Tests
EmulationTest.cs
Add test for SetScreenSettingsOverride functionality         

dotnet/test/common/BiDi/Emulation/EmulationTest.cs

  • Adds test method CanSetScreenSettingsOverride to verify functionality
  • Includes browser compatibility checks ignoring Chrome, Edge, and
    Firefox
  • Tests method with ScreenArea parameter and context options
  • Verifies method executes without throwing exceptions
+15/-0   

@selenium-ci selenium-ci added the C-dotnet .NET Bindings label Dec 8, 2025
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logs: The new SetScreenSettingsOverrideAsync action appears to change emulation state without
any added audit logging or metadata capturing who/what initiated it.

Referred Code
public async Task<SetScreenSettingsOverrideResult> SetScreenSettingsOverrideAsync(ScreenArea? screenArea, SetScreenSettingsOverrideOptions? options = null)
{
    var @params = new SetScreenSettingsOverrideParameters(screenArea, options?.Contexts, options?.UserContexts);

    return await Broker.ExecuteCommandAsync(new SetScreenSettingsOverrideCommand(@params), options, _jsonContext.SetScreenSettingsOverrideCommand, _jsonContext.SetScreenSettingsOverrideResult).ConfigureAwait(false);
}

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Input validation: The new ScreenArea lacks validation for non-positive width/height and the API path does
not handle null/invalid parameters beyond passing them to the broker.

Referred Code
public sealed record ScreenArea(long Width, long Height);

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Missing validation: External inputs like ScreenArea and context lists are forwarded without validation or
range checks which could allow invalid values to reach lower layers.

Referred Code
internal sealed record SetScreenSettingsOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenArea? ScreenArea, IEnumerable<BrowsingContext.BrowsingContext>? Contexts, IEnumerable<Browser.UserContext>? UserContexts) : Parameters;

public sealed class SetScreenSettingsOverrideOptions : CommandOptions
{
    public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; set; }

    public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
}

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@nvborisenko
Copy link
Member Author

Honestly I don't know what is the best approach to ship binding without internal testing: remote end doesn't support it (yet?). Merging it with assumption we will return to it and unignore tests.

@nvborisenko nvborisenko merged commit 3b1b226 into SeleniumHQ:trunk Dec 8, 2025
13 checks passed
@nvborisenko nvborisenko deleted the bidi-emulation-set-screen-settings branch December 8, 2025 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants