Skip to content

Commit ad6c0aa

Browse files
MattiasBuelensdomenic
authored andcommitted
Use ArrayBuffer.transfer() in Streams tests
1 parent 627b47d commit ad6c0aa

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

streams/readable-byte-streams/bad-buffers-and-views.any.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ promise_test(t => {
123123
async_test(t => {
124124
const stream = new ReadableStream({
125125
pull: t.step_func_done(c => {
126-
// Detach it by reading into it
127-
reader.read(c.byobRequest.view);
126+
c.byobRequest.view.buffer.transfer();
128127

129128
assert_throws_js(TypeError, () => c.byobRequest.respond(1),
130129
'respond() must throw if the corresponding view has become detached');
@@ -141,9 +140,7 @@ async_test(t => {
141140
const stream = new ReadableStream({
142141
pull: t.step_func_done(c => {
143142
c.close();
144-
145-
// Detach it by reading into it
146-
reader.read(c.byobRequest.view);
143+
c.byobRequest.view.buffer.transfer();
147144

148145
assert_throws_js(TypeError, () => c.byobRequest.respond(0),
149146
'respond() must throw if the corresponding view has become detached');
@@ -159,9 +156,8 @@ async_test(t => {
159156
async_test(t => {
160157
const stream = new ReadableStream({
161158
pull: t.step_func_done(c => {
162-
// Detach it by reading into it
163159
const view = new Uint8Array([1, 2, 3]);
164-
reader.read(view);
160+
view.buffer.transfer();
165161

166162
assert_throws_js(TypeError, () => c.byobRequest.respondWithNewView(view));
167163
}),
@@ -364,8 +360,7 @@ async_test(t => {
364360
async_test(t => {
365361
const stream = new ReadableStream({
366362
pull: t.step_func_done(c => {
367-
// Detach it by reading into it
368-
reader.read(c.byobRequest.view);
363+
c.byobRequest.view.buffer.transfer();
369364

370365
assert_throws_js(TypeError, () => c.enqueue(new Uint8Array([1])),
371366
'enqueue() must throw if the BYOB request\'s buffer has become detached');
@@ -382,9 +377,7 @@ async_test(t => {
382377
const stream = new ReadableStream({
383378
pull: t.step_func_done(c => {
384379
c.close();
385-
386-
// Detach it by reading into it
387-
reader.read(c.byobRequest.view);
380+
c.byobRequest.view.buffer.transfer();
388381

389382
assert_throws_js(TypeError, () => c.enqueue(new Uint8Array([1])),
390383
'enqueue() must throw if the BYOB request\'s buffer has become detached');

0 commit comments

Comments
 (0)