diff --git a/index.bs b/index.bs index a94d67e5..25945a92 100644 --- a/index.bs +++ b/index.bs @@ -126,6 +126,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 @@ -3061,6 +3065,12 @@ or null and an [=struct/item=] named viewport overrides map which is a weak map between [=user contexts=] and [=viewport configuration=]. +A [=remote end=] has a navigable to locale overrides map which is a weak +map between [=navigables=] and strings. + +A [=remote end=] has a user context to locale overrides map which is a +weak map between [=user contexts=] and strings. + ### Types ### {#module-browsingcontext-types} #### The browsingContext.BrowsingContext Type #### {#type-browsingContext-Browsingcontext} @@ -4810,6 +4820,10 @@ TODO: Move it as a hook in the html spec instead. 1. If [=geolocation overrides map=] [=map/contains=] |user context|, [=set emulated position data=] with |navigable| and [=geolocation overrides map=][|user context|]. + 1. If [=user context to locale overrides map=] [=map/contains=] |user context|, + [=set emulated locale=] with |navigable| and + [=user context to locale overrides map=][|user context|]. + 1. If [=viewport overrides map=] [=map/contains=] |user context|: 1. If |navigable| is a [=/top-level traversable=] and the viewport field of @@ -5627,7 +5641,8 @@ relating to emulation of browser APIs.
 EmulationCommand = (
-  emulation.SetGeolocationOverride
+  emulation.SetGeolocationOverride //
+  emulation.SetLocaleOverride
 )
 
@@ -5750,6 +5765,104 @@ The [=remote end steps=] with |command parameters| are: +#### The emulation.setLocaleOverride Command #### {#command-emulation-setLocaleOverride} + +The emulation.setLocaleOverride command modifies +locale on the given top-level traversables or user contexts. + +
+
Command Type
+
+
+      emulation.SetLocaleOverride = (
+        method: "emulation.setLocaleOverride",
+        params: emulation.SetLocaleOverrideParameters
+      )
+
+      emulation.SetLocaleOverrideParameters = {
+        locale: text / null,
+        ? contexts: [+browsingContext.BrowsingContext],
+        ? userContexts: [+browser.UserContext],
+      }
+    
+
+
Result Type
+
+ + EmptyResult + +
+
+ +
+To set emulated locale given |navigable| and |locale|: + +1. If |locale| is null, [=map/remove=] |navigable| from + [=navigable to locale overrides map=]. + +1. Otherwise, [=map/set=] [=navigable to locale overrides map=][|navigable|] to + |locale|. + +
+ +
+ +The [=remote end steps=] with |command parameters| are: + +1. If |command parameters| [=map/contains=] "userContexts" + and |command parameters| [=map/contains=] "context", + return [=error=] with [=error code=] [=invalid argument=]. + +1. If |command parameters| doesn't [=map/contain=] "userContexts" + and |command parameters| doesn't [=map/contain=] "context", + return [=error=] with [=error code=] [=invalid argument=]. + +1. Let |emulated locale| be null. + +1. If |command parameters| [=map/contains=] "locale": + + 1. Set |emulated locale| to |command parameters|["locale"]. + + 1. If [=IsStructurallyValidLanguageTag=](|emulated locale|) returns false, + return [=error=] with [=error code=] [=invalid argument=]. + +1. Let |navigables| be a [=/set=]. + +1. If the contexts 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|["contexts"]. + +1. Otherwise: + + 1. Assert the userContexts field of |command parameters| is present. + + 1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=] + with |command parameters|["userContexts"]. + + 1. For each |user context| of |user contexts|: + + 1. If |emulated locale| is null, [=map/remove=] |user context| from + [=user context to locale overrides map=]. + + 1. Otherwise, [=user context to locale overrides map=][|user context|] to + |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. [=Set emulated locale=] with |navigable| and |locale|. + +1. Return [=success=] with data null. + +
+ ## The network Module ## {#module-network} The network module contains commands and events @@ -8217,6 +8330,33 @@ ScriptEvent = ( ) +
+Whenever the [=DefaultLocale=] algorithm is invoked, the [=remote end=] must run the +following steps, instead of the ones defined by [=DefaultLocale=] specification: + +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. If [=navigable to locale overrides map=] [=map/contains=] + |top-level traversable|: + + 1. Return [=navigable to locale overrides map=][|top-level traversable|]. + +1. Proceed according to [=DefaultLocale=] specification. + +
+ ### Preload Scripts ### {#preload-scripts} A Preload script is one which runs on creation of a new {{Window}},