Skip to content

Commit

Permalink
Bug 1736789 [wpt PR 31328] - Throw DataCloneError when transferring…
Browse files Browse the repository at this point in the history
… non-transferable objects, a=testonly

Automatic update from web-platform-tests
Throw `DataCloneError` when transferring non-transferable objects

Currently attempting to transfer non-transferable objects using the
structured clone algorithm throws a `TypeError`, rather than a
`DataCloneError` `DOMException` as per the spec.

This seems like a holdover from the original definition of transferable
objects as the `Transferable` WebIDL type, since transfer lists would be
defined as `sequence<Transferable>` and so would throw a `TypeError` on
conversion. whatwg/html#727 changed transfer
lists to be `sequence<object>` and changed the
`StructuredCloneWithTransfer` algorithm (now
`StructuredSerializeWithTransfer`) to throw a `DataCloneError`
`DOMException` if any element in the transfer list is not transferable.

Bug: 816447
Change-Id: I9f4f88a2d7a593766f394256606a688f299c7b57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3229544
Reviewed-by: Yuki Shiino <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Commit-Queue: Yuki Shiino <[email protected]>
Cr-Commit-Position: refs/heads/main@{#934398}

--

wpt-commits: 4287b41333755fc3a4909a06ecb0780623c637fc
wpt-pr: 31328
  • Loading branch information
andreubotella authored and moz-wptsync-bot committed Oct 29, 2021
1 parent 02b1822 commit f027ecd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ test(t => {
TypeError,
() => chunk.copyTo(new Uint8Array(2)), 'destination is not large enough');

const detached = makeDetachedArrayBuffer();
assert_throws_js(
TypeError,
() => chunk.copyTo(makeDetachedArrayBuffer()), 'destination is detached');
() => chunk.copyTo(detached), 'destination is detached');
}, 'Test copyTo() exception if destination invalid');
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ test(t => {
TypeError,
() => chunk.copyTo(new Uint8Array(2)), 'destination is not large enough');

const detached = makeDetachedArrayBuffer();
assert_throws_js(
TypeError,
() => chunk.copyTo(makeDetachedArrayBuffer()), 'destiation is detached');
() => chunk.copyTo(detached), 'destination is detached');
}, 'Test copyTo() exception if destiation invalid');
5 changes: 3 additions & 2 deletions testing/web-platform/tests/webcodecs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ function testCanvas(ctx, width, height, expected_pixel, imageSetting, assert_com
}

function makeDetachedArrayBuffer() {
let buffer = new Uint8Array();
const buffer = new ArrayBuffer(10);
const view = new Uint8Array(buffer);
new MessageChannel().port1.postMessage(buffer, [buffer]);
return buffer;
return view;
}

0 comments on commit f027ecd

Please sign in to comment.