Skip to content

emulation.setLocaleOverride #924

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

Merged
merged 6 commits into from
Jun 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ spec: CONSOLE; urlPrefix: https://console.spec.whatwg.org
text: formatter; url: formatter
text: formatting specifier; url: formatting-specifiers
text: printer; url: printer
spec: ECMASCRIPT-I18N; urlPrefix: https://tc39.es/ecma402/
type: dfn
text: DefaultLocale; url: #sec-defaultlocale
text: IsStructurallyValidLanguageTag; url: #sec-isstructurallyvalidlanguagetag
spec: ECMASCRIPT; urlPrefix: https://tc39.es/ecma262/
type: dfn
text: Array; url: sec-array-objects
Expand Down Expand Up @@ -3116,6 +3120,9 @@ or null and an [=struct/item=] named <dfn attribute for="viewport-configuration"

A [=remote end=] has a <dfn>viewport overrides map</dfn> which is a weak map between [=user contexts=] and [=viewport configuration=].

A [=remote end=] has a <dfn>locale overrides map</dfn> which is a weak map between
[=navigables=] or [=user contexts=] and string or null.

### Types ### {#module-browsingcontext-types}

#### The browsingContext.BrowsingContext Type #### {#type-browsingContext-Browsingcontext}
Expand Down Expand Up @@ -5768,6 +5775,7 @@ relating to emulation of browser APIs.
<pre class="cddl" data-cddl-module="remote-cddl">
EmulationCommand = (
emulation.SetGeolocationOverride //
emulation.SetLocaleOverride //
emulation.SetScreenOrientationOverride
)
</pre>
Expand Down Expand Up @@ -5898,6 +5906,125 @@ The [=remote end steps=] with |command parameters| are:

</div>

#### The emulation.setLocaleOverride Command #### {#command-emulation-setLocaleOverride}

The <dfn export for=commands>emulation.setLocaleOverride</dfn> command modifies
locale on the given top-level traversables or user contexts.

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl" data-cddl-module="remote-cddl">
emulation.SetLocaleOverride = (
method: "emulation.setLocaleOverride",
params: emulation.SetLocaleOverrideParameters
)

emulation.SetLocaleOverrideParameters = {
locale: text / null,
? contexts: [+browsingContext.BrowsingContext],
? userContexts: [+browser.UserContext],
}
</pre>
</dd>
<dt>Result Type</dt>
<dd>
<code>
EmptyResult
</code>
</dd>
</dl>

<div algorithm="updated DefaultLocale steps">
The [=DefaultLocale=] algorithm is implementation defined. A WebDriver-BiDi
[=remote end=] must have an implementation that runs the following steps:

1. Let |emulated locale| be null.

1. Let |realm| be [=current Realm Record=].

1. Let |global object| be |realm|'s [=realm/global object=].

1. If |global object| implements {{WindowProxy}}:

1. Let |window| be the value of |global object|'s \[[WindowProxy]]
[=internal slot=].

1. Let |navigable| be |window|'s [=window/navigable=].

1. Let |top-level traversable| be |navigable|’s
[=navigable/top-level traversable=].

1. Let |user context| be |top-level traversable|'s [=associated user context=].

1. If [=locale overrides map=] [=map/contains=] |top-level traversable|, set
|emulated locale| to [=locale overrides map=][|top-level traversable|].

1. Otherwise, if [=locale overrides map=] [=map/contains=]
|user context|, set |emulated locale| to
[=locale overrides map=][|user context|].

1. If |emulated locale| is not null, return |emulated locale|.

1. Return the result of implementation-defined steps in accordance with the
requirements of the [=DefaultLocale=] specification.

</div>

<div algorithm="remote end steps for emulation.setLocaleOverride">

The [=remote end steps=] with |command parameters| are:

1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
and |command parameters| [=map/contains=] "<code>context</code>",
return [=error=] with [=error code=] [=invalid argument=].

1. If |command parameters| doesn't [=map/contain=] "<code>userContexts</code>"
and |command parameters| doesn't [=map/contain=] "<code>context</code>",
return [=error=] with [=error code=] [=invalid argument=].

1. Let |emulated locale| be null.

1. If |command parameters| [=map/contains=] "<code>locale</code>":

1. Set |emulated locale| to |command parameters|["<code>locale</code>"].

1. If [=IsStructurallyValidLanguageTag=](|emulated locale|) returns false,
return [=error=] with [=error code=] [=invalid argument=].

1. Let |navigables| be a [=/set=].

1. If the <code>contexts</code> field of |command parameters| is present:

1. Let |navigables| be the result of [=trying=] to
[=get valid top-level traversables by ids=] with
|command parameters|["<code>contexts</code>"].

1. Otherwise:

1. Assert the <code>userContexts</code> field of |command parameters| is present.

1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
with |command parameters|["<code>userContexts</code>"].

1. For each |user context| of |user contexts|:

1. [=map/Set=] [=locale overrides map=][|user context|] to |emulated locale|.

1. [=list/For each=] |top-level traversable| of the list of all
[=/top-level traversables=] whose [=associated user context=] is
|user context|:

1. [=list/Append=] |top-level traversable| to |navigables|.

1. For each |navigable| of |navigables|:

1. [=map/Set=] [=locale overrides map=][|navigable|] to |emulated locale|.

1. Return [=success=] with data null.

</div>

#### The emulation.setScreenOrientationOverride Command #### {#command-emulation-setScreenOrientationOverride}

The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn> command
Expand Down