diff --git a/source b/source index 01a93e619a2..660d56e4e04 100644 --- a/source +++ b/source @@ -2316,8 +2316,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute getting the keys, getting the values, sorting in descending order, - size, and - iterate + size, + iterate, and + clone
  • The list data structure and the associated definitions for append, extend, @@ -2942,6 +2943,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • upon fulfillment
  • mark as handled
  • [Global]
  • +
  • [PropagatesAsyncContext]
  • [LegacyFactoryFunction]
  • [LegacyLenientThis]
  • [LegacyNullToEmptyString]
  • @@ -3200,6 +3202,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The nsMaxInstant and nsMinInstant values
  • + +

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

    + +
    WebAssembly
    @@ -5137,6 +5148,41 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute XSLT, XPath, and HTML in the template element section.

    + + + +

    Interactions with AsyncContext

    + +
    +

    To run an + algorithm steps with an Async Context Mapping mapping: + JSASYNCCONTEXT

    + +
      +
    1. Let previousMapping be + AsyncContextSwap(mapping).

    2. + +
    3. +

      Let returnValue be the result of running steps. If this throws an + exception e, then:

      + +
        +
      1. Perform AsyncContextSwap(previousMapping).

      2. + +
      3. Throw e.

      4. +
      + +
    4. Perform AsyncContextSwap(previousMapping).

    5. + +
    6. Return returnValue.

    7. +
    +
    + +

    Specifications should not use the AsyncContextSwap abstract operation defined in + JSASYNCCONTEXT, or otherwise set or mutate an agent record's [[AsyncContextMapping]] + field. Instead they should run an algorithm with + an Async Context Mapping, which properly cleans up after itself.

    + @@ -66678,6 +66724,10 @@ o............A....e

    A script element has a delaying the load event boolean, initially false.

    +

    A script element has an execution Async Context Mapping, which is + either null or an Async Context Mapping, initially null. It is used so async-local + state from the script preparation is available when the script is executed.

    +

    A script element has a type, which is either null, "classic", "module", "importmap", or "speculationrules", initially null. It is @@ -67184,6 +67234,9 @@ document.body.append(script1, script2); +

  • Set el's execution Async Context Mapping to + AsyncContextSnapshot().

  • +
  • If el does not have a src content attribute:

    @@ -67450,90 +67503,106 @@ document.body.append(script1, script2); script element el:

      -
    1. Let document be el's node document.

    2. +
    3. Assert: el's execution Async Context Mapping is not + null.

    4. -
    5. If el's preparation-time document is not equal to - document, then return.

    6. +
    7. +

      Run the following steps with + el's execution Async Context Mapping:

      -
    8. Unblock rendering on el.

    9. +

      In the case where prepare the script element + immediately invoked this algorithm, this does not change the current Async + Context Mapping.

      -
    10. If el's result is null, then fire an event named error - at el, and return.

    11. +
        +
      1. Set el's execution Async Context Mapping to null.

      2. -
      3. If el's from an external file is - true, or el's type is "module", then increment document's ignore-destructive-writes - counter.

      4. +
      5. Let document be el's node document.

      6. -
      7. -

        Switch on el's type:

        +
      8. If el's preparation-time document is not equal to + document, then return.

      9. -
        -
        "classic"
        -
        -
          -
        1. Let oldCurrentScript be the value to which document's currentScript object was most recently - set.

        2. +
        3. Unblock rendering on el.

        4. -
        5. -

          If el's root is not a shadow root, then - set document's currentScript - attribute to el. Otherwise, set it to null.

          - -

          This does not use the in a document tree check, as - el could have been removed from the document prior to execution, and in that - scenario currentScript still needs to - point to it.

          -
        6. +
        7. If el's result is null, then fire an event named error + at el, and return.

        8. -
        9. Run the classic script given by - el's result.

        10. +
        11. If el's from an external file is + true, or el's type is "module", then increment document's ignore-destructive-writes + counter.

        12. -
        13. Set document's currentScript attribute to - oldCurrentScript.

        14. -
        -
        +
      10. +

        Switch on el's type:

        -
        "module"
        -
        -
          -
        1. Assert: document's currentScript attribute is null.

        2. +
          +
          "classic"
          +
          +
            +
          1. Let oldCurrentScript be the value to which document's currentScript object was most recently + set.

          2. -
          3. Run the module script given by - el's result.

          4. -
          -
          +
        3. +

          If el's root is not a shadow root, then + set document's currentScript + attribute to el. Otherwise, set it to null.

          + +

          This does not use the in a document tree check, as + el could have been removed from the document prior to execution, and in that + scenario currentScript still needs to + point to it.

          +
        4. -
          "importmap"
          -
          -
            -
          1. Register an import map given el's relevant global - object and el's result.

          2. -
          -
          +
        5. Run the classic script given by + el's result.

        6. -
          "speculationrules"
          -
          -
            -
          1. Register speculation rules given el's relevant global - object and el's result.

          2. -
          -
          -
          - +
        7. Set document's currentScript attribute to + oldCurrentScript.

        8. +
        +
        -
      11. Decrement the ignore-destructive-writes counter of document, if - it was incremented in the earlier step.

      12. +
        "module"
        +
        +
          +
        1. Assert: document's currentScript attribute is null.

        2. -
        3. If el's from an external file is - true, then fire an event named load at el.

        4. +
        5. Run the module script given by + el's result.

        6. +
        +
        + +
        "importmap"
        +
        +
          +
        1. Register an import map given el's relevant global + object and el's result.

        2. +
        +
        + +
        "speculationrules"
        +
        +
          +
        1. Register speculation rules given el's relevant global + object and el's result.

        2. +
        +
        +
        + + +
      13. Decrement the ignore-destructive-writes counter of document, if + it was incremented in the earlier step.

      14. + +
      15. If el's from an external file is + true, then fire an event named load at el.

      16. +
      +
    @@ -68504,7 +68573,7 @@ interface HTMLCanvasElement : HTMLElement { RenderingContext? getContext(DOMString contextId, optional any options = null); USVString toDataURL(optional DOMString type = "image/png", optional any quality); - undefined toBlob(BlobCallback _callback, optional DOMString type = "image/png", optional any quality); + undefined toBlob([PropagatesAsyncContext] BlobCallback _callback, optional DOMString type = "image/png", optional any quality); OffscreenCanvas transferControlToOffscreen(); }; @@ -85378,9 +85447,30 @@ dictionary CommandEventInit : EventInit { target be null.

  • -

    If blur event target is not null, fire a focus event - named blur at blur event target, with - related blur target as the related target.

    +

    If blur event target is not null:

    + +
      +
    1. +

      If blur event target's relevant agent is not the + surrounding agent, or if blur event target's relevant settings + object's origin is not + same origin with the current settings object's origin, then run the following steps with Async Context Mapping « ». + Otherwise, run the following steps:

      + +
        +
      1. Fire a focus event named blur at + blur event target, with related blur target as the related + target.

        +
      + +

      Issue #3506: If + focus event target's relevant agent is not the surrounding agent, then the event + should be fired in a task in the relevant agent's event loop.

      + +
    2. +

    In some cases, e.g., if entry is an area element's shape, a scrollable region, or a viewport, no @@ -85428,9 +85518,30 @@ dictionary CommandEventInit : EventInit { focus target be null.

  • -

    If focus event target is not null, fire a focus event - named focus at focus event target, with - related focus target as the related target.

    +

    If focus event target is not null:

    + +
      +
    1. +

      If focus event target's relevant agent is not the + surrounding agent, or if focus event target's relevant + settings object's origin is not + same origin with the current settings object's origin, then run the following steps with Async Context Mapping « ». + Otherwise, run the following steps:

      + +
        +
      1. Fire a focus event named focus at + focus event target, with related focus target as the related + target.

      2. +
      + +

      Issue #3506: If + focus event target's relevant agent is not the surrounding agent, then the event + should be fired in a task in the relevant agent's event loop.

      + +
    2. +

    In some cases, e.g. if entry is an area element's shape, a scrollable region, or a viewport, no event is fired.

    @@ -89255,7 +89366,7 @@ DND-v5: DataTransferItem? kind; readonly attribute DOMString type; - undefined getAsString(FunctionStringCallback? _callback); File? getAsFile(); @@ -115613,14 +115724,16 @@ new PaymentRequest(…); // Allowed to use

    A global object has an in error reporting mode boolean, which is initially false.

    -

    A global object has an outstanding rejected promises weak set, a - set of Promise objects, initially empty. This set - must not create strong references to any of its members, and implementations are free to limit - its size in an implementation-defined manner, e.g., by removing old entries from it - when new ones are added.

    +

    A global object has an outstanding rejected promises weak map, a + map from Promise objects to + Async Context Mappings, initially empty. This map must + not create strong references to any of its keys, and implementations are free to limit its size + in an implementation-defined manner, e.g., by removing old entries from it when new + ones are added.

    -

    A global object has an about-to-be-notified rejected promises list, a - list of Promise objects, initially empty.

    +

    A global object has an about-to-be-notified rejected promises map, a + map from Promise objects to + Async Context Mappings, initially empty.

    A global object has an import map, initially an empty import map.

    @@ -118353,39 +118466,48 @@ dictionary ErrorEventInit : EventInit { global:

      -
    1. Let list be a clone of global's - about-to-be-notified rejected promises list.

    2. +
    3. Let map be a clone of global's + about-to-be-notified rejected promises map.

    4. -
    5. If list is empty, then return.

    6. +
    7. If map is empty, then return.

    8. -
    9. Empty global's about-to-be-notified - rejected promises list.

    10. +
    11. Clear global's about-to-be-notified + rejected promises map.

    12. Queue a global task on the DOM manipulation task source given global to run the following step:

        -
      1. For each promise p of list:

        +
      2. For each entry p → + asyncContextMapping of map:

        1. If p.[[PromiseIsHandled]] is true, then continue.

        2. -
        3. Let notCanceled be the result of firing - an event named unhandledrejection at - global, using PromiseRejectionEvent, with the cancelable attribute initialized to true, the promise attribute initialized to - p, and the reason - attribute initialized to p.[[PromiseResult]].

        4. +
        5. +

          Let notCanceled be the result of running the following steps with Async Context Mapping + asyncContextMapping:

          + +
            +
          1. Return the result of firing an event named + unhandledrejection at global, + using PromiseRejectionEvent, with the cancelable attribute initialized to true, the promise attribute initialized to + p, and the reason + attribute initialized to p.[[PromiseResult]].

          2. +
          +
        6. If notCanceled is true, then the user agent may report p.[[PromiseResult]] to a developer console.

        7. -
        8. If p.[[PromiseIsHandled]] is false, then append p to global's outstanding rejected - promises weak set.

        9. +
        10. If p.[[PromiseIsHandled]] is false, then set + (global's outstanding rejected promises weak map)[p] to + asyncContextMapping.

      @@ -119984,8 +120106,9 @@ dictionary PromiseRejectionEventInit : EventInitIf operation is "reject", then:

        -
      1. Append promise to global's - about-to-be-notified rejected promises list.

      2. +
      3. Set (global's about-to-be-notified + rejected promises map)[promise] to + AsyncContextSnapshot().

    13. @@ -119993,23 +120116,31 @@ dictionary PromiseRejectionEventInit : EventInitIf operation is "handle", then:

        -
      1. If global's about-to-be-notified rejected promises list contains promise, then remove promise from that list and return.

      2. +
      3. If global's about-to-be-notified rejected promises map contains an entry with the key promise, then remove that entry and return.

      4. -
      5. If global's outstanding rejected promises weak set does not - contain promise, then return.

      6. +
      7. If global's outstanding rejected promises weak map does not + contain an entry with the key promise, then + return.

      8. + +
      9. Remove an entry with the key promise from + global's outstanding rejected promises weak map.

      10. -
      11. Remove promise from global's - outstanding rejected promises weak set.

      12. +
      13. +

        Queue a global task on the DOM manipulation task source given + global to run the following steps + with Async Context Mapping AsyncContextSnapshot():

        -
      14. Queue a global task on the DOM manipulation task source given - global to fire an event named rejectionhandled at global, using - PromiseRejectionEvent, with the promise attribute initialized to - promise, and the reason - attribute initialized to promise.[[PromiseResult]].

      15. +
          +
        1. Fire an event named rejectionhandled at global, using + PromiseRejectionEvent, with the promise attribute initialized to + promise, and the reason + attribute initialized to promise.[[PromiseResult]].

        2. +
        +
    @@ -120125,7 +120256,9 @@ dictionary PromiseRejectionEventInit : EventInit

    Queue a global task on the JavaScript engine task source given - global to perform the following steps:

    + global to run the following steps + with Async Context Mapping + finalizationRegistry.[[FinalizationRegistryAsyncContextMapping]]:

    1. Let entry be @@ -121613,35 +121746,42 @@ import "https://example.com/foo/../module2.mjs"; true.

    2. -

      While the event loop's microtask queue is not empty:

      +

      Run the following steps with Async + Context Mapping « »:

        -
      1. Let oldestMicrotask be the result of dequeuing - from the event loop's microtask queue.

      2. +
      3. +

        While the event loop's microtask queue is not empty:

        -
      4. Set the event loop's currently running task to - oldestMicrotask.

      5. +
          +
        1. Let oldestMicrotask be the result of dequeuing + from the event loop's microtask queue.

        2. -
        3. -

          Run oldestMicrotask.

          +
        4. Set the event loop's currently running task to + oldestMicrotask.

        5. -

          This might involve invoking scripted callbacks, which eventually calls the - clean up after running script steps, which call this perform a microtask - checkpoint algorithm again, which is why we use the performing a microtask - checkpoint flag to avoid reentrancy.

          +
        6. +

          Run oldestMicrotask.

          + +

          This might involve invoking scripted callbacks, which eventually calls the + clean up after running script steps, which call this perform a microtask + checkpoint algorithm again, which is why we use the performing a microtask + checkpoint flag to avoid reentrancy.

          +
        7. + +
        8. Set the event loop's currently running task back to + null.

        9. +
        -
      6. Set the event loop's currently running task back to - null.

      7. +
      8. For each environment settings object settingsObject whose + responsible event loop is this event loop, notify about rejected + promises given settingsObject's global object.

    3. -
    4. For each environment settings object settingsObject whose - responsible event loop is this event loop, notify about rejected - promises given settingsObject's global object.

    5. -
    6. Cleanup Indexed Database transactions.

    7. @@ -123319,7 +123459,7 @@ interface mixin WindowOrWorkerGlobalScope { undefined clearInterval(optional long id = 0); // microtask queuing - undefined queueMicrotask(VoidFunction callback); + undefined queueMicrotask([PropagatesAsyncContext] VoidFunction callback); // ImageBitmap Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options = {}); @@ -124914,9 +125054,12 @@ interface XMLSerializer {
    8. Let uniqueHandle be null.

    9. +
    10. Let savedAsyncContextMapping be AsyncContextSnapshot().

    11. +
    12. -

      Let task be a task that runs the following - substeps:

      +

      Let task be a task that runs the following steps with the Async Context Mapping + savedAsyncContextMapping:

      1. Assert: uniqueHandle is a unique internal value, @@ -127680,7 +127823,7 @@ loadMySprites().then(runDemo);

        callback FrameRequestCallback = undefined (DOMHighResTimeStamp time);
         
         interface mixin AnimationFrameProvider {
        -  unsigned long requestAnimationFrame(FrameRequestCallback callback);
        +  unsigned long requestAnimationFrame([PropagatesAsyncContext] FrameRequestCallback callback);
           undefined cancelAnimationFrame(unsigned long handle);
         };
         Window includes AnimationFrameProvider;
        @@ -155976,6 +156119,9 @@ INSERT INTERFACES HERE
            
        [JPEG]
        JPEG File Interchange Format, E. Hamilton.
        +
        [JSASYNCCONTEXT]
        +
        AsyncContext. Ecma International.
        +
        [JSERRORSTACKS]
        (Non-normative) Error Stacks. Ecma International.