diff --git a/index.bs b/index.bs index ea638529..2e441226 100644 --- a/index.bs +++ b/index.bs @@ -7797,10 +7797,12 @@ before any author-defined script have run. TODO: Extend this to scripts in other kinds of realms. A [=BiDi session=] has a preload script map which is a [=/map=] in -which the keys are [[!RFC9562|UUID]]s, and the values are [=structs=] with an item named function declaration, which is a string, -arguments, contexts, which is a list or null, and an item named sandbox which is a string -or null. +which the keys are [[!RFC9562|UUID]]s, and the values are [=structs=] with +an [=struct/item=] named function declaration, which is a string, +an [=struct/item=] named arguments, which is a list, +an [=struct/item=] named contexts, which is a list or null, +an [=struct/item=] named sandbox, which is a string or null, +and an [=struct/item=] named user contexts, which is a [=/set=]. Note: If executing a [=preload script=] fails, either due to a syntax error, or a runtime exception, an [[ECMAScript]] exception is reported in the realm in @@ -7814,16 +7816,26 @@ To run WebDriver BiDi preload scripts given |environment setti 1. Let |navigable| be |document|'s [=/navigable=]. +1. Let |user context| be |navigable|'s [=associated user context=]. + +1. Let |user context id| be |user context|'s [=user context id=]. + 1. For each |session| in [=active BiDi sessions=]: 1. For each |preload script| in |session|'s [=preload script map=]'s [=values=]: + 1. If |preload script|'s user contexts's [=set/size=] is not zero: + + 1. If |preload script|'s user contexts does not [=list/contain=] |user context id|, + [=continue=]. + 1. If |preload script|'s contexts is not null: 1. Let |navigable id| be |navigable|’s [=navigable/top-level traversable=]'s id. - 1. If |preload script|'s contexts does not [=list/contains|contain=] |navigable id|, continue. + 1. If |preload script|'s contexts does not [=list/contain=] |navigable id|, + [=continue=]. 1. If |preload script|'s sandbox is not null, let |realm| be [=get or create a sandbox realm=] with |preload script|'s sandbox and @@ -9754,6 +9766,7 @@ script=]. functionDeclaration: text, ? arguments: [*script.ChannelValue], ? contexts: [+browsingContext.BrowsingContext], + ? userContexts: [+browser.UserContext], ? sandbox: text } @@ -9771,12 +9784,18 @@ script=].
The [=remote end steps=] given |session| and |command parameters| are: +1. If |command parameters| [=map/contains=] "userContexts" + and |command parameters| [=map/contains=] "contexts", + return [=error=] with [=error code=] [=invalid argument=]. + 1. Let |function declaration| be the functionDeclaration field of |command parameters|. 1. Let |arguments| be the arguments field of |command parameters| if present, or an empty [=/list=] otherwise. +1. Let |user contexts| to be a [=/set=]. + 1. Let |navigables| be null. 1. If the contexts field of |command parameters| is present: @@ -9791,6 +9810,16 @@ The [=remote end steps=] given |session| and |command parameters| are: 1. Append |navigable| to |navigables|. +1. Otherwise, if |command parameters| [=map/contains=] userContexts: + + 1. Set |user contexts| to [=set/create|create a set=] with |command parameters|["userContexts"]. + + 1. For each |user context id| of |user contexts|: + + 1. Set |user context| to [=get user context=] with |user context id|. + + 1. If |user context| is null, return [=error=] with [=error code=] [=no such user context=]. + 1. Let |sandbox| be the value of the "sandbox" field in |command parameters|, if present, or null otherwise. @@ -9798,10 +9827,12 @@ The [=remote end steps=] given |session| and |command parameters| are: 1. Let |preload script map| be |session|'s [=preload script map=]. -1. Set |preload script map|[|script|] to a struct with function - declaration |function declaration|, arguments - |arguments|, contexts - |navigables|, and sandbox |sandbox|. +1. Set |preload script map|[|script|] to a struct with + function declaration |function declaration|, + arguments |arguments|, + contexts |navigables|, + sandbox |sandbox|, and + user contexts |user contexts|. 1. Return a new [=/map=] matching the script.AddPreloadScriptResult with the script field set to |script|.