• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1structuredCloneBatteryOfTests.push({
2  description: 'ArrayBuffer',
3  async f(runner) {
4    const buffer = new Uint8Array([1]).buffer;
5    const copy = await runner.structuredClone(buffer, [buffer]);
6    assert_equals(buffer.byteLength, 0);
7    assert_equals(copy.byteLength, 1);
8  }
9});
10
11structuredCloneBatteryOfTests.push({
12  description: 'MessagePort',
13  async f(runner) {
14    const {port1, port2} = new MessageChannel();
15    const copy = await runner.structuredClone(port2, [port2]);
16    const msg = new Promise(resolve => port1.onmessage = resolve);
17    copy.postMessage('ohai');
18    assert_equals((await msg).data, 'ohai');
19  }
20});
21
22// TODO: ImageBitmap
23