diff --git a/source b/source index 74da4041ade..3b0f70e3b09 100644 --- a/source +++ b/source @@ -2813,6 +2813,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • frozen array and creating a frozen array
  • create a new object implementing the interface
  • +
  • define the global property references
  • callback this value
  • converting between Web IDL types and JS types
  • invoking and @@ -3021,6 +3022,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
  • @@ -3080,6 +3082,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute + +

    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
    @@ -3382,9 +3394,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute current time, the shared monotonic clock, the coarsen time - algorithm, and the DOMHighResTimeStamp - typedef. HRT

    + typedef, and the Performance + interface. HRT

    @@ -9488,7 +9502,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.

      @@ -11816,7 +11830,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. @@ -11918,11 +11932,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 @@ -29396,7 +29410,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 @@ -34922,7 +34936,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 @@ -53864,7 +53878,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 @@ -87719,7 +87733,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. @@ -87727,13 +87741,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 )
                  @@ -87742,8 +87756,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):

                    @@ -87769,8 +87784,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, @@ -87787,15 +87802,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{ @@ -88818,7 +88833,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. @@ -89257,10 +89272,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. @@ -89281,9 +89296,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:

                    @@ -102862,8 +102878,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.

                    @@ -103082,16 +103098,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

                    + +
                      +
                    • 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 @@ -103246,32 +103278,40 @@ 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.

                    -

                    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

                      A principal realm has a [[HostDefined]] field, which contains the 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

                      Return realm execution context.

                  +
                  Synthetic realm settings objects
                  + +

                  Each synthetic realm has an associated synthetic realm settings object + with the following fields:

                  + +
                  +

                  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 realm settings objects' module map entries are copies of successfully + fetched modules found in the principal realm's module map, so this map never contains entries + which are null or "fetching".

                  +
                  +
                  + +

                  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:

                  + +
                    +
                  • 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 + ShadowRealm constructor, which creates the global object's realm.

                  • + +
                  • 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:

                  + +
                    +
                  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 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
                  @@ -103426,9 +103570,9 @@ new PaymentRequest(…); // Allowed to use data-x="">a.html.

                3. The incumbent realm is that of b.html.

                4. -
                5. The current realm is that of c.html (since it is the - print() method from c.html whose code is - running).

                6. +
                7. The current principal realm is that of c.html (since it is the print() method from + c.html whose code is running).

                8. The relevant realm of the object on which the print() method is being called is that of d.html.

                9. @@ -103474,13 +103618,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.

                  @@ -103503,7 +103647,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

                10. Return context's Realm component's principal realm's settings object.

                @@ -103786,12 +103932,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
                @@ -103913,11 +104070,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
                @@ -103982,6 +104141,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:

                @@ -104465,7 +104629,8 @@ document.querySelector("button").addEventListener("click", bound);
              3. 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:

                  @@ -104474,7 +104639,8 @@ document.querySelector("button").addEventListener("click", bound);
                1. Fetch the descendants of and link result given settingsObject, "script", and onComplete.

                2. + data-x="">script", settings object's realm, and onComplete.

              @@ -104491,7 +104657,8 @@ document.querySelector("button").addEventListener("click", bound);
            3. 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:

                @@ -104692,7 +104859,8 @@ document.querySelector("button").addEventListener("click", bound);
              1. 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.

                @@ -104704,8 +104872,9 @@ document.querySelector("button").addEventListener("click", bound);
              2. Fetch the descendants of and link result given fetchClient, - destination, and onComplete. If performFetch was given, pass - it along as well.

              3. + destination, settingsObject's + realm, and onComplete. + If performFetch was given, pass it along as well.

            @@ -104791,10 +104960,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).

            @@ -104807,14 +104976,14 @@ document.querySelector("button").addEventListener("click", bound); moduleRequest.

          3. Assert: the result of running the module type allowed steps - given moduleType and settingsObject's realm is true. Otherwise we would not have reached this point because a - failure would have been raised when inspecting moduleRequest.[[Attributes]] in + 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 create a JavaScript module script or fetch a single imported module script.

          4. -
          5. Let moduleMap be settingsObject's module map.

          6. +
          7. Let moduleMap be moduleMapRealm's module map.

          8. If moduleMap[(url, moduleType)] is "fetching", wait in parallel until that entry's value @@ -104825,6 +104994,23 @@ document.querySelector("button").addEventListener("click", bound); data-x="map exists">exists, run onComplete given moduleMap[(url, moduleType)], and return.

          9. +
          10. +

            If moduleMapRealm is a synthetic realm, then:

            + +
              +
            1. Let script be the result of + cloning a module + given url, moduleType and moduleMapRealm.

            2. + +
            3. Set moduleMap[(url, + moduleType)] to script.

            4. + +
            5. Run onComplete given script.

            6. + +
            7. Return.

            8. +
            +
          11. +
          12. Set moduleMap[(url, moduleType)] to "fetching".

          13. @@ -104902,6 +105088,9 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-script-fetch-options-referrer-policy">referrer policy to referrerPolicy.

            +
          14. Let settingsObject be moduleMapRealm's settings object.

          15. +
          16. If mimeType is a JavaScript MIME type and moduleType is "javascript", then set moduleScript to the result of creating a JavaScript module script given sourceText, @@ -104933,13 +105122,92 @@ document.querySelector("button").addEventListener("click", bound);

          +

          To clone a module given a URL, moduleType, and + moduleMapRealm, perform the following steps.

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

          2. + +
          3. Let parentModuleMap be moduleMapRealm's + principal realm's settings object's module map.

          4. + +
          5. Assert: parentModuleMap[(url, moduleType)] + exists.

          6. + +
          7. Let parentModule be parentModuleMap[(url, + moduleType)].

          8. + +
          9. Let childModule be a new module script that this algorithm will + subsequently initialize.

          10. + +
          11. Set childModule's realm to + moduleMapRealm.

          12. + +
          13. Set childModule's base URL to + parentModule's base URL.

          14. + +
          15. Set childModule's fetch + options to parentModule's fetch options.

          16. + +
          17. Set childModule's error to + rethrow to parentModule's error + to rethrow.

            Should this be cloned? Can this be an arbitrary + value?
          18. + +
          19. Let parentRecord be parentModule's record.

          20. + +
          21. +

            If parentRecord is null, then:

            + +
              +
            1. Let parentParseError be parentModule's parse error.

            2. +
            3. Assert: parentParseError is a SyntaxError + instance.

            4. + +
            5. Set childModule's parse + error to a new SyntaxError in moduleMapRealm with the same + message as parentParseError.

            6. + +
            7. Set childModule's record to + null.

            8. + +
            9. Return childModule.

            10. +
            +
          22. + +
          23. Set childModule's error to + rethrow to null.

          24. + +
          25. Can parentModule be a CSS or JSON module?

          26. + +
          27. Set childModule's record to + a new Source Text Module Record { [[Realm]]: moduleMapRealm, + [[Environment]]: undefined, [[Namespace]]: undefined, [[Status]]: unlinked, [[EvaluationError]]: + undefined, [[HostDefined]]: childModule, [[ECMAScriptCode]]: + parentRecord.[[ECMAScriptCode]], [[Context]]: empty, [[ImportMeta]]: empty, + [[RequestedModules]]: parentRecord.[[RequestedModules]], + [[ImportEntries]]: parentRecord.[[ImportEntries]], + [[LocalExportEntries]]: parentRecord.[[LocalImportEntries]], + [[IndirectExportEntries]]: parentRecord.[[IndirectImportEntries]], + [[StarExportEntries]]: parentRecord.[[StarImportEntries]], [[DFSIndex]]: undefined, + [[DFSAncestorIndex]]: undefined }. Is 'unlinked' correct?

          28. + +
          29. Return childModule.

          30. +
          + +

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

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

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

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

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

        @@ -104987,8 +105255,8 @@ document.querySelector("button").addEventListener("click", bound);
      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 + settings's realm.

      9. Set script's base URL to baseURL.

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

      12. -
      13. Set script's settings - object to settings.

      14. +
      15. Set script's realm to + settings's realm.

      16. Set script's base URL to baseURL.

      17. @@ -105851,9 +106119,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. @@ -106609,7 +106878,8 @@ dictionary PromiseRejectionEventInit : EventInit

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

          -
        10. Let settings object be the current settings object.

        11. +
        12. Let settings object be the current principal settings + object. Should this work for synthetic realms?

        13. If script is not null, then set settings object to script's settings @@ -106795,7 +107065,8 @@ dictionary PromiseRejectionEventInit : EventInit

        14. If realm is not null, then let job settings be the settings object for realm. Otherwise, + data-x="concept-realm-settings-object">settings object for the principal realm of realm. Otherwise, let job settings be null.

          @@ -106928,7 +107199,7 @@ 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.

        15. @@ -107142,11 +107413,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 the + current realm is set to the appropriate synthetic realm.

            +
          4. -

            If settingsObject's global - object implements WorkletGlobalScope or ServiceWorkerGlobalScope +

            If moduleMapRealm's principal + realm's (can we check moduleMapRealm directly?) + global object implements + WorkletGlobalScope or ServiceWorkerGlobalScope and loadState is undefined, then:

            loadState is undefined when the current fetching process has been @@ -107178,9 +107456,6 @@ import "https://example.com/foo/../module2.mjs";

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

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

            3. -
            4. Set fetchOptions to the new descendant script fetch options for referencingScript's fetch options.

            5. @@ -107191,6 +107466,15 @@ import "https://example.com/foo/../module2.mjs";
            6. Set fetchReferrer to referrer's base URL.

            7. + +
            8. +

              Set moduleMapRealm to referencing script'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.

              +
            @@ -107208,6 +107492,10 @@ import "https://example.com/foo/../module2.mjs";
          5. +
          6. Let settingsObject be moduleMapRealm's + principal realm's + settings object.

          7. +
          8. Disallow further import maps given settingsObject.

          9. Let url be the result of resolving a @@ -107246,7 +107534,7 @@ import "https://example.com/foo/../module2.mjs";

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

            @@ -107287,6 +107575,71 @@ import "https://example.com/foo/../module2.mjs";
          +
          HostInitializeShadowRealm(realm)
          + +

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

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

          2. + +
          3. Set settings's principal realm to the + current principal realm.

          4. + +
          5. Set settings's underlying realm to + realm.

          6. + +
          7. Set settings's module + map to a new module map, initially empty.

          8. + +
          9. Set realm.[[HostDefined]] to settings.

          10. + +
          11. Define the global property references on realm.[[GlobalObject]], + given realm.

          12. + +
          13. +

            Let selfSteps be the following series of steps:

            + +
              +
            1. Let thisValue be the result of getting the ShadowRealm global object with realm and the this + value.

            2. +
            3. Return thisValue.

            4. +
            +
          14. + +
          15. Let selfGetter be CreateBuiltinFunction(selfSteps, 0, + "get self", « », realm).

          16. + +
          17. Let selfDescriptor be the PropertyDescriptor{[[Get]]: + selfGetter, [[Set]]: undefined, [[Enumerable]]: true, [[Configurable]]: + true}.

          18. + +
          19. Perform ! DefinePropertyOrThrow(realm.[[GlobalObject]], "self", + selfDescriptor).

          20. +
          + + To get the ShadowRealm global object given calleeRealm and + thisValue, perform the following steps: + +
            +
          1. Assert: calleeRealm is a synthetic realm

          2. +
          3. If thisValue is null or undefined, return + calleeRealm.[[GlobalObject]].

          4. +
          5. If Type(thisValue) is not Object, then throw a + TypeError.

          6. +
          7. If thisValue is not a global object, then throw a + TypeError.

          8. +
          9. Assert: thisValue is + calleeRealm.[[GlobalObject]].

          10. +
          11. Return thisValue.

          12. +
          +

          Event loops

          @@ -108467,7 +108820,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. @@ -108479,7 +108832,7 @@ import "https://example.com/foo/../module2.mjs";
          -
        16. Let realm be the current realm.

        17. +
        18. Let realm be the current principal realm.

        19. Let p be a new promise.

        20. @@ -108528,15 +108881,15 @@ import "https://example.com/foo/../module2.mjs";
          • 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.

          • + example, if we'd saved just the current principal 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 OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl

            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.

            + fall back to the current principal settings object's + API base URL.

          • @@ -116462,7 +116816,7 @@ enum WorkerType { "classic", "module" }; steps:

              -
            1. Let outside settings be the current settings object.

              +
            2. Let outside settings be the current principal settings object.

            3. Let worker URL be the result of encoding-parsing a URL given @@ -116557,7 +116911,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.

            4. -
            5. Let outside settings be the current settings object.

            6. +
            7. Let outside settings be the current principal settings + object.

            8. Let urlRecord be the result of encoding-parsing a URL given @@ -116759,7 +117114,8 @@ interface SharedWorker : EventTarget { data-x="concept-WorkerGlobalScope-type">type is "module", throw a TypeError exception.

            9. -
            10. Let settings object be the current settings object.

            11. +
            12. Let settings object be the current principal settings + object.

            13. If urls is empty, return.

            14. @@ -140000,6 +140356,9 @@ INSERT INTERFACES HERE
              [JSON]
              The JavaScript Object Notation (JSON) Data Interchange Format, T. Bray. IETF.
              +
              [JSSHADOWREALM]
              +
              ShadowRealm API. Ecma International.
              +
              [LONGTASKS]
              Long Tasks, D. Denicola, I. Grigorik, S. Panicker. W3C.