Skip to content

Commit 7b6126a

Browse files
daeyeonruyadorno
authored andcommitted
test: update Web Streams WPT
This updates the tests and the status file via running `git node wpt streams`. Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com PR-URL: #44234 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent f7be92f commit 7b6126a

File tree

74 files changed

+2610
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2610
-290
lines changed

test/fixtures/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Last update:
2424
- interfaces: https://github.com/web-platform-tests/wpt/tree/fc086c82d5/interfaces
2525
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
2626
- resources: https://github.com/web-platform-tests/wpt/tree/c5b428f15a/resources
27-
- streams: https://github.com/web-platform-tests/wpt/tree/8f60d94439/streams
27+
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
2828
- url: https://github.com/web-platform-tests/wpt/tree/0e5b126cd0/url
2929
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
3030
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// META: script=/resources/idlharness-shadowrealm.js
2+
idl_test_shadowrealm(["streams"], ["dom"]);

test/fixtures/wpt/streams/piping/abort.any.js

+104-71
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/recording-streams.js
33
// META: script=../resources/test-utils.js
44
'use strict';
@@ -53,29 +53,28 @@ promise_test(t => {
5353
});
5454
}, 'an aborted signal should cause the writable stream to reject with an AbortError');
5555

56-
promise_test(() => {
57-
let error;
58-
const rs = recordingReadableStream(errorOnPull, hwm0);
59-
const ws = new WritableStream();
60-
const abortController = new AbortController();
61-
const signal = abortController.signal;
62-
abortController.abort();
63-
return rs.pipeTo(ws, { signal })
64-
.catch(e => {
65-
error = e;
66-
})
67-
.then(() => Promise.all([
68-
rs.getReader().closed,
69-
ws.getWriter().closed.catch(e => {
70-
assert_equals(e, error, 'the writable should be errored with the same object');
71-
})
72-
]))
73-
.then(() => {
56+
for (const reason of [null, undefined, error1]) {
57+
promise_test(async t => {
58+
const rs = recordingReadableStream(errorOnPull, hwm0);
59+
const ws = new WritableStream();
60+
const abortController = new AbortController();
61+
const signal = abortController.signal;
62+
abortController.abort(reason);
63+
const pipeToPromise = rs.pipeTo(ws, { signal });
64+
if (reason !== undefined) {
65+
await promise_rejects_exactly(t, reason, pipeToPromise, 'pipeTo rejects with abort reason');
66+
} else {
67+
await promise_rejects_dom(t, 'AbortError', pipeToPromise, 'pipeTo rejects with AbortError');
68+
}
69+
const error = await pipeToPromise.catch(e => e);
70+
await rs.getReader().closed;
71+
await promise_rejects_exactly(t, error, ws.getWriter().closed, 'the writable should be errored with the same object');
72+
assert_equals(signal.reason, error, 'signal.reason should be error'),
7473
assert_equals(rs.events.length, 2, 'cancel should have been called');
7574
assert_equals(rs.events[0], 'cancel', 'first event should be cancel');
7675
assert_equals(rs.events[1], error, 'the readable should be canceled with the same object');
77-
});
78-
}, 'all the AbortError objects should be the same object');
76+
}, `(reason: '${reason}') all the error objects should be the same object`);
77+
}
7978

8079
promise_test(t => {
8180
const rs = recordingReadableStream(errorOnPull, hwm0);
@@ -115,61 +114,74 @@ promise_test(t => {
115114
});
116115
}, 'preventCancel and preventAbort should prevent canceling the readable and aborting the readable');
117116

118-
promise_test(t => {
119-
const rs = new ReadableStream({
120-
start(controller) {
121-
controller.enqueue('a');
122-
controller.enqueue('b');
123-
controller.close();
124-
}
125-
});
126-
const abortController = new AbortController();
127-
const signal = abortController.signal;
128-
const ws = recordingWritableStream({
129-
write() {
130-
abortController.abort();
117+
for (const reason of [null, undefined, error1]) {
118+
promise_test(async t => {
119+
const rs = new ReadableStream({
120+
start(controller) {
121+
controller.enqueue('a');
122+
controller.enqueue('b');
123+
controller.close();
124+
}
125+
});
126+
const abortController = new AbortController();
127+
const signal = abortController.signal;
128+
const ws = recordingWritableStream({
129+
write() {
130+
abortController.abort(reason);
131+
}
132+
});
133+
const pipeToPromise = rs.pipeTo(ws, { signal });
134+
if (reason !== undefined) {
135+
await promise_rejects_exactly(t, reason, pipeToPromise, 'pipeTo rejects with abort reason');
136+
} else {
137+
await promise_rejects_dom(t, 'AbortError', pipeToPromise, 'pipeTo rejects with AbortError');
131138
}
132-
});
133-
return promise_rejects_dom(t, 'AbortError', rs.pipeTo(ws, { signal }), 'pipeTo should reject')
134-
.then(() => {
135-
assert_equals(ws.events.length, 4, 'only chunk "a" should have been written');
136-
assert_array_equals(ws.events.slice(0, 3), ['write', 'a', 'abort'], 'events should match');
137-
assert_equals(ws.events[3].name, 'AbortError', 'abort reason should be an AbortError');
138-
});
139-
}, 'abort should prevent further reads');
139+
const error = await pipeToPromise.catch(e => e);
140+
assert_equals(signal.reason, error, 'signal.reason should be error');
141+
assert_equals(ws.events.length, 4, 'only chunk "a" should have been written');
142+
assert_array_equals(ws.events.slice(0, 3), ['write', 'a', 'abort'], 'events should match');
143+
assert_equals(ws.events[3], error, 'abort reason should be error');
144+
}, `(reason: '${reason}') abort should prevent further reads`);
145+
}
140146

141-
promise_test(t => {
142-
let readController;
143-
const rs = new ReadableStream({
144-
start(c) {
145-
readController = c;
146-
c.enqueue('a');
147-
c.enqueue('b');
148-
}
149-
});
150-
const abortController = new AbortController();
151-
const signal = abortController.signal;
152-
let resolveWrite;
153-
const writePromise = new Promise(resolve => {
154-
resolveWrite = resolve;
155-
});
156-
const ws = recordingWritableStream({
157-
write() {
158-
return writePromise;
147+
for (const reason of [null, undefined, error1]) {
148+
promise_test(async t => {
149+
let readController;
150+
const rs = new ReadableStream({
151+
start(c) {
152+
readController = c;
153+
c.enqueue('a');
154+
c.enqueue('b');
155+
}
156+
});
157+
const abortController = new AbortController();
158+
const signal = abortController.signal;
159+
let resolveWrite;
160+
const writePromise = new Promise(resolve => {
161+
resolveWrite = resolve;
162+
});
163+
const ws = recordingWritableStream({
164+
write() {
165+
return writePromise;
166+
}
167+
}, new CountQueuingStrategy({ highWaterMark: Infinity }));
168+
const pipeToPromise = rs.pipeTo(ws, { signal });
169+
await delay(0);
170+
await abortController.abort(reason);
171+
await readController.close(); // Make sure the test terminates when signal is not implemented.
172+
await resolveWrite();
173+
if (reason !== undefined) {
174+
await promise_rejects_exactly(t, reason, pipeToPromise, 'pipeTo rejects with abort reason');
175+
} else {
176+
await promise_rejects_dom(t, 'AbortError', pipeToPromise, 'pipeTo rejects with AbortError');
159177
}
160-
}, new CountQueuingStrategy({ highWaterMark: Infinity }));
161-
const pipeToPromise = rs.pipeTo(ws, { signal });
162-
return delay(0).then(() => {
163-
abortController.abort();
164-
readController.close(); // Make sure the test terminates when signal is not implemented.
165-
resolveWrite();
166-
return promise_rejects_dom(t, 'AbortError', pipeToPromise, 'pipeTo should reject');
167-
}).then(() => {
178+
const error = await pipeToPromise.catch(e => e);
179+
assert_equals(signal.reason, error, 'signal.reason should be error');
168180
assert_equals(ws.events.length, 6, 'chunks "a" and "b" should have been written');
169181
assert_array_equals(ws.events.slice(0, 5), ['write', 'a', 'write', 'b', 'abort'], 'events should match');
170-
assert_equals(ws.events[5].name, 'AbortError', 'abort reason should be an AbortError');
171-
});
172-
}, 'all pending writes should complete on abort');
182+
assert_equals(ws.events[5], error, 'abort reason should be error');
183+
}, `(reason: '${reason}') all pending writes should complete on abort`);
184+
}
173185

174186
promise_test(t => {
175187
const rs = new ReadableStream({
@@ -373,3 +385,24 @@ promise_test(t => {
373385
assert_array_equals(rs.events, ['pull'], 'cancel should not have been called');
374386
});
375387
}, 'abort should do nothing after the writable is errored');
388+
389+
promise_test(async t => {
390+
const rs = new ReadableStream({
391+
pull(c) {
392+
c.enqueue(new Uint8Array([]));
393+
},
394+
type: "bytes",
395+
});
396+
const ws = new WritableStream();
397+
const [first, second] = rs.tee();
398+
399+
let aborted = false;
400+
first.pipeTo(ws, { signal: AbortSignal.abort() }).catch(() => {
401+
aborted = true;
402+
});
403+
await delay(0);
404+
assert_true(!aborted, "pipeTo should not resolve yet");
405+
await second.cancel();
406+
await delay(0);
407+
assert_true(aborted, "pipeTo should be aborted now");
408+
}, "pipeTo on a teed readable byte stream should only be aborted when both branches are aborted");

test/fixtures/wpt/streams/piping/close-propagation-backward.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/recording-streams.js
33
'use strict';
44

test/fixtures/wpt/streams/piping/close-propagation-forward.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/error-propagation-backward.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/error-propagation-forward.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/flow-control.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/rs-utils.js
44
// META: script=../resources/recording-streams.js

test/fixtures/wpt/streams/piping/general.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/multiple-propagation.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/pipe-through.any.js

+64-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/rs-utils.js
33
// META: script=../resources/test-utils.js
44
// META: script=../resources/recording-streams.js
@@ -266,3 +266,66 @@ test(() => {
266266
}
267267
}), 'pipeThrough should throw');
268268
}, 'pipeThrough() should throw if an option getter grabs a writer');
269+
270+
test(() => {
271+
const rs = new ReadableStream();
272+
const readable = new ReadableStream();
273+
const writable = new WritableStream();
274+
rs.pipeThrough({readable, writable}, null);
275+
}, 'pipeThrough() should not throw if option is null');
276+
277+
test(() => {
278+
const rs = new ReadableStream();
279+
const readable = new ReadableStream();
280+
const writable = new WritableStream();
281+
rs.pipeThrough({readable, writable}, {signal:undefined});
282+
}, 'pipeThrough() should not throw if signal is undefined');
283+
284+
function tryPipeThrough(pair, options)
285+
{
286+
const rs = new ReadableStream();
287+
if (!pair)
288+
pair = {readable:new ReadableStream(), writable:new WritableStream()};
289+
try {
290+
rs.pipeThrough(pair, options)
291+
} catch (e) {
292+
return e;
293+
}
294+
}
295+
296+
test(() => {
297+
let result = tryPipeThrough({
298+
get readable() {
299+
return new ReadableStream();
300+
},
301+
get writable() {
302+
throw "writable threw";
303+
}
304+
}, { });
305+
assert_equals(result, "writable threw");
306+
307+
result = tryPipeThrough({
308+
get readable() {
309+
throw "readable threw";
310+
},
311+
get writable() {
312+
throw "writable threw";
313+
}
314+
}, { });
315+
assert_equals(result, "readable threw");
316+
317+
result = tryPipeThrough({
318+
get readable() {
319+
throw "readable threw";
320+
},
321+
get writable() {
322+
throw "writable threw";
323+
}
324+
}, {
325+
get preventAbort() {
326+
throw "preventAbort threw";
327+
}
328+
});
329+
assert_equals(result, "readable threw");
330+
331+
}, 'pipeThrough() should throw if readable/writable getters throw');

test/fixtures/wpt/streams/piping/then-interception.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
// META: script=../resources/test-utils.js
33
// META: script=../resources/recording-streams.js
44
'use strict';

test/fixtures/wpt/streams/piping/throwing-options.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
'use strict';
33

44
class ThrowingOptions {

test/fixtures/wpt/streams/piping/transform-streams.any.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
'use strict';
33

44
promise_test(() => {

test/fixtures/wpt/streams/queuing-strategies.any.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// META: global=window,worker,jsshell
1+
// META: global=window,worker
22
'use strict';
33

44
const highWaterMarkConversions = new Map([
@@ -75,8 +75,23 @@ for (const QueuingStrategy of [CountQueuingStrategy, ByteLengthQueuingStrategy])
7575
assert_equals(sc.size(), 2, 'size() on the subclass should override the parent');
7676
assert_true(sc.subClassMethod(), 'subClassMethod() should work');
7777
}, `${QueuingStrategy.name}: subclassing should work correctly`);
78+
79+
test(() => {
80+
const size = new QueuingStrategy({ highWaterMark: 5 }).size;
81+
assert_false('prototype' in size);
82+
}, `${QueuingStrategy.name}: size should not have a prototype property`);
7883
}
7984

85+
test(() => {
86+
const size = new CountQueuingStrategy({ highWaterMark: 5 }).size;
87+
assert_throws_js(TypeError, () => new size());
88+
}, `CountQueuingStrategy: size should not be a constructor`);
89+
90+
test(() => {
91+
const size = new ByteLengthQueuingStrategy({ highWaterMark: 5 }).size;
92+
assert_throws_js(TypeError, () => new size({ byteLength: 1024 }));
93+
}, `ByteLengthQueuingStrategy: size should not be a constructor`);
94+
8095
test(() => {
8196
const size = (new CountQueuingStrategy({ highWaterMark: 5 })).size;
8297
assert_equals(size.length, 0);

0 commit comments

Comments
 (0)