Skip to content

Commit 07db129

Browse files
authored
Forced colors mode WebDriver emulation command (#905)
* forced colors mode emulation * add parame restriction for theme * add comma * make theme data name more specific * remove first two steps of algo * add logic for setting fcm emulation in browsingContext.setViewport command * pre-commit error * address feedback about method params * address feedback * update cddl * update ordering * Clean up merge in index.bs * remove null * Revert "remove null" This reverts commit 886e84f. * address latest feedback * context->contexts * update to only convert null once * fix ordering
1 parent db0ca7b commit 07db129

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

index.bs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,6 +4892,12 @@ TODO: Move it as a hook in the html spec instead.
48924892
1. If [=geolocation overrides map=] [=map/contains=] |user context|,
48934893
[=set emulated position data=] with |navigable| and [=geolocation overrides map=][|user context|].
48944894

4895+
1. If [=forced colors mode theme overrides map=] [=map/contains=] |user context|:
4896+
4897+
1. Let |theme| be [=forced colors mode theme overrides map=][|user context|].
4898+
4899+
1. [=Set emulated forced colors theme data=] with |navigable| and |theme|.
4900+
48954901
1. If [=screen orientation overrides map=] [=map/contains=] |user context|,
48964902
[=set emulated screen orientation=] with |navigable| and
48974903
[=screen orientation overrides map=][|user context|].
@@ -5813,13 +5819,17 @@ relating to emulation of browser APIs.
58135819

58145820
<pre class="cddl" data-cddl-module="remote-cddl">
58155821
EmulationCommand = (
5822+
emulation.SetForcedColorsModeThemeOverride //
58165823
emulation.SetGeolocationOverride //
58175824
emulation.SetLocaleOverride //
58185825
emulation.SetScreenOrientationOverride //
58195826
emulation.SetTimezoneOverride
58205827
)
58215828
</pre>
58225829

5830+
A [=remote end=] has a <dfn>forced colors mode theme overrides map</dfn> which is a weak map
5831+
between [=user contexts=] and string or null.
5832+
58235833
A <dfn>geolocation override</dfn> is a [=struct=] with:
58245834
* [=struct/item=] named <dfn attribute for="geolocation override">latitude</dfn> which is a float;
58255835
* [=struct/item=] named <dfn attribute for="geolocation override">longitude</dfn> which is a float;
@@ -5840,6 +5850,81 @@ A [=remote end=] has a <dfn>screen orientation overrides map</dfn> which is a we
58405850
map between [=user contexts=] and [=screen orientation override=].
58415851

58425852
### Commands ### {#module-emulation-commands}
5853+
#### The emulation.setForcedColorsModeThemeOverride Command #### {#command-emulation-setForcedColorsModeThemeOverride}
5854+
5855+
The <dfn export for=commands>emulation.setForcedColorsModeThemeOverride</dfn> command modifies
5856+
[=forced colors mode=] theming characteristics on the given top-level traversables or user contexts.
5857+
5858+
<dl>
5859+
<dt>Command Type</dt>
5860+
<dd>
5861+
<pre class="cddl" data-cddl-module="remote-cddl">
5862+
emulation.SetForcedColorsModeThemeOverride = (
5863+
method: "emulation.setForcedColorsModeThemeOverride",
5864+
params: emulation.SetForcedColorsModeThemeOverrideParameters
5865+
)
5866+
5867+
emulation.SetForcedColorsModeThemeOverrideParameters = {
5868+
theme: emulation.ForcedColorsModeTheme / null,
5869+
? contexts: [+browsingContext.BrowsingContext],
5870+
? userContexts: [+browser.UserContext],
5871+
}
5872+
5873+
emulation.ForcedColorsModeTheme = "light" / "dark"
5874+
</pre>
5875+
</dd>
5876+
<dt>Result Type</dt>
5877+
<dd>
5878+
<code>
5879+
EmptyResult
5880+
</code>
5881+
</dd>
5882+
</dl>
5883+
5884+
Note: Check out the {{ForcedColorsModeAutomationTheme}} for the corresponding enum mapping in the CSS specification.
5885+
5886+
<div algorithm="remote end steps for emulation.setForcedColorsModeThemeOverride">
5887+
5888+
The [=remote end steps=] with |command parameters| are:
5889+
5890+
1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
5891+
and |command parameters| [=map/contains=] "<code>contexts</code>",
5892+
return [=error=] with [=error code=] [=invalid argument=].
5893+
5894+
1. If |command parameters| doesn't [=map/contain=] "<code>userContexts</code>"
5895+
and |command parameters| doesn't [=map/contain=] "<code>contexts</code>",
5896+
return [=error=] with [=error code=] [=invalid argument=].
5897+
5898+
1. Let |theme| be |command parameters|["<code>theme</code>"].
5899+
5900+
1. If |theme| is null, set |theme| to "<code>none</code>".
5901+
5902+
1. Let |navigables| be a [=/set=].
5903+
5904+
1. If the <code>contexts</code> field of |command parameters| is present:
5905+
5906+
1. Let |navigables| be the result of [=trying=] to [=get valid top-level traversables by ids=] with |command parameters|["<code>contexts</code>"].
5907+
5908+
1. Otherwise:
5909+
5910+
1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=] with |command parameters|["<code>userContexts</code>"].
5911+
5912+
1. For each |user context| of |user contexts|:
5913+
5914+
1. [=map/Set=] [=forced colors mode theme overrides map=][|user context|] to |theme|.
5915+
5916+
1. [=list/For each=] |top-level traversable| of the list of all [=/top-level traversables=]
5917+
whose [=associated user context=] is |user context|:
5918+
5919+
1. [=list/Append=] |top-level traversable| to |navigables|.
5920+
5921+
1. For each |navigable| of |navigables|:
5922+
5923+
1. [=Set emulated forced colors theme data=] with |navigable| and |theme|.
5924+
5925+
1. Return [=success=] with data null.
5926+
5927+
</div>
58435928

58445929
#### The emulation.setGeolocationOverride Command #### {#command-emulation-setGeolocationOverride}
58455930

0 commit comments

Comments
 (0)