diff --git a/source b/source index 548d8ea5110..dc873bcff6c 100644 --- a/source +++ b/source @@ -2756,6 +2756,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 @@ -2907,6 +2908,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The CreateBuiltinFunction abstract operation
  • The CreateByteDataBlock abstract operation
  • The CreateDataProperty abstract operation
  • +
  • The DefinePropertyOrThrow abstract operation
  • The DetachArrayBuffer abstract operation
  • The EnumerableOwnProperties abstract operation
  • The FinishDynamicImport abstract operation
  • @@ -2954,6 +2956,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
  • @@ -2967,6 +2970,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The FinalizationRegistry class
  • The RegExp class
  • The SharedArrayBuffer class
  • +
  • The SyntaxError class
  • The TypeError class
  • The RangeError class
  • The WeakRef class
  • @@ -3003,6 +3007,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The Synthetic Module Record specification type
  • The ParseJSONModule abstract operation
  • + +

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

    + +
    WebAssembly
    @@ -3289,9 +3303,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.

    + typedef, and the Performance + interface.

    @@ -8922,7 +8938,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.

      @@ -11133,7 +11149,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. @@ -11235,11 +11251,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 @@ -28238,7 +28254,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 @@ -33573,7 +33589,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 @@ -52372,7 +52388,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 @@ -83660,7 +83676,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. @@ -83668,13 +83684,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 )
                  @@ -83683,8 +83699,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):

                    @@ -83710,8 +83727,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, @@ -83728,15 +83745,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{ @@ -84758,7 +84775,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. @@ -85204,10 +85221,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. @@ -85228,9 +85245,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:

                    @@ -94461,8 +94479,8 @@ new PaymentRequest(…); // Allowed to use data-x="">This pointer is not yet defined in the JavaScript specification; see tc39/ecma262#1357.

                    -

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

                    +

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

                    @@ -94681,16 +94699,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: +

                    + +
                      +
                    • 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 @@ -94848,31 +94882,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 - objects that are either Window or WorkerGlobalScope objects.

                    +

                    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.

                    -

                    There is always a 1-to-1-to-1 mapping between realms, global objects, and environment settings objects:

                    +

                    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 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 realm then has a [[GlobalObject]] field, which contains the synthetic realm settings object's global object.

                  • +
                  + +

                  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
                  @@ -95031,9 +95176,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. @@ -95079,13 +95224,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.

                  @@ -95108,7 +95253,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.

                @@ -95391,12 +95538,23 @@ document.querySelector("button").addEventListener("click", bound);

                The JavaScript specification defines the current realm, also known as the "current Realm Record".

                -

                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
                @@ -95517,10 +95675,13 @@ document.querySelector("button").addEventListener("click", bound); data-x="struct">structs. 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
                @@ -95585,6 +95746,11 @@ document.querySelector("button").addEventListener("click", bound); 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:

                @@ -96057,15 +96223,17 @@ document.querySelector("button").addEventListener("click", bound);
              3. Fetch the descendants of and link result given settings object, "script", visited set, and onComplete.

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

            To fetch an import() module script graph given a moduleRequest, a - script, a settings object, some options, and an - onComplete algorithm, run these steps. onComplete must be an algorithm - accepting null (on failure) or a module script (on success).

            + script, a settings object, some options, a module map + realm, and an onComplete algorithm, run these steps. + onComplete must be an algorithm accepting null (on failure) or a + module script (on success).

            1. Disallow further import maps given settings object.

            2. @@ -96103,7 +96271,7 @@ document.querySelector("button").addEventListener("click", bound);
            3. Fetch the descendants of and link result given settings object, destination, - visited set, and onComplete.

            4. + visited set, module map realm, and onComplete.

          @@ -96134,7 +96302,9 @@ document.querySelector("button").addEventListener("click", bound);
        6. Fetch the descendants of and link result given settings object, - destination, visited set, and with an empty algorithm.

        7. + destination, visited set, settings object's realm, and with an empty + algorithm.

        Generally, performing these steps will be beneficial for performance, as it @@ -96165,7 +96335,8 @@ document.querySelector("button").addEventListener("click", bound);

      4. Fetch the descendants of and link script, given settings object, the - destination "script", visited set, and + destination "script", visited set, settings object's + realm, and onComplete.

      @@ -96379,15 +96550,16 @@ document.querySelector("button").addEventListener("click", bound);
    2. Fetch the descendants of and link result given fetch client settings - object, destination, visited set, and - onComplete. If performFetch was given, pass it along as well.

    3. + object, destination, visited set, settings object's + realm, and onComplete. + If performFetch was given, pass it along as well.

    -

    To fetch the descendants of and link a module script module - script, given a fetch client settings object, a destination, a - visited set, an onComplete algorithm, and an optional To fetch the descendants of and link a module script module script, given + a fetch client settings object, a destination, a visited set, a + module map realm, an onComplete algorithm, 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).

    @@ -96796,8 +96968,8 @@ document.querySelector("button").addEventListener("click", bound);
  • Let script be a new classic script that this algorithm will subsequently initialize.

  • -
  • Set script's settings - object to settings.

  • +
  • Set script's realm to + settings's realm.

  • Set script's base URL to baseURL.

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

  • -
  • Set script's settings - object to settings.

  • +
  • Set script's realm to + settings's realm.

  • Set script's base URL to baseURL.

  • @@ -97629,9 +97801,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. @@ -98554,7 +98727,8 @@ dictionary PromiseRejectionEventInit : EventInit
    10. 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.

      @@ -98667,8 +98841,8 @@ 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 implementations of HostResolveImportedModule and - HostImportModuleDynamically, by falling back to using the current settings - object's API base URL.

      + HostImportModuleDynamically, by falling back to using the current principal + settings object's API base URL.

    11. @@ -98876,7 +99050,8 @@ import "https://example.com/foo/../module2.mjs"; User agents must use the following implementation:

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

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

      4. If settings object's global @@ -98899,6 +99074,13 @@ import "https://example.com/foo/../module2.mjs";

      5. Let fetch options be the default classic script fetch options.

      6. +
      7. +

        Let module map realm be the current realm.

        + +

        In the case of the ShadowRealm.prototype.importValue API the + current realm is set to the appropriate synthetic realm.

        +
      8. +
      9. If referencingScriptOrModule is not null, then:

        @@ -98916,6 +99098,15 @@ import "https://example.com/foo/../module2.mjs";
      10. Assert: fetch options is not null, as referencing script is a classic script or a JavaScript module script.

      11. + +
      12. +

        Set module map realm 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.

        +

      As explained for HostResolveImportedModule, in the common @@ -98924,8 +99115,8 @@ import "https://example.com/foo/../module2.mjs";

    12. Fetch an import() module script graph given moduleRequest, - referencing script, settings object, fetch options, and with - the following steps given result:

      + referencing script, settings object, fetch options, + module map realm, and with the following steps given result:

      1. Let promise be null. @@ -98950,7 +99141,7 @@ import "https://example.com/foo/../module2.mjs"; agents must use the following implementation:

          -
        1. Let moduleMap and referencingScript be null.

        2. +
        3. Let referencingScript be null.

        4. If referencingScriptOrModule is not null, then:

          @@ -98959,9 +99150,13 @@ import "https://example.com/foo/../module2.mjs";
        5. Set referencingScript to referencingScriptOrModule.[[HostDefined]].

        6. -
        7. Set moduleMap to referencingScript's - settings object's - module map.

        8. +
        9. +

          Let moduleMapRealm be referencingScript's realm.

          + +

          Module map realm could be a synthetic realm in the + case of a dynamic import() expression evaluated within a synthetic realm.

          +
      2. @@ -98969,10 +99164,12 @@ import "https://example.com/foo/../module2.mjs";

        Otherwise:

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

        2. +
        3. Assert: there is a current realm.

        4. -
        5. Set moduleMap to the current settings object's module map.

        6. +
        7. Let moduleMapRealm be the current realm.

        8. + +
        9. moduleMapRealm could be a synthetic Realm in the + case of a call to ShadowRealm.prototype.importValue.

        @@ -99003,6 +99200,99 @@ import "https://example.com/foo/../module2.mjs";
      3. Let moduleType be the result of running the module type from module request steps given moduleRequest.

      4. +
      5. Let resolvedModuleScript be the result of finding and possibly cloning the module at url given + moduleType and moduleMapRealm.

      6. + +
      7. Return resolvedModuleScript's record.

      8. +
      + +

      To find and possibly clone a module given a URL, moduleType, + and moduleMapRealm, perform the following steps, returning + a module script:

      + +
        +
      1. Let moduleMap be moduleMapRealm's module map.

      2. + +
      3. +

        If moduleMap[(url, moduleType)] does not + exist, then:

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

        2. + +
        3. Let parentModuleMap be moduleMapRealm's + principal realm 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. Let parentParseError be parentModule's parse error.

        18. + +
        19. +

          If parentParseError is null, then:

          +
            +
          1. Set childModule's parse + error to null.

          2. +
          +
        20. + +
        21. +

          Otherwise,

          +
            +
          1. Assert: parentParseError is a SyntaxError + instance.

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

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

        24. + +
        25. Let parentRecord be parentModule's record.

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

        28. + +
        29. Set moduleMap[(url, moduleType)] to + childModule.

        30. +
        +
      4. +
      5. Let resolvedModuleScript be moduleMap[(url, moduleType)]. (This entry must exist for us to have gotten to this point.)

      6. @@ -99013,8 +99303,7 @@ import "https://example.com/foo/../module2.mjs";
      7. Assert: resolvedModuleScript's record is not null.

        -
      8. Return resolvedModuleScript's record.

      9. +
      10. Return resolvedModuleScript.

      HostGetSupportedImportAssertions()
      @@ -99028,6 +99317,70 @@ import "https://example.com/foo/../module2.mjs";
    13. Return « "type" ».

    +
    HostInitializeShadowRealm(realm)
    + +

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

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

    @@ -100141,7 +100494,7 @@ import "https://example.com/foo/../module2.mjs";
    1. Let parsed be the result of parsing - string relative to the current settings object.

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

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

    4. @@ -100153,7 +100506,7 @@ import "https://example.com/foo/../module2.mjs";
    -
  • Let realm be the current realm.

  • +
  • Let realm be the current principal realm.

  • Let p be a new promise.

  • @@ -100202,15 +100555,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 HostResolveImportedModule and - HostImportModuleDynamically will fall back to the current settings - object's API base URL.

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

    • @@ -107961,7 +108314,7 @@ enum WorkerType { "classic", "module" }; DOMException if the request violates a policy decision (e.g. if the user agent is configured to not allow the page to start dedicated workers).

      -
    • Let outside settings be the current settings object.

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

    • Parse the scriptURL argument relative to outside settings.

    • @@ -108061,7 +108414,8 @@ interface SharedWorker : EventTarget { data-x="">name member is set to the value of options and whose other members are set to their default values.

      -
    • Let outside settings be the current settings object.

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

    • Parse scriptURL relative to outside settings.

    • @@ -108264,7 +108618,8 @@ interface SharedWorker : EventTarget { data-x="concept-WorkerGlobalScope-type">type is "module", throw a TypeError exception.

      -
    • Let settings object be the current settings object.

    • +
    • Let settings object be the current principal settings + object.

    • If urls is empty, return.

    • @@ -131244,6 +131599,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.