Skip to content

Invalid globalThis.structuredClone interface #40246

Closed
@petamoriken

Description

Version

v17.0.0-rc.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

related: #39759

According to the specification, the structuredClone options do not take a list of transfers as an array. This is different from postMessage.

https://html.spec.whatwg.org/multipage/structured-data.html#structured-cloning
https://html.spec.whatwg.org/multipage/web-messaging.html#message-ports

const value = new Uint8Array(4);

// valid
port.postMessage(value, [value.buffer]);

// valid
port.postMessage(value, { transfer: [value.buffer] });

// invalid (No transfer)
structuredClone(value, [value.buffer]);

// valid
structuredClone(value, { transfer: [value.buffer] });

minimum test code:

import assert from "assert";

const value = new Uint8Array(4);
structuredClone(value, [value.buffer]);

assert( value.length !== 0 );

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions