You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add BiDi media feature overrides to .NET emulation
✨ Enhancement🧪 Tests🕐 20-40 Minutes
AI Description
• Adds .NET BiDi support for overriding CSS media features by context or user context.
• Models protocol features with optional nullable values and kebab-case enum serialization.
• Verifies applying selected overrides and restoring browser defaults.
The implementation follows the established .NET BiDi emulation-command pattern and uses typed records, Optional values, existing converters, and source-generated JSON metadata. A string-based feature map would reduce declarations but sacrifice protocol discoverability and compile-time safety, so the current approach is preferable.
Files changed (4) +376 / -0
Enhancement (3) +350 / -0
EmulationModule.csWire the media-features override command+11/-0
Wire the media-features override command
• Registers emulation.setMediaFeaturesOverride, builds its scoped parameters, and executes it through the existing module pipeline. Adds parameter and result types to the source-generated JSON serializer context.
• Defines command parameters, scoping options, result type, and the full typed MediaFeatures surface. Optional nullable values distinguish omitted features from explicit null resets, while converters emit protocol-compatible property and enum names.
EmulationTests.csCover setting and resetting media-feature overrides+26/-0
Cover setting and resetting media-feature overrides
• Adds integration tests that submit representative enum and numeric media features for a browsing context. Also verifies that a null feature set restores browser defaults without errors.
1. features uses wrong shape✗ Dismissed📘 Rule violation≡ Correctness
Description
SetMediaFeaturesOverrideParameters.Features serializes as a single object keyed by CSS feature
names, such as {"any-hover":"none","color":8}, instead of the protocol-required nullable array of
{name, value} records, such as
[{"name":"any-hover","value":"none"},{"name":"color","value":"8"}]. Non-null overrides therefore
have both an incompatible container shape and, for numeric features, the wrong JSON value type,
which can cause conforming endpoints to reject or misread emulation.setMediaFeaturesOverride.
+internal sealed record SetMediaFeaturesOverrideParameters(+ [property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] MediaFeatures? Features,
Evidence
Rule 2 requires equivalent language bindings to remain behaviorally aligned, and the repository's
Ruby BiDi protocol schema defines features as a nullable list of MediaFeature records whose
name and value fields are strings. In contrast, the added .NET parameter uses a single
MediaFeatures object with feature names mapped directly to JSON properties, including numeric
values declared as long; because OptionalConverter serializes the underlying values unchanged,
those values become JSON numbers rather than the required strings, proving that the .NET wire model
conflicts with the applicable binding and protocol schema.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`SetMediaFeaturesOverrideParameters.Features` is modeled as a single `MediaFeatures` object, producing a wire object keyed by CSS media-feature names instead of the protocol-required nullable array of `{name, value}` records. Numeric feature values are also serialized as JSON numbers rather than strings.
## Issue Context
Replace the object-based `MediaFeatures` wire model with a list-valued model whose records contain string `name` and `value` fields. Update the public .NET signature, parameter model, serialization metadata, and tests together; preserve explicit JSON `null` for resetting the override, and ensure numeric and enum feature values are represented as protocol strings within each record.
## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Emulation/SetMediaFeaturesOverride.cs[25-155]
- dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[27-27]
- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs[81-84]
- dotnet/test/webdriver/BiDi/Emulation/EmulationTests.cs[86-109]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. Media tests are always ignored✗ Dismissed📘 Rule violation☼ Reliability
Description
Both new media-feature tests are marked to ignore Chrome, Edge, and Firefox, so the added coverage
never executes on the supported browser matrix. This leaves the new command without applicable
regression coverage and can allow serialization or protocol regressions to pass unnoticed.
The checklist requires changed behavior to have focused regression coverage. The first new test is
ignored for Chrome, Edge, and Firefox, and the second test has the same all-browser ignore
configuration, meaning neither test runs in the current browser matrix.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The new media-feature tests are ignored for every listed browser, so they provide no executable regression coverage.
## Issue Context
The test methods exercise `SetMediaFeaturesOverrideAsync`, but all supported browser entries are disabled with `IgnoreBrowser` attributes. Keep browser skips only where required by a documented capability gap, and add an executable lower-level serialization/command test if no current browser supports the feature.
## Fix Focus Areas
- dotnet/test/webdriver/BiDi/Emulation/EmulationTests.cs[87-115]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Context sources
Review mode: 🚀 Fast: The latest push only renames a public method parameter and its local use in two closely related declarations, with no behavioral or high-risk logic change.
Tip of the day
💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record
1. features uses wrong shape✗ Dismissed📘 Rule violation≡ Correctness
Description
SetMediaFeaturesOverrideParameters.Features serializes as a single object keyed by CSS feature
names, such as {"any-hover":"none","color":8}, instead of the protocol-required nullable array of
{name, value} records, such as
[{"name":"any-hover","value":"none"},{"name":"color","value":"8"}]. Non-null overrides therefore
have both an incompatible container shape and, for numeric features, the wrong JSON value type,
which can cause conforming endpoints to reject or misread emulation.setMediaFeaturesOverride.
+internal sealed record SetMediaFeaturesOverrideParameters(+ [property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] MediaFeatures? Features,
Evidence
Rule 2 requires equivalent language bindings to remain behaviorally aligned, and the repository's
Ruby BiDi protocol schema defines features as a nullable list of MediaFeature records whose
name and value fields are strings. In contrast, the added .NET parameter uses a single
MediaFeatures object with feature names mapped directly to JSON properties, including numeric
values declared as long; because OptionalConverter serializes the underlying values unchanged,
those values become JSON numbers rather than the required strings, proving that the .NET wire model
conflicts with the applicable binding and protocol schema.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`SetMediaFeaturesOverrideParameters.Features` is modeled as a single `MediaFeatures` object, producing a wire object keyed by CSS media-feature names instead of the protocol-required nullable array of `{name, value}` records. Numeric feature values are also serialized as JSON numbers rather than strings.
## Issue Context
Replace the object-based `MediaFeatures` wire model with a list-valued model whose records contain string `name` and `value` fields. Update the public .NET signature, parameter model, serialization metadata, and tests together; preserve explicit JSON `null` for resetting the override, and ensure numeric and enum feature values are represented as protocol strings within each record.
## Fix Focus Areas
- dotnet/src/webdriver/BiDi/Emulation/SetMediaFeaturesOverride.cs[25-155]
- dotnet/src/webdriver/BiDi/Emulation/IEmulationModule.cs[27-27]
- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs[81-84]
- dotnet/test/webdriver/BiDi/Emulation/EmulationTests.cs[86-109]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
1. Media tests are always ignored✗ Dismissed📘 Rule violation☼ Reliability
Description
Both new media-feature tests are marked to ignore Chrome, Edge, and Firefox, so the added coverage
never executes on the supported browser matrix. This leaves the new command without applicable
regression coverage and can allow serialization or protocol regressions to pass unnoticed.
The checklist requires changed behavior to have focused regression coverage. The first new test is
ignored for Chrome, Edge, and Firefox, and the second test has the same all-browser ignore
configuration, meaning neither test runs in the current browser matrix.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The new media-feature tests are ignored for every listed browser, so they provide no executable regression coverage.
## Issue Context
The test methods exercise `SetMediaFeaturesOverrideAsync`, but all supported browser entries are disabled with `IgnoreBrowser` attributes. Keep browser skips only where required by a documented capability gap, and add an executable lower-level serialization/command test if no current browser supports the feature.
## Fix Focus Areas
- dotnet/test/webdriver/BiDi/Emulation/EmulationTests.cs[87-115]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
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
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.
https://w3c.github.io/webdriver-bidi/#command-emulation-setMediaFeaturesOverride
💥 What does this PR do?
Add support of
emulation.setMediaFeaturesOverridecommand.🤖 AI assistance
💡 Additional Considerations
Optional<>andKebabCaseConverterworks nicely here.🔄 Types of changes