diff --git a/source b/source index 01a93e619a2..5e79d3f0b0b 100644 --- a/source +++ b/source @@ -2942,6 +2942,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • upon fulfillment
  • mark as handled
  • [Global]
  • +
  • [PropagatesAsyncContext]
  • [LegacyFactoryFunction]
  • [LegacyLenientThis]
  • [LegacyNullToEmptyString]
  • @@ -3200,6 +3201,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 +5147,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 +66723,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 +67233,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 +67502,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. Run the module script given by + el's result.

        4. +
        +
        -
      13. If el's from an external file is - true, then fire an event named load at el.

      14. +
        "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. +
        +
        +
        + + +
      15. Decrement the ignore-destructive-writes counter of document, if + it was incremented in the earlier step.

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

      18. +
      +
    @@ -68504,7 +68572,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 +85446,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 +85517,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 +89365,7 @@ DND-v5: DataTransferItem? kind; readonly attribute DOMString type; - undefined getAsString(FunctionStringCallback? _callback); File? getAsFile(); @@ -121613,35 +121723,42 @@ import "https://example.com/foo/../module2.mjs"; true.

  • -

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

        +

        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.

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

  • -
  • Cleanup Indexed Database transactions.

  • @@ -123319,7 +123436,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 +125031,12 @@ interface XMLSerializer {
  • Let uniqueHandle be null.

  • +
  • Let savedAsyncContextMapping be AsyncContextSnapshot().

  • +
  • -

    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 +127800,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 +156096,9 @@ INSERT INTERFACES HERE
          
      [JPEG]
      JPEG File Interchange Format, E. Hamilton.
      +
      [JSASYNCCONTEXT]
      +
      AsyncContext. Ecma International.
      +
      [JSERRORSTACKS]
      (Non-normative) Error Stacks. Ecma International.