-
Notifications
You must be signed in to change notification settings - Fork 46
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
Try to ensure sandboxed preload scripts run in the correct realm #768
Open
jgraham
wants to merge
1
commit into
main
Choose a base branch
from
sandbox_realm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1257,8 +1257,55 @@ To <dfn>get or create a sandbox realm</dfn> given |name| and |navigable|: | |
<div algorithm> | ||
To <dfn>create a sandbox realm</dfn> with |window|: | ||
|
||
Issue: Define creation of sandbox realm. This is going to return a | ||
{{SandboxWindowProxy}} wrapping |window|. | ||
1. Let |window environment settings| be the [=environment settings object=] whose | ||
[=relevant global object=] is |window|. | ||
|
||
1. Let |global| be a new {{SandboxWindowProxy}} wrapping |window|. | ||
|
||
Issue: This is the key step but it's basically totally undefined. | ||
|
||
1. Let |agent| be |window environment settings|'s [=realm=]'s <a spec=html for=realm>agent</a>. | ||
|
||
1. Let |execution context| be the result of [=creating a new realm=] given |agent| using | ||
|global| as the host-defined global object. | ||
|
||
1. Let |realm| be the value of |execution context|'s Realm component. | ||
|
||
1. Let |settings object| be a new [=environment settings object=] whose algorithms are defined as follows: | ||
|
||
<dl> | ||
<dt>The [=realm execution context=]. | ||
<dd>Return |execution context|. | ||
|
||
<dt>The [=environment settings object/module map=] | ||
<dd>Return |global|'s module map. | ||
Issue: Need to define module map for {{SandboxWindowProxy}} objects. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this issue is not rendered properly? Perhaps it needs newlines or needs to be outside of dl. |
||
|
||
<dt>The [=API base URL=] | ||
<dd>Return |window environment settings|' [=API base url=]. | ||
|
||
<dt>[=environment settings object/origin=] | ||
<dd>Return |window environment settings|' [=environment settings object/origin=]. | ||
|
||
<dt>[=environment settings object/policy container=] | ||
<dd>Return |window environment settings|' [=environment settings object/policy container=]. | ||
|
||
<dt>The [=environment settings object/cross-origin isolated capability=] | ||
<dd>Return true. | ||
|
||
<dt>The [=time origin=] | ||
<dd>Return |window environment settings|' [=time origin=]. | ||
|
||
1. Set |settings object|'s [=environment/id=] to a new unique opaque string, | ||
[=creation URL=] to |window environment settings|' [=creation URL=], | ||
[=top-level creation URL=] to |window environment settings|' [=top-level | ||
creation URL=], [=target browsing context=] to |window environment settings|' | ||
[=target browsing context=], [=active service worker=] to null, and | ||
[=top-level origin=] to |window environment settings|' [=top-level origin=]. | ||
|
||
1. Set |realm|'s \[[HostDefined]] field to |settings object|. | ||
|
||
1. Return |realm| | ||
|
||
</div> | ||
|
||
|
@@ -7093,8 +7140,8 @@ 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, and an | ||
item named <code>sandbox</code> which is a string or null. | ||
|
||
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 | ||
|
@@ -7119,10 +7166,12 @@ To <dfn export>run WebDriver BiDi preload scripts</dfn> given |environment setti | |
|
||
1. If <code>contexts</code> does not [=list/contains|contain=] |navigable id|, return. | ||
|
||
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 | ||
|navigable|. Otherwise let |realm| be |environment settings|' | ||
[=realm execution context=]'s Realm component. | ||
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 |navigable|, and set |environment settings| to | ||
the [=environment settings object=] whose [=realm execution context=]'s | ||
Realm component is |realm|. Otherwise let |realm| be | ||
|environment settings|' [=realm execution context=]'s Realm component. | ||
|
||
1. Let |exception reporting global| be be |environment settings|' | ||
[=realm execution context=]'s Realm component's [=realm/global object=]. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at call sites of "create a sandbox realm" the argument should be navigable, so probably we need the env settings object of |navigable|'s [=active window=].