Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c079abe

Browse filesBrowse files
daeyeonruyadorno
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 8c1fe86 commit c079abe
Copy full SHA for c079abe

File tree

Expand file treeCollapse file tree

2 files changed

+9
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-8
lines changed
Open diff view settings
Collapse file

‎lib/internal/webstreams/readablestream.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/readablestream.js
+9Lines 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,
Collapse file

‎test/wpt/status/streams.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/streams.json
-8Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.