diff --git a/index.bs b/index.bs
index 74918963..bd5ab899 100644
--- a/index.bs
+++ b/index.bs
@@ -1257,8 +1257,55 @@ To get or create a sandbox realm given |name| and |navigable|:
To
create a sandbox realm 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
agent.
+
+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:
+
+
+ - The [=realm execution context=].
+
- Return |execution context|.
+
+
- The [=environment settings object/module map=]
+
- Return |global|'s module map.
+ Issue: Need to define module map for {{SandboxWindowProxy}} objects.
+
+
- The [=API base URL=]
+
- Return |window environment settings|' [=API base url=].
+
+
- [=environment settings object/origin=]
+
- Return |window environment settings|' [=environment settings object/origin=].
+
+
- [=environment settings object/policy container=]
+
- Return |window environment settings|' [=environment settings object/policy container=].
+
+
- The [=environment settings object/cross-origin isolated capability=]
+
- Return true.
+
+
- The [=time origin=]
+
- 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|
@@ -7093,8 +7140,8 @@ 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.
+arguments
, contexts
, which is a list or null, and an
+item named sandbox
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 run WebDriver BiDi preload scripts given |environment setti
1. If contexts
does not [=list/contains|contain=] |navigable id|, return.
- 1. If |preload script|'s sandbox
is not null, let |realm| be [=get
- or create a sandbox realm=] with |preload script|'s sandbox
and
- |navigable|. Otherwise let |realm| be |environment settings|'
- [=realm execution context=]'s Realm component.
+ 1. If |preload script|'s sandbox
is not null, let |realm| be
+ [=get or create a sandbox realm=] with |preload script|'s
+ sandbox
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=].