diff --git a/source b/source index b8b39d4b899..3947d130844 100644 --- a/source +++ b/source @@ -94350,16 +94350,29 @@ function receiver(e) {
-

When a script invokes the postMessage(message, targetOrigin, - transfer) method on a Window object, the user agent must - follow these steps:

+

The postMessage(message, + targetOrigin, transfer) method, when invoked on a + Window object must run the following steps:

    +
  1. Let targetWindow be this Window object.

    + +
  2. Let targetRealm be targetWindow's Realm.

  3. + +
  4. Let incumbentSettings be the incumbent settings object.

  5. + + +
  6. If targetOrigin is a single U+002F SOLIDUS character (/), then set + targetOrigin to incumbentSettings's origin.

    +
  7. -

    If the value of the targetOrigin argument is neither a single U+002A ASTERISK - character (*) nor a single U+002F SOLIDUS character (/), then:

    +

    Otherwise, if targetOrigin is not a single U+002A ASTERISK character (*), + then:

    1. Let parsedURL be the result of running the URL parser on @@ -94373,59 +94386,39 @@ function receiver(e) {

  8. -
  9. Let targetRealm be this Window object's Realm.

  10. - -
  11. Let incumbentSettings be the incumbent settings object.

  12. - -
  13. Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). Rethrow any exceptions.

  14. -
  15. Let message clone be cloneRecord.[[Clone]].

  16. +
  17. Let messageClone be cloneRecord.[[Clone]].

  18. -
  19. Let new ports be a new frozen array consisting of all +

  20. Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.

  21. Return, but continue running these steps in in parallel.

  22. -
  23. -

    If the targetOrigin argument is a single literal U+002F SOLIDUS character (/), and - this Window object's associated - Document's origin is not same origin with - incumbentSettings's responsible document's origin, then - abort these steps.

    - -

    Otherwise, if the targetOrigin argument is not a single literal U+002A ASTERISK - character (*) and this Window object's associated Document's origin - is not same origin with targetOrigin, then abort these steps.

    -
  24. - -
  25. Create a trusted event that uses the - MessageEvent interface, with the event type message, which does not bubble, is not cancelable, and has no - default action. The data attribute must be - initialised to the value of message clone, the origin attribute must be initialised to the Unicode serialisation of the - origin specified by incumbentSettings, the

    If the targetOrigin argument is not a single literal U+002A ASTERISK character + (*) and targetWindow's associated + Document's origin is not same origin with + targetOrigin, then abort these steps.

  26. + +
  27. Create a trusted event e that uses + the MessageEvent interface, with the event type message, which does not bubble and is not cancelable. The data attribute must be initialised to + messageClone, the origin attribute must + be initialised to the Unicode + serialisation of incumbentSettings's origin, the source attribute must be initialised to the - WindowProxy object corresponding to the global object (a Window object) - specified by incumbentSettings, and the ports attribute must be initialised to the new - ports array.

  28. + WindowProxy object corresponding incumbentSettings's global object (a Window object), and + the ports attribute must be initialised to + newPorts.

    -
  29. Queue a task to dispatch the - event created in the previous step at the Window object on which the method was - invoked. The task source for this task is the - posted message task source.

  30. +
  31. Queue a task to dispatch + e at targetWindow. The task source for this task is the posted message task source.

@@ -94888,14 +94881,13 @@ interface MessagePort : EventTarget {
-

The postMessage() method, when - called on a port source port, must cause the user agent to run the following - steps:

+

The postMessage(message, + transfer) method, when invoked on a MessagePort object, must + run the following steps:

    - -
  1. Let target port be the port with which source port - is entangled, if any.

  2. +
  3. Let targetPort be the port with which this MessagePort is + entangled, if any; otherwise let it be null.

  4. Let doomed be false.

    @@ -94906,22 +94898,23 @@ interface MessagePort : EventTarget { called.)

  5. -
  6. If any of the objects in transfer are the source port, then throw a - "DataCloneError" DOMException and abort these +

  7. If any of the objects in transfer are this MessagePort, then throw + a "DataCloneError" DOMException and abort these steps.

  8. -
  9. If any of the objects in transfer are the target port, if any, then - let doomed be true, and optionally report to a developer console that the target port - was posted to itself, causing the communication channel to be lost.

  10. +
  11. If targetPort is not null and any of the objects in transfer are + targetPort, then set doomed to true, and optionally report to a developer + console that the target port was posted to itself, causing the communication channel to be + lost.

  12. -

    Let targetRealm be target port's Let targetRealm be targetPort's owner's Realm, if there is a target port and doomed is false, and - otherwise some arbitrary Realm.

    + realm">Realm, if targetPort is non-null and doomed is false; + otherwise let targetRealm be some arbitrary Realm.

    targetRealm is used when cloning and transferring objects below. If - there is no target port, or if the target port is one of the objects being + there is no target port, or if the targetPort is one of the objects being transferred, the transferable objects given in the second argument, if any, are still transferred, but since they are then discarded, it doesn't matter where they are transferred to.)

    @@ -94930,14 +94923,14 @@ interface MessagePort : EventTarget {
  13. Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). Rethrow any exceptions.

  14. -
  15. Let message clone be cloneRecord.[[Clone]].

  16. +
  17. Let messageClone be cloneRecord.[[Clone]].

  18. -
  19. Let new ports be a new frozen array consisting of all +

  20. Let newPorts be a new frozen array consisting of all MessagePort objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.

  21. -
  22. If there is no target port (i.e. if source port - is not entangled), or if doomed is true, then abort these steps.

  23. +
  24. If there is no targetPort (i.e. if this MessagePort is not + entangled), or if doomed is true, then abort these steps.

  25. -
  26. Create an event e that uses the MessageEvent interface, with the name message, which does not bubble, is not cancelable, and has no - default action.

  27. - -
  28. Let the data attribute of e be - initialised to the value of message clone.

  29. - -
  30. Let the ports attribute of e be - initialised to the new ports array.

  31. +
  32. Create an event e that uses the MessageEvent interface, with the + name message, which does not bubble and is not + cancelable. The data attribute must be initialised to + messageClone and the ports attribute must + be initialised to newPorts.

  33. -

    Add a task that runs the following steps to the port - message queue of target port:

    + message queue of targetPort:

      -
    1. Let target be the MessagePort in whose port message queue the event e now finds itself.

    2. Dispatch e at target.

    3. -
    -
  34. -

@@ -95186,112 +95170,95 @@ interface BroadcastChannel : EventTarget {

The name attribute must return the channel name.

-

The postMessage() method, - when invoked on a BroadcastChannel object source with an - argument message, must run the following steps:

+

The postMessage(message) method, + when invoked on a BroadcastChannel object, must run the following steps:

    +
  1. Let source be this BroadcastChannel.

  2. -
  3. Let source settings be source's - BroadcastChannel settings object.

    +
  4. Let sourceSettings be source's BroadcastChannel + settings object.

  5. If source's closed flag is true, then throw an "InvalidStateError" DOMException and abort these steps.

  6. -
  7. Let source channel be source's - channel name.

    +
  8. Let sourceChannel be source's channel name.

  9. Let targetRealm be a user-agent defined Realm.

  10. -
  11. Let cloned message be StructuredClone(message, +

  12. Let clonedMessage be StructuredClone(message, targetRealm). Rethrow any exceptions.

  13. -

    Let destinations be a list of BroadcastChannel objects that match the following criteria:

      -
    • -

      Their BroadcastChannel settings object specifies either:

        -
      • a global object that is a Window object and a responsible document that is fully active, or

      • a global object that is a - WorkerGlobalScope object whose closing flag is false and whose + WorkerGlobalScope object whose closing flag is false and whose worker is a suspendable worker.

      • -
      -
    • -
    • Their BroadcastChannel settings object specifies an - origin that is the same origin as the origin specified - by source settings.

    • +
    • Their BroadcastChannel settings object's origin + is same origin with sourceSettings's origin.

    • -
    • Their channel name is a case-sensitive match for source channel.

    • +
    • Their channel name is a case-sensitive match for + sourceChannel.

    • Their closed flag is false.

    • -
    -
  14. Remove source from destinations.

  15. -
  16. - -

    Sort destinations such that all BroadcastChannel objects - whose BroadcastChannel settings - objects specify the same responsible event loop are sorted in creation - order, oldest first. (This does not define a complete ordering. Within this constraint, user - agents may sort the list in any user-agent defined manner.)

    - -
  17. +
  18. Sort destinations such that all BroadcastChannel objects whose + BroadcastChannel settings + objects specify the same responsible event loop are sorted in creation + order, oldest first. (This does not define a complete ordering. Within this constraint, user + agents may sort the list in any user-agent defined manner.)

  19. - -

    For each BroadcastChannel object in destinations, - queue a task that runs the following steps:

    +

    For each BroadcastChannel object destination in + destinations, queue a task that runs the following steps:

      -
    1. Let targetRealm be BroadcastChannel object's relevant - settings object's Realm.

    2. - -
    3. Create an event that uses the MessageEvent interface, with the event type - message, which does not bubble, is not cancelable, and has - no default action. The data attribute must be - initialised to StructuredClone(cloned message, - targetRealm), and the origin - attribute must be initialised to the Unicode - serialisation of the origin specified by source settings. This - event is not trusted.

    4. - -
    5. Dispatch the event at the - BroadcastChannel object.

    6. +
    7. Let targetRealm be destination's relevant settings + object's Realm.

    8. + +
    9. Create an event e that uses the MessageEvent interface, with the + event type message, which does not bubble and is not + cancelable. The data attribute must be initialised + to StructuredClone(clonedMessage, targetRealm) + and the origin attribute must be initialised to + the Unicode serialisation of + sourceSettings's origin.

    10. +
    11. Dispatch e at + destination.

    -

    The tasks must use the DOM - manipulation task source, and, for those where the event loop specified by the target BroadcastChannel object's - BroadcastChannel settings object is a browsing context event loop, must - be associated with the responsible - document specified by that target BroadcastChannel object's - BroadcastChannel settings object.

    - +

    The tasks must use the DOM manipulation task + source, and, for those where the event loop specified by the target + BroadcastChannel object's BroadcastChannel settings + object is a browsing context event loop, must be associated + with the responsible document specified by that target + BroadcastChannel object's BroadcastChannel settings + object.

  20. -

While a BroadcastChannel object whose