diff --git a/source b/source index fd018b599ac..4aa64c3d3dd 100644 --- a/source +++ b/source @@ -2868,6 +2868,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • upon rejection
  • upon fulfillment
  • mark as handled
  • +
  • is global prototype chain mutable
  • [Global]
  • [LegacyFactoryFunction]
  • [LegacyLenientThis]
  • @@ -3036,6 +3037,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The HostMakeJobCallback abstract operation
  • The HostPromiseRejectionTracker abstract operation
  • The InitializeHostDefinedRealm abstract operation
  • +
  • The SetRealmGlobalObject abstract operation
  • The IsAccessorDescriptor abstract operation
  • The IsCallable abstract operation
  • The IsConstructor abstract operation
  • @@ -3065,6 +3067,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The RunJobs abstract operation
  • The SameValue abstract operation
  • The ScriptEvaluation abstract operation
  • +
  • The SetDefaultGlobalBindings abstract operation
  • The SetImmutablePrototype abstract operation
  • The ToBoolean abstract operation
  • The ToString abstract operation
  • @@ -3142,6 +3145,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The nsMaxInstant and nsMinInstant values
  • + +

    User agents that support JavaScript must also implement the ShadowRealm API + proposal. The following terms are defined there, and used in this specification: + JSSHADOWREALM

    + +
    WebAssembly
    @@ -3453,6 +3466,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • current wall time
  • Unix epoch
  • DOMHighResTimeStamp
  • +
  • Performance
  • @@ -9601,7 +9615,7 @@ interface DOMStringList {
    1. -

      If the current settings object's If the current principal settings object's cross-origin isolated capability is false, then throw a "DataCloneError" DOMException.

      @@ -10647,7 +10661,7 @@ o.myself = o;
      -

      The The structuredClone(value, options) method steps are:

      @@ -11924,7 +11938,7 @@ console.assert(el.constructor === Element); overridden constructor steps:

        -
      1. Let registry be the current global object's +

      2. Let registry be the current principal global object's CustomElementRegistry object.

      3. @@ -12026,11 +12040,11 @@ document.createElement("bad-1"); // (2)
        1. 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.

        2. -
        3. Set element's node document to the current global - object's associated +

        4. Set element's node document to the current principal + global object's associated Document.

        5. Set element's namespace to @@ -29775,7 +29789,7 @@ img.decode().then(() => { the legacy factory function must perform the following steps:

            -
          1. Let document be the current global object's

            Let document be the current principal global object's associated Document.

          2. Let img be the result of creating an @@ -35311,7 +35325,7 @@ interface HTMLAudioElement : HTMLMediaElement must perform the following steps:

              -
            1. Let document be the current global object's

              Let document be the current principal global object's associated Document.

            2. Let audio be the result of creating an @@ -54301,7 +54315,7 @@ interface HTMLOptionElement : HTMLElement { function must perform the following steps:

                -
              1. Let document be the current global object's

                Let document be the current principal global object's associated Document.

              2. Let option be the result of creating an @@ -62819,8 +62833,8 @@ document.body.append(script1, script2);

                1. Let script be the result of creating a classic script using - source text, settings object, base URL, and - options.

                2. + source text, settings object's realm, base URL, and options.

                3. Mark as ready el given script.

                @@ -63372,7 +63386,7 @@ not-slash = %x0000-002E / %x0030-10FFFF to a 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 @@ -88937,7 +88951,7 @@ dictionary DragEventInit : MouseEventInit {
                IsPlatformObjectSameOrigin ( O )
                  -
                1. 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.

                2. @@ -88945,13 +88959,13 @@ dictionary DragEventInit : MouseEventInit {

                  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 w.document, this - step is invoked before the document getter is reached as part - of the [[Get]] algorithm for the WindowProxy - w.

                  +

                  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 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 )
                  @@ -88960,8 +88974,9 @@ dictionary DragEventInit : MouseEventInit { practice this is handled by the caller calling CrossOriginPropertyFallback.

                    -
                  1. Let crossOriginKey be a tuple consisting of the current settings - object, O's relevant settings object, and P.

                  2. +
                  3. Let crossOriginKey be a tuple consisting of the current principal + settings object, O's relevant settings object, and + P.

                  4. For each e of CrossOriginProperties(O):

                    @@ -88987,8 +89002,8 @@ dictionary DragEventInit : MouseEventInit {
                  5. Let value be originalDesc.[[Value]].

                  6. If IsCallable(value) is true, then set value to - an anonymous built-in function, created in the current realm, that performs - the same steps as the IDL operation P on object O.

                  7. + an anonymous built-in function, created in the current principal realm, that + performs the same steps as the IDL operation P on object O.

                  8. Set crossOriginDesc to PropertyDescriptor{ [[Value]]: value, @@ -89005,15 +89020,15 @@ dictionary DragEventInit : MouseEventInit {

                  9. Let crossOriginGet be undefined.

                  10. If e.[[NeedsGet]] is true, then set crossOriginGet to an - anonymous built-in function, created in the current realm, that performs the - same steps as the getter of the IDL attribute P on object + anonymous built-in function, created in the current principal realm, that + performs the same steps as the getter of the IDL attribute P on object O.

                  11. Let crossOriginSet be undefined.

                  12. 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 principal realm, that + performs the same steps as the setter of the IDL attribute P on object O.

                  13. Set crossOriginDesc to PropertyDescriptor{ @@ -90028,7 +90043,7 @@ dictionary WindowPostMessageOptions : StructuredSeri

                  14. 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.

                  15. Return container.

                  16. @@ -90467,10 +90482,10 @@ interface BarProp { this.

                  17. 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.

                  18. + data-x="window bc">browsing context, P, and the current principal + settings object.

                  19. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).

                  20. @@ -90491,9 +90506,10 @@ interface BarProp { this.

                  21. 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.

                  22. + should be reported, given the current principal global object's + browsing context, W's browsing context, P, and the current principal + settings object.

                  23. If IsPlatformObjectSameOrigin(W) is true, then:

                    @@ -92544,8 +92560,8 @@ enum NavigationHistoryBehavior {
                  24. -

                    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.

                    @@ -92569,8 +92585,8 @@ enum NavigationHistoryBehavior {
                  -
                3. Clean up after running script given navigation's relevant - settings object.

                4. +
                5. Clean up after running script given navigation's relevant realm.

                In implementations, same-document navigations can cause is same document is true.

              3. -

                Prepare to run script given navigation's relevant settings - object.

                +

                Prepare to run script given navigation's relevant realm.

                This is done to avoid the JavaScript execution context stack becoming empty @@ -95259,8 +95275,8 @@ interface NavigationDestination { apiMethodTracker.

              4. -

                Clean up after running script given navigation's relevant - settings object.

                +

                Clean up after running script given navigation's relevant realm.

                Per the previous note, this stops suppressing any potential promise handler microtasks, causing them to run @@ -99535,8 +99551,9 @@ location.href = '#foo';

              5. Let baseURL be settings's API base URL.

              6. Let script be the result of creating a classic script given - scriptSource, settings, baseURL, and the default script - fetch options.

              7. + scriptSource, settings's realm, baseURL, and the default script fetch + options.

              8. Let evaluationStatus be the result of running the classic script script.

              9. @@ -103303,12 +103320,12 @@ location.href = '#foo';
                1. Prepare to run script given document's - relevant settings object.

                2. + relevant realm.

                3. Activate transition.

                4. Clean up after running script given document's - relevant settings object.

                5. + relevant realm.

                Activating a view transition might resolve/reject promises, so by wrapping the @@ -105278,8 +105295,8 @@ new PaymentRequest(…); // Allowed to use data-x="concept-relevant-realm">relevant realm's agent.

                -

                The agent equivalent of the current realm is the surrounding - agent.

                +

                The agent equivalent of the current principal realm is the + surrounding agent.

      @@ -105498,16 +105515,32 @@ new PaymentRequest(…); // Allowed to use

      Realms and their counterparts

      The 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

      + +

      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 @@ -105654,8 +105687,17 @@ new PaymentRequest(…); // Allowed to use

      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 Window, WorkerGlobalScope, or WorkletGlobalScope objects.

      @@ -105673,27 +105715,26 @@ new PaymentRequest(…); // Allowed to use
      -

      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:

    +
    Synthetic realm settings objects
    + +

    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.

    + +

    An underlying realm

    + +

    The synthetic realm which this settings object represents.

    + +

    A module map

    + +

    A module map that is used when importing JavaScript modules.

    +
    + +

    Synthetic realms are created with global objects which are initialized by the JavaScript specification's + SetDefaultGlobalBindings algorithm. Synthetic + global objects implement only certain specifically exposed interfaces.

    + +

    Analogously, there is always a 1-to-1-to-1 mapping between synthetic realms, synthetic global + objects, and synthetic realm settings + objects:

    + + + +

    The principal realm of any + realm realm is defined by the following algorithm:

    + +
      +
    1. +

      If realm.[[HostDefined]] is a synthetic realm settings object, + then:

      + +
        +
      1. Assert: realm is a synthetic realm.

      2. + +
      3. Set realm to the principal realm of + realm.[[HostDefined]].

      4. +
      +
    2. + +
    3. Assert: realm.[[HostDefined]] is an environment settings + object and realm is a principal realm.

    4. + +
    5. Return realm.

    6. +
    + +

    The execution context of a + realm realm is defined by the following algorithm:

    + +
      +
    1. If realm is a principal realm, then return the + realm execution context of the + environment settings object of + realm.

    2. + +
    3. Assert: realm is a synthetic realm.

    4. + +
    5. Return the execution context + of the synthetic realm settings + object of realm.

    6. +
    + +

    The module map of a realm + realm is defined by the following algorithm:

    + +
      +
    1. If realm is a principal realm, then return the module map of the + environment settings object of + realm.

    2. + +
    3. Assert: realm is a synthetic realm.

    4. + +
    5. Return the module map + of the synthetic realm settings + object of realm.

    6. +
    +

    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:

    + what principal realm is to be used—or, equivalently, what principal global + object or environment settings object is to be used. In general, there are at + least four possibilities:

    Entry
    @@ -105848,9 +106009,9 @@ new PaymentRequest(…); // Allowed to use data-x="">a.html.

  • 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 principal 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.

  • @@ -105896,13 +106057,13 @@ new PaymentRequest(…); // Allowed to use </script>

    If the algorithm for the getBattery() method - had instead used the current realm, all the results would be reversed. That is, - after the first call to getBattery() in outer.html, the Navigator object in current principal realm, all the results would be reversed. + That is, after the first call to getBattery() in + outer.html, the Navigator object in inner.html would be permanently storing a Promise object created in outer.html's realm, and calls like that inside the - hello() function would thus return a promise from the "wrong" realm. Since - this is undesirable, the algorithm instead uses the hello() function would thus return a promise from the "wrong" realm. + Since this is undesirable, the algorithm instead uses the relevant realm, giving the sensible results indicated in the comments above.

    @@ -105925,7 +106086,8 @@ new PaymentRequest(…); // Allowed to use

    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:

      -
    1. Push settings onto the backup incumbent settings object - stack.

    2. +
    3. Push realm onto the backup incumbent realm stack.

    4. Let context be the topmost script-having execution context.

    5. @@ -105969,8 +106131,8 @@ new PaymentRequest(…); // Allowed to use skip-when-determining-incumbent counter.

    -

    To clean up after running a callback with an environment settings - object settings:

    +

    To clean up after running a callback with a realm + realm:

    1. @@ -105984,19 +106146,18 @@ new PaymentRequest(…); // Allowed to use
    2. If context is not null, decrement context's skip-when-determining-incumbent counter.

    3. -
    4. Assert: the topmost entry of the backup incumbent settings object - stack is settings.

    5. +
    6. Assert: the topmost entry of the backup incumbent realm stack is + realm.

    7. -
    8. Remove settings from the backup incumbent settings object - stack.

    9. +
    10. 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:

    1. Let context be the topmost script-having execution @@ -106008,31 +106169,30 @@ new PaymentRequest(…); // Allowed to use

      1. -

        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.

      2. -
      3. Return the topmost entry of the backup incumbent settings object - stack.

      4. +
      5. Return the topmost entry of the backup incumbent realm stack.

    2. -
    3. Return context's Realm component's settings object.

    4. +
    5. 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 @@ -106052,10 +106212,10 @@ new PaymentRequest(…); // Allowed to use frames[0].postMessage("some data", "*"); </script> -

    There are two interesting environment settings - objects here: that of window, and that of frames[0]. Our concern is: what is the incumbent settings object at - the time that the algorithm for postMessage() +

    There are two interesting realms here: that of + window, and that of frames[0]. + Our concern is: what is the incumbent realm at the + time that the algorithm for postMessage() executes?

    It should be that of window, to capture the intuitive notion that the @@ -106105,15 +106265,15 @@ new PaymentRequest(…); // Allowed to use

    This time, the result involves more complicated mechanisms:

    When 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.

    + Web IDL callback type, the incumbent realm 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.

    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.

    @@ -106128,11 +106288,12 @@ new PaymentRequest(…); // Allowed to use data-x="dom-window-postMessage">postMessage(), with no ScriptEvaluation context or similar below it.

    -

    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.

    @@ -106157,21 +106318,21 @@ document.querySelector("button").addEventListener("click", bound); }; </script> -

    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.

    + converted to a Web IDL callback type, the incumbent realm is that corresponding to 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.

    + data-x="">a.html's realm (stored as the 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.

    + incumbent global 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 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 @@ -106208,12 +106368,23 @@ 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.

    +

    Note that the current realm, unlike the entry, incumbent and + relevant concepts, can refer to a synthetic realm. Almost all uses of the "current" + concept in this document and other Web specifications need to refer to the current principal + realm as well. One exception is JavaScript module processing, as synthetic realms have a separate set of module instances (derived from a common + module map across the shared environment settings object).

    + +

    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.

    Relevant
    @@ -106233,45 +106404,45 @@ document.querySelector("button").addEventListener("click", bound);
    Enabling and disabling scripting
    -

    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:

    -

    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.

    Secure contexts
    @@ -106335,11 +106506,13 @@ document.querySelector("button").addEventListener("click", bound); module script). All scripts have:

    -
    A settings object
    +
    A 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.

    A record
    @@ -106407,6 +106580,11 @@ document.querySelector("button").addEventListener("click", bound); containing document, for inline scripts.

    +

    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:

    @@ -106756,9 +106934,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.

  • + sourceText, settingsObject's realm, response's URL, + options, mutedErrors, and url.

  • Run onComplete given script.
  • @@ -106837,9 +107015,9 @@ document.querySelector("button").addEventListener("click", bound); decoding bodyBytes.

  • Let script be the result of creating a classic script using - sourceText, settingsObject, response's URL, and the default script fetch - options.

  • + sourceText, settingsObject's realm, response's URL, and + the default script fetch options.

  • Run onComplete given script.

  • @@ -106918,9 +107096,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, the default script fetch options, and - mutedErrors.

  • + sourceText, settingsObject's realm, response's URL, the + default script fetch options, and mutedErrors.

  • Return script.

  • @@ -106932,11 +107110,13 @@ document.querySelector("button").addEventListener("click", bound); accepting null (on failure) or a module script (on success).

      -
    1. Disallow further import maps given settingsObject.

    2. +
    3. Disallow further import maps given settingsObject's + realm.

    4. 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:

        @@ -106958,11 +107138,13 @@ document.querySelector("button").addEventListener("click", bound); script (on success).

          -
        1. Disallow further import maps given settingsObject.

        2. +
        3. Disallow further import maps given settingsObject's + realm.

        4. 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:

            @@ -106990,10 +107172,12 @@ document.querySelector("button").addEventListener("click", bound); algorithm accepting null (on failure) or a module script (on success).

              -
            1. Disallow further import maps given settingsObject.

            2. +
            3. Disallow further import maps given settingsObject's + realm.

            4. Let script be the result of creating a JavaScript module script - using sourceText, settingsObject, baseURL, and + using sourceText, settingsObject's + realm, baseURL, and options.

            5. Fetch the descendants of @@ -107161,7 +107345,8 @@ document.querySelector("button").addEventListener("click", bound);

            6. Fetch a single module script given url, - fetchClient, destination, options, settingsObject, + fetchClient, destination, options, settingsObject's + realm, "client", true, and onSingleFetchComplete as defined below. If performFetch was given, pass it along as well.

              @@ -107260,10 +107445,10 @@ document.querySelector("button").addEventListener("click", bound);

              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 options options, a realm moduleMapRealm, + a referrer referrer, + an optional ModuleRequest Record moduleRequest, + a boolean isTopLevel, 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).

              @@ -107276,13 +107461,14 @@ document.querySelector("button").addEventListener("click", bound); moduleRequest.

            7. 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.

            8. + given moduleType and moduleMapRealm 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.

              -
            9. Let moduleMap be settingsObject's module map.

            10. +
            11. Let moduleMap be moduleMapRealm's module map.

            12. If moduleMap[(url, moduleType)] is "fetching", wait in parallel until that entry's value @@ -107371,8 +107557,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.

            13. + moduleMapRealm, response's + URL, and options.

            14. Otherwise:

              @@ -107383,18 +107569,18 @@ document.querySelector("button").addEventListener("click", bound);
            15. 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.

            16. 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.

            17. + moduleMapRealm.

            18. 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.

            19. + moduleMapRealm.

            @@ -107416,10 +107602,10 @@ document.querySelector("button").addEventListener("click", bound);

            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).

            @@ -107434,11 +107620,11 @@ document.querySelector("button").addEventListener("click", bound); request steps given moduleRequest.

          1. If the result of running the module type allowed steps given - moduleType and settingsObject is false, then run onComplete - given null, and return.

          2. + moduleType and moduleMapRealm is false, then + run onComplete given null, and return.

          3. 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.

          @@ -107446,9 +107632,9 @@ document.querySelector("button").addEventListener("click", bound);
          Creating scripts

          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):

            @@ -107462,14 +107648,14 @@ document.querySelector("button").addEventListener("click", bound); baseURL is sanitized here.

            -
          1. If scripting is disabled for - settings, then set source to the empty string.

          2. +
          3. If scripting is disabled for + realm, then set source to the empty string.

          4. Let script be a new classic script that this algorithm will subsequently initialize.

          5. -
          6. Set script's settings - object to settings.

          7. +
          8. Set script's realm to + realm.

          9. Set script's base URL to baseURL.

          10. @@ -107487,8 +107673,7 @@ document.querySelector("button").addEventListener("click", bound);
          11. Let result be ParseScript(source, - settings's realm, - script).

            + realm, script).

            Passing script as the last parameter here ensures result.[[HostDefined]] will be script.

            @@ -107513,19 +107698,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:

            -
          1. If scripting is disabled for - settings, then set source to the empty string.

          2. +
          3. If scripting is disabled for + realm, then set source to the empty string.

          4. Let script be a new module script that this algorithm will subsequently initialize.

          5. -
          6. Set script's settings - object to settings.

          7. +
          8. Set script's realm to + realm.

          9. Set script's base URL to baseURL.

          10. @@ -107538,8 +107723,7 @@ document.querySelector("button").addEventListener("click", bound);
          11. Let result be ParseModule(source, - settings's realm, - script).

            + realm, script).

            Passing script as the last parameter here ensures result.[[HostDefined]] will be script.

            @@ -107563,15 +107747,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:

          1. -

            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.

            @@ -107580,8 +107763,8 @@ document.querySelector("button").addEventListener("click", bound);
          2. Let script be a new module script that this algorithm will subsequently initialize.

          3. -
          4. Set script's settings - object to settings.

          5. +
          6. Set script's realm to + realm.

          7. Set script's base URL to baseURL.

          8. @@ -107594,8 +107777,7 @@ document.querySelector("button").addEventListener("click", bound);
          9. 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 @@ -107625,14 +107807,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:

            1. Let script be a new module script that this algorithm will subsequently initialize.

            2. -
            3. Set script's settings - object to settings.

            4. +
            5. Set script's realm to + realm.

            6. Set script's base URL and fetch options to null.

            7. @@ -107665,14 +107847,14 @@ document.querySelector("button").addEventListener("click", bound);

            To create a JSON module script, given a - string source and an environment settings object settings:

            + string source and a realm realm:

            1. Let script be a new module script that this algorithm will subsequently initialize.

            2. -
            3. Set script's settings - object to settings.

            4. +
            5. Set script's realm to + realm.

            6. Set script's base URL and fetch options to null.

            7. @@ -107725,7 +107907,7 @@ document.querySelector("button").addEventListener("click", bound);

            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:

            1. If moduleType is not "javascript-or-wasm", "

              If moduleType is "css" and the CSSStyleSheet interface is not exposed in - settings's realm, then - return false.

            2. + realm, then return false.

            3. Return true.

            @@ -107759,15 +107940,15 @@ document.querySelector("button").addEventListener("click", bound); and an optional boolean rethrow errors (default false):

              -
            1. Let settings be the settings - object of script.

            2. +
            3. Let realm be the realm of + script.

            4. -
            5. Check if we can run script with settings. If this returns "do +

            6. Check if we can run script with realm. If this returns "do not run" then return NormalCompletion(empty).

            7. Record classic script execution start time given script.

            8. -
            9. Prepare to run script given settings.

            10. +
            11. Prepare to run script given realm.

            12. Let evaluationStatus be null.

            13. @@ -107796,7 +107977,7 @@ document.querySelector("button").addEventListener("click", bound); errors is false, then:

                -
              1. Clean up after running script with settings.

              2. +
              3. Clean up after running script with realm.

              4. Rethrow evaluationStatus.[[Value]].

              @@ -107806,7 +107987,7 @@ document.querySelector("button").addEventListener("click", bound); errors is true, then:

                -
              1. Clean up after running script with settings.

              2. +
              3. Clean up after running script with realm.

              4. Throw a "NetworkError" DOMException.

              @@ -107817,10 +107998,9 @@ document.querySelector("button").addEventListener("click", bound);
              1. Report an exception given by evaluationStatus.[[Value]] for - script's settings object's - global object.

              2. + realm's global object.

                -
              3. Clean up after running script with settings.

              4. +
              5. Clean up after running script with realm.

              6. Return evaluationStatus.

              @@ -107828,7 +108008,7 @@ document.querySelector("button").addEventListener("click", bound);
          10. -
          11. Clean up after running script with settings.

          12. +
          13. Clean up after running script with realm.

          14. If evaluationStatus is a normal completion, then return evaluationStatus.

          15. @@ -107844,15 +108024,15 @@ document.querySelector("button").addEventListener("click", bound); and an optional boolean preventErrorReporting (default false):

              -
            1. Let settings be the settings - object of script.

            2. +
            3. Let realm be the realm of + script.

            4. -
            5. Check if we can run script with settings. If this returns "do not - run", then return a promise resolved with undefined.

            6. +
            7. Check if we can run script with realm. If this returns "do not + run", then return a promise resolved with with undefined.

            8. Record module script execution start time given script.

            9. -
            10. Prepare to run script given settings.

            11. +
            12. Prepare to run script given realm.

            13. Let evaluationPromise be null.

            14. @@ -107884,50 +108064,60 @@ document.querySelector("button").addEventListener("click", bound);
            15. 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.

            16. + reason for realm's + global object.

              -
            17. Clean up after running script with settings.

            18. +
            19. Clean up after running script with realm.

            20. 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".

              -
            1. If the global object specified by - settings is a Window object whose Document object is not +

            2. If the global object specified by + realm is a Window object whose Document object is not fully active, then return "do not run".

              -
            3. If scripting is disabled for - settings, then return "do not run".

              +
            4. If scripting is disabled for + realm, then return "do not run".

            5. 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:

              -
            1. Push settings's realm execution context onto the JavaScript - execution context stack; it is now the running JavaScript execution - context.

            2. +
            3. Push realm's execution + context onto the JavaScript execution context stack; it is now the + running JavaScript execution context.

            4. -
            5. Add settings to the surrounding agent's event loop's currently running task's - script evaluation environment settings object set.

            6. +
            7. +

              If realm is a principal realm, then:

              + +
                +
              1. Let settings be realm's settings object.

              2. + +
              3. Add settings to the surrounding agent's event loop's currently running task's + script evaluation environment settings object set.

              4. +
              +
            -

            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:

              -
            1. Assert: settings's realm execution context is the +

            2. Assert: realm's execution context is the running JavaScript execution context.

            3. -
            4. Remove settings's realm execution context from the - JavaScript execution context stack.

            5. +
            6. Remove realm's execution + context from the JavaScript execution context stack.

            7. If the JavaScript execution context stack is now empty, perform a microtask checkpoint. (If this runs scripts, these algorithms will be invoked @@ -108386,9 +108576,10 @@ dictionary PromiseRejectionEventInit : EventInitOtherwise:

                -
              1. Assert: there is a current settings object.

              2. +
              3. Assert: there is a current principal settings object.

              4. -
              5. Set settingsObject to the current settings object.

              6. +
              7. Set settingsObject to the current principal settings + object.

              8. Set baseURL to settingsObject's API base URL.

              9. @@ -108883,12 +109074,11 @@ dictionary PromiseRejectionEventInit : EventInitEach Window has an import maps allowed boolean, initially true.

                -

                To disallow further import maps given an environment settings object - settingsObject:

                +

                To disallow further import maps given a realm realm:

                  -
                1. Let global be settingsObject's global object.

                2. +
                3. Let global be realm's global object.

                4. If global does not implement Window, then return.

                5. @@ -109273,14 +109463,13 @@ dictionary PromiseRejectionEventInit : EventInit

                  If script is a classic script and script's muted errors is true, then return.

                  -
                6. Let settingsObject be the current settings object.

                7. +
                8. Let realm be the current realm.

                9. -
                10. If script is not null, then set settingsObject to - script's settings - object.

                11. +
                12. If script is not null, then set realm to script's + realm.

                13. -
                14. Let global be settingsObject's global object.

                15. +
                16. Let global be realm's + global object.

                17. If operation is "reject", then:

                  @@ -109359,14 +109548,14 @@ dictionary PromiseRejectionEventInit : EventInitJAVASCRIPT

                    -
                  1. Let incumbent settings be - callback.[[HostDefined]].[[IncumbentSettings]].

                  2. +
                  3. Let incumbent realm be + callback.[[HostDefined]].[[IncumbentRealm]].

                  4. Let script execution context be callback.[[HostDefined]].[[ActiveScriptContext]].

                  5. -

                    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.

                    @@ -109387,8 +109576,7 @@ dictionary PromiseRejectionEventInit : EventInitpop script execution context from the JavaScript execution context stack.

                  6. -
                  7. Clean up after running a callback with incumbent - settings.

                  8. +
                  9. Clean up after running a callback with incumbent realm.

                  10. Return result.

                  @@ -109425,8 +109613,7 @@ dictionary PromiseRejectionEventInit : EventInit
                18. Let entry be - finalizationRegistry.[[CleanupCallback]].[[Callback]].[[Realm]]'s environment settings object.

                19. + finalizationRegistry.[[CleanupCallback]].[[Callback]].[[Realm]].

                20. Check if we can run script with entry. If this returns "do not run", then return.

                21. @@ -109478,42 +109665,16 @@ dictionary PromiseRejectionEventInit : EventInitJAVASCRIPT

                    -
                  1. -

                    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.

                    -
                    -
                  2. -
                  3. Queue a microtask to perform the following steps:

                      -
                    1. If job settings is not null, then check if we can run script - with job settings. If this returns "do not run" then return.

                    2. +
                    3. If realm is not null, then check if we can run script with + realm. If this returns "do not run" then return.

                    4. -

                      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.

                      @@ -109532,8 +109693,8 @@ dictionary PromiseRejectionEventInit : EventInitHostMakeJobCallback and restores them in HostCallJobCallback.

                    5. -
                    6. If job settings is not null, then clean up after running script - with job settings.

                    7. +
                    8. If realm is not null, then clean up after running script + with realm.

                    9. If result is an abrupt completion, then @@ -109554,6 +109715,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.

                    +
                    + +
                    HostEnqueueTimeoutJob(job, realm, milliseconds)
                    @@ -109584,7 +109766,8 @@ dictionary PromiseRejectionEventInit : EventInitJAVASCRIPT

                      -
                    1. Let incumbent settings be the incumbent settings object.

                    2. +
                    3. Let incumbent realm be the incumbent + realm.

                    4. Let active script be the active script.

                    5. @@ -109593,8 +109776,7 @@ dictionary PromiseRejectionEventInit : EventInit

                      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.

                      @@ -109632,12 +109814,12 @@ dictionary PromiseRejectionEventInit : EventInitAs a consequence, this means that when the import() 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 } }.

  • @@ -109847,11 +110029,18 @@ import "https://example.com/foo/../module2.mjs";
    must use the following implementation: JAVASCRIPT

      -
    1. Let settingsObject be the current settings object.

    2. +
    3. +

      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.

      +
    4. -

      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 @@ -109883,14 +110072,20 @@ import "https://example.com/foo/../module2.mjs";

      1. Set referencingScript to referrer.[[HostDefined]].

        -
      2. Set settingsObject to referencingScript's settings object.

      3. -
      4. Set fetchReferrer to referencingScript's base URL.

      5. Set originalFetchOptions to referencingScript's fetch options.

      6. + +
      7. +

        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.

        +
      @@ -109959,7 +110154,7 @@ import "https://example.com/foo/../module2.mjs";
    5. If the result of running the module type allowed steps given - moduleType and settingsObject is false, then:

      + moduleType and moduleMapRealm is false, then:

      1. Let completion be Completion Record { [[Type]]: throw, @@ -109983,7 +110178,7 @@ import "https://example.com/foo/../module2.mjs";

    6. -
    7. Disallow further import maps given settingsObject.

    8. +
    9. Disallow further import maps given moduleMapRealm.

    10. Let url be the result of resolving a module specifier given referencingScript and @@ -110004,13 +110199,19 @@ import "https://example.com/foo/../module2.mjs";

    +
  • Let settingsObject 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.

  • +
  • Let fetchClient be moduleMapRealm's + principal realm's + settings object.

  • If loadState is not undefined, then:

    @@ -110025,7 +110226,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.

    @@ -110066,7 +110267,54 @@ import "https://example.com/foo/../module2.mjs";
  • - +
    HostInitializeShadowRealm(realm, context)
    + +

    JavaScript contains an implementation-defined HostInitializeShadowRealm(realm, + context) abstract operation. User agents must use the following implementation: + JSSHADOWREALM

    + +
      +
    1. Set realm's is global prototype chain mutable to true.

      + +
    2. Let globalObject be a new ShadowRealmGlobalScope + object with realm.

    3. + +
    4. Let settings be a new synthetic realm settings object that this + algorithm will subsequently initialize.

    5. + +
    6. Set settings's execution context to + context.

    7. + +
    8. Set settings's principal realm to the + current principal realm.

    9. + +
    10. Set settings's underlying realm to + realm.

    11. + +
    12. Set settings's module + map to a new module map, initially empty.

    13. + +
    14. Set realm.[[HostDefined]] to settings.

    15. + +
    16. Return globalObject.

    17. +
    + +
    The ShadowRealmGlobalScope interface
    + +
    [Global]
    +interface ShadowRealmGlobalScope : EventTarget {
    +  readonly attribute ShadowRealmGlobalScope self;
    +};
    + +

    The self getter steps are to return + this.

    + +

    Event loops

    @@ -111124,7 +111372,7 @@ import "https://example.com/foo/../module2.mjs"; goal is met. This means running the following steps:

      -
    1. Let global be the current global object.

    2. +
    3. Let global be the current principal global object.

    4. Let timeBeforePause be the current high resolution time given global.

    5. @@ -111297,7 +111545,7 @@ import "https://example.com/foo/../module2.mjs";
      1. Let parsed be the result of encoding-parsing a URL given - string, relative to the current settings object.

      2. + string, relative to the current principal settings object.

      3. If parsed is failure, then return a promise rejected with a "SyntaxError" DOMException.

      4. @@ -111309,7 +111557,7 @@ import "https://example.com/foo/../module2.mjs";
      -
    6. Let realm be the current realm.

    7. +
    8. Let realm be the current principal realm.

    9. Let p be a new promise.

    10. @@ -111358,15 +111606,15 @@ import "https://example.com/foo/../module2.mjs";