diff --git a/source b/source index 0d819eccb96..b09e547904a 100644 --- a/source +++ b/source @@ -2868,6 +2868,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
[Global]
[LegacyFactoryFunction]
[LegacyLenientThis]
User agents that support JavaScript must also implement the ShadowRealm API + proposal. The following terms are defined there, and used in this specification: + JSSHADOWREALM
+ +DOMHighResTimeStamp
Performance
If the current settings object's If the current principal settings object's cross-origin isolated
capability is false, then throw a "DataCloneError
"
DOMException
.
The The structuredClone(value,
options)
method steps are:
Let registry be the current global object's +
Let registry be the current principal global object's
CustomElementRegistry
object.
Let element be the result of internally creating a new object implementing the interface - to which the active function object corresponds, given the current + to which the active function object corresponds, given the current principal realm and NewTarget.
Set element's node document to the current global
- object's associated
+ Set element's node document to the current principal
+ global object's associated
Set element's namespace to
@@ -29913,7 +29927,7 @@ img.decode().then(() => {
the legacy factory function must perform the following steps: Let document be the current global object's Let document be the current principal global object's associated Let img be the result of creating an
@@ -35449,7 +35463,7 @@ interface HTMLAudioElement : HTMLMediaElement
must perform the following steps: Let document be the current global object's Let document be the current principal global object's associated Let audio be the result of creating an
@@ -54655,7 +54669,7 @@ interface HTMLOptionElement : HTMLElement {
function must perform the following steps: Let document be the current global object's Let document be the current principal global object's associated Let option be the result of creating an
@@ -63265,8 +63279,8 @@ document.body.append(script1, script2);
Let script be the result of creating a classic script using
- source text, settings object, base URL, and
- options. Mark as ready el given script. Return true if the current settings object's Return true if the current principal settings object's origin is same origin-domain with
O's relevant settings object's origin, and false otherwise. This abstract operation does not return a Completion Record. Here the current settings object roughly corresponds to the "caller",
- because this check occurs before the execution
- context for the getter/setter/method in question makes its way onto the JavaScript
- execution context stack. For example, in the code Here the current principal settings object roughly corresponds to the
+ "caller", because this check occurs before the execution context for the getter/setter/method in question makes its way onto the
+ JavaScript execution context stack. For example, in the code Document
.
-
Document
.
-
Document
.
-
@@ -63809,7 +63823,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
to a Document
.
Document
object with a null browsing
context, and, accordingly, any script
elements they create need to have
their already started set to true in the prepare the script element
- algorithm and never get executed (scripting is
+ algorithm and never get executed (scripting is
disabled). Such script
elements still need to have their parser
document set, though, such that their async
IDL
attribute will return false in the absence of an async
@@ -89499,7 +89513,7 @@ dictionary DragEventInit : MouseEventInit {
IsPlatformObjectSameOrigin ( O )
-
w.document
, this
- step is invoked before the document
getter is reached as part
- of the [[Get]] algorithm for the WindowProxy
- w.w.document
, this step is invoked before the document
getter is reached as part of the [[Get]] algorithm for the WindowProxy
w.CrossOriginGetOwnPropertyHelper ( O, P )
@@ -89522,8 +89536,9 @@ dictionary DragEventInit : MouseEventInit {
practice this is handled by the caller calling CrossOriginPropertyFallback.
Let crossOriginKey be a tuple consisting of the current settings - object, O's relevant settings object, and P.
Let crossOriginKey be a tuple consisting of the current principal + settings object, O's relevant settings object, and + P.
For each e of CrossOriginProperties(O):
@@ -89574,8 +89589,8 @@ dictionary DragEventInit : MouseEventInit {Let crossOriginSet be undefined.
If e.[[NeedsSet]] is true, then set crossOriginSet to an - anonymous built-in function, created in the current realm, that performs the - same steps as the setter of the IDL attribute P on object + anonymous built-in function, created in the current realm, that + performs the same steps as the setter of the IDL attribute P on object O.
Set crossOriginDesc to PropertyDescriptor{
@@ -90602,7 +90617,7 @@ dictionary WindowPostMessageOptions : StructuredSeri
If container's node document's origin is not same origin-domain with the
- current settings object's current principal settings object's origin, then return null. Return container.
Check if an access between two browsing contexts - should be reported, given the current global object's + should be reported, given the current principal global object's browsing context, W's browsing context, P, and the current settings - object.
If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
Check if an access between two browsing contexts - should be reported, given the current global object's browsing - context, W's browsing context, P, - and the current settings object.
If IsPlatformObjectSameOrigin(W) is true, then:
@@ -93118,8 +93134,8 @@ enum NavigationHistoryBehavior {Prepare to run script given navigation's relevant settings - object.
+Prepare to run script given navigation's relevant realm.
See the discussion for other navigation API events to understand why we do this.
@@ -93143,8 +93159,8 @@ enum NavigationHistoryBehavior {Clean up after running script given navigation's relevant - settings object.
Clean up after running script given navigation's relevant realm.
In implementations, same-document navigations can cause is same document is true.
Prepare to run script given navigation's relevant settings - object.
+Prepare to run script given navigation's relevant realm.
@@ -106295,16 +106312,32 @@ new PaymentRequest(…); // Allowed to useThe JavaScript specification introduces the realm concept, representing a global - environment in which script is run. Each realm comes with an implementation-defined - global object; much of this specification is devoted to defining that global object - and its properties.
+ environment in which script is run. + +In the context of the JavaScript ShadowRealm API proposal, there are two kinds of realms: + JSSHADOWREALM
+ +A principal realm comes with an implementation-defined + global object; much of this specification is devoted to defining that global object + and its properties.
A synthetic realm is created by the ShadowRealm API and includes a reduced set + of properties.
For web specifications, it is often useful to associate values or algorithms with a
- realm/global object pair. When the values are specific to a particular type of realm, they are
- associated directly with the global object in question, e.g., in the definition of the
+ principal realm/global object pair. When the values are specific to a particular type of realm,
+ they are associated directly with the global object in question, e.g., in the definition of the
Window
or WorkerGlobalScope
interfaces. When the values have utility
across multiple realms, we use the environment settings object concept.
Each synthetic realm originates from a principal realm + (its settings object's + principal realm). + Generally, in contexts where the associated values or algorithms of a realm are needed, + the associated values and algorithms of this associated principal realm are used.
+Finally, in some cases it is necessary to track associated values before a realm/global object/environment settings object even comes into existence (for example, during navigation). These values are tracked in the @@ -106446,13 +106479,44 @@ new PaymentRequest(…); // Allowed to use object's relevant agent's event loop.
+Each synthetic realm has an associated synthetic realm settings object + with the following fields:
+ +An execution context
The JavaScript execution context for the scripts within this realm.
A principal realm
The principal realm which this synthetic realm exists within.
A module map
A module map that is used when importing JavaScript modules.
A global object is a JavaScript object that is the [[GlobalObject]] field of a realm.
-In this specification, all realms are created with global
+ A realm's global object is found in its [[GlobalObject]] field. A global
+ object's realm is the unique
+ realm whose global object is that object. A principal global object is a global object of a principal
+ realm. Similarly, a synthetic global object is a global object of a
+ synthetic realm. In this specification, all principal realms
+ are created with global
objects that are either There is always a 1-to-1-to-1 mapping between realms, global objects, and environment settings objects: There is always a 1-to-1-to-1 mapping between principal
+ realms, principal global objects, and environment settings objects: A realm has a [[HostDefined]] field, which contains the realm's
- settings object. A principal realm has a [[HostDefined]] field, which contains the
+ principal realm's settings object. A realm has a [[GlobalObject]] field, which contains the realm's global
- object. A principal realm has a global
+ object. Each global object in this specification is created during the creation of a corresponding realm, known as
- the global
- object's realm. Each principal global object in this specification is created during the
+ creation of a corresponding principal
+ realm, which is the global object's
+ realm. Each global object in this
- specification is created alongside a corresponding environment settings object,
- known as its relevant settings object. Each principal global object
+ in this specification is created alongside a corresponding environment settings
+ object, known as its relevant settings object. An environment settings object's realm execution context's
Realm component is
+ Analogously, there is always a 1-to-1-to-1 mapping between synthetic realms, synthetic global
+ objects, and synthetic realm settings
+ objects: A synthetic realm has a [[HostDefined]] field, which contains the synthetic realm's settings
+ object. A synthetic realm has a global
+ object. Each synthetic global object in this specification is created as part of the
+ Each synthetic global object in this specification is created alongside a
+ corresponding synthetic realm settings object, known as its relevant synthetic
+ realm settings object. A synthetic realm settings object's realm execution context's
+ Realm component is the synthetic realm settings object's realm. A synthetic realm settings object's synthetic realm settings object's global object is its
+ realm's
+ global. The principal realm of any
+ realm realm is defined by the following algorithm: If realm.[[HostDefined]] is a synthetic realm settings object,
+ then: Assert: realm is a synthetic realm. Set realm to the principal realm of
+ realm.[[HostDefined]]. Assert: realm.[[HostDefined]] is an environment settings
+ object and realm is a principal realm. Return realm. The execution context of a
+ realm realm is defined by the following algorithm: If realm is a principal realm, then return the
+ realm execution context of the
+ environment settings object of
+ realm. Assert: realm is a synthetic realm. Return the execution context
+ of the synthetic realm settings
+ object of realm. The module map of a realm
+ realm is defined by the following algorithm: If realm is a principal realm, then return the module map of the
+ environment settings object of
+ realm. Assert: realm is a synthetic realm. Return the module map
+ of the synthetic realm settings
+ object of realm. When defining algorithm steps throughout this specification, it is often important to indicate
what realm is to be used—or, equivalently, what global object or
- environment settings object is to be used. In general, there are at least four
- possibilities:Window
, WorkerGlobalScope
, or
WorkletGlobalScope
objects.
-
-
+
+
+ ShadowRealm
constructor, which creates the global object's realm.
+
+
+
+
+
+
+
+
+
+
+
+
The incumbent realm is that of b.html
.
The current realm is that of c.html
(since it is the
- print()
method from c.html
whose code is
- running).
The current realm is that of c.html
(since it is the print()
method from
+ c.html
whose code is running).
The relevant realm of the object on which
the print()
method is being called is that of d.html
.
With this in hand, we define the entry execution context to be the most recently pushed item in the JavaScript execution context stack that is a realm execution context. The entry - realm is the entry execution context's Realm component.
+ realm is the principal realm of the + entry execution context's Realm component.Then, the entry settings object is the environment settings object of the cleaning up after running a callback, this value will be incremented and decremented.
-Every event loop has an associated backup incumbent settings object - stack, initially empty. Roughly speaking, it is used to determine the incumbent - settings object when no author code is on the stack, but author code is responsible for the - current algorithm having been run in some way. The process of preparing to run a callback and cleaning up after running a callback manipulate this stack. WEBIDL
+Every event loop has an associated backup incumbent realm stack, + initially empty. Roughly speaking, it is used to determine the incumbent realm when no author code is on the stack, but + author code is responsible for the current algorithm having been run in some way. + The process of preparing to run a callback and + cleaning up after running a callback + manipulate this stack. WEBIDL
When Web IDL is used to invoke author code, or when HostEnqueuePromiseJob invokes a promise job, they use the following - algorithms to track relevant data for determining the incumbent settings object:
+ algorithms to track relevant data for determining the incumbent realm: -To prepare to run a callback with an environment settings object - settings:
+To prepare to run a callback with a realm realm:
Push settings onto the backup incumbent settings object - stack.
Push realm onto the backup incumbent realm stack.
Let context be the topmost script-having execution context.
To clean up after running a callback with an environment settings - object settings:
+To clean up after running a callback with a realm + realm:
If context is not null, decrement context's skip-when-determining-incumbent counter.
Assert: the topmost entry of the backup incumbent settings object - stack is settings.
Assert: the topmost entry of the backup incumbent realm stack is + realm.
Remove settings from the backup incumbent settings object - stack.
Remove realm from the backup incumbent realm stack.
Here, the topmost script-having execution context is the topmost entry of the JavaScript execution context stack that has a non-null ScriptOrModule component, or null if there is no such entry in the JavaScript execution context stack.
-With all this in place, the incumbent settings object is determined as - follows:
+With all this in place, the incumbent realm + is determined as follows:
Let context be the topmost script-having execution
@@ -106824,31 +106977,30 @@ new PaymentRequest(…); // Allowed to use
Assert: the backup incumbent settings object stack is not
- empty. This assert would fail if you try to obtain the incumbent settings
- object from inside an algorithm that was triggered neither by calling scripts nor by Web IDL invoking a callback. For example, it would
- trigger if you tried to obtain the incumbent settings object inside an algorithm
- that ran periodically as part of the event loop, with no involvement of author
- code. In such cases the incumbent concept
- cannot be used. Assert: the backup incumbent realm stack is not empty. This assert would fail if you try to obtain the incumbent realm from inside an algorithm that was
+ triggered neither by calling scripts nor by Web IDL invoking a callback.
+ For example, it would trigger if you tried to obtain the incumbent realm inside an algorithm that ran
+ periodically as part of the event loop, with no involvement of author code.
+ In such cases the incumbent concept cannot
+ be used. Return the topmost entry of the backup incumbent settings object
- stack. Return the topmost entry of the backup incumbent realm stack.
Return context's Realm component's settings object.
Return context's Realm component.
Then, the incumbent realm is the realm of the incumbent settings - object.
+Then, the incumbent settings object is the + incumbent realm's + principal realm's + settings object.
Similarly, the incumbent global object is
the global object of the incumbent
@@ -106868,10 +107020,10 @@ new PaymentRequest(…); // Allowed to use
frames[0].postMessage("some data", "*");
</script>
- There are two interesting environment settings
- objects here: that of There are two interesting realms here: that of
+ It should be that of This time, the result involves more complicated mechanisms: When window
, and that of frames[0]
. Our concern is: what is the incumbent settings object at
- the time that the algorithm for postMessage()
+ window
, and that of frames[0]
.
+ Our concern is: what is the incumbent realm at the
+ time that the algorithm for postMessage()
executes?window
, to capture the intuitive notion that the
@@ -106921,15 +107073,15 @@ new PaymentRequest(…); // Allowed to use
bound
is converted to a
- Web IDL callback type, the incumbent settings object is that corresponding to window
(in the same manner as in our starter example above). Web IDL stores this
- as the resulting callback value's callback context.window
(in the same manner as in our starter example
+ above). Web IDL stores this as the resulting callback value's callback context.
When the task posted by setTimeout()
executes, the algorithm for that task uses Web IDL to
invoke the stored callback value. Web IDL in
turn calls the above prepare to run a callback algorithm. This pushes the stored
- callback context onto the backup incumbent settings object stack. At
+ callback context onto the backup incumbent realm stack. At
this time (inside the timer task) there is no author code on the stack, so the topmost
script-having execution context is null, and nothing gets its
skip-when-determining-incumbent counter incremented.
This is where we fall back to the backup incumbent settings object stack. As
- noted above, it will contain as its topmost entry the relevant settings object of
- window
. So that is what is used as the incumbent settings
- object while executing the postMessage()
- algorithm.
This is where we fall back to the backup incumbent realm stack.
+ As noted above, it will contain as its topmost entry the relevant realm of window
.
+ So its settings object is what is used as the
+ incumbent settings object while executing the postMessage()
algorithm.
Again there are two interesting environment
- settings objects in play: that of a.html
, and that of b.html
. When the location.assign()
- method triggers the Location
-object navigate algorithm, what will be
- the incumbent settings object? As before, it should intuitively be that of a.html
: the click
listener was originally
- scheduled by a.html
, so even if something involving b.html
causes the listener to fire, the incumbent responsible is that of a.html
.
Again there are two interesting realms in play: that of
+ a.html
, and that of b.html
.
+ When the location.assign()
method triggers the
+ Location
-object navigate algorithm, what will be the incumbent realm?
+ As before, it should intuitively be that of a.html
: the click
listener was originally scheduled by a.html
, so even if something involving b.html
causes the
+ listener to fire, the incumbent responsible is
+ that of a.html
.
The callback setup is similar to the previous example: when bound
is
- converted to a Web IDL callback type, the
- incumbent settings object is that corresponding to a.html
,
- which is stored as the callback's callback context.
a.html
, which is stored as the callback's callback context.
When the click()
method is called inside b.html
, it dispatches a is author code on the stack; the topmost
script-having execution context is that of the
onLoad
function,
whose skip-when-determining-incumbent counter gets incremented. Additionally, a.html
's environment settings object (stored as the
- EventHandler
's callback context) is pushed onto the
- backup incumbent settings object stack.
EventHandler
's
+ callback context) is pushed onto the backup incumbent realm stack.
Now, when the Location
-object navigate algorithm looks up the
- incumbent settings object, the topmost script-having execution
- context is still that of the onLoad
function (due to the fact we
- are using a bound function as the callback). Its skip-when-determining-incumbent
- counter value is one, however, so we fall back to the backup incumbent settings
- object stack. This gives us the environment settings object of a.html
, as expected.
onLoad
+ function (due to the fact we are using a bound function as the callback).
+ Its skip-when-determining-incumbent counter value is one, however, so we fall back
+ to the backup incumbent realm stack.
+ This gives us the realm of a.html
, as expected.
Note that this means that even though it is the iframe
inside a.html
that navigates, it is a.html
itself that is used
@@ -107024,12 +107176,27 @@ document.querySelector("button").addEventListener("click", bound);
The JavaScript specification defines the current realm, also known as the "current Realm Record". JAVASCRIPT
-Then, the current settings object is the environment settings object of the current
+ The current principal realm is the principal realm of the current
realm. Similarly, the current global object is the global object of the current realm. Then, the current principal settings object is the environment settings object of the current
+ principal realm. Similarly, the current principal global object is the global object of the
+ current principal realm. Note that the current realm can refer to a synthetic realm.
+ Whether to use the "current" or "current principal" concept depends on the situation.
+ For example, if you need a realm to create an object or a function you should probably
+ use the current realm, while if you are checking whether some operation is allowed or not
+ in the current context you are probably looking for the current principal settings
+ object; notably the settings object for a synthetic realm contains much less
+ information.
+ Note that in the context of APIs that are not exposed in a synthetic realm, both
+ concepts coincide.Relevant
@@ -107047,47 +107214,59 @@ document.querySelector("button").addEventListener("click", bound);
object of the relevant realm for
o.
The relevant principal realm for a platform object o + is o's relevant realm's + principal realm.
+ +The relevant principal settings object for a platform object + o is o's relevant principal realm's + environment settings object.
+ +The relevant principal global object for a platform object + o is o's relevant principal realm's + global object.
+Scripting is enabled for - an environment settings object settings when all of the following - conditions are true:
+Scripting is enabled for a realm realm + when all of the following conditions are true:
Window
object,
- or settings's global object's
+ Window
object,
+ or realm's global object's
associated Document
's active
sandboxing flag set does not have its sandboxed scripts browsing context flag
set.Scripting is disabled - for an environment settings object when scripting is not enabled for it, i.e., when any of the above conditions - are false.
+Scripting is disabled for a realm when + scripting is not enabled for it, i.e., when any of the + above conditions are false.
Scripting is enabled for a node node if node's node document's browsing - context is non-null, and scripting is - enabled for node's relevant settings object.
+ context is non-null, and scripting is + enabled for node's relevant + realm.Scripting is disabled for a node when scripting is not enabled, i.e., when its node document's browsing context is null or when scripting is disabled for its relevant settings - object.
+ data-x="concept-realm-noscript">scripting is disabled for its relevant realm.An environment settings object, containing various settings that are shared - with other scripts in the same context.
A realm where the script is evaluated, which is shared with other + scripts in the same context. Note that, in the case of + module scripts (but not classic scripts), this realm can be a synthetic + realm.
The settings object of a script is the + settings object of the + principal realm of the script's + realm.
A classic script is a type of script that has the following additional item:
@@ -107564,9 +107750,9 @@ document.querySelector("button").addEventListener("click", bound); CORS-cross-origin, and false otherwise.Let script be the result of creating a classic script given - sourceText, settingsObject, response's URL, options, - mutedErrors, and url.
Let script be the result of creating a classic script using - sourceText, settingsObject, response's URL, and the default script fetch - options.
Run onComplete given script.
Let script be the result of creating a classic script given - sourceText, settingsObject, response's URL, the default script fetch options, and - mutedErrors.
Return script.
Fetch a single module script given url, settingsObject,
- "script
", options, settingsObject, "script
", options, settingsObject's
+ realm, "client
", true, and with the following steps given result:
Fetch a single module script given url, settingsObject,
- destination, options, settingsObject, "destination, options, settingsObject's
+ realm, "
client
", true, and with the following steps given result:
Let script be the result of creating a JavaScript module script - using sourceText, settingsObject, baseURL, and + using sourceText, settingsObject's + realm, baseURL, and options.
Fetch the descendants of
@@ -107967,7 +108156,8 @@ document.querySelector("button").addEventListener("click", bound);
Fetch a single module script given url,
- fetchClient, destination, options, settingsObject,
+ fetchClient, destination, options, settingsObject's
+ realm,
" To fetch a single module script, given a URL url, an
environment settings object fetchClient, a destination destination, a script
- fetch options options, an environment settings object
- settingsObject, a referrer
- referrer, an optional ModuleRequest Record moduleRequest, a
- boolean isTopLevel, an algorithm
+ fetch optionsclient
", true, and onSingleFetchComplete as defined below. If
performFetch was given, pass it along as well.
Assert: the result of running the module type allowed steps - given moduleType and settingsObject is true. Otherwise, we would not have - reached this point because a failure would have been raised when inspecting - moduleRequest.[[Attributes]] in - HostLoadImportedModule or fetch a single imported module script.
Let moduleMap be settingsObject's module map.
Let moduleMap be moduleMapRealm's module map.
If moduleMap[(url, moduleType)] is
"fetching
", wait in parallel until that entry's value
@@ -108176,8 +108367,8 @@ document.querySelector("button").addEventListener("click", bound);
"application/wasm
" and moduleType is "javascript-or-wasm
", then set moduleScript to the result of
creating a WebAssembly module script given bodyBytes,
- settingsObject, response's URL, and options.
Otherwise:
@@ -108188,18 +108379,18 @@ document.querySelector("button").addEventListener("click", bound);If mimeType is a JavaScript MIME type and moduleType
is "javascript-or-wasm
", then set moduleScript to the result of
creating a JavaScript module script given sourceText,
- settingsObject, response's moduleMapRealm, response's URL, and options.
If the MIME type essence of mimeType is "text/css
"
and moduleType is "css
", then set moduleScript to
the result of creating a CSS module script given sourceText and
- settingsObject.
If mimeType is a JSON MIME type and
moduleType is "json
", then set moduleScript to
the result of creating a JSON module script given sourceText and
- settingsObject.
To fetch a single imported module script, given a URL url, an environment settings object fetchClient, a destination destination, a script - fetch options options, environment settings object - settingsObject, a referrer - referrer, a ModuleRequest Record moduleRequest, an - algorithm onComplete, and an optional options, a realm moduleMapRealm, + a referrer referrer, + a ModuleRequest Record moduleRequest, + an algorithm onComplete, and an optional perform the fetch hook performFetch, run these steps. onComplete must be an algorithm accepting null (on failure) or a module script (on success).
@@ -108239,11 +108430,11 @@ document.querySelector("button").addEventListener("click", bound); request steps given moduleRequest.If the result of running the module type allowed steps given - moduleType and settingsObject is false, then run onComplete - given null, and return.
Fetch a single module script given url, fetchClient, - destination, options, settingsObject, referrer, + destination, options, moduleMapRealm, referrer, moduleRequest, false, and onComplete. If performFetch was given, pass it along as well.
To create a classic script, given a - string source, an environment settings object - settings, a URL baseURL, a script fetch options - options, an optional boolean mutedErrors (default false), and an optional + string source, a realm realm, + a URL baseURL, a script fetch options options, + an optional boolean mutedErrors (default false), and an optional URL-or-null sourceURLForWindowScripts (default null):
If scripting is disabled for - settings, then set source to the empty string.
If scripting is disabled for + realm, then set source to the empty string.
Let script be a new classic script that this algorithm will subsequently initialize.
Set script's settings - object to settings.
Set script's realm to + realm.
Set script's base URL to baseURL.
Let result be ParseScript(source, - settings's realm, - script).
+ realm, script).Passing script as the last parameter here ensures result.[[HostDefined]] will be script.
@@ -108318,19 +108508,19 @@ document.querySelector("button").addEventListener("click", bound);To create a JavaScript module script, - given a string source, an environment settings - object settings, a URL baseURL, and a script fetch - options options:
+ given a string source, a realm realm, + a URL baseURL, and a script fetch options + options:If scripting is disabled for - settings, then set source to the empty string.
If scripting is disabled for + realm, then set source to the empty string.
Let script be a new module script that this algorithm will subsequently initialize.
Set script's settings - object to settings.
Set script's realm to + realm.
Set script's base URL to baseURL.
Let result be ParseModule(source, - settings's realm, - script).
+ realm, script).Passing script as the last parameter here ensures result.[[HostDefined]] will be script.
@@ -108368,15 +108557,14 @@ document.querySelector("button").addEventListener("click", bound);To create a WebAssembly module script, - given a byte sequence bodyBytes, an environment settings - object settings, a URL baseURL, and a script fetch - options options:
+ given a byte sequence bodyBytes, a realm realm, + a URL baseURL, and a script fetch options + options:If scripting is disabled for - settings, then set bodyBytes to the byte sequence 0x00 0x61 0x73 0x6d 0x01 - 0x00 0x00 0x00.
+If scripting is disabled for realm, + then set bodyBytes to the byte sequence 0x00 0x61 0x73 0x6d 0x01 0x00 0x00 0x00.
This byte sequence corresponds to an empty WebAssembly module with only the magic bytes and version number provided.
@@ -108385,8 +108573,8 @@ document.querySelector("button").addEventListener("click", bound);Let script be a new module script that this algorithm will subsequently initialize.
Set script's settings - object to settings.
Set script's realm to + realm.
Set script's base URL to baseURL.
Let result be the result of parsing a - WebAssembly module given bodyBytes, - settings's realm, and + WebAssembly module given bodyBytes, realm, and script.
Passing script as the last parameter here ensures @@ -108430,14 +108617,14 @@ document.querySelector("button").addEventListener("click", bound); and multi-instantiation. WASMESM
To create a CSS module script, given a - string source and an environment settings object settings:
+ string source and a realm realm:Let script be a new module script that this algorithm will subsequently initialize.
Set script's settings - object to settings.
Set script's realm to + realm.
Set script's base URL and fetch options to null.
To create a JSON module script, given a - string source and an environment settings object settings:
+ string source and a realm realm:Let script be a new module script that this algorithm will subsequently initialize.
Set script's settings - object to settings.
Set script's realm to + realm.
Set script's base URL and fetch options to null.
The module type allowed steps, given a string moduleType - and an environment settings object settings, are as follows:
+ and a realm realm, are as follows:If moduleType is not " If moduleType is "javascript-or-wasm
", "css
" and the
CSSStyleSheet
interface is not exposed in
- settings's realm, then
- return false.
Return true.
Let settings be the settings - object of script.
Let realm be the realm of + script.
Check if we can run script with settings. If this returns "do +
Check if we can run script with realm. If this returns "do not run" then return NormalCompletion(empty).
Record classic script execution start time given script.
Prepare to run script given settings.
Prepare to run script given realm.
Let evaluationStatus be null.
Clean up after running script with settings.
Clean up after running script with realm.
Rethrow evaluationStatus.[[Value]].
Clean up after running script with settings.
Clean up after running script with realm.
Throw a "NetworkError
" DOMException
.
Report an exception given by evaluationStatus.[[Value]] for - script's settings object's - global object.
Clean up after running script with settings.
Clean up after running script with realm.
Return evaluationStatus.
Clean up after running script with settings.
Clean up after running script with realm.
If evaluationStatus is a normal completion, then return evaluationStatus.
Let settings be the settings - object of script.
Let realm be the realm of + script.
Check if we can run script with settings. If this returns "do not +
Check if we can run script with realm. If this returns "do not run", then return a promise resolved with undefined.
Record module script execution start time given script.
Prepare to run script given settings.
Prepare to run script given realm.
Let evaluationPromise be null.
If preventErrorReporting is false, then upon rejection of evaluationPromise with reason, report an exception given by - reason for script's settings - object's global object.
Clean up after running script with settings.
Clean up after running script with realm.
Return evaluationPromise.
The steps to check if we can run script with an environment settings - object settings are as follows. They return either "run" or "do not run".
+The steps to check if we can run script with a realm realm + are as follows. They return either "run" or "do not run".
If the global object specified by
- settings is a Window
object whose Document
object is not
+
If the global object specified by
+ realm is a Window
object whose Document
object is not
fully active, then return "do not run".
If scripting is disabled for - settings, then return "do not run".
+If scripting is disabled for + realm, then return "do not run".
Return "run".
The steps to prepare to run script with an environment settings - object settings are as follows:
+The steps to prepare to run script with a realm realm + are as follows:
Push settings's realm execution context onto the JavaScript - execution context stack; it is now the running JavaScript execution - context.
Push realm's execution + context onto the JavaScript execution context stack; it is now the + running JavaScript execution context.
If realm is a principal realm:
-Add settings to the surrounding agent's event loop's currently running task's - script evaluation environment settings object set.
Let settings be realm's settings object.
Add settings to the surrounding agent's event loop's currently running task's + script evaluation environment settings object set.
The steps to clean up after running script with an environment settings - object settings are as follows:
+The steps to clean up after running script with a realm + realm are as follows:
Assert: settings's realm execution context is the +
Assert: realm's execution context is the running JavaScript execution context.
Remove settings's realm execution context from the - JavaScript execution context stack.
Remove realm's execution + context from the JavaScript execution context stack.
If the JavaScript execution context stack is now empty, perform a microtask checkpoint. (If this runs scripts, these algorithms will be invoked @@ -108944,7 +109139,7 @@ document.querySelector("button").addEventListener("click", bound);
The The reportError(e)
method steps are to
report an exception e for this.
Let settingsObject and baseURL be null.
Let realm and baseURL be null.
If referringScript is not null, then:
Set settingsObject to referringScript's - settings object.
Set realm to referringScript's + realm.
Set baseURL to referringScript's base URL.
Assert: there is a current settings object.
Assert: there is a current realm.
Set settingsObject to the current settings object.
Set realm to the current realm.
Set baseURL to settingsObject's API base - URL.
Set baseURL to realm's + principal realm's + settings object's + API base URL.
Let importMap be an empty import map.
If settingsObject's global
- object implements Window
, then set importMap to
- settingsObject's global object's
+
If realm's global object implements
+ Window
, then set importMap to realm's
+ global object's
import map.
Let serializedBaseURL be baseURL, PromiseRejectionEventInit : EventInitIf result is not null, then:
Add module to resolved module set given settingsObject, - serializedBaseURL, normalizedSpecifier, and asURL.
Add module to resolved module set given realm's + global object, serializedBaseURL, + normalizedSpecifier, and asURL.
Return result.
Import maps are not currently supported in + synthetic realms. This could change in the future.
+The simplest use of import maps is to globally remap a bare module specifier:
@@ -109708,14 +109909,15 @@ dictionary PromiseRejectionEventInit : EventInitspecifier as a URL with a boolean that indicates that the specifier is either bare or URL-like that is special. -To add module to resolved module set given an environment settings - object settingsObject, a string serializedBaseURL, a - string normalizedSpecifier, and a URL-or-null - asURL:
+To add module to resolved module set given + a realm realm, + a string serializedBaseURL, + a string normalizedSpecifier, + and a URL-or-null asURL:
Let global be settingsObject's global object.
Let global be realm's global object.
If global does not implement Window
, then return.
If script is a classic script and script's muted errors is true, then return.
-Let settingsObject be the current settings object.
Let realm be the current realm.
If script is not null, then set settingsObject to - script's settings - object.
If script is not null, then set realm to script's + realm.
Let global be settingsObject's global object.
Let global be realm's + global object.
If operation is "reject
", then:
Let incumbent settings be - callback.[[HostDefined]].[[IncumbentSettings]].
Let incumbent realm be + callback.[[HostDefined]].[[IncumbentRealm]].
Let script execution context be callback.[[HostDefined]].[[ActiveScriptContext]].
Prepare to run a callback with incumbent settings.
+Prepare to run a callback with incumbent realm.
This affects the incumbent concept while the callback runs.
@@ -110563,8 +110764,7 @@ dictionary PromiseRejectionEventInit : EventInitpop script execution context from the JavaScript execution context stack.Clean up after running a callback with incumbent - settings.
Clean up after running a callback with incumbent realm.
Return result.
Let entry be - finalizationRegistry.[[CleanupCallback]].[[Callback]].[[Realm]]'s environment settings object.
Check if we can run script with entry. If this returns "do not run", then return.
If realm is not null, then let job settings be the settings object for realm. Otherwise, - let job settings be null.
- -If realm is not null, it is the realm of the author code that will
- run. When job is returned by NewPromiseReactionJob, it is the realm of
- the promise's handler function. When job is returned by
- NewPromiseResolveThenableJob, it is the realm of the then
- function.
-
-
If realm is null, either no author code will run or author code is guaranteed to
- throw. For the former, the author may not have passed in code to run, such as in promise.then(null, null)
. For the latter, it is because a revoked Proxy was
- passed. In both cases, all the steps below that would otherwise use job settings
- get skipped.
NewPromiseResolveThenableJob - and NewPromiseReactionJob - both seem to provide non-null realms (the current Realm Record) in the case of a revoked - proxy. The previous text could be updated to reflect that.
-Queue a microtask to perform the following steps:
If job settings is not null, then check if we can run script - with job settings. If this returns "do not run" then return.
If realm is not null, then check if we can run script with + realm. If this returns "do not run" then return.
If job settings is not null, then prepare to run script with - job settings.
+If realm is not null, then prepare to run script with + realm.
This affects the entry concept while the job runs.
@@ -110708,8 +110881,8 @@ dictionary PromiseRejectionEventInit : EventInitHostMakeJobCallback and restores them in HostCallJobCallback.If job settings is not null, then clean up after running script - with job settings.
If realm is not null, then clean up after running script + with realm.
If result is an abrupt completion, then @@ -110730,6 +110903,27 @@ dictionary PromiseRejectionEventInit : EventInit
If realm is not null, it is the realm of the author code that will
+ run. When job is returned by NewPromiseReactionJob, it is the realm of
+ the promise's handler function. When job is returned by
+ NewPromiseResolveThenableJob, it is the realm of the then
+ function.
+
+
If realm is null, either no author code will run or author code is guaranteed to
+ throw. For the former, the author may not have passed in code to run, such as in promise.then(null, null)
. For the latter, it is because a revoked Proxy was
+ passed. In both cases, all the steps below that would otherwise use realm
+ get skipped.
NewPromiseResolveThenableJob + and NewPromiseReactionJob + both seem to provide non-null realms (the current Realm Record) in the case of a revoked + proxy. The previous text could be updated to reflect that.
+Let incumbent settings be the incumbent settings object.
Let incumbent realm be the incumbent + realm.
Let active script be the active script.
If active script is not null, set script execution context to a new JavaScript execution context, with its Function field set to null, its Realm field - set to active script's settings - object's realm, and its + set to active script's realm, and its ScriptOrModule set to active script's record.
@@ -110808,12 +111002,12 @@ dictionary PromiseRejectionEventInit : EventInitAs a consequence, this means that when theimport()
expression is evaluated,
there will still be no active script. Fortunately that is handled by our
implementation of HostLoadImportedModule by falling back to using the
- current settings object's API base URL.
+ current principal settings object's API base URL.
Return the JobCallback Record { [[Callback]]: callable, - [[HostDefined]]: { [[IncumbentSettings]]: incumbent settings, [[ActiveScriptContext]]: + [[HostDefined]]: { [[IncumbentRealm]]: incumbent realm, [[ActiveScriptContext]]: script execution context } }.
Let settingsObject be the current settings object.
Let moduleMapRealm be the current realm.
+ +In the case of the ShadowRealm.prototype.importValue
API both the
+ current realm and referrer are set to the corresponding
+ synthetic realm.
If settingsObject's global
- object implements WorkletGlobalScope
or ServiceWorkerGlobalScope
+
If moduleMapRealm's principal
+ realm's global object implements
+ WorkletGlobalScope
or ServiceWorkerGlobalScope
and loadState is undefined, then:
loadState is undefined when the current fetching process has been @@ -111060,14 +111261,20 @@ import "https://example.com/foo/../module2.mjs";
Set referencingScript to referrer.[[HostDefined]].
-Set settingsObject to referencingScript's settings object.
Set fetchReferrer to referencingScript's base URL.
Set originalFetchOptions to referencingScript's fetch options.
Set moduleMapRealm to referencingScript's realm.
+ +In the case of a dynamic import nested within a module loaded through the
+ ShadowRealm.prototype.importValue
API, the realm of the script is set to the
+ appropriate synthetic realm.
If the result of running the module type allowed steps given - moduleType and settingsObject is false, then:
+ moduleType and moduleMapRealm is false, then:Let completion be Completion Record { [[Type]]: throw, @@ -111179,14 +111386,16 @@ import "https://example.com/foo/../module2.mjs";
Let fetchClient be moduleMapRealm's + principal realm's + settings object.
Let fetchOptions be the result of getting the descendant script fetch options given - originalFetchOptions, url, and settingsObject.
Let destination be "script"
.
Let fetchClient be settingsObject.
If loadState is not undefined, then:
@@ -111200,7 +111409,7 @@ import "https://example.com/foo/../module2.mjs";Fetch a single imported module script given url, fetchClient, destination, fetchOptions, - settingsObject, fetchReferrer, moduleRequest, and + moduleMapRealm, fetchReferrer, moduleRequest, and onSingleFetchComplete as defined below. If loadState is not undefined and loadState.[[PerformFetch]] is not null, pass loadState.[[PerformFetch]] along as well.
@@ -111241,6 +111450,83 @@ import "https://example.com/foo/../module2.mjs";ShadowRealmGlobalScope
interface[Global]
+interface ShadowRealmGlobalScope : EventTarget {
+ readonly attribute ShadowRealmGlobalScope self;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onrejectionhandled;
+ attribute EventHandler onunhandledrejection;
+};
+
+ The self
getter steps are to return
+ this.
The following are the event handlers (and their corresponding event handler event types) that must be supported,
+ as event handler IDL attributes, by objects implementing the
+ ShadowRealmGlobalScope
interface:
Event handler | Event handler event type + |
---|---|
onerror | error
+ |
onrejectionhandled | rejectionhandled
+ |
onunhandledrejection | unhandledrejection
+ |
When performing InitializeHostDefinedRealm
+ in the ShadowRealm
constructor, the steps to
+ create a global object created in a host-defined manner are the following:
Let realm be the current realm.
+ +Set realm's is global prototype chain mutable to true.
+ +Let globalObject be a new ShadowRealmGlobalScope
+ object with realm.
Return globalObject.
JavaScript contains an implementation-defined HostInitializeShadowRealm(realm, + context, O) abstract operation. + User agents must use the following implementation: JSSHADOWREALM
+ +Let globalObject be realm.[[GlobalObject]].
Let settings be a new synthetic realm settings object that this + algorithm will subsequently initialize.
Set settings's execution context to + context.
Set settings's principal realm to O's + associated realm's + principal realm.
Set settings's module + map to a new module map, initially empty.
Set realm.[[HostDefined]] to settings.
Return NormalCompletion(unused).
Let event loop be global's relevant agent's event loop.
Let document be global's associated Document
, if global is
- a Window
object; otherwise null.
Let principal global be global's + realm's + principal realm's + global.
Let document be principal global's associated Document
,
+ if principal global is a Window
object; otherwise null.
Queue a task given source, event loop, document, and steps.
Let global be the current global object.
Let global be the current principal global object.
Let timeBeforePause be the current high resolution time given global.
Let parsed be the result of encoding-parsing a URL given - string, relative to the current settings object.
If parsed is failure, then return a promise rejected with a
"SyntaxError
" DOMException
.
It does its URL parsing up front, on the event loop, before going to the in parallel steps. This is necessary, since parsing depends on the current - settings object, which would no longer be current after going in + principal settings object, which would no longer be current after going in parallel.
Alternately, it could have saved a reference to the current settings
+ Alternately, it could have saved a reference to the current principal settings
object's API base URL and used it during the in parallel steps;
that would have been equivalent. However, we recommend instead doing as much work as possible up
front, as this example does. Attempting to save the correct values can be error prone; for
- example, if we'd saved just the current settings object, instead of its API
- base URL, there would have been a potential race.
It implicitly passes a list of strings from the
initial steps to the in parallel steps. This is OK, as both
Let special error event handling be true if event is an
ErrorEvent
object, event's type
is
"error
", and event's currentTarget
implements the
- WindowOrWorkerGlobalScope
mixin. Otherwise, let special error event
- handling be false.WindowOrWorkerGlobalScope
mixin or the ShadowRealmGlobalScope
+ interface. Otherwise, let special error event handling be false.
Process the Event
object event as follows:
In practice, this only affects the resolution of relative URLs via import()
,
which consult the base URL of the associated
script. Nulling out [[ScriptOrModule]] means that HostLoadImportedModule will
- fall back to the current settings object's API base URL.
UniversalGlobalScope
mixinThe UniversalGlobalScope
mixin is for use of APIs that are to be exposed on all
+ global objects.
Other standards are encouraged to further extend it using partial
+ interface mixin UniversalGlobalScope { … };
along with an
+ appropriate reference.
interface mixin UniversalGlobalScope {
+ readonly attribute boolean isSecureContext;
+
+ undefined reportError(any e);
+
+ // base64 utility methods
+ DOMString btoa(DOMString data);
+ ByteString atob(DOMString data);
+
+ // microtask queuing
+ undefined queueMicrotask(VoidFunction callback);
+
+ // structured cloning
+ any structuredClone(any value, optional StructuredSerializeOptions options = {});
+};
+Window includes UniversalGlobalScope;
+WorkerGlobalScope includes UniversalGlobalScope;
+ShadowRealmGlobalScope includes UniversalGlobalScope;
+WorkletGlobalScope includes UniversalGlobalScope;
+
+ The atob()
and btoa()
methods
+ allow developers to transform content to and from the base64 encoding.
In these APIs, for mnemonic purposes, the "b" can be considered to stand for + "binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the + input and output of these functions are Unicode strings.
+ +result = self.btoa(data)
Takes the input data, in the form of a Unicode string containing only characters in the range + U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and + converts it to its base64 representation, which it returns.
+ +Throws an "InvalidCharacterError
" DOMException
+ exception if the input string contains any out-of-range characters.
result = self.atob(data)
Takes the input data, in the form of a Unicode string containing base64-encoded binary data, + decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each + representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary + data.
+ +Throws an "InvalidCharacterError
" DOMException
if the
+ input string is not valid base64 data.
The btoa(data)
method must throw an
+ "InvalidCharacterError
" DOMException
if data
+ contains any character whose code point is greater than U+00FF. Otherwise, the user agent must
+ convert data to a byte sequence whose nth byte is the eight-bit
+ representation of the nth code point of data, and then must apply
+ forgiving-base64 encode to that byte sequence and return the result.
The atob(data)
method steps are:
Let decodedData be the result of running forgiving-base64 decode + on data.
If decodedData is failure, then throw an
+ "InvalidCharacterError
" DOMException
.
Return decodedData.
WindowOrWorkerGlobalScope
mixinThe WindowOrWorkerGlobalScope
mixin is for use of APIs that are to be exposed on
@@ -113685,30 +114066,17 @@ interface mixin WindowEventHandlers {
interface mixin WindowOrWorkerGlobalScope {
[Replaceable] readonly attribute USVString origin;
- readonly attribute boolean isSecureContext;
readonly attribute boolean crossOriginIsolated;
- undefined reportError(any e);
-
- // base64 utility methods
- DOMString btoa(DOMString data);
- ByteString atob(DOMString data);
-
// timers
long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments);
undefined clearTimeout(optional long id = 0);
long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments);
undefined clearInterval(optional long id = 0);
- // microtask queuing
- undefined queueMicrotask(VoidFunction callback);
-
// ImageBitmap
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options = {});
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options = {});
-
- // structured cloning
- any structuredClone(any value, optional StructuredSerializeOptions options = {});
};
Window includes WindowOrWorkerGlobalScope;
WorkerGlobalScope includes WindowOrWorkerGlobalScope;
@@ -113747,10 +114115,12 @@ document.body.appendChild(frame)
The The isSecureContext
getter steps are to return true if
- this's relevant settings object is a secure context, or
- false otherwise.
The origin
getter steps are to return this's
@@ -113767,66 +114137,6 @@ document.body.appendChild(frame)
The atob()
and btoa()
methods
- allow developers to transform content to and from the base64 encoding.
In these APIs, for mnemonic purposes, the "b" can be considered to stand for - "binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the - input and output of these functions are Unicode strings.
- -result = self.btoa(data)
Takes the input data, in the form of a Unicode string containing only characters in the range - U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and - converts it to its base64 representation, which it returns.
- -Throws an "InvalidCharacterError
" DOMException
- exception if the input string contains any out-of-range characters.
result = self.atob(data)
Takes the input data, in the form of a Unicode string containing base64-encoded binary data, - decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each - representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary - data.
- -Throws an "InvalidCharacterError
" DOMException
if the
- input string is not valid base64 data.
The btoa(data)
method must throw an
- "InvalidCharacterError
" DOMException
if data
- contains any character whose code point is greater than U+00FF. Otherwise, the user agent must
- convert data to a byte sequence whose nth byte is the eight-bit
- representation of the nth code point of data, and then must apply
- forgiving-base64 encode to that byte sequence and return the result.
The atob(data)
method steps are:
Let decodedData be the result of running forgiving-base64 decode - on data.
If decodedData is failure, then throw an
- "InvalidCharacterError
" DOMException
.
Return decodedData.
APIs for dynamically inserting markup into the document interact with the parser, @@ -115258,7 +115568,7 @@ enum DOMParserSupportedType {
Let script be the result of creating a classic script given - handler, settings object, base URL, and fetch + handler, realm, base URL, and fetch options.
Run the classic script
@@ -121042,7 +121352,7 @@ enum WorkerType { "classic", "module" };
object, scriptURL, "Worker constructor
", and "script
".
Let outside settings be the current settings object.
+Let outside settings be the current principal settings object.
Let worker URL be the result of encoding-parsing a URL given @@ -121143,7 +121453,8 @@ interface SharedWorker : EventTarget { data-x="">name member is set to the value of options and whose other members are set to their default values.
Let outside settings be the current settings object.
Let outside settings be the current principal settings + object.
Let urlRecord be the result of encoding-parsing a URL given
@@ -121363,7 +121674,8 @@ interface SharedWorker : EventTarget {
data-x="concept-WorkerGlobalScope-type">type is "module
", throw a
TypeError
exception.
Let settings object be the current settings object.
Let settings object be the current principal settings + object.
If urls is empty, return.