GeezerVison is showing github.com — test: update streams wpt · nodejs/node@041a490
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/1e140d63ec/resources | 30 | | -- streams: https://github.com/web-platform-tests/wpt/tree/2bd26e124c/streams | | 30 | +- streams: https://github.com/web-platform-tests/wpt/tree/bc9dcbbf1a/streams | 31 | 31 | - url: https://github.com/web-platform-tests/wpt/tree/67880a4eb8/url | 32 | 32 | - user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing | 33 | 33 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/idlharness-shadowrealm.window.js -2Lines changed: 0 additions & 2 deletions Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/idlharness.any.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -// META: global=window,worker | | 1 | +// META: global=window,worker,shadowrealm-in-window | 2 | 2 | // META: script=/resources/WebIDLParser.js | 3 | 3 | // META: script=/resources/idlharness.js | 4 | 4 | // META: timeout=long | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/readable-byte-streams/general.any.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -870,11 +870,11 @@ promise_test(() => { | 870 | 870 | start(c) { | 871 | 871 | controller = c; | 872 | 872 | }, | 873 | | - async pull() { | | 873 | + pull() { | 874 | 874 | byobRequestDefined.push(controller.byobRequest !== null); | 875 | 875 | const initialByobRequest = controller.byobRequest; | 876 | 876 |
| 877 | | - const transferredView = await transferArrayBufferView(controller.byobRequest.view); | | 877 | + const transferredView = transferArrayBufferView(controller.byobRequest.view); | 878 | 878 | transferredView[0] = 0x01; | 879 | 879 | controller.byobRequest.respondWithNewView(transferredView); | 880 | 880 |
| @@ -2288,7 +2288,7 @@ promise_test(async t => { | 2288 | 2288 | await pullCalledPromise; | 2289 | 2289 |
| 2290 | 2290 | // Transfer the original BYOB request's buffer, and respond with a new view on that buffer | 2291 | | - const transferredView = await transferArrayBufferView(controller.byobRequest.view); | | 2291 | + const transferredView = transferArrayBufferView(controller.byobRequest.view); | 2292 | 2292 | const newView = transferredView.subarray(0, 1); | 2293 | 2293 | newView[0] = 42; | 2294 | 2294 |
| @@ -2328,7 +2328,7 @@ promise_test(async t => { | 2328 | 2328 | await pullCalledPromise; | 2329 | 2329 |
| 2330 | 2330 | // Transfer the original BYOB request's buffer, and respond with an empty view on that buffer | 2331 | | - const transferredView = await transferArrayBufferView(controller.byobRequest.view); | | 2331 | + const transferredView = transferArrayBufferView(controller.byobRequest.view); | 2332 | 2332 | const newView = transferredView.subarray(0, 0); | 2333 | 2333 |
| 2334 | 2334 | controller.close(); | |
Collapse file Copy file name to clipboard +54Lines changed: 54 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 | +'use strict'; | | 4 | + | | 5 | +// Tests which patch the global environment are kept separate to avoid | | 6 | +// interfering with other tests. | | 7 | + | | 8 | +promise_test(async (t) => { | | 9 | + let controller; | | 10 | + const rs = new ReadableStream({ | | 11 | + type: 'bytes', | | 12 | + start(c) { | | 13 | + controller = c; | | 14 | + } | | 15 | + }); | | 16 | + const reader = rs.getReader({mode: 'byob'}); | | 17 | + | | 18 | + const length = 0x4000; | | 19 | + const buffer = new ArrayBuffer(length); | | 20 | + const bigArray = new BigUint64Array(buffer, length - 8, 1); | | 21 | + | | 22 | + const read1 = reader.read(new Uint8Array(new ArrayBuffer(0x100))); | | 23 | + const read2 = reader.read(bigArray); | | 24 | + | | 25 | + let flag = false; | | 26 | + Object.defineProperty(Object.prototype, 'then', { | | 27 | + get: t.step_func(() => { | | 28 | + if (!flag) { | | 29 | + flag = true; | | 30 | + assert_equals(controller.byobRequest, null, 'byobRequest should be null after filling both views'); | | 31 | + } | | 32 | + }), | | 33 | + configurable: true | | 34 | + }); | | 35 | + t.add_cleanup(() => { | | 36 | + delete Object.prototype.then; | | 37 | + }); | | 38 | + | | 39 | + controller.enqueue(new Uint8Array(0x110).fill(0x42)); | | 40 | + assert_true(flag, 'patched then() should be called'); | | 41 | + | | 42 | + // The first read() is filled entirely with 0x100 bytes | | 43 | + const result1 = await read1; | | 44 | + assert_false(result1.done, 'result1.done'); | | 45 | + assert_typed_array_equals(result1.value, new Uint8Array(0x100).fill(0x42), 'result1.value'); | | 46 | + | | 47 | + // The second read() is filled with the remaining 0x10 bytes | | 48 | + const result2 = await read2; | | 49 | + assert_false(result2.done, 'result2.done'); | | 50 | + assert_equals(result2.value.constructor, BigUint64Array, 'result2.value constructor'); | | 51 | + assert_equals(result2.value.byteOffset, length - 8, 'result2.value byteOffset'); | | 52 | + assert_equals(result2.value.length, 1, 'result2.value length'); | | 53 | + assert_array_equals([...result2.value], [0x42424242_42424242n], 'result2.value contents'); | | 54 | +}, 'Patched then() sees byobRequest after filling all pending pull-into descriptors'); |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/readable-byte-streams/tee.any.js +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -934,3 +934,36 @@ promise_test(async () => { | 934 | 934 | assert_typed_array_equals(result4.value, new Uint8Array([0]).subarray(0, 0), 'second chunk from branch2 should be correct'); | 935 | 935 |
| 936 | 936 | }, 'ReadableStream teeing with byte source: respond() and close() while both branches are pulling'); | | 937 | + | | 938 | +promise_test(async t => { | | 939 | + let pullCount = 0; | | 940 | + const arrayBuffer = new Uint8Array([0x01, 0x02, 0x03]).buffer; | | 941 | + const enqueuedChunk = new Uint8Array(arrayBuffer, 2); | | 942 | + assert_equals(enqueuedChunk.length, 1); | | 943 | + assert_equals(enqueuedChunk.byteOffset, 2); | | 944 | + const rs = new ReadableStream({ | | 945 | + type: 'bytes', | | 946 | + pull(c) { | | 947 | + ++pullCount; | | 948 | + if (pullCount === 1) { | | 949 | + c.enqueue(enqueuedChunk); | | 950 | + } | | 951 | + } | | 952 | + }); | | 953 | + | | 954 | + const [branch1, branch2] = rs.tee(); | | 955 | + const reader1 = branch1.getReader(); | | 956 | + const reader2 = branch2.getReader(); | | 957 | + | | 958 | + const [result1, result2] = await Promise.all([reader1.read(), reader2.read()]); | | 959 | + assert_equals(result1.done, false, 'reader1 done'); | | 960 | + assert_equals(result2.done, false, 'reader2 done'); | | 961 | + | | 962 | + const view1 = result1.value; | | 963 | + const view2 = result2.value; | | 964 | + // The first stream has the transferred buffer, but the second stream has the | | 965 | + // cloned buffer. | | 966 | + const underlying = new Uint8Array([0x01, 0x02, 0x03]).buffer; | | 967 | + assert_typed_array_equals(view1, new Uint8Array(underlying, 2), 'reader1 value'); | | 968 | + assert_typed_array_equals(view2, new Uint8Array([0x03]), 'reader2 value'); | | 969 | +}, 'ReadableStream teeing with byte source: reading an array with a byte offset should clone correctly'); |
Collapse file Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<html class="test-wait"> | | 2 | +<meta charset="utf-8"> | | 3 | +<script type="module"> | | 4 | + let a = window.open() | | 5 | + try { | | 6 | + let dir = await a.navigator.storage.getDirectory() | | 7 | + let hdl = await dir.getFileHandle("7399d8cf-9ff9-494d-89eb-d3045f229c27", {"create": true}) | | 8 | + let map = new Map([[]]) | | 9 | + let b = ReadableStream.from(map) | | 10 | + let c = await hdl.createWritable({ }) | | 11 | + await b.pipeTo(c, { }).catch(() => { | | 12 | + // Error expected as we are not piping the right form of chunk to FileHandle | | 13 | + }) | | 14 | + } finally { | | 15 | + document.documentElement.classList.remove("test-wait") | | 16 | + a.close() | | 17 | + } | | 18 | +</script> |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/readable-streams/owning-type-video-frame.any.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -// META: global=window,worker,shadowrealm | | 1 | +// META: global=window,worker | 2 | 2 | // META: script=../resources/test-utils.js | 3 | 3 | // META: script=../resources/rs-utils.js | 4 | 4 | 'use strict'; | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/resources/rs-utils.js +42-13Lines changed: 42 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | (function () { | | 3 | + // Fake setInterval-like functionality in environments that don't have it | | 4 | + class IntervalHandle { | | 5 | + constructor(callback, delayMs) { | | 6 | + this.callback = callback; | | 7 | + this.delayMs = delayMs; | | 8 | + this.cancelled = false; | | 9 | + Promise.resolve().then(() => this.check()); | | 10 | + } | | 11 | + | | 12 | + async check() { | | 13 | + while (true) { | | 14 | + await new Promise(resolve => step_timeout(resolve, this.delayMs)); | | 15 | + if (this.cancelled) { | | 16 | + return; | | 17 | + } | | 18 | + this.callback(); | | 19 | + } | | 20 | + } | | 21 | + | | 22 | + cancel() { | | 23 | + this.cancelled = true; | | 24 | + } | | 25 | + } | | 26 | + | | 27 | + let localSetInterval, localClearInterval; | | 28 | + if (typeof globalThis.setInterval !== "undefined" && | | 29 | + typeof globalThis.clearInterval !== "undefined") { | | 30 | + localSetInterval = globalThis.setInterval; | | 31 | + localClearInterval = globalThis.clearInterval; | | 32 | + } else { | | 33 | + localSetInterval = function setInterval(callback, delayMs) { | | 34 | + return new IntervalHandle(callback, delayMs); | | 35 | + } | | 36 | + localClearInterval = function clearInterval(handle) { | | 37 | + handle.cancel(); | | 38 | + } | | 39 | + } | 3 | 40 |
| 4 | 41 | class RandomPushSource { | 5 | 42 | constructor(toPush) { | | 18 | 55 | } | 19 | 56 |
| 20 | 57 | if (!this.started) { | 21 | | - this._intervalHandle = setInterval(writeChunk, 2); | | 58 | + this._intervalHandle = localSetInterval(writeChunk, 2); | 22 | 59 | this.started = true; | 23 | 60 | } | 24 | 61 |
| 25 | 62 | if (this.paused) { | 26 | | - this._intervalHandle = setInterval(writeChunk, 2); | | 63 | + this._intervalHandle = localSetInterval(writeChunk, 2); | 27 | 64 | this.paused = false; | 28 | 65 | } | 29 | 66 |
| | 37 | 74 |
| 38 | 75 | if (source.toPush > 0 && source.pushed > source.toPush) { | 39 | 76 | if (source._intervalHandle) { | 40 | | - clearInterval(source._intervalHandle); | | 77 | + localClearInterval(source._intervalHandle); | 41 | 78 | source._intervalHandle = undefined; | 42 | 79 | } | 43 | 80 | source.closed = true; | | 55 | 92 |
| 56 | 93 | if (this.started) { | 57 | 94 | this.paused = true; | 58 | | - clearInterval(this._intervalHandle); | | 95 | + localClearInterval(this._intervalHandle); | 59 | 96 | this._intervalHandle = undefined; | 60 | 97 | } else { | 61 | 98 | throw new Error('Can\'t pause reading an unstarted source.'); | | 178 | 215 | } | 179 | 216 |
| 180 | 217 | function transferArrayBufferView(view) { | 181 | | - const noopByteStream = new ReadableStream({ | 182 | | - type: 'bytes', | 183 | | - pull(c) { | 184 | | - c.byobRequest.respond(c.byobRequest.view.byteLength); | 185 | | - c.close(); | 186 | | - } | 187 | | - }); | 188 | | - const reader = noopByteStream.getReader({ mode: 'byob' }); | 189 | | - return reader.read(view).then((result) => result.value); | | 218 | + return structuredClone(view, { transfer: [view.buffer] }); | 190 | 219 | } | 191 | 220 |
| 192 | 221 | self.RandomPushSource = RandomPushSource; | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/streams/transferable/transfer-with-messageport.window.js +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,7 +105,7 @@ async function transferMessagePortWith(constructor) { | 105 | 105 | await transferMessagePortWithOrder3(new constructor()); | 106 | 106 | } | 107 | 107 |
| 108 | | -async function advancedTransferMesagePortWith(constructor) { | | 108 | +async function advancedTransferMessagePortWith(constructor) { | 109 | 109 | await transferMessagePortWithOrder4(new constructor()); | 110 | 110 | await transferMessagePortWithOrder5(new constructor()); | 111 | 111 | await transferMessagePortWithOrder6(new constructor()); | @@ -166,7 +166,7 @@ async function mixedTransferMessagePortWithOrder3() { | 166 | 166 | ); | 167 | 167 | } | 168 | 168 |
| 169 | | -async function mixedTransferMesagePortWith() { | | 169 | +async function mixedTransferMessagePortWith() { | 170 | 170 | await mixedTransferMessagePortWithOrder1(); | 171 | 171 | await mixedTransferMessagePortWithOrder2(); | 172 | 172 | await mixedTransferMessagePortWithOrder3(); | @@ -185,19 +185,19 @@ promise_test(async t => { | 185 | 185 | }, "Transferring a MessagePort with a TransformStream should set `.ports`"); | 186 | 186 |
| 187 | 187 | promise_test(async t => { | 188 | | - await transferMessagePortWith(ReadableStream); | | 188 | + await advancedTransferMessagePortWith(ReadableStream); | 189 | 189 | }, "Transferring a MessagePort with a ReadableStream should set `.ports`, advanced"); | 190 | 190 |
| 191 | 191 | promise_test(async t => { | 192 | | - await transferMessagePortWith(WritableStream); | | 192 | + await advancedTransferMessagePortWith(WritableStream); | 193 | 193 | }, "Transferring a MessagePort with a WritableStream should set `.ports`, advanced"); | 194 | 194 |
| 195 | 195 | promise_test(async t => { | 196 | | - await transferMessagePortWith(TransformStream); | | 196 | + await advancedTransferMessagePortWith(TransformStream); | 197 | 197 | }, "Transferring a MessagePort with a TransformStream should set `.ports`, advanced"); | 198 | 198 |
| 199 | 199 | promise_test(async t => { | 200 | | - await mixedTransferMesagePortWith(); | | 200 | + await mixedTransferMessagePortWith(); | 201 | 201 | }, "Transferring a MessagePort with multiple streams should set `.ports`"); | 202 | 202 |
| 203 | 203 | test(() => { | |
|