@@ -7524,8 +7524,9 @@ TODO: Extend this to scripts in other kinds of realms.
7524
7524
A [=BiDi session=] has a <dfn>preload script map</dfn> which is a [=/map=] in
7525
7525
which the keys are [[!RFC9562|UUID]] s, and the values are [=structs=] with an <a
7526
7526
for=struct> item</a> named <code> function declaration</code> , which is a string,
7527
- <code> arguments</code> , <code> contexts</code> , which is a list or null, and an item named <code> sandbox</code> which is a string
7528
- or null.
7527
+ <code> arguments</code> , <code> contexts</code> , which is a list or null,
7528
+ an item named <code> sandbox</code> , which is a string or null,
7529
+ and an item named <code> applyToOpeningContexts</code> , which is a boolean.
7529
7530
7530
7531
Note: If executing a [=preload script=] fails, either due to a syntax error, or
7531
7532
a runtime exception, an [[ECMAScript]] exception is reported in the realm in
@@ -7546,9 +7547,19 @@ To <dfn export>run WebDriver BiDi preload scripts</dfn> given |environment setti
7546
7547
7547
7548
1. If |preload script|'s <code> contexts</code> is not null:
7548
7549
7549
- 1. Let |navigable id | be |navigable|’s [=navigable/top-level traversable=] 's id .
7550
+ 1. Let |should script run | be false .
7550
7551
7551
- 1. If |preload script|'s <code> contexts</code> does not [=list/contains|contain=] |navigable id|, continue.
7552
+ 1. While |navigable| is not null:
7553
+
7554
+ 1. Let |navigable id| be |navigable|’s [=navigable/top-level traversable=] 's id.
7555
+
7556
+ 1. If |preload script|'s <code> contexts</code> [=list/contains=] |navigable id|,
7557
+ set |should run script| to true and break.
7558
+
7559
+ 1. If |preload script|'s <code> applyToOpeningContexts</code> is true,
7560
+ set |navigable| to |navigable|'s [=original opener=] . Otherwise, break.
7561
+
7562
+ 1. If |should script run| is false, continue;
7552
7563
7553
7564
1. If |preload script|'s <code> sandbox</code> is not null, let |realm| be [=get
7554
7565
or create a sandbox realm=] with |preload script|'s <code> sandbox</code> and
@@ -9479,6 +9490,7 @@ script=].
9479
9490
functionDeclaration: text,
9480
9491
? arguments: [*script.ChannelValue] ,
9481
9492
? contexts: [+browsingContext.BrowsingContext] ,
9493
+ ? applyToOpeningContexts: bool .default false,
9482
9494
? sandbox: text
9483
9495
}
9484
9496
</pre>
@@ -9519,14 +9531,18 @@ The [=remote end steps=] given |session| and |command parameters| are:
9519
9531
1. Let |sandbox| be the value of the "<code> sandbox</code> " field in |command
9520
9532
parameters|, if present, or null otherwise.
9521
9533
9534
+ 1. Let |applyToOpeningContexts| be true if |command parameters|["<code>applyToOpeningContexts</code>"]
9535
+ is true, and false otherwise.
9536
+
9522
9537
1. Let |script| be the string representation of a [[!RFC9562|UUID]] .
9523
9538
9524
9539
1. Let |preload script map| be |session|'s [=preload script map=] .
9525
9540
9526
9541
1. Set |preload script map|[|script|] to a struct with <code> function
9527
9542
declaration</code> |function declaration|, <code> arguments</code>
9528
9543
|arguments|, <code> contexts</code>
9529
- |navigables|, and <code> sandbox</code> |sandbox|.
9544
+ |navigables|, <code> sandbox</code> |sandbox|, and
9545
+ <code> applyToOpeningContexts</code> |applyToOpeningContexts|.
9530
9546
9531
9547
1. Return a new [=/map=] matching the <code> script.AddPreloadScriptResult</code> with the
9532
9548
<code> script</code> field set to |script|.
0 commit comments