-
Notifications
You must be signed in to change notification settings - Fork 78
emulation.setMediaFeaturesOverride
#1076
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: main
Are you sure you want to change the base?
Changes from 46 commits
49c74f3
f37f1ee
81ffe34
801a1bd
43108d9
2b43d31
df3cab1
3d59948
2aa7e4b
b5d97cf
6301b81
8fbb426
694e64b
92b9183
97b36c3
27f8016
13da3aa
2baf4d5
3c71c7b
8b902f1
efd4fdd
ecf7cbf
0fb4a75
fe4e633
55325be
7a75b6d
c373238
abb4e1a
45bb310
6da5727
80f80bd
555180b
e10e4eb
c6511ae
03ab6df
42ef86d
a2eba0f
4cb48eb
6d0c419
21a5a68
a2a4053
fa4e3da
bdb0af4
a4cba20
06de83e
312ce41
3a1ec08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -327,6 +327,8 @@ spec: MEDIAQUERIES4; urlPrefix: https://drafts.csswg.org/mediaqueries-4/ | |||||
| type: dfn | ||||||
| text: resolution media feature; url: #resolution | ||||||
| text: media type; url: #media-type | ||||||
| text: media feature; url: #media-features | ||||||
| text: mf-name; url: #typedef-mf-name | ||||||
| spec: RFC9110; urlPrefix: https://httpwg.org/specs/rfc9110.html | ||||||
| type: dfn | ||||||
| text: field-name token; url: #fields.names | ||||||
|
|
@@ -6113,6 +6115,7 @@ EmulationCommand = ( | |||||
| emulation.SetForcedColorsModeThemeOverride // | ||||||
| emulation.SetGeolocationOverride // | ||||||
| emulation.SetLocaleOverride // | ||||||
| emulation.SetMediaFeaturesOverride // | ||||||
| emulation.SetNetworkConditions // | ||||||
| emulation.SetScreenOrientationOverride // | ||||||
| emulation.SetScreenSettingsOverride // | ||||||
|
|
@@ -6130,6 +6133,7 @@ EmulationResult = ( | |||||
| emulation.SetForcedColorsModeThemeOverrideResult / | ||||||
| emulation.SetGeolocationOverrideResult / | ||||||
| emulation.SetLocaleOverrideResult / | ||||||
| emulation.SetMediaFeaturesOverrideResult / | ||||||
| emulation.SetScreenOrientationOverrideResult / | ||||||
| emulation.SetScriptingEnabledResult / | ||||||
| emulation.SetScrollbarTypeOverrideResult / | ||||||
|
|
@@ -6475,7 +6479,142 @@ The [=remote end steps=] with |command parameters| are: | |||||
|
|
||||||
| </div> | ||||||
|
|
||||||
| #### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions} | ||||||
| #### The emulation.setMediaFeaturesOverride Command #### {#command-emulation-setMediaFeaturesOverride} | ||||||
|
|
||||||
| The <dfn export for=commands>emulation.setMediaFeaturesOverride</dfn> command | ||||||
| allows overriding the values of various media features. | ||||||
|
|
||||||
| <dl> | ||||||
| <dt>Command Type</dt> | ||||||
| <dd> | ||||||
| <pre class="cddl" data-cddl-module="remote-cddl"> | ||||||
| emulation.SetMediaFeaturesOverride = ( | ||||||
| method: "emulation.setMediaFeaturesOverride", | ||||||
| params: emulation.SetMediaFeaturesOverrideParameters | ||||||
| ) | ||||||
|
|
||||||
| emulation.SetMediaFeaturesOverrideParameters = { | ||||||
| features: emulation.MediaFeatures / null, | ||||||
| ? contexts: [+browsingContext.BrowsingContext], | ||||||
| ? userContexts: [+browser.UserContext], | ||||||
| } | ||||||
|
|
||||||
| emulation.MediaFeatures = { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not a fan of this API as it requires changing WebDriver BiDi spec whenever there is a new media feature available in the underlying browser.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since media query features generally support unknown values, e.g., in CSS rules or in the matchMedia API, I think it might be beneficial to just pass a list of media features to the browser without re-listing all possible feature names in the WebDriver BiDi's CDDL. WDYT @jgraham ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lutien WDYT about this proposal?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can ensure interoperability between the browsers if we don't specify the supported media features here, and we have to write wpt tests anyway for every feature. |
||||||
| ? "any-hover": "none" / "hover" / null, | ||||||
| ? "any-pointer": "none" / "coarse" / "fine" / null, | ||||||
| ? "color": js-uint / null, | ||||||
| ? "color-gamut": "srgb" / "p3" / "rec2020" / null, | ||||||
| ? "color-index": js-uint / null, | ||||||
| ? "display-mode": "fullscreen" / "standalone" / "minimal-ui" / "browser" / "picture-in-picture" / null, | ||||||
| ? "dynamic-range": "standard" / "high" / null, | ||||||
| ? "environment-blending": "opaque" / "additive" / "subtractive" / null, | ||||||
| ? "forced-colors": "none" / "active" / null, | ||||||
| ? "grid": 0 / 1 / null, | ||||||
| ? "horizontal-viewport-segments": js-uint / null, | ||||||
| ? "hover": "none" / "hover" / null, | ||||||
| ? "inverted-colors": "none" / "inverted" / null, | ||||||
| ? "monochrome": js-uint / null, | ||||||
| ? "nav-controls": "back" / null, | ||||||
|
sadym-chromium marked this conversation as resolved.
Outdated
|
||||||
| ? "overflow-block": "none" / "scroll" / "optional-paged" / "paged" / null, | ||||||
| ? "overflow-inline": "none" / "scroll" / null, | ||||||
| ? "pointer": "none" / "coarse" / "fine" / null, | ||||||
| ? "prefers-color-scheme": "light" / "dark" / null, | ||||||
| ? "prefers-contrast": "no-preference" / "more" / "less" / "custom" / null, | ||||||
| ? "prefers-reduced-data": "no-preference" / "reduce" / null, | ||||||
| ? "prefers-reduced-motion": "no-preference" / "reduce" / null, | ||||||
| ? "prefers-reduced-transparency": "no-preference" / "reduce" / null, | ||||||
| ? "scan": "interlace" / "progressive" / null, | ||||||
| ? "scripting": "none" / "initial-only" / "enabled" / null, | ||||||
| ? "update": "none" / "slow" / "fast" / null, | ||||||
| ? "vertical-viewport-segments": js-uint / null, | ||||||
| ? "video-color-gamut": "srgb" / "p3" / "rec2020" / null, | ||||||
| ? "video-dynamic-range": "standard" / "high" / null, | ||||||
| } | ||||||
| </pre> | ||||||
| </dd> | ||||||
| <dt>Return Type</dt> | ||||||
| <dd> | ||||||
| <pre class="cddl" data-cddl-module="local-cddl"> | ||||||
| emulation.SetMediaFeaturesOverrideResult = EmptyResult | ||||||
| </pre> | ||||||
| </dd> | ||||||
| </dl> | ||||||
|
|
||||||
| A [=remote end=] has a <dfn>media features override configurations map</dfn>, which is a [=/map=] | ||||||
| between string and [=WebDriver configuration=]. | ||||||
|
|
||||||
| <div algorithm> | ||||||
| To get <dfn export>WebDriver BiDi media feature value</dfn> for [=/Document=] |document| and media | ||||||
| feature name |name|: | ||||||
|
|
||||||
| 1. Let |navigable| be |document|'s [=/node navigable=]. | ||||||
|
|
||||||
| 1. If [=media features override configurations map=] does not [=map/contain=] |name|, | ||||||
| return null. | ||||||
|
|
||||||
| 1. Let |media feature override| be the result of [=get WebDriver configuration value=] of | ||||||
| [=media features override configurations map=][|name|] for |navigable|. | ||||||
|
|
||||||
| 1. If |media feature override| is [=WebDriver configuration/unset=], return null. | ||||||
|
|
||||||
| 1. Return |media feature override|. | ||||||
|
|
||||||
| </div> | ||||||
|
|
||||||
| <div algorithm="remote end steps for emulation.setMediaFeaturesOverride"> | ||||||
|
|
||||||
| The [=remote end steps=] with |command parameters| are: | ||||||
|
|
||||||
| 1. Let |media features override| be |command parameters|["<code>features</code>"]. | ||||||
|
|
||||||
| 1. If |media features override| is null: | ||||||
|
|
||||||
| Note: to remove all the media feature emulations at once, we need a list of media features names. | ||||||
| We use keys of the [=media features override configurations map=], as it contains all the media | ||||||
| features that were ever used. | ||||||
|
|
||||||
| 1. Set |media features override| to a new [=/map=]. | ||||||
|
|
||||||
| 1. For each |media feature name| of the result of [=map/get the keys=] of | ||||||
| [=media features override configurations map=]: | ||||||
|
|
||||||
| 1. [=map/Set=] |media features override|[|media feature name|] to null. | ||||||
|
|
||||||
| 1. For each |media feature name| of the result of [=map/get the keys=] of |media features override|: | ||||||
|
|
||||||
| 1. If the implementation is unable to emulate [=media feature=] |media feature name| with | ||||||
| value of |media features override|[|media feature name|] for any reason, return [=error=] with | ||||||
| [=error code=] [=unsupported operation=]. | ||||||
|
|
||||||
| 1. Let |affected navigables| be a new [=/set=]. | ||||||
|
|
||||||
| 1. For each |media feature name| of the result of [=map/get the keys=] of |media features override|: | ||||||
|
|
||||||
| 1. If [=media features override configurations map=] does not [=map/contain=] | ||||||
| |media feature name|, [=map/set=] | ||||||
| [=media features override configurations map=][|media feature name|] to a new | ||||||
| [=WebDriver configuration=] with [=WebDriver configuration/associated type=] string or | ||||||
| integer. | ||||||
|
|
||||||
| 1. Let |media feature override| be |media features override|[|media feature name|]. | ||||||
|
|
||||||
| 1. If |media feature override| is null, set |media feature override| to | ||||||
| [=WebDriver configuration/unset=]. | ||||||
|
|
||||||
| 1. Set |affected navigables| to the [=set/union=] of |affected navigables| and the result of | ||||||
| [=trying=] to [=store WebDriver configuration=] | ||||||
| [=media features override configurations map=][|media feature name|] |media feature override| | ||||||
| for |command parameters|. | ||||||
|
|
||||||
| 1. For each |navigable| of |affected navigables|: | ||||||
| 1. [=list/For each=] |document| currently loaded in |navigable| or its [=descendant navigables=]: | ||||||
| 1. Run [=evaluate media queries and report changes=] for |document|. | ||||||
|
|
||||||
| 1. Return [=success=] with data null. | ||||||
|
|
||||||
| </div> | ||||||
|
|
||||||
| #### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions} | ||||||
|
|
||||||
| The <dfn export for=commands>emulation.setNetworkConditions</dfn> command | ||||||
| emulates specific network conditions for the given browsing context or for a user | ||||||
|
|
@@ -14989,6 +15128,27 @@ Insert the following steps at the start of the [=determine the device pixel rati | |||||
|
|
||||||
| 1. If [=device pixel ratio overrides=] [=map/contains=] <var ignore>window</var>'s [=window/navigable=], return [=device pixel ratio overrides=][<var ignore>window</var>'s [=window/navigable=]]. | ||||||
|
|
||||||
| ### Evaluating Media Queries ### {#patchs-evaluating-media-queries} | ||||||
|
|
||||||
| Issue: Remove after https://github.com/w3c/csswg-drafts/pull/13549 is merged. | ||||||
|
|
||||||
| The <dfn export>evaluate media feature</dfn> algorithm is modified to support WebDriver BiDi | ||||||
| overrides. Replace the step "The result is the result of evaluating the specified media feature" to: | ||||||
|
|
||||||
| <div algorithm="evaluate media feature"> | ||||||
| To get the result of evaluating a [=media feature=] |media feature| in the given [=/Document=] |document|: | ||||||
|
|
||||||
| 1. Let |media feature name| be the |media feature|'s [=mf-name=]. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: this will render as |
||||||
|
|
||||||
| 1. Let |emulated value| be the result of getting [=WebDriver BiDi media feature value=] for the | ||||||
| |document| and |media feature name|. | ||||||
|
|
||||||
| 1. If |emulated value| is not null, return |emulated value|. | ||||||
|
|
||||||
| 1. Otherwise, return the result of evaluating the specified |media feature|. | ||||||
|
|
||||||
| </div> | ||||||
|
|
||||||
| # Appendices # {#appendices} | ||||||
|
|
||||||
| <em>This section is non-normative.</em> | ||||||
|
|
||||||
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.
The spec already exports these terms although, for
<mf-name>, the correct way to reference the term is going to be with the<<mf-name>>shorthand syntax.(FWIW, the spec also exports "media type", but it's been introduced before this PR)