diff --git a/index.bs b/index.bs index d664e778b..5160ffe8a 100644 --- a/index.bs +++ b/index.bs @@ -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: -#### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions} +#### The emulation.setMediaFeaturesOverride Command #### {#command-emulation-setMediaFeaturesOverride} + +The emulation.setMediaFeaturesOverride command +allows overriding the values of various media features. + +
+
Command Type
+
+
+      emulation.SetMediaFeaturesOverride = (
+        method: "emulation.setMediaFeaturesOverride",
+        params: emulation.SetMediaFeaturesOverrideParameters
+      )
+
+      emulation.SetMediaFeaturesOverrideParameters = {
+        features: emulation.MediaFeatures / null,
+        ? contexts: [+browsingContext.BrowsingContext],
+        ? userContexts: [+browser.UserContext],
+      }
+
+      emulation.MediaFeatures = {
+        ? "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": "none" / "back" / null,
+        ? "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,
+      }
+    
+
+
Return Type
+
+
+      emulation.SetMediaFeaturesOverrideResult = EmptyResult
+      
+
+
+ +A [=remote end=] has a media features override configurations map, which is a [=/map=] +between string and [=WebDriver configuration=]. + +
+To get WebDriver BiDi media feature value 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|. + +
+ +
+ +The [=remote end steps=] with |command parameters| are: + +1. Let |media features override| be |command parameters|["features"]. + +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. + +
+ +#### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions} The emulation.setNetworkConditions 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=] window's [=window/navigable=], return [=device pixel ratio overrides=][window's [=window/navigable=]]. +### Evaluating Media Queries ### {#patchs-evaluating-media-queries} + +Issue: Remove after https://github.com/w3c/csswg-drafts/pull/13549 is merged. + +The evaluate media feature algorithm is modified to support WebDriver BiDi +overrides. Replace the step "The result is the result of evaluating the specified media feature" to: + +
+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=]. + +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|. + +
+ # Appendices # {#appendices} This section is non-normative.