Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow applying preload scripts to opened contexts #803

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -7524,8 +7524,9 @@ TODO: Extend this to scripts in other kinds of realms.
A [=BiDi session=] has a <dfn>preload script map</dfn> which is a [=/map=] in
which the keys are [[!RFC9562|UUID]]s, and the values are [=structs=] with an <a
for=struct>item</a> named <code>function declaration</code>, which is a string,
<code>arguments</code>, <code>contexts</code>, which is a list or null, and an item named <code>sandbox</code> which is a string
or null.
<code>arguments</code>, <code>contexts</code>, which is a list or null,
an item named <code>sandbox</code>, which is a string or null,
and an item named <code>applyToOpeningContexts</code>, which is a boolean.

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
Expand All @@ -7546,9 +7547,19 @@ To <dfn export>run WebDriver BiDi preload scripts</dfn> given |environment setti

1. If |preload script|'s <code>contexts</code> is not null:

1. Let |navigable id| be |navigable|’s [=navigable/top-level traversable=]'s id.
1. Let |is script run allowed| be false.

1. If |preload script|'s <code>contexts</code> does not [=list/contains|contain=] |navigable id|, continue.
1. While |navigable| is not null:

1. Let |navigable id| be |navigable|’s [=navigable/top-level traversable=]'s id.

1. If |preload script|'s <code>contexts</code> [=list/contains=] |navigable id|,
set |is script run allowed| to true and break.

1. If |preload script|'s <code>applyToOpeningContexts</code> is true,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
set |navigable| to |navigable|'s [=original opener=]. Otherwise, break.

1. If |is script run allowed| is false, continue;

1. If |preload script|'s <code>sandbox</code> is not null, let |realm| be [=get
or create a sandbox realm=] with |preload script|'s <code>sandbox</code> and
Expand Down Expand Up @@ -9479,6 +9490,7 @@ script=].
functionDeclaration: text,
? arguments: [*script.ChannelValue],
? contexts: [+browsingContext.BrowsingContext],
? applyToOpeningContexts: bool .default false,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
? sandbox: text
}
</pre>
Expand Down Expand Up @@ -9519,14 +9531,18 @@ The [=remote end steps=] given |session| and |command parameters| are:
1. Let |sandbox| be the value of the "<code>sandbox</code>" field in |command
parameters|, if present, or null otherwise.

1. Let |applyToOpeningContexts| be true if |command parameters|["<code>applyToOpeningContexts</code>"]
is true, and false otherwise.

1. Let |script| be the string representation of a [[!RFC9562|UUID]].

1. Let |preload script map| be |session|'s [=preload script map=].

1. Set |preload script map|[|script|] to a struct with <code>function
declaration</code> |function declaration|, <code>arguments</code>
|arguments|, <code>contexts</code>
|navigables|, and <code>sandbox</code> |sandbox|.
|navigables|, <code>sandbox</code> |sandbox|, and
<code>applyToOpeningContexts</code> |applyToOpeningContexts|.

1. Return a new [=/map=] matching the <code>script.AddPreloadScriptResult</code> with the
<code>script</code> field set to |script|.
Expand Down