GeezerVison is showing github.com — test: update WPT for streams to f8f26a372f · nodejs/node@8146a97
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -27,7 +27,7 @@ Last update: | 27 | 27 | - performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline | 28 | 28 | - resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing | 29 | 29 | - resources: https://github.com/web-platform-tests/wpt/tree/6a2f322376/resources | 30 | | -- streams: https://github.com/web-platform-tests/wpt/tree/bc9dcbbf1a/streams | | 30 | +- streams: https://github.com/web-platform-tests/wpt/tree/f8f26a372f/streams | 31 | 31 | - url: https://github.com/web-platform-tests/wpt/tree/7a3645b79a/url | 32 | 32 | - urlpattern: https://github.com/web-platform-tests/wpt/tree/f07c03cbed/urlpattern | 33 | 33 | - user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing | |
Collapse file Copy file name to clipboard +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | spec: https://streams.spec.whatwg.org/ | 2 | 2 | suggested_reviewers: | 3 | | - - domenic | 4 | | - - yutakahirano | 5 | 3 | - youennf | 6 | 4 | - wanderview | 7 | 5 | - ricea | | 6 | + - MattiasBuelens |
Collapse file Copy file name to clipboard +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +features: | | 2 | +- name: streams | | 3 | + files: | | 4 | + # Top-level only. Subdirectories have their own mapping. | | 5 | + - "*" |
Collapse file Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +features: | | 2 | +- name: streams | | 3 | + files: "**" |
Collapse file Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +features: | | 2 | +- name: readable-byte-streams | | 3 | + files: "**" |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/readable-byte-streams/bad-buffers-and-views.any.js +5-12Lines changed: 5 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -123,8 +123,7 @@ promise_test(t => { | 123 | 123 | async_test(t => { | 124 | 124 | const stream = new ReadableStream({ | 125 | 125 | 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(); | 128 | 127 |
| 129 | 128 | assert_throws_js(TypeError, () => c.byobRequest.respond(1), | 130 | 129 | 'respond() must throw if the corresponding view has become detached'); | @@ -141,9 +140,7 @@ async_test(t => { | 141 | 140 | const stream = new ReadableStream({ | 142 | 141 | pull: t.step_func_done(c => { | 143 | 142 | c.close(); | 144 | | - | 145 | | - // Detach it by reading into it | 146 | | - reader.read(c.byobRequest.view); | | 143 | + c.byobRequest.view.buffer.transfer(); | 147 | 144 |
| 148 | 145 | assert_throws_js(TypeError, () => c.byobRequest.respond(0), | 149 | 146 | 'respond() must throw if the corresponding view has become detached'); | @@ -159,9 +156,8 @@ async_test(t => { | 159 | 156 | async_test(t => { | 160 | 157 | const stream = new ReadableStream({ | 161 | 158 | pull: t.step_func_done(c => { | 162 | | - // Detach it by reading into it | 163 | 159 | const view = new Uint8Array([1, 2, 3]); | 164 | | - reader.read(view); | | 160 | + view.buffer.transfer(); | 165 | 161 |
| 166 | 162 | assert_throws_js(TypeError, () => c.byobRequest.respondWithNewView(view)); | 167 | 163 | }), | @@ -364,8 +360,7 @@ async_test(t => { | 364 | 360 | async_test(t => { | 365 | 361 | const stream = new ReadableStream({ | 366 | 362 | 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(); | 369 | 364 |
| 370 | 365 | assert_throws_js(TypeError, () => c.enqueue(new Uint8Array([1])), | 371 | 366 | 'enqueue() must throw if the BYOB request\'s buffer has become detached'); | @@ -382,9 +377,7 @@ async_test(t => { | 382 | 377 | const stream = new ReadableStream({ | 383 | 378 | pull: t.step_func_done(c => { | 384 | 379 | c.close(); | 385 | | - | 386 | | - // Detach it by reading into it | 387 | | - reader.read(c.byobRequest.view); | | 380 | + c.byobRequest.view.buffer.transfer(); | 388 | 381 |
| 389 | 382 | assert_throws_js(TypeError, () => c.enqueue(new Uint8Array([1])), | 390 | 383 | 'enqueue() must throw if the BYOB request\'s buffer has become detached'); | |
Collapse file Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// META: global=window,worker | | 2 | +'use strict'; | | 3 | + | | 4 | +test(() => { | | 5 | + const byteReadable = new ReadableStream({type: 'bytes'}); | | 6 | + byteReadable.getReader(); | | 7 | + assert_throws_js(TypeError, () => byteReadable.tee(), 'byteReadable.tee() must throw'); | | 8 | +}, 'tee() on a locked byte stream does not crash'); | | 9 | + |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/readable-byte-streams/general.any.js +86Lines changed: 86 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -236,6 +236,29 @@ promise_test(t => { | 236 | 236 | }); | 237 | 237 | }, 'ReadableStream with byte source: Test that erroring a stream does not release a BYOB reader automatically'); | 238 | 238 |
| | 239 | +promise_test(async t => { | | 240 | + const rs = new ReadableStream({ | | 241 | + type: 'bytes', | | 242 | + start(c) { | | 243 | + c.enqueue(new Uint8Array([1, 2, 3])); | | 244 | + } | | 245 | + }); | | 246 | + | | 247 | + const reader1 = rs.getReader({mode: 'byob'}); | | 248 | + reader1.releaseLock(); | | 249 | + | | 250 | + const reader2 = rs.getReader({mode: 'byob'}); | | 251 | + | | 252 | + // Should be a no-op | | 253 | + reader1.releaseLock(); | | 254 | + | | 255 | + const result = await reader2.read(new Uint8Array([0, 0, 0])); | | 256 | + assert_typed_array_equals(result.value, new Uint8Array([1, 2, 3]), | | 257 | + 'read() should still work on reader2 even after reader1 is released'); | | 258 | + assert_false(result.done, 'done'); | | 259 | + | | 260 | +}, 'ReadableStream with byte source: cannot use an already-released BYOB reader to unlock a stream again'); | | 261 | + | 239 | 262 | promise_test(async t => { | 240 | 263 | const stream = new ReadableStream({ | 241 | 264 | type: 'bytes' | @@ -992,6 +1015,69 @@ promise_test(() => { | 992 | 1015 | }, 'ReadableStream with byte source: respond(3) to read(view) with 2 element Uint16Array enqueues the 1 byte ' + | 993 | 1016 | 'remainder'); | 994 | 1017 |
| | 1018 | +promise_test(() => { | | 1019 | + let pullCount = 0; | | 1020 | + | | 1021 | + let controller; | | 1022 | + let byobRequest; | | 1023 | + let viewInfo; | | 1024 | + | | 1025 | + const stream = new ReadableStream({ | | 1026 | + start(c) { | | 1027 | + controller = c; | | 1028 | + }, | | 1029 | + pull() { | | 1030 | + ++pullCount; | | 1031 | + | | 1032 | + byobRequest = controller.byobRequest; | | 1033 | + const view = byobRequest.view; | | 1034 | + viewInfo = extractViewInfo(view); | | 1035 | + | | 1036 | + view[0] = 0x01; | | 1037 | + view[1] = 0x02; | | 1038 | + view[2] = 0x03; | | 1039 | + | | 1040 | + controller.byobRequest.respond(3); | | 1041 | + }, | | 1042 | + type: 'bytes' | | 1043 | + }); | | 1044 | + | | 1045 | + const reader = stream.getReader({ mode: 'byob' }); | | 1046 | + const read1 = reader.read(new Uint16Array(2)); | | 1047 | + const read2 = reader.read(new Uint8Array(1)); | | 1048 | + | | 1049 | + return read1.then(result => { | | 1050 | + assert_equals(pullCount, 1); | | 1051 | + | | 1052 | + assert_false(result.done, 'done'); | | 1053 | + | | 1054 | + const view = result.value; | | 1055 | + assert_equals(view.byteOffset, 0, 'byteOffset'); | | 1056 | + assert_equals(view.byteLength, 2, 'byteLength'); | | 1057 | + | | 1058 | + const dataView = new DataView(view.buffer, view.byteOffset, view.byteLength); | | 1059 | + assert_equals(dataView.getUint16(0), 0x0102); | | 1060 | + | | 1061 | + return read2; | | 1062 | + }).then(result => { | | 1063 | + assert_equals(pullCount, 1); | | 1064 | + assert_not_equals(byobRequest, null, 'byobRequest must not be null'); | | 1065 | + assert_equals(viewInfo.constructor, Uint8Array, 'view.constructor should be Uint8Array'); | | 1066 | + assert_equals(viewInfo.bufferByteLength, 4, 'view.buffer.byteLength should be 4'); | | 1067 | + assert_equals(viewInfo.byteOffset, 0, 'view.byteOffset should be 0'); | | 1068 | + assert_equals(viewInfo.byteLength, 4, 'view.byteLength should be 4'); | | 1069 | + | | 1070 | + assert_false(result.done, 'done'); | | 1071 | + | | 1072 | + const view = result.value; | | 1073 | + assert_equals(view.byteOffset, 0, 'byteOffset'); | | 1074 | + assert_equals(view.byteLength, 1, 'byteLength'); | | 1075 | + | | 1076 | + assert_equals(view[0], 0x03); | | 1077 | + }); | | 1078 | +}, 'ReadableStream with byte source: respond(3) to read(view) with 2 element Uint16Array fulfills second read(view) ' + | | 1079 | + 'with the 1 byte remainder'); | | 1080 | + | 995 | 1081 | promise_test(t => { | 996 | 1082 | const stream = new ReadableStream({ | 997 | 1083 | start(controller) { | |
Collapse file Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// META: global=window,worker,shadowrealm | | 2 | +// META: script=../resources/test-utils.js | | 3 | +// META: script=../resources/rs-test-templates.js | | 4 | +'use strict'; | | 5 | + | | 6 | +templatedRSEmpty('ReadableStream with byte source (empty)', () => { | | 7 | + return new ReadableStream({ type: 'bytes' }); | | 8 | +}); | | 9 | + | | 10 | +templatedRSEmptyReader('ReadableStream with byte source (empty) default reader', () => { | | 11 | + const stream = new ReadableStream({ type: 'bytes' }); | | 12 | + const reader = stream.getReader(); | | 13 | + return { stream, reader, read: () => reader.read() }; | | 14 | +}); | | 15 | + | | 16 | +templatedRSEmptyReader('ReadableStream with byte source (empty) BYOB reader', () => { | | 17 | + const stream = new ReadableStream({ type: 'bytes' }); | | 18 | + const reader = stream.getReader({ mode: 'byob' }); | | 19 | + return { stream, reader, read: () => reader.read(new Uint8Array([0])) }; | | 20 | +}); | | 21 | + | | 22 | +templatedRSThrowAfterCloseOrError('ReadableStream with byte source', (extras) => { | | 23 | + return new ReadableStream({ type: 'bytes', ...extras }); | | 24 | +}); |
Collapse file Copy file name to clipboard +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +features: | | 2 | +- name: streams | | 3 | + files: | | 4 | + - "*" | | 5 | + - "!async-iterator.any.js" | | 6 | + - "!from.any.js" | | 7 | + # 'owning' type is not yet standardized | | 8 | + - "!owning-type*" | | 9 | +- name: async-iterable-streams | | 10 | + files: | | 11 | + - async-iterator.any.js | | 12 | +- name: readablestream-from | | 13 | + files: | | 14 | + - from.any.js |
|