From c398de39cc23dc92733b5a967e44954ea7489073 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 9 Jun 2023 17:27:53 +0200 Subject: [PATCH 1/7] Require support for AsyncContext --- source | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source b/source index 760de2984fc..7ad2ff6cabc 100644 --- a/source +++ b/source @@ -3080,6 +3080,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute + +

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

+ +
WebAssembly
@@ -106783,9 +106792,16 @@ dictionary PromiseRejectionEventInit : EventInitThis affects the active script while the callback runs.

+
  • Let previousContextMapping be AsyncContextSwap(callback.[[AsyncContextSnapshot]]).

  • +
  • Let result be Call(callback.[[Callback]], V, argumentsList).

  • +
  • Perform AsyncContextSwap(previousContextMapping).

  • +
  • If script execution context is not null, then pop script execution context from the JavaScript execution context stack.

  • @@ -107019,7 +107035,11 @@ dictionary PromiseRejectionEventInit : EventInit +
  • Let snapshot be AsyncContextSnapshot().

  • +
  • Return the JobCallback Record { [[Callback]]: callable, + [[AsyncContextSnapshot]]: snapshot, [[HostDefined]]: { [[IncumbentSettings]]: incumbent settings, [[ActiveScriptContext]]: script execution context } }.

  • @@ -140070,6 +140090,9 @@ INSERT INTERFACES HERE
    [JPEG]
    JPEG File Interchange Format, E. Hamilton.
    +
    [JSASYNCCONTEXT]
    +
    AsyncContext. Ecma International.
    +
    [JSERRORSTACKS]
    (Non-normative) Error Stacks. Ecma International.
    From cb107a3a344120e77ea8fab63a6cfee4fb864b11 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 11 Oct 2023 15:45:37 +0200 Subject: [PATCH 2/7] wip --- source | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source b/source index 7ad2ff6cabc..15c78aae2cf 100644 --- a/source +++ b/source @@ -110688,6 +110688,9 @@ partial interface ShadowRoot { object; otherwise let thisArg be the WindowProxy that corresponds to global.

    +
  • Let snapshot be AsyncContextSnapshot().

  • +
  • If previousId was given, let id be previousId; otherwise, let id be an implementation-defined integer that is greater than zero and does not already exist in global's @@ -110721,6 +110724,10 @@ partial interface ShadowRoot { substeps:

      +
    1. Let previousContextMapping be AsyncContextSwap(callback.[[AsyncContextSnapshot]]).

    2. +
    3. If id does not exist in global's map of active timers, then abort these steps.

    4. @@ -110806,6 +110813,10 @@ partial interface ShadowRoot {
    5. Otherwise, remove global's map of active timers[id].

    6. + + +
    7. Perform AsyncContextSwap(previousContextMapping).

  • From 8f1c62ca75d1a118b9ff48fc8779b6581f239bb7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 20 Nov 2023 16:55:32 +0100 Subject: [PATCH 3/7] fix ref syntax --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 15c78aae2cf..0ba0bddf2fb 100644 --- a/source +++ b/source @@ -3082,8 +3082,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

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

    + proposal. The following terms are defined there, and used in this specification: + JSASYNCCONTEXT

    • The AsyncContextSnapshot abstract operation
    • From 0b6836caa2c9d54d8005d8f0fc76734f7c6c6c38 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 6 Dec 2023 10:17:31 +0100 Subject: [PATCH 4/7] fix timers --- source | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source b/source index 0ba0bddf2fb..60e96d3a160 100644 --- a/source +++ b/source @@ -110724,13 +110724,13 @@ partial interface ShadowRoot { substeps:

        +
      1. If id does not exist in global's + map of active timers, then abort these steps.

      2. +
      3. Let previousContextMapping be AsyncContextSwap(callback.[[AsyncContextSnapshot]]).

      4. -
      5. If id does not exist in global's - map of active timers, then abort these steps.

      6. -
      7. If handler is a Function, then invoke handler given arguments with the callback this @@ -110745,8 +110745,8 @@ partial interface ShadowRoot {

      8. Perform HostEnsureCanCompileStrings(realm). - If this throws an exception, catch it, report the exception, and abort these - steps.

      9. + If this throws an exception, catch it, report the exception, and jump to the + step labeled return.

      10. Let settings object be global's relevant settings object.

      11. @@ -110800,7 +110800,7 @@ partial interface ShadowRoot {
      12. If id does not exist in global's - map of active timers, then abort these steps.

        + map of active timers, then jump to the step labeled return.

        It might have been removed via the author code in handler calling clearTimeout() or ShadowRoot {

      13. Otherwise, remove global's map of active timers[id].

      14. - -
      15. Perform

        Return: Perform AsyncContextSwap(previousContextMapping).

      From 0df4545ccc3704bbf9bbb99892fc29f3ed37b29f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 13 Dec 2023 11:51:42 +0100 Subject: [PATCH 5/7] postMessage --- source | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/source b/source index 60e96d3a160..289c19448b9 100644 --- a/source +++ b/source @@ -114305,6 +114305,9 @@ function receiver(e) { StructuredSerializeWithTransfer(message, transfer). Rethrow any exceptions.

      +
    • Let snapshot be AsyncContextSnapshot().

    • +
    • Queue a global task on the posted message task source given targetWindow to run the following steps:

      @@ -114315,6 +114318,9 @@ function receiver(e) { Document's origin is not same origin with targetOrigin, then return.

    • +
    • Let previousContextMapping be AsyncContextSwap(snapshot).

    • +
    • Let origin be the serialization of incumbentSettings's origin.

    • @@ -114333,7 +114339,7 @@ function receiver(e) { targetWindow, using MessageEvent, with the origin attribute initialized to origin and the source attribute initialized to - source, and then return.

      + source, and then jump to the step below labeled return.

    • Let messageClone be deserializeRecord.[[Deserialized]].

    • @@ -114348,8 +114354,11 @@ function receiver(e) { attribute initialized to origin, the source attribute initialized to source, the data attribute initialized to - messageClone, and the ports attribute - initialized to newPorts.

      + messageClone, the ports attribute + initialized to newPorts, and useCallerAsyncContextFlag flag set.

      + +
    • Return: Perform AsyncContextSwap(previousContextMapping).

    • @@ -114805,6 +114814,9 @@ dictionary StructuredSerializeOptions { algorithm runs scripts). We don't throw an exception for 'doomed' being true, because this can't necessarily be detected right now every time --> +
    • Let snapshot be AsyncContextSnapshot().

    • +
    • Add a task that runs the following steps to the port message queue of targetPort:

      @@ -114821,6 +114833,9 @@ dictionary StructuredSerializeOptions {
    • Let targetRealm be finalTargetPort's relevant realm.

    • +
    • Let previousContextMapping be AsyncContextSwap(snapshot).

    • +
    • Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, @@ -114828,7 +114843,8 @@ dictionary StructuredSerializeOptions {

      If this throws an exception, catch it, fire an event named messageerror at - finalTargetPort, using MessageEvent, and then return. + finalTargetPort, using MessageEvent, and then jump to the step below + labeled return.

    • Let messageClone be deserializeRecord.[[Deserialized]].

    • @@ -114840,9 +114856,12 @@ dictionary StructuredSerializeOptions {
    • Fire an event named message at finalTargetPort, using MessageEvent, with the data attribute - initialized to messageClone and the messageClone, the ports attribute initialized to - newPorts.

    • + newPorts, and useCallerAsyncContextFlag flag set.

      + +
    • Return: Perform AsyncContextSwap(previousContextMapping).

    • From c2e3cbc300d3f5829a3abb2bf1d4c499b9fbf5ea Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 4 Apr 2024 17:12:59 +0200 Subject: [PATCH 6/7] call-time context for unhandledrejection --- source | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/source b/source index 289c19448b9..019bae41781 100644 --- a/source +++ b/source @@ -105776,19 +105776,28 @@ dictionary ErrorEventInit : EventInit { global to run the following substep:

        -
      1. For each promise p in list:

        +
      2. For each tuple element in list:

          +
        1. Let p be element[0]. +

        2. If p's [[PromiseIsHandled]] internal slot is true, continue to the next iteration of the loop.

        3. +
        4. Let previousContextMapping be AsyncContextSwap(element[1]).

        5. +
        6. Let notHandled 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 the value of p's [[PromiseResult]] internal slot.

        7. + initialized to the value of p's [[PromiseResult]] internal slot, with + useCallerAsyncContextFlag set.

          + +
        8. Perform AsyncContextSwap(previousContextMapping).

        9. If notHandled is false, then the promise rejection is handled. Otherwise, the promise rejection is @@ -106715,8 +106724,11 @@ dictionary PromiseRejectionEventInit : EventInitIf operation is "reject", then:

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

          2. +
          3. Let snapshot be AsyncContextSnapshot().

          4. + +
          5. Append (promise, snapshot) to + settings object's about-to-be-notified rejected promises list.

        10. @@ -106725,8 +106737,9 @@ dictionary PromiseRejectionEventInit : EventInit
        11. If settings object's about-to-be-notified rejected promises - list contains promise, then remove promise from that list and return.

        12. + list
          contains an element element for + which element[0] is promise, then remove element from that list and return.

        13. If settings object's outstanding rejected promises weak set does not contain promise, then return.

        14. @@ -106743,7 +106756,8 @@ dictionary PromiseRejectionEventInit : EventInitPromiseRejectionEvent
          , with the promise attribute initialized to promise, and the reason - attribute initialized to promise.[[PromiseResult]].

          + attribute initialized to promise.[[PromiseResult]], and useCallerAsyncContextFlag + set.

      From 49543e79a73c1aa73510521feb4acaa3912319a1 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 12 Apr 2024 17:22:33 +0200 Subject: [PATCH 7/7] Event handlers --- source | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source b/source index 019bae41781..fc32f30a920 100644 --- a/source +++ b/source @@ -3088,6 +3088,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • The AsyncContextSnapshot abstract operation
      • The AsyncContextSwap abstract operation
      • +
      • The Async Context Mapping Record specification type
      @@ -108918,7 +108919,8 @@ import "https://example.com/foo/../module2.mjs";
      steps.

    • Set eventHandler's value to the - internal raw uncompiled handler value/location.

    • + internal raw uncompiled handler (value, location, + AsyncContextSnapshot()).

    • Activate an event handler given eventTarget and localName.

    • @@ -109261,6 +109263,8 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl
    • A location where the script body originated, in case an error needs to be reported +
    • A list of Async Context Mapping + Records

    When the user agent is to get the @@ -109275,9 +109279,11 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl

  • Let eventHandler be handlerMap[name].

  • +
  • Let value be eventHandler's + value.

  • +
  • -

    If eventHandler's value is an - internal raw uncompiled handler, then:

    +

    If value is an internal raw uncompiled handler, then:

    1. If eventTarget is an element, then let element be @@ -109289,11 +109295,9 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl

    2. If scripting is disabled for document, then return null.

    3. -
    4. Let body be the uncompiled script body in eventHandler's value.

    5. +
    6. Let body be value[0].

    7. -
    8. Let location be the location where the script body originated, as - given by eventHandler's value.

    9. +
    10. Let location be value[1].

    11. If element is not null and element has a form owner, let form owner be that form owner. @@ -109448,10 +109452,13 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnl

    12. +
    13. Let context be the tuple (settings object, + value[2]).

    14. +
    15. Set eventHandler's value to the result of creating a Web IDL EventHandler callback function object whose object - reference is function and whose callback context is settings - object.

    16. + reference is function and whose callback context is + context.