mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
Automatic update from web-platform-tests TextDecoderStream: Permit detached buffers Since https://github.com/heycam/webidl/pull/605 converting a chunk to a BufferSource no longer throws if the chunk is detached. Update the TextDecoderStream implementation and tests to match the new behaviour. Change-Id: I26230d9cbfce871b3dae75e612539564d4578977 Reviewed-on: https://chromium-review.googlesource.com/c/1404906 Reviewed-by: Joshua Bell <jsbell@chromium.org> Commit-Queue: Adam Rice <ricea@chromium.org> Cr-Commit-Position: refs/heads/master@{#621897} -- wpt-commits: 35d1ca9cb52f755566ba6681fe555626379b9e2c wpt-pr: 14794
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
// META: global=worker
|
|
|
|
'use strict';
|
|
|
|
const badChunks = [
|
|
{
|
|
name: 'undefined',
|
|
value: undefined
|
|
},
|
|
{
|
|
name: 'null',
|
|
value: null
|
|
},
|
|
{
|
|
name: 'numeric',
|
|
value: 3.14
|
|
},
|
|
{
|
|
name: 'object, not BufferSource',
|
|
value: {}
|
|
},
|
|
{
|
|
name: 'array',
|
|
value: [65]
|
|
},
|
|
{
|
|
name: 'SharedArrayBuffer',
|
|
// Use a getter to postpone construction so that all tests don't fail where
|
|
// SharedArrayBuffer is not yet implemented.
|
|
get value() {
|
|
return new SharedArrayBuffer();
|
|
}
|
|
},
|
|
{
|
|
name: 'shared Uint8Array',
|
|
get value() {
|
|
new Uint8Array(new SharedArrayBuffer())
|
|
}
|
|
}
|
|
];
|
|
|
|
for (const chunk of badChunks) {
|
|
promise_test(async t => {
|
|
const tds = new TextDecoderStream();
|
|
const reader = tds.readable.getReader();
|
|
const writer = tds.writable.getWriter();
|
|
const writePromise = writer.write(chunk.value);
|
|
const readPromise = reader.read();
|
|
await promise_rejects(t, new TypeError(), writePromise, 'write should reject');
|
|
await promise_rejects(t, new TypeError(), readPromise, 'read should reject');
|
|
}, `chunk of type ${chunk.name} should error the stream`);
|
|
}
|