Bug 1706169 [wpt PR 28586] - [ReadableByteStream] Handle enqueuing when detach, a=testonly

Automatic update from web-platform-tests
[ReadableByteStream] Handle enqueuing when detach

Attempting to call enqueue() on a ReadableByteStreamController after
controller.byobRequest.view.buffer had been detached would crash with a
null pointer dereference.

Make it throw an exception instead.

BUG=1200302

Change-Id: I86b1511ef154a42ca78271618e00d8e1c5e6ae5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2836768
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#874225}

--

wpt-commits: 5233fe69580d5d5d10e46869958093ea771a743f
wpt-pr: 28586
This commit is contained in:
Adam Rice 2021-04-24 09:10:25 +00:00 коммит произвёл moz-wptsync-bot
Родитель 8ecfb13e14
Коммит 219b96d070
1 изменённых файлов: 21 добавлений и 0 удалений

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

@ -0,0 +1,21 @@
promise_test(async t => {
const error = new Error('cannot proceed');
const rs = new ReadableStream({
type: 'bytes',
pull(controller) {
t.step(() => {
const buffer = controller.byobRequest.view.buffer;
// Detach the buffer.
postMessage(buffer, '*', [buffer]);
// Try to enqueue with a new buffer.
assert_throws_js(TypeError, () => controller.enqueue(new Uint8Array([42])));
// If we got here the test passed.
controller.error(error);
});
}
});
const reader = rs.getReader({ mode: 'byob' });
await promise_rejects_exactly(t, error, reader.read(new Uint8Array(1)));
}, 'enqueue after detaching byobRequest.view.buffer should throw');