Skip to content

Commit 96c3373

Browse files
daeyeondanielleadams
authored andcommitted
stream: improve views validation on BYOBRequest
- This throws if the view is zero-length when there is an active reader when using `ReadableStreamBYOBRequest.respondWithNewView()`. - By doing that, we can get all tests passed in `readable-byte-streams/bad-buffers-and-views.any.js`. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: #44155 Refs: https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-with-new-view Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 741402d commit 96c3373

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/internal/webstreams/readablestream.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,15 @@ function readableByteStreamControllerRespondWithNewView(controller, view) {
25162516
const viewBuffer = ArrayBufferViewGetBuffer(view);
25172517
const viewBufferByteLength = ArrayBufferGetByteLength(viewBuffer);
25182518

2519+
if (stream[kState].state === 'closed') {
2520+
if (viewByteLength !== 0)
2521+
throw new ERR_INVALID_STATE.TypeError('View is not zero-length');
2522+
} else {
2523+
assert(stream[kState].state === 'readable');
2524+
if (viewByteLength === 0)
2525+
throw new ERR_INVALID_STATE.TypeError('View is zero-length');
2526+
}
2527+
25192528
const {
25202529
byteOffset,
25212530
byteLength,

test/wpt/status/streams.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,5 @@
44
},
55
"transferable/deserialize-error.window.js": {
66
"skip": "Browser-specific test"
7-
},
8-
"readable-byte-streams/bad-buffers-and-views.any.js": {
9-
"fail": {
10-
"note": "TODO: implement detached ArrayBuffer support",
11-
"expected": [
12-
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer is zero-length (in the readable state)"
13-
]
14-
}
157
}
168
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy