Bug 1523562 [wpt PR 14794] - TextDecoderStream: Permit detached buffers, a=testonly

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
This commit is contained in:
Adam Rice 2019-01-31 18:31:15 +00:00 коммит произвёл James Graham
Родитель a02c6cd044
Коммит 4078f670b8
2 изменённых файлов: 20 добавлений и 20 удалений

Просмотреть файл

@ -23,26 +23,6 @@ const badChunks = [
name: 'array',
value: [65]
},
{
name: 'detached ArrayBufferView',
value: (() => {
const u8 = new Uint8Array([65]);
const ab = u8.buffer;
const mc = new MessageChannel();
mc.port1.postMessage(ab, [ab]);
return u8;
})()
},
{
name: 'detached ArrayBuffer',
value: (() => {
const u8 = new Uint8Array([65]);
const ab = u8.buffer;
const mc = new MessageChannel();
mc.port1.postMessage(ab, [ab]);
return ab;
})()
},
{
name: 'SharedArrayBuffer',
// Use a getter to postpone construction so that all tests don't fail where

Просмотреть файл

@ -39,3 +39,23 @@ promise_test(async () => {
assert_array_equals(array, [expectedOutputString],
'the output should be in one chunk');
}, 'a trailing empty chunk should be ignored');
promise_test(async () => {
const buffer = new ArrayBuffer(3);
const view = new Uint8Array(buffer, 1, 1);
view[0] = 65;
new MessageChannel().port1.postMessage(buffer, [buffer]);
const input = readableStreamFromArray([view]);
const output = input.pipeThrough(new TextDecoderStream());
const array = await readableStreamToArray(output);
assert_array_equals(array, [], 'no chunks should be output');
}, 'decoding a transferred Uint8Array chunk should give no output');
promise_test(async () => {
const buffer = new ArrayBuffer(1);
new MessageChannel().port1.postMessage(buffer, [buffer]);
const input = readableStreamFromArray([buffer]);
const output = input.pipeThrough(new TextDecoderStream());
const array = await readableStreamToArray(output);
assert_array_equals(array, [], 'no chunks should be output');
}, 'decoding a transferred ArrayBuffer chunk should give no output');