diff --git a/source b/source index 3e907bc3626..b4b2752adb5 100644 --- a/source +++ b/source @@ -78126,9 +78126,13 @@ interface Window : Eve void print(); void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []); + void postMessage(any message, optional WindowPostMessageOptions options); }; Window includes GlobalEventHandlers; -Window includes WindowEventHandlers; + +dictionary WindowPostMessageOptions : PostMessageOptions { + USVString targetOrigin = "/"; +}; -
  • Let targetWindow be this Window object.

    -
  • Let targetRealm be targetWindow's Realm.

  • @@ -96032,6 +96040,9 @@ function receiver(e) { window, in same-origin cases. See discussion at https://github.com/whatwg/html/issues/1542#issuecomment-233502636 --> +
  • Let targetOrigin be options["targetOrigin"].

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

    @@ -96052,6 +96063,8 @@ function receiver(e) {
  • +
  • Let transfer be options["transfer"].

  • +
  • Let serializeWithTransferResult be StructuredSerializeWithTransfer(message, transfer). Rethrow any exceptions.

  • @@ -96070,7 +96083,7 @@ function receiver(e) { origin">serialization
    of incumbentSettings's origin.

    -
  • Let source be the WindowProxy object's corresponding to +

  • Let source be the WindowProxy object corresponding to incumbentSettings's global object (a Window object).

  • @@ -96105,6 +96118,30 @@ function receiver(e) { +

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

    +
      +
    1. Let targetWindow be this Window object.

    2. + +
    3. Run the window post message steps providing targetWindow, + message, and options.

    4. +
    + +

    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. + +
    3. Let options be «[ "targetOrigin" → + targetOrigin, "transfer" → transfer ]».

    4. + +
    5. Run the window post message steps providing targetWindow, + message, and options.

    6. +
    + @@ -96380,16 +96417,22 @@ interface MessageChannel {
    [Exposed=(Window,Worker,AudioWorklet), Transferable]
     interface MessagePort : EventTarget {
       void postMessage(any message, optional sequence<object> transfer = []);
    +  void postMessage(any message, PostMessageOptions options);
       void start();
       void close();
     
       // event handlers
       attribute EventHandler onmessage;
       attribute EventHandler onmessageerror;
    +};
    +
    +dictionary PostMessageOptions {
    +  sequence<object> transfer = [];
     };
    port . postMessage(message [, transfer] )
    +
    port . postMessage(message [, { transfer }] )

    Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.

    @@ -96541,13 +96584,11 @@ interface MessagePort : EventTarget {
    -

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

    +

    The message port post message steps, given a targetPort, message + and options are as follows:

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

    2. +
        +
      1. Let transfer be options["transfer"].

      2. If transfer contains this MessagePort, then throw a "DataCloneError" @@ -96614,6 +96655,33 @@ interface MessagePort : EventTarget {

      +

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

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

      2. + +
      3. Run the message port post message steps providing targetPort, + message and options.

      4. +
      + +

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

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

      2. + +
      3. Let options be «[ "transfer" → transfer + ]».

      4. + +
      5. Run the message port post message steps providing targetPort, + message and options.

      6. +
      +

      The start() method, when invoked, must @@ -97508,6 +97576,7 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope [Replaceable] readonly attribute DOMString name; void postMessage(any message, optional sequence<object> transfer = []); + void postMessage(any message, PostMessageOptions options); void close(); @@ -97532,6 +97601,9 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope

      dedicatedWorkerGlobal . postMessage(message [, transfer ])
      +
      dedicatedWorkerGlobal . postMessage(message + [, { transfer } ])
      Clones message and transmits it to the Worker object associated with dedicatedWorkerGlobal. transfer can be passed as a list of objects that are to be transferred rather than cloned.
      @@ -97548,10 +97620,16 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope data-x="concept-WorkerGlobalScope-name">name. Its value represents the name given to the worker using the Worker constructor, used primarily for debugging purposes.

      -

      The postMessage() - method on DedicatedWorkerGlobalScope objects must act as if, when invoked, it - immediately invoked the method of the same name - on the port, with the same arguments, and returned the same return value.

      +

      The postMessage(message, + transfer) and postMessage(message, + options) methods on DedicatedWorkerGlobalScope objects + act as if, when invoked, it immediately invoked the respective postMessage(message, transfer) + and postMessage(message, + options) on the port, with the same arguments, and returned the same return + value.

      To close a worker, given a workerGlobal, run these steps:

      @@ -98243,6 +98321,7 @@ interface Worker : EventTarget { void terminate(); void postMessage(any message, optional sequence<object> transfer = []); + void postMessage(any message, PostMessageOptions options); attribute EventHandler onmessage; attribute EventHandler onmessageerror; }; @@ -98271,7 +98350,11 @@ enum WorkerType { "classic", "module" };
      worker . terminate()
      Aborts worker's associated global environment.
      -
      worker . postMessage(message [, transfer ]) +
      worker . postMessage(message [, transfer ] ) +
      worker . postMessage(message [, { transfer } ] )
      Clones message and transmits it to worker's global environment. transfer can be passed as a list of objects that are to be transferred rather than cloned.
      @@ -98290,10 +98373,15 @@ enum WorkerType { "classic", "module" };

      All messages received by that port must immediately be retargeted at the Worker object.

      -

      The postMessage() method on - Worker objects must act as if, when invoked, it immediately invoked the method of the same name on the port, with the same - arguments, and returned the same return value.

      +

      The postMessage(message, + transfer) and postMessage(message, + options) methods on Worker objects act as if, when invoked, + they immediately invoked the respective postMessage(message, transfer) + and postMessage(message, + options) on the port, with the same arguments, and returned the same return + value.