@@ -7797,10 +7797,12 @@ before any author-defined script have run.
7797
7797
TODO: Extend this to scripts in other kinds of realms.
7798
7798
7799
7799
A [=BiDi session=] has a <dfn>preload script map</dfn> which is a [=/map=] in
7800
- which the keys are [[!RFC9562|UUID]] s, and the values are [=structs=] with an <a
7801
- for=struct> item</a> named <code> function declaration</code> , which is a string,
7802
- <code> arguments</code> , <code> contexts</code> , which is a list or null, and an item named <code> sandbox</code> which is a string
7803
- or null.
7800
+ which the keys are [[!RFC9562|UUID]] s, and the values are [=structs=] with
7801
+ an [=struct/item=] named <code> function declaration</code> , which is a string,
7802
+ an [=struct/item=] named <code> arguments</code> , which is a list,
7803
+ an [=struct/item=] named <code> contexts</code> , which is a list or null,
7804
+ an [=struct/item=] named <code> sandbox</code> , which is a string or null,
7805
+ and an [=struct/item=] named <code> user contexts</code> , which is a [=/set=] .
7804
7806
7805
7807
Note: If executing a [=preload script=] fails, either due to a syntax error, or
7806
7808
a runtime exception, an [[ECMAScript]] exception is reported in the realm in
@@ -7814,16 +7816,26 @@ To <dfn export>run WebDriver BiDi preload scripts</dfn> given |environment setti
7814
7816
7815
7817
1. Let |navigable| be |document|'s [=/navigable=] .
7816
7818
7819
+ 1. Let |user context| be |navigable|'s [=associated user context=] .
7820
+
7821
+ 1. Let |user context id| be |user context|'s [=user context id=] .
7822
+
7817
7823
1. For each |session| in [=active BiDi sessions=] :
7818
7824
7819
7825
1. For each |preload script| in |session|'s [=preload script map=]' s
7820
7826
[=values=] :
7821
7827
7828
+ 1. If |preload script|'s <code>user contexts</code>' s [=set/size=] is not zero:
7829
+
7830
+ 1. If |preload script|'s <code> user contexts</code> does not [=list/contain=] |user context id|,
7831
+ [=continue=] .
7832
+
7822
7833
1. If |preload script|'s <code> contexts</code> is not null:
7823
7834
7824
7835
1. Let |navigable id| be |navigable|’s [=navigable/top-level traversable=] 's id.
7825
7836
7826
- 1. If |preload script|'s <code> contexts</code> does not [=list/contains|contain=] |navigable id|, continue.
7837
+ 1. If |preload script|'s <code> contexts</code> does not [=list/contain=] |navigable id|,
7838
+ [=continue=] .
7827
7839
7828
7840
1. If |preload script|'s <code> sandbox</code> is not null, let |realm| be [=get
7829
7841
or create a sandbox realm=] with |preload script|'s <code> sandbox</code> and
@@ -9754,6 +9766,7 @@ script=].
9754
9766
functionDeclaration: text,
9755
9767
? arguments: [*script.ChannelValue] ,
9756
9768
? contexts: [+browsingContext.BrowsingContext] ,
9769
+ ? userContexts: [+browser.UserContext] ,
9757
9770
? sandbox: text
9758
9771
}
9759
9772
</pre>
@@ -9771,12 +9784,18 @@ script=].
9771
9784
<div algorithm="remote end steps for script.addPreloadScript">
9772
9785
The [=remote end steps=] given |session| and |command parameters| are:
9773
9786
9787
+ 1. If |command parameters| [=map/contains=] "<code> userContexts</code> "
9788
+ and |command parameters| [=map/contains=] "<code> contexts</code> ",
9789
+ return [=error=] with [=error code=] [=invalid argument=] .
9790
+
9774
9791
1. Let |function declaration| be the <code> functionDeclaration</code> field of |command
9775
9792
parameters|.
9776
9793
9777
9794
1. Let |arguments| be the <code> arguments</code> field of |command
9778
9795
parameters| if present, or an empty [=/list=] otherwise.
9779
9796
9797
+ 1. Let |user contexts| to be a [=/set=] .
9798
+
9780
9799
1. Let |navigables| be null.
9781
9800
9782
9801
1. If the <code> contexts</code> field of |command parameters| is present:
@@ -9791,17 +9810,29 @@ The [=remote end steps=] given |session| and |command parameters| are:
9791
9810
9792
9811
1. Append |navigable| to |navigables|.
9793
9812
9813
+ 1. Otherwise, if |command parameters| [=map/contains=] <code> userContexts</code> :
9814
+
9815
+ 1. Set |user contexts| to [=set/create|create a set=] with |command parameters|["<code>userContexts</code>"] .
9816
+
9817
+ 1. For each |user context id| of |user contexts|:
9818
+
9819
+ 1. Set |user context| to [=get user context=] with |user context id|.
9820
+
9821
+ 1. If |user context| is null, return [=error=] with [=error code=] [=no such user context=] .
9822
+
9794
9823
1. Let |sandbox| be the value of the "<code> sandbox</code> " field in |command
9795
9824
parameters|, if present, or null otherwise.
9796
9825
9797
9826
1. Let |script| be the string representation of a [[!RFC9562|UUID]] .
9798
9827
9799
9828
1. Let |preload script map| be |session|'s [=preload script map=] .
9800
9829
9801
- 1. Set |preload script map|[|script|] to a struct with <code> function
9802
- declaration</code> |function declaration|, <code> arguments</code>
9803
- |arguments|, <code> contexts</code>
9804
- |navigables|, and <code> sandbox</code> |sandbox|.
9830
+ 1. Set |preload script map|[|script|] to a struct with
9831
+ <code> function declaration</code> |function declaration|,
9832
+ <code> arguments</code> |arguments|,
9833
+ <code> contexts</code> |navigables|,
9834
+ <code> sandbox</code> |sandbox|, and
9835
+ <code> user contexts</code> |user contexts|.
9805
9836
9806
9837
1. Return a new [=/map=] matching the <code> script.AddPreloadScriptResult</code> with the
9807
9838
<code> script</code> field set to |script|.
0 commit comments