diff --git a/source b/source index 8e773640058..b6bf8181376 100644 --- a/source +++ b/source @@ -2985,17 +2985,30 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d @@toStringTag
  • Well-Known Intrinsic Objects, including %ObjProto_toString% + data-x-href="https://tc39.github.io/ecma262/#sec-arraybuffer-constructor">%ArrayBuffer%, + %ArrayPrototype%, + %ObjProto_toString%, and %ObjProto_valueOf%
  • The FunctionBody production
  • The Module production
  • The Pattern production
  • The Script production
  • -
  • The List specification type
  • +
  • The Type notation
  • +
  • The List + and Record + specification types
  • The Property Descriptor specification type
  • The Source Text Module Record specification type and its ModuleEvaluation and ModuleDeclarationInstantiation methods
  • +
  • The ArrayCreate abstract operation
  • The Call abstract operation
  • +
  • The CloneArrayBuffer abstract operation
  • +
  • The CreateDataProperty abstract operation
  • +
  • The DetachArrayBuffer abstract operation
  • The EnqueueJob abstract operation
  • The FunctionCreate abstract operation
  • The GetActiveScriptOrModule abstract operation
  • @@ -3005,6 +3018,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • The IsAccessorDescriptor abstract operation
  • The IsCallable abstract operation
  • The IsDataDescriptor abstract operation
  • +
  • The IsDetachedBuffer abstract operation
  • The NewObjectEnvironment abstract operation
  • The OrdinaryGetPrototypeOf abstract operation
  • @@ -3024,6 +3038,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • The ToBoolean abstract operation
  • The ToString abstract operation
  • The ToUint32 abstract operation
  • +
  • The TypedArrayCreate abstract operation
  • The NextJob algorithm step
  • The Abstract Equality Comparison algorithm
  • The Strict Equality Comparison algorithm @@ -3031,6 +3046,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • The SyntaxError class
  • The TypeError class
  • The typeof operator +
  • The TypedArray Constructors table
  • @@ -7547,389 +7563,473 @@ interface DOMStringMap {

    Safe passing of structured data

    -

    Transferable objects

    +

    This section uses the terminology and typographic conventions from the JavaScript + specification.

    -

    Some objects support being copied and closed in one operation. This is called - transferring the object, and is used in particular to transfer ownership of unsharable or - expensive resources across document and worker boundaries, including across documents of different - origins.

    +

    Cloneable objects

    -

    The following Transferable types exist:

    +

    Cloneable objects support being cloned across event + loops. That is, they support being cloned across document and worker boundaries, including + across documents of different origins. Not all objects are + cloneable objects and not all aspects of objects that are cloneable + objects are necessarily preserved when cloned.

    - +

    IDL-defined cloneable objects are cloneable objects defined through IDL that have + the following internal method:

    -

    The following IDL block formalizes this:

    - -
    typedef (ArrayBuffer
    -         or CanvasProxy
    -         or MessagePort
    -         or ImageBitmap) Transferable;
    - -

    To transfer a Transferable object to a new owner, the user agent must - run the steps defined for the type of object in question. The steps will return a new object of - the same type, and will permanently neuter the - original object. (This is an irreversible and non-idempotent operation; once an object has been - transferred, it cannot be transferred, or indeed used, again.)

    - -

    To transfer an - ArrayBuffer object old to a new owner - owner, a user agent must create a new ArrayBuffer object pointing at the same underlying data as - old, thus obtaining new, must neuter the old object, and must finally - return new.

    - - -

    Rules for how to transfer a - CanvasProxy object and how to transfer a - MessagePort object are given in the relevant sections of this specification.

    - -

    When a user agent is required to obtain a structured clone of a value, optionally - with a transfer map, it must run the following algorithm, which either returns a separate - value, or throws an exception. If a transfer map is provided, it consists of an association - list of Transferable objects to placeholder objects.

    +

    [[Clone]] ( targetRealm, memory )

    + -
      +

      IDL-defined clonable objects must define the [[Clone]] internal method such that + it either throws or returns a clone of this, created in targetRealm. It is up to + IDL-defined cloneable objects to define what cloning means for them.

      -
    1. Let input be the value being cloned.

    2. +

      Objects defined in the JavaScript specification are handled by the StructuredClone + abstract operation directly.

      -
    3. Let transfer map be the transfer map passed to the algorithm, if any, or - the empty list otherwise.

    4. +

      Transferable objects

      -
    5. Let memory be an association list of pairs of objects, initially empty. This is - used to handle duplicate references. In each pair of objects, one is called the source object and the other the destination object.

    6. +

      Transferable objects support being transferred across event loops. Transferring is effectively recreating the object while sharing a + reference to the underlying data and then detaching the object being transferred. This is useful + to transfer ownership of expensive resources. Not all objects are transferable + objects and not all aspects of objects that are transferable objects are + necessarily preserved when transferred.

      -
    7. For each mapping in transfer map, add a mapping from the - Transferable object (the source object) to the placeholder object (the destination - object) to memory.

    8. +

      Transferring is an irreversible and non-idempotent operation. Once an object has + been transferred, it cannot be transferred, or indeed used, again.

      -
    9. Let output be the value resulting from calling the internal structured - cloning algorithm with input as the "input" argument, and - memory as the "memory" argument.

    10. +

      IDL-defined transferable objects are transferable objects defined through IDL that + have a [[Detached]] internal slot and the following internal method:

      -
    11. Return output.

    12. - -
    +

    [[Transfer]] ( targetRealm )

    -

    The internal structured cloning algorithm is always called with two arguments, - input and memory, and its behaviour is as follows:

    +

    IDL-defined transferable objects must define the [[Transfer]] internal method such + that it either throws or returns a clone of this, created in targetRealm, with + this's underlying data shared with the return value, and this's + [[Detached]] internal slot value set to true. It is up to IDL-defined transferable + objects to define what transfering means for them.

    -
      +

      Objects defined in the JavaScript specification are handled by the + StructuredCloneWithTransfer abstract operation directly. (Technically, by + IsTransferable and TransferHelper.)

      -
    1. If input is the source object of a pair of objects in memory, then - return the destination object in that pair of objects and abort these steps.

    2. +

      StructuredCloneWithTransfer ( + input, transferList, targetRealm )

      -
    3. If input is a primitive value, then return that value and abort these - steps.

    4. +
        +
      1. +

        Let memory be an empty map.

        -
      2. Let deep clone be none.

      3. +

        The purpose of the memory map, both here and in the + StructuredClone abstract operation, is to avoid cloning objects twice. This ends up + preserving cycles and the identity of duplicate objects in graphs.

        +
      4. +

        For each object transferable in transferList: -

        The input value is an object. Jump to the appropriate step below:

        +
          +
        1. If IsTransferable(transferable) is false, then throw a + DataCloneError exception.

        2. -
          +
        3. Let placeholder be a user-agent-defined placeholder object.

        4. -
          If input is a Boolean object
          +
        5. Create an entry in memory with key transferable and value + placeholder.

        6. +
        +
      5. -

        Let output be a newly constructed Boolean object with the same value as - input.

        +
      6. Let clone be the result of ? + StructuredClone(input, targetRealm, + memory).

      7. -
        If input is a Number object
        +
      8. Let outputTransferList be a new empty List.

      9. -

        Let output be a newly constructed Number object with the same value as - input.

        +
      10. +

        For each object transferable in transferList: -

        If input is a String object
        +
          +
        1. Let placeholderResult be the value of the entry in memory whose + key is transferable.

        2. -

          Let output be a newly constructed String object with the same value as - input.

          +
        3. Let transferResult be ? TransferHelper(transferable, + targetRealm).

        4. -
          If input is a Date object
          +
        5. +

          Within clone, replace references to placeholderResult with + transferResult, such that everything holding a reference to + placeholderResult, now holds a reference to transferResult.

          -

          Let output be a newly constructed Date object with the same - value as input.

          +

          This is a rather unusual low-level operation for which no primitives are + defined by ECMAScript.

          +
        6. -
          If input is a RegExp object
          +
        7. Add transferResult as the last element of + outputTransferList.

        8. +
        +
      11. -
        +
      12. Return { [[Clone]]: clone, [[TransferList]]: outputTransferList + }.

      13. +
      -

      Let output be a newly constructed RegExp object with the same - pattern and flags as input.

      +

      Originally the StructuredCloneWithTransfer abstract operation was + known as the "structured clone" algorithm. The StructuredClone abstract operation was + known as the "internal structured clone" algorithm. Transferring objects, now handled by the + StructuredCloneWithTransfer abstract operation, were formerly handled by parts of the + algorithm of the postMessage() method on the + Window object and the postMessage() + method on the MessagePort object.

      -

      The value of the lastIndex property is not copied.

      +

      StructuredClone ( + input, targetRealm [ , memory ] )

      - +
        +
      1. If memory was not supplied, let memory be an empty map.

      2. -
        If input is a Blob object
        +
      3. If memory contains an entry with key input, then return that entry's + value.

      4. -

        If input is closed, throw a - DataCloneError exception and abort the overall structured clone - algorithm. Otherwise, let output be a newly constructed object of the same class as - input, corresponding to the same underlying data.

        +
      5. If Type(input) is Undefined, Null, Boolean, + String, or Number, then return input.

      6. -
        If input is a FileList object
        +
      7. If Type(input) is Symbol, then throw a + DataCloneError exception.

      8. -

        Let output be a newly constructed FileList object containing a - list of newly constructed File objects corresponding to the same underlying data - as those in input, maintaining their relative order.

        +
      9. Let deepClone be "none".

      10. -
        If input is an ImageData object
        +
      11. If input has a [[BooleanData]] internal slot, then let output be a + new Boolean object in targetRealm whose [[BooleanData]] internal slot value is the + [[BooleanData]] internal slot value of input.

      12. -

        Let output be a newly constructed ImageData object whose width and height - have values equal to the corresponding attributes on input, and whose data attribute has the value obtained from invoking the - internal structured cloning algorithm recursively with the value of the data attribute on input as the new - "input" argument and memory as the new "memory" - argument.

        +
      13. Otherwise, if input has a [[NumberData]] internal slot, then let + output be a new Number object in targetRealm whose [[NumberData]] internal + slot value is the [[NumberData]] internal slot value of input.

      14. -
        If input is an ImageBitmap object
        +
      15. Otherwise, if input has a [[StringData]] internal slot, then let + output be a new String object in targetRealm whose [[StringData]] internal + slot value is the [[StringData]] internal slot value of input.

      16. -

        If input has been neutered, throw a DataCloneError - exception and abort the overall structured clone algorithm. Otherwise, let - output be a newly constructed ImageBitmap object whose - bitmap data is a copy of - input's bitmap data, and - whose origin-clean flag is set to the same - value as input's origin-clean - flag.

        +
      17. Otherwise, if input has a [[DateValue]] internal slot, then let + output be a new Date object in targetRealm whose [[DateValue]] internal + slot value is the [[DateValue]] internal slot value of input.

      18. -
        If input is an ArrayBuffer object
        +
      19. Otherwise, if input has a [[RegExpMatcher]] internal slot, then let + output be a new RegExp object in targetRealm whose [[RegExpMatcher]] + internal slot value is the [[RegExpMatcher]] internal slot value of input, whose + [[OriginalSource]] internal slot value is the [[OriginalSource]] internal slot value of + input, and whose whose [[OriginalFlags]] internal slot value is the [[OriginalFlags]] + internal slot value of input.

      20. -

        If input has been neutered, throw a DataCloneError - exception and abort the overall structured clone algorithm. Otherwise, let - output be a newly constructed ArrayBuffer - object whose contents are a copy of input's contents, with the same length.

        +
      21. +

        Otherwise, if input has an [[ArrayBufferData]] internal slot, then:

        -
        If input is an object with a [[DataView]] internal slot
        +
          +
        1. If IsDetachedBuffer(input) is true, then throw a + DataCloneError exception.

        2. -
          +
        3. Let outputArrayBuffer be the %ArrayBuffer% intrinsic object in + targetRealm. -

          Let output be a newly constructed object of the same class as input, - with its [[DataView]] internal property present, its [[ViewedArrayBuffer]] internal property - set to the value obtained from invoking the internal structured cloning algorithm - recursively with the value of the internal property on input as the new - "input" argument and memory as the new "memory" argument, and - with the [[ByteLength]] and [[ByteOffset]] internal properties set to the same value as their - counterparts on input.

          +
        4. Let output be ? CloneArrayBuffer(input, 0, + outputArrayBuffer).

        5. +
        +
      22. - +
      23. +

        Otherwise, if input has a [[ViewedArrayBuffer]] internal slot, then:

        - +
          +
        1. Let buffer be the value of input's [[ViewedArrayBuffer]] internal + slot.

        2. -
          If input is an Array object
          +
        3. Let bufferClone be ? StructuredClone(buffer, + targetRealm, memory).

        4. -
          +
        5. If input has a [[DataView]] internal slot, then let output be a + new DataView object in targetRealm whose [[DataView]] internal slot value is true, + whose [[ViewedArrayBuffer]] internal slot value is bufferClone, whose [[ByteLength]] + internal slot value is the [[ByteLength]] internal slot value of input, and whose + [[ByteOffset]] internal slot value is the [[ByteOffset]] internal slot value of + input.

        6. -

          Let output be a newly constructed empty Array - object whose length is equal to the length of - input, and set deep clone to own.

          +
        7. +

          Otherwise:

          -

          This means that the length of sparse arrays is preserved.

          +
            +
          1. Assert: input has a [[TypedArrayName]] internal slot.

          2. -
        8. +
        9. Let constructor be the intrinsic object listed in column one of The + TypedArray Constructors table for the value of input's + [[TypedArrayName]] internal slot in targetRealm.

        10. -
          If input is an Object object
          +
        11. Let byteOffset be input's [[ByteOffset]] internal slot + value.

        12. -

          Let output be a newly constructed empty Object object, and set deep clone to own.

          +
        13. Let length be input's [[ArrayLength]] internal slot + value.

        14. -
          If input is a Map object
          +
        15. Let output be ? TypedArrayCreate(constructor, + « bufferClone, byteOffset, length »). +

        +
      24. +
      + -

      Let output be a newly constructed empty Map - object, and set deep clone to map.

      +
    5. +

      Otherwise, if input has [[MapData]] internal slot, then:

      -
      If input is a Set object
      +
        +
      1. Let output be a new Map object in targetRealm whose [[MapData]] + internal slot value is a new empty List.

      2. -

        Let output be a newly constructed empty Set - object, and set deep clone to set.

        +
      3. Set deepClone to "map".

      4. +
      +
    6. -
      If input is an object that another specification defines how to clone
      +
    7. +

      Otherwise, if input has [[SetData]] internal slot, then:

      -

      Let output be a clone of the object as defined by the other - specification.

      +
        +
      1. Let output be a new Set object in targetRealm whose [[SetData]] + internal slot value is a new empty List.

      2. -
        If input is another native object type (e.g. Error, Function)
        If - input is a host object (e.g. a DOM node)
        +
      3. Set deepClone to "set".

      4. +
      +
    8. -

      Throw a DataCloneError exception and abort the overall structured - clone algorithm.

      +
    9. +

      Otherwise, if input is an Array exotic object, then:

      + - +
        +
      1. Let inputLen be OrdinaryGetOwnProperty(input, + "length").[[Value]].

      2. -

        For the purposes of the algorithm above, an object is a particular type of object - class if its [[Class]] internal property is equal to class.

        +
      3. Let outputProto be the %ArrayPrototype% intrinsic object in + targetRealm.

      4. -

        For example, "input is an Object - object" if input's [[Class]] internal property is equal to the string "Object".

        +
      5. Let output be ArrayCreate(inputLen, + outputProto).

      6. +
      7. Set deepClone to "own".

      8. +
    10. -
    11. Add a mapping from input (the source object) to output (the - destination object) to memory.

    12. +
    13. Otherwise, if IsCallable(input) is true, then throw a + DataCloneError exception.

    14. -
    15. +
    16. Otherwise, if input has an [[ErrorData]] internal slot, then throw a + DataCloneError exception.

    17. + +
    18. Otherwise, if input has a [[Clone]] internal method, then let + output be ? input.[[Clone]](targetRealm).

    19. + +
    20. Otherwise, if input is an exotic object, then throw a + DataCloneError exception.

    21. -

      If deep clone is set to map, then run these substeps. These substeps use - the terminology and typographic conventions used in the JavaScript specification's definition of - Maps.

      +
    22. +

      Otherwise:

        +
      1. Let output be a new Object in targetRealm.

      2. -
      3. Let original be the List that is the value of input's [[MapData]] - internal slot.

      4. +
      5. Set deepClone to "own".

      6. +
      +
    23. -
    24. Let source be a new empty List. +

    25. Create an entry in memory whose key is input and value is + output.

    26. -
    27. +
    28. +

      If deepClone is "map", then:

      -

      For each Record {[[Key]], [[Value]]} entry that is an element of - original, run the following substeps:

      +
        +
      1. Let inputList the value of input's [[MapData]] internal + slot.

      2. -
          +
        1. Let copiedList be a new empty List. -

        2. Let new entry be the Record {[[Key]]: entry.[[Key]], [[Value]]: - entry.[[Value]]}.

        3. +
        4. +

          Repeat for each Record {[[Key]], [[Value]]} entry that is an + element of inputList,

          -
        5. If new entry.[[Key]] is not empty, append new entry as - the last element of source.

        6. +
            +
          1. Let copiedEntry be a new Record { + [[Key]]: entry.[[Key]], + [[Value]]: entry.[[Value]] }.

          2. +
          3. If copiedEntry.[[Key]] is not empty, append copiedEntry as the + last element of copiedList.

          -
        7. Let target be the List that is the value of output's [[MapData]] - internal slot.

        8. +
        9. Let outputList be the value of output's [[MapData]] internal + slot.

        10. - -

          For each Record {[[Key]], [[Value]]} entry that is an element of - source, run the following substeps:

          +

          For each Record {[[Key]], [[Value]]} entry that is an element of + copiedList,

            +
          1. Let outputKey be ? StructuredClone(entry.[[Key]], + targetRealm, memory).

          2. -
          3. Let key have the value obtained from invoking the internal structured - cloning algorithm recursively with entry.[[Key]] as the new - "input" argument and memory as the new "memory" - argument.

          4. +
          5. Let outputValue be ? + StructuredClone(entry.[[Value]], targetRealm, + memory).

          6. -
          7. Let value have the value obtained from invoking the internal - structured cloning algorithm recursively with entry.[[Value]] as the new - "input" argument and memory as the new "memory" - argument.

          8. +
          9. Add { [[Key]]: outputKey, [[Value]]: outputValue } as the last + element of outputList.

          10. +
          +
        11. -
        12. Let new entry be the Record {[[Key]]: key, [[Value]]: - value}.

        13. +
        14. Set deepClone to "own".

        15. +
        + -
      3. Append new entry as the last element of target.

      4. +
      5. +

        If deepClone is "set", then:

        -
      +
        +
      1. Let copiedList be a copy of the value of input's [[SetData]] + internal slot.

      2. - +
      3. Let outputList be the value of output's [[SetData]] internal + slot.

      4. -
      5. Set deep clone to own.

      6. +
      7. +

        For each entry that is an element of copiedList that is not + empty,

        -
      +
        +
      1. Let outputEntry be ? StructuredClone(entry, + targetResult, memory).

      2. + +
      3. Add outputEntry as the last element of outputList.

      4. +
      +
    29. +
    30. Set deepClone to "own".

    31. +
  • - -

    If deep clone is set to set, then run these substeps. These substeps use - the terminology and typographic conventions used in the JavaScript specification's definition of - Sets.

    +

    If deepClone is "own", then for each key in ? + input.[[OwnPropertyKeys]]():

      +
    1. +

      If Type(key) is String, then:

      -
    2. Let source be a copy of the List that is the value of input's - [[SetData]] internal slot.

    3. - -
    4. Let target be the List that is the value of output's [[SetData]] - internal slot.

    5. +
        +
      1. Let inputValue be ? input.[[Get]](key, + input).

      2. -
      3. +
      4. Let outputValue be ? + StructuredClone(inputValue, targetRealm, + memory).

      5. -

        For each entry that is an element of source that is not empty, - run the following substeps:

        +
      6. Perform ? CreateDataProperty(output, key, + outputValue).

      7. +
      + +
    +
  • -
      +
    1. Return output.

    2. +
    -
  • Let new entry have the value obtained from invoking the internal - structured cloning algorithm recursively with entry as the new - "input" argument and memory as the new "memory" - argument.

  • +

    In general implementations will need to use some kind of serialization and + marshalling to implement the creation of objects in targetRealm, as + targetRealm could be in a different event loop and not easily accessible + to the code that invokes StructuredCloneWithTransfer or + StructuredClone.

    -
  • Append new entry as the last element of target.

  • +

    IsTransferable ( O )

    - +
      +
    1. Assert: Type(O) is Object.

    2. - +
    3. +

      If O has an [[ArrayBufferData]] internal slot, then:

      -
    4. Set deep clone to own.

    5. +
        +
      1. If IsDetachedBuffer(O) is true, then return false.

      2. +
      3. Return true.

      -
    6. - -

      If deep clone is set to own, then, for each enumerable own property in - input, run the following steps:

      +

      Otherwise, if O has a [[Detached]] internal slot, then:

        +
      1. If O's [[Detached]] internal slot value is true, then return + false.

      2. -
      3. Let name be the name of the property.

      4. +
      5. Return true.

      6. +
      +
    7. + +
    8. Return false.

    9. +
    -
  • Let source value be the result of calling the [[Get]] internal method of - input with the argument name. If the [[Get]] internal method of a - property involved executing script, and that script threw an uncaught exception, then abort the - overall structured clone algorithm, with that exception being passed through to - the caller.

  • +

    TransferHelper ( input, targetRealm )

    -
  • Let cloned value be the result of invoking the internal structured - cloning algorithm recursively with source value as the "input" - argument and memory as the "memory" argument. If this results in an - exception, then abort the overall structured clone algorithm, with that exception - being passed through to the caller.

  • +
      +
    1. +

      If input has an [[ArrayBufferData]] internal slot, then:

      -
    2. Add a new property to output having the name name, and having - the value cloned value, using - CreateDataProperty(output, name, cloned value).

    3. +
        +
      1. Let output be a new ArrayBuffer object in targetRealm whose + [[ArrayBufferByteLength]] internal slot value is the [[ArrayBufferByteLength]] internal slot + value of input, and whose [[ArrayBufferData]] internal slot value is the + [[ArrayBufferData]] internal slot value of input.

      2. +
      3. Perform ! DetachArrayBuffer(input).

      4. + +
      5. Return output.

      + -

      The order of the properties in the input and output objects must be the - same, and any properties whose [[Get]] internal method involves running script must be processed - in that same order.

      +
    4. Return ? input.[[Transfer]](targetRealm).

    5. +
    -

    This does not walk the prototype chain.

    +

    Monkey patch for Blob and FileList objects

    -

    Property descriptors, setters, getters, and analogous features are not copied in - this process. For example, the property in the input could be marked as read-only, but in the - output it would just have the default state (typically read-write, though that could depend on - the scripting environment).

    +

    This monkey patch will be removed in due course. See w3c/FileAPI issue 32.

    -

    Properties of Array objects are not treated any differently than those of other - Objects. In particular, this means that non-index properties of arrays are copied as well.

    +

    Blob objects are cloneable objects.

    - +

    Each Blob object's [[Clone]] internal method, given + targetRealm and ignoring memory, must run these steps:

    -
  • Return output.

  • +
      +
    1. If this is closed, then throw a + DataCloneError exception.

    2. +
    3. Return a new instance of this in targetRealm, corresponding to the + same underlying data.

    -

    This algorithm preserves cycles and preserves the identity of duplicate objects in - graphs.

    +

    FileList objects are cloneable objects.

    + +

    Each FileList object's [[Clone]] internal method, given + targetRealm and memory, must run these steps:

    + +
      +
    1. Let output be a new FileList object in + targetRealm.

    2. + +
    3. For each file in this, add ? + StructuredClone(file, targetRealm, memory) to the + end of the list of File objects of output.

    4. + +
    5. Return output.

    6. +
    @@ -20440,8 +20540,8 @@ interface HTMLHyperlinkElementUtils { data-x="concept-hyperlink-url-set">set the url.

    This is only observable for blob: URLs as - parsing them involves the structured clone - algorithm.

    + parsing them involves the StructuredClone abstract + operation.

    An element implementing the HTMLHyperlinkElementUtils mixin has an associated reinitialise url algorithm, which runs these steps:

    @@ -59653,8 +59753,7 @@ callback BlobCallback = void (Blob? blob);
    [Exposed=(Window,Worker)]
     interface CanvasProxy {
       void setContext(RenderingContext context);
    -};
    -// CanvasProxy implements Transferable;
    +};
    @@ -59680,7 +59779,7 @@ interface CanvasProxy { the given object.

    Throws an InvalidStateError exception if the CanvasProxy has been - transferred.

    + transferred.

    @@ -59705,11 +59804,13 @@ interface CanvasProxy { -

    A CanvasProxy object can be neutered (like any Transferable object), - meaning it can no longer be transferred, and - can be disabled, meaning it can no longer be bound - to rendering contexts. When first created, a CanvasProxy object must be neither.

    +

    Each CanvasProxy object has a [[Detached]] internal slot (like any + transferable object).

    + +

    Each CanvasProxy object can be disabled, meaning it can no longer be bound to + rendering contexts. When first created, a CanvasProxy object must not be disabled.

    A CanvasProxy is created with a link to a canvas element. A CanvasProxy object that has not been CanvasProxy { data-x="concept-CanvasProxy-disabled">disabled, throw an InvalidStateError exception and abort these steps.

    -
  • If the CanvasProxy object has not been neutered, then neuter it.

  • +
  • Set CanvasProxy object's [[Detached]] internal slot value to + true.

  • If context's context bitmap mode is fixed, then throw an @@ -59748,13 +59848,19 @@ interface CanvasProxy { -

    To transfer a - CanvasProxy object old to a new owner owner, - a user agent must create a new CanvasProxy object linked to the same - canvas element as old, thus obtaining new, - must neuter and disable the old object, and must - finally return new.

    +

    Each CanvasProxy object's [[Transfer]] + internal method, given a targetRealm, must run these steps:

    + +
      +
    1. Let new be a new CanvasProxy object in targetRealm, + linked to the same canvas element as this.

    2. + +
    3. Set this's [[Detached]] internal slot value to true.

    4. + +
    5. Disable this.

    6. + +
    7. Return new.

    8. +
    @@ -64967,7 +65073,7 @@ partial dictionary MouseEventInit { canvas are replaced wholesale, with no composition, alpha blending, no shadows, etc.

    Throws an InvalidStateError exception if the imagedata - object's data has been neutered.

    + object's data's [[Detached]] internal slot value is true.

    @@ -64981,6 +65087,27 @@ partial dictionary MouseEventInit {

    The ImageData() constructors and the createImageData() methods are used to instantiate new ImageData objects.

    +

    ImageData objects are cloneable objects.

    + +

    Each ImageData object's [[Clone]] internal method, given + targetRealm and memory, must run these steps:

    + +
      +
    1. Let output be a new ImageData object in targetRealm + whose width and + height have values equal to the corresponding + attributes on this.

    2. + +
    3. Let inputData be the value of this's data attribute.

    4. + +
    5. Set output's data attribute value to ? + StructuredClone(inputData, targetRealm, + memory).

    6. + +
    7. Return output.

    8. +
    +

    When the ImageData() constructor is invoked with two numeric arguments sw and sh, it must return a new ImageData object representing a transparent black rectangle with a width equal to @@ -65093,9 +65220,8 @@ partial dictionary MouseEventInit {

  • If the imagedata argument's data attribute has been neutered, throw an InvalidStateError - exception and abort these steps.

    + data-x="dom-imagedata-data">data attribute value's [[Detached]] internal + slot value is true, throw an InvalidStateError exception and abort these steps.

  • @@ -77051,7 +77177,7 @@ dictionary DragEventInit : MouseEventInit { unsigned long requestAnimationFrame(FrameRequestCallback callback); void cancelAnimationFrame(unsigned long handle); - void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer); + void postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []); }; Window implements GlobalEventHandlers; Window implements WindowEventHandlers; @@ -77845,7 +77971,7 @@ callback FrameRequestCallback = void (DOMHighResTimeStamp
  • -

    If IsPlatformObjectSameOrigin(W) is true, then return ! +

    If IsPlatformObjectSameOrigin(W) is true, then return OrdinaryGetOwnProperty(W, P).

    This violates JavaScript's internal method invariants. History {

  • If this History object is associated with a Document that is not fully active, throw a SecurityError.

  • -
  • Let cloned data be a structured clone of the specified - data. If this throws an exception, then rethrow that exception and abort - these steps.

  • +
  • Let targetRealm be this History object's relevant settings + object's Realm.

  • + +
  • Let cloned data be StructuredClone(data, + targetRealm). Rethrow any exceptions.

  • @@ -79315,11 +79443,14 @@ interface History {
  • +
  • Let targetRealm be this History object's relevant settings + object's Realm.

  • +
  • -

    Set history.state to a structured clone - of cloned data.

    +

    Set history.state to + StructuredClone(cloned data, targetRealm).

  • @@ -80220,7 +80351,7 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O

    If IsPlatformObjectSameOrigin(this) is true, then:

      -
    1. Let desc be ! OrdinaryGetOwnProperty(this, +

    2. Let desc be OrdinaryGetOwnProperty(this, P).

    3. If the value of the [[DefaultProperties]] internal slot of this @@ -81714,9 +81845,11 @@ State: <OUTPUT NAME=I>1</OUTPUT> <INPUT VALUE="Increment" TYPE=BUTTON O restore persisted user state and update aspects of the document and its rendering.

    4. -
    5. If the entry is a state object entry, let state be a - structured clone of that state object. Otherwise, let state be - null.

    6. +
    7. Let targetRealm be the current Realm Record.

    8. + +
    9. If the entry is a state object entry, let state be + StructuredClone(that state object, targetRealm). Otherwise, let + state be null.

    10. Set history.state to state.

    11. @@ -90076,7 +90209,6 @@ interface ImageBitmap { readonly attribute unsigned long width; readonly attribute unsigned long height; }; -ImageBitmap implements Transferable; typedef (HTMLImageElement or HTMLVideoElement or @@ -90124,10 +90256,10 @@ interface ImageBitmapFactories {

      Rejects the promise with an InvalidStateError exception if the source image is not in a valid state (e.g. an img element that hasn't finished loading, or a CanvasRenderingContext2D object whose bitmap data has zero length along one or - both dimensions, an ImageBitmap object that has been neutered, or an ImageData object - whose data is data attribute has been neutered).

      + both dimensions, an ImageBitmap object whose [[Detached]] internal + slot value is true, or an ImageData object whose data attribute value's [[Detached]] internal + slot value is true.

      Rejects the promise with a SecurityError exception if the script is not allowed to access the image data of @@ -90169,22 +90301,37 @@ interface ImageBitmapFactories { true and may be changed to false by the steps of createImageBitmap().

      -

      To transfer an ImageBitmap - object old to a new owner owner, a user agent must run the following - steps:

      +

      ImageBitMap objects are cloneable objects and transferable + objects.

      + +

      Each ImageBitmap object's [[Clone]] internal method, given + targetRealm and ignoring memory, must run these steps:

        -
      1. Create a new ImageBitmap object pointing at the same underlying bitmap data as old, thus obtaining - new;

      2. +
      3. If this's [[Detached]] internal slot is true, then throw a + DataCloneError exception.

      4. + +
      5. Return a new ImageBitmap object in targetRealm whose bitmap data is a copy of this's bitmap data, and whose origin-clean flag is set to the same value as + this's origin-clean flag.

      6. +
      + +

      Each ImageBitmap object's [[Transfer]] internal method, given + targetRealm, must run these steps:

      + +
        +
      1. Let new be a new ImageBitmap object in targetRealm, + pointing at the same underlying bitmap data + as this.

      2. Set new's bitmap's origin-clean flag to the same values as - old's bitmap's origin-clean - flag;

      3. + this's bitmap's origin-clean + flag.

        -
      4. Neuter the old - object;

      5. +
      6. Set this's [[Detached]] internal slot value to true.

      7. Return new.

      @@ -90372,9 +90519,9 @@ interface ImageBitmapFactories {
    12. If either the sw or sh arguments are specified but zero, return a promise rejected with an IndexSizeError exception and abort these steps.

    13. -
    14. If the image object's data - attribute has been neutered, return a promise rejected with an - InvalidStateError exception and abort these steps.

    15. +
    16. If the image object's data attribute + value's [[Detached]] internal slot value is true, return a promise rejected with + an InvalidStateError exception and abort these steps.

    17. Create a new ImageBitmap object.

    18. @@ -90436,7 +90583,7 @@ interface ImageBitmapFactories { but zero, return a promise rejected with an IndexSizeError exception and abort these steps.

      -
    19. If image is neutered, return a +

    20. If image's [[Detached]] internal slot value is true, return a promise rejected with an InvalidStateError exception and abort these steps.

    21. @@ -92679,8 +92826,10 @@ function receiver(e) {
      -

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

      +

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

        @@ -92688,59 +92837,17 @@ function receiver(e) { ASTERISK character (*), a single U+002F SOLIDUS character (/), nor an absolute URL, then throw a SyntaxError exception and abort the overall set of steps.

        -
      1. Let new ports be an empty array.

      2. +
      3. Let targetRealm be this Window object's JavaScript + realm.

      4. -
      5. Let transfer map be an empty association list of - Transferable objects to placeholder objects.

      6. +
      7. Let cloneRecord be StructuredCloneWithTransfer(message, + transfer, targetRealm). Rethrow any exceptions.

      8. -
      9. +
      10. Let message clone be cloneRecord.[[Clone]].

      11. -

        If the method was invoked with a third argument transfer, run these - substeps:

        - -
          - -
        1. If any object is listed in transfer more than once, or any of the - Transferable objects listed in transfer are marked as neutered, then throw a - DataCloneError exception and abort these steps.

        2. - -
        3. For each object x in transfer in turn, add a - mapping from x to a new unique placeholder object created for x to transfer map, and if x is a - MessagePort object, also append the placeholder object to the new - ports array.

        4. - -
        - - - -
      12. Let message clone be the result of obtaining a structured - clone of the message argument, with transfer map - as the transfer map. If this throws an exception, then throw that exception and abort - these steps.

      13. - -
      14. - -

        If the method was invoked with a third argument transfer, run these - substeps:

        - -
          - -
        1. Let new owner be the environment settings object of the - Window object on which the method was invoked.

        2. - -
        3. For each object x in transfer in turn, obtain - a new object y by transferring the object x to new - owner, and replace the placeholder object that was created for the object x by the new object y wherever the placeholder exists - (i.e. in message clone and in new ports).

        4. - -
        - -
      15. - -
      16. Make new ports into a read - only array.

      17. +
      18. Let new ports be a new read only + array consisting of all MessagePort objects in + cloneRecord.[[TransferList]], if any, maintaining their relative order.

      19. Return from the postMessage() method, but in parallel continue running these steps.

      20. @@ -93058,15 +93165,14 @@ interface MessageChannel {
        [Exposed=(Window,Worker)]
         interface MessagePort : EventTarget {
        -  void postMessage(any message, optional sequence<Transferable> transfer);
        +  void postMessage(any message, optional sequence<object> transfer = []);
           void start();
           void close();
         
           // event handlers
           attribute EventHandler onmessage;
         };
        -// MessagePort implements Transferable;
        +-->};
        @@ -93142,10 +93248,10 @@ interface MessagePort : EventTarget { unshipped port message queue is used instead.)

        The has been shipped flag is set to true when a port, its twin, or - the object it was cloned from, is or has been transferred. When a MessagePort's has been shipped flag - is true, its port message queue acts as a first-class task source, - unaffected to any unshipped port message queue.

        + the object it was cloned from, is or has been transferred. When a MessagePort's + has been shipped flag is true, its port message queue acts as a + first-class task source, unaffected to any unshipped port message + queue.

        When the user agent is to create a new MessagePort object with a particular environment settings object as its owner, it must instantiate @@ -93185,27 +93291,31 @@ interface MessagePort : EventTarget {

      -

      When the user agent is to clone a port original port, with the - clone being owned by owner, it must run the following steps, which return a - new MessagePort object. These steps must be run atomically.

      +

      MessagePort objects are transferable + objects.

      + +

      Each MessagePort object's [[Transfer]] internal method, given a + targetRealm, must run these steps:

        -
      1. Set original port's has been shipped flag to - true.

      2. +
      3. Set this's has been shipped flag to true.

      4. -
      5. Create a new MessagePort object whose owner is owner, and let new port be that object.

      6. +
      7. Let new be a new + MessagePort object in targetRealm whose owner is targetRealm's [[GlobalObject]]'s + relevant settings object.

      8. -
      9. Set new port's has been shipped flag to true.

      10. +
      11. Set new's has been shipped flag to true.

      12. Move all the tasks that are to fire message events in the port message queue of original port to the port message queue of new - port, if any, leaving the new port's port message queue - in its initial disabled state, and, if the new port's owner specifies a responsible event loop that is - a browsing context event loop, associating the moved tasks with the responsible document specified by new port's owner.

      13. + data-x="event-message">message events in the port message queue of + this to the port message queue of new, if any, leaving + new's port message queue in its initial disabled state, and, if + new's owner specifies a responsible + event loop that is a browsing context event loop, associating + the moved tasks with the responsible document + specified by new's owner.

      14. - -

        If the original port is entangled with another port, then run these - substeps:

        +

        If this is entangled with another port, then run these substeps:

          +
        1. Let remote port be the port with which this is entangled.

        2. -
        3. Let the remote port be the port with which the original port is entangled.

        4. - -
        5. Set remote port's has been shipped flag to - true.

        6. - -
        7. Entangle the remote port and new - port objects. The original port object will be disentangled by this - process.

        8. +
        9. Set remote port's has been shipped flag to true.

        10. +
        11. Entangle remote port and new. this will be + disentangled by this process.

        -
      15. -
      16. Return new port. It is the clone.

      17. +
      18. Set this's [[Detached]] internal slot value to true.

      19. +
      20. Return new. It is the clone.

      -

      To transfer a - MessagePort object old to a new owner owner, - a user agent must clone the old object with - the clone being owned by owner, thus obtaining new, must - neuter the old port, and - must finally return new.

      -

      The postMessage() method, when @@ -93263,121 +93360,42 @@ interface MessagePort : EventTarget { is entangled, if any.

    22. +

      Let doomed be false.

      -

      Let doomed be false. It is set to true if a condition is detected that - will make this message cause the port to be unusable; specifically, if the message contains target port as one of the objects being transferred. (This condition cannot necessarily be detected when the method is called.)

      - +

      It is set to true if a condition is detected that will make this message cause + the port to be unusable; specifically, if the message contains target port as one of + the objects being transferred. (This condition cannot necessarily be detected when the method is + called.)

    23. -
    24. +
    25. If any of the objects in transfer are the source port, then throw a + DataCloneError exception and abort these steps.

    26. -

      Let new ports be an empty array.

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

    28. +

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

      -

      Let transfer map be an empty association list of - Transferable objects to placeholder objects.

      - +

      targetRealm is used when cloning and transfering objects below. If + there is no target port, or if the target port 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.)

    29. -
    30. - -

      If the method was invoked with a second argument transfer, run these - substeps:

      - -
        - -
      1. - -

        If any object is listed in transfer more than once, or any of the - Transferable objects listed in transfer are marked as neutered, then throw a - DataCloneError exception and abort these steps.

        - -
      2. - -
      3. - -

        If any of the objects in transfer are the source - port, then throw a DataCloneError exception and abort these steps.

        +
      4. Let cloneRecord be StructuredCloneWithTransfer(message, + transfer, targetRealm). Rethrow any exceptions.

      5. - - -
      6. +
      7. Let message clone be cloneRecord.[[Clone]].

      8. -

        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.

        - - - -
      9. - -

        For each object x in transfer in turn, add a - mapping from x to a new unique placeholder object created for x to transfer map, and if x is a - MessagePort object, also append the placeholder object to the new - ports array.

        - -
      10. - -
      - -
    31. - -
    32. - -

      Let message clone be the result of obtaining a structured - clone of the message argument, with transfer map - as the transfer map. If this throws an exception, then throw that exception and abort - these steps.

      - -
    33. - -
    34. - -

      If the method was invoked with a second argument transfer, run these - substeps:

      - -
        - -
      1. - -

        Let new owner be the owner of - target port, if there is a target port and doomed is false, or else some arbitrary owner. (This new - owner is used when transferring objects below. If there is no target - port, or if the target port 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.)

        - -
      2. - - -
      3. - -

        For each object x in transfer in turn, obtain a - new object y by transferring the object x to new - owner, and replace the placeholder object that was created for the object x by the new object y wherever the placeholder exists - (i.e. in message clone and in new ports).

        - -
      4. - -
      - -
    35. - -
    36. - -

      Make new ports into a read only - array.

      - -
    37. +
    38. Let new ports be a new read only + array consisting of all MessagePort objects in + cloneRecord.[[TransferList]], if any, maintaining their relative order.

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

    40. @@ -93642,8 +93660,10 @@ interface BroadcastChannel : EventTarget {
    41. Let source channel be source's channel name.

      -
    42. Let cloned message be a structured clone of the message argument. If this throws an exception, then rethrow that exception and - abort these steps.

    43. +
    44. Let targetRealm be a user-agent defined Realm.

    45. + +
    46. Let cloned message be StructuredClone(message, + targetRealm). Rethrow any exceptions.

    47. @@ -93700,16 +93720,19 @@ interface BroadcastChannel : EventTarget { queue a task that runs the following steps:

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

      2. 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 a structured clone of cloned message, and the origin attribute must be initialised - to the Unicode serialisation of the - origin specified by source settings. This event is not trusted.

      3. + 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. Dispatch the event at the BroadcastChannel object.

      5. @@ -94332,7 +94355,7 @@ interface WorkerGlobalScope : EventTarget {
        [Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker]
         /*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
        -  void postMessage(any message, optional sequence<Transferable> transfer);
        +  void postMessage(any message, optional sequence<object> transfer = []);
           attribute EventHandler onmessage;
         };
        @@ -94947,7 +94970,7 @@ interface AbstractWorker { interface Worker : EventTarget { void terminate(); - void postMessage(any message, optional sequence<Transferable> transfer); + void postMessage(any message, optional sequence<object> transfer = []); attribute EventHandler onmessage; }; @@ -117011,6 +117034,7 @@ INSERT INTERFACES HERE Alexis Deveria, Alice Boxhall, Allan Clements, + Allen Wirfs-Brock, Ami Fischman, Amos Jeffries, Anders Carlsson,