Skip to content

Commit 3652916

Browse files
emulation.setUserAgentOverride
Initial draft of `emulation.setUserAgentOverride` command. Requires defining a list of related navigables for the "default User-Agent value" caller. # Conflicts: # index.bs
1 parent b7393ef commit 3652916

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

index.bs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ spec: SCREEN-ORIENTATION; urlPrefix: https://www.w3.org/TR/screen-orientation
207207
text: screen orientation; url: #dom-screenorientation
208208
text: screen orientation change steps; url: #dfn-screen-orientation-change-steps
209209
text: screen orientation values lists; url: #dfn-screen-orientation-values-lists
210+
spec: FETCH; urlPrefix: https://fetch.spec.whatwg.org/
211+
type: dfn
212+
text: default User-Agent value; url: #default-user-agent-value
210213
spec: HTML; urlPrefix: https://html.spec.whatwg.org/multipage/
211214
type: dfn
212215
text: 2D context creation algorithm; url: canvas.html#2d-context-creation-algorithm
@@ -3145,6 +3148,9 @@ A [=remote end=] has a <dfn>timezone overrides map</dfn> which is a weak map bet
31453148
A [=remote end=] has an <dfn>unhandled prompt behavior overrides map</dfn> which is a
31463149
weak map between [=user contexts=] and [=unhandled prompt behavior struct=].
31473150

3151+
A [=remote end=] has a <dfn>user agent overrides map</dfn> which is a weak map
3152+
between [=navigables=] or [=user contexts=] and string or null.
3153+
31483154
A [=remote end=] has a <dfn>scripting enabled overrides map</dfn> which is a weak
31493155
map between [=navigables=] or [=user contexts=] and boolean or null.
31503156

@@ -5830,6 +5836,8 @@ EmulationCommand = (
58305836
emulation.SetScreenOrientationOverride //
58315837
emulation.SetScriptingEnabled //
58325838
emulation.SetTimezoneOverride
5839+
emulation.SetScreenOrientationOverride //
5840+
emulation.SetUserAgentOverride
58335841
)
58345842
</pre>
58355843

@@ -6279,6 +6287,126 @@ The [=remote end steps=] with |command parameters| are:
62796287

62806288
</div>
62816289

6290+
#### The emulation.setUserAgentOverride Command #### {#command-emulation-setUserAgentOverride}
6291+
6292+
The <dfn export for=commands>emulation.setUserAgentOverride</dfn> command modifies
6293+
User-Agent on the given top-level traversables or user contexts.
6294+
6295+
<dl>
6296+
<dt>Command Type</dt>
6297+
<dd>
6298+
<pre class="cddl" data-cddl-module="remote-cddl">
6299+
emulation.SetUserAgentOverride = (
6300+
method: "emulation.setUserAgentOverride",
6301+
params: emulation.SetUserAgentOverrideParameters
6302+
)
6303+
6304+
emulation.SetUserAgentOverrideParameters = {
6305+
userAgent: text / null,
6306+
? contexts: [+browsingContext.BrowsingContext],
6307+
? userContexts: [+browser.UserContext],
6308+
}
6309+
</pre>
6310+
</dd>
6311+
<dt>Result Type</dt>
6312+
<dd>
6313+
<code>
6314+
EmptyResult
6315+
</code>
6316+
</dd>
6317+
</dl>
6318+
6319+
<div algorithm="updated `User-Agent` getter steps">
6320+
The [=default User-Agent value=] getter steps is implementation defined. A
6321+
WebDriver-BiDi [=remote end=] must have an implementation that runs the following
6322+
steps:
6323+
6324+
Issue: get |related navigables|.
6325+
6326+
1. Let |related navigables| be the implementation-defined list of navigables related
6327+
to the caller of these steps.
6328+
6329+
1. Let |emulated user agent| be the result of [=get emulated user agent=] given
6330+
|related navigables|.
6331+
6332+
1. If |emulated user agent| is not null, return |emulated user agent|.
6333+
6334+
1. Return the result of implementation-defined steps in accordance with the
6335+
requirements of the [=default User-Agent value=] specification.
6336+
6337+
</div>
6338+
6339+
<div algorithm>
6340+
To <dfn>get emulated user agent</dfn> given |navigables|:
6341+
6342+
1. For each |navigable| or |navigables|:
6343+
6344+
1. Let |top-level navigable| be |navigable|'s [=navigable/top-level traversable=].
6345+
6346+
1. If [=user agent overrides map=] contains |top-level navigable|, return
6347+
[=user agent overrides map=][|top-level navigable|].
6348+
6349+
1. Let |user context| be |top-level navigable|'s [=associated user context=].
6350+
6351+
1. If [=user agent overrides map=] contains |user context|, return
6352+
[=user agent overrides map=][|user context|].
6353+
6354+
1. Return null.
6355+
6356+
</div>
6357+
6358+
<div algorithm="remote end steps for emulation.setUserAgentOverride">
6359+
6360+
The [=remote end steps=] with |command parameters| are:
6361+
6362+
1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
6363+
and |command parameters| [=map/contains=] "<code>context</code>",
6364+
return [=error=] with [=error code=] [=invalid argument=].
6365+
6366+
1. If |command parameters| doesn't [=map/contain=] "<code>userContexts</code>"
6367+
and |command parameters| doesn't [=map/contain=] "<code>context</code>",
6368+
return [=error=] with [=error code=] [=invalid argument=].
6369+
6370+
1. Let |emulated user agent| be null.
6371+
6372+
1. If |command parameters| [=map/contains=] "<code>userAgent</code>":
6373+
6374+
1. Set |emulated user agent| to |command parameters|["<code>userAgent</code>"].
6375+
6376+
1. Let |navigables| be a [=/set=].
6377+
6378+
1. If the <code>contexts</code> field of |command parameters| is present:
6379+
6380+
1. Let |navigables| be the result of [=trying=] to
6381+
[=get valid top-level traversables by ids=] with
6382+
|command parameters|["<code>contexts</code>"].
6383+
6384+
1. Otherwise:
6385+
6386+
1. Assert the <code>userContexts</code> field of |command parameters| is present.
6387+
6388+
1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
6389+
with |command parameters|["<code>userContexts</code>"].
6390+
6391+
1. For each |user context| of |user contexts|:
6392+
6393+
1. [=map/Set=] [=user agent overrides map=][|user context|] to
6394+
|emulated user agent|.
6395+
6396+
1. [=list/For each=] |top-level traversable| of the list of all
6397+
[=/top-level traversables=] whose [=associated user context=] is
6398+
|user context|:
6399+
6400+
1. [=list/Append=] |top-level traversable| to |navigables|.
6401+
6402+
1. For each |navigable| of |navigables|:
6403+
6404+
1. [=map/Set=] [=user agent overrides map=][|navigable|] to |emulated user agent|.
6405+
6406+
1. Return [=success=] with data null.
6407+
6408+
</div>
6409+
62826410
#### The emulation.setScriptingEnabled Command #### {#command-emulation-setScriptingEnabled}
62836411

62846412
The <dfn export for=commands>emulation.setScriptingEnabled</dfn> command emulates

0 commit comments

Comments
 (0)