Skip to content

Commit 887350c

Browse files
authored
Streams: update tests for Web IDL conversion
Follows whatwg/streams#1035. Notable changes: - Updates for the normative changes listed there. - Introduce an idlharness test - Remove various tests for things that are covered by idlharness, such as brand checks, the order of getting values from dictionaries, etc. - Updated for the fact that everything is now globally exposed, so some roundabout code to get constructors can be removed. - Slight timing updates: the pattern of returning a promise from an underlying sink/source/transformer `start()` function, then waiting on that before doing asserts, does not work with Web IDL's "promise resolved with". So instead we use `flushAsyncEvents()` to wait a little longer. - Consolidated queuing strategy tests into a single file, since after deleting the things covered by idlharness, most of the tests are shared. - Added tests that underlyingSink/underlyingSource are converted after queuingStrategy, since those dictionary conversions are done in prose. - Added a test for various updates to the Web IDL async iterators specification.
1 parent 80836cc commit 887350c

31 files changed

+999
-1990
lines changed

interfaces/streams.idl

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
[Exposed=(Window,Worker,Worklet)]
2+
interface ReadableStream {
3+
constructor(optional object underlyingSource, optional QueuingStrategy strategy = {});
4+
5+
readonly attribute boolean locked;
6+
7+
Promise<void> cancel(optional any reason);
8+
ReadableStreamReader getReader(optional ReadableStreamGetReaderOptions options = {});
9+
ReadableStream pipeThrough(ReadableWritablePair transform, optional StreamPipeOptions options = {});
10+
Promise<void> pipeTo(WritableStream destination, optional StreamPipeOptions options = {});
11+
sequence<ReadableStream> tee();
12+
13+
async iterable<any>(optional ReadableStreamIteratorOptions options = {});
14+
};
15+
16+
typedef (ReadableStreamDefaultReader or ReadableStreamBYOBReader) ReadableStreamReader;
17+
18+
enum ReadableStreamReaderMode { "byob" };
19+
20+
dictionary ReadableStreamGetReaderOptions {
21+
ReadableStreamReaderMode mode;
22+
};
23+
24+
dictionary ReadableStreamIteratorOptions {
25+
boolean preventCancel = false;
26+
};
27+
28+
dictionary ReadableWritablePair {
29+
required ReadableStream readable;
30+
required WritableStream writable;
31+
};
32+
33+
dictionary StreamPipeOptions {
34+
boolean preventClose = false;
35+
boolean preventAbort = false;
36+
boolean preventCancel = false;
37+
AbortSignal signal;
38+
};
39+
40+
dictionary UnderlyingSource {
41+
UnderlyingSourceStartCallback start;
42+
UnderlyingSourcePullCallback pull;
43+
UnderlyingSourceCancelCallback cancel;
44+
ReadableStreamType type;
45+
[EnforceRange] unsigned long long autoAllocateChunkSize;
46+
};
47+
48+
typedef (ReadableStreamDefaultController or ReadableByteStreamController) ReadableStreamController;
49+
50+
callback UnderlyingSourceStartCallback = any (ReadableStreamController controller);
51+
callback UnderlyingSourcePullCallback = Promise<void> (ReadableStreamController controller);
52+
callback UnderlyingSourceCancelCallback = Promise<void> (optional any reason);
53+
54+
enum ReadableStreamType { "bytes" };
55+
56+
[Exposed=(Window,Worker,Worklet)]
57+
interface ReadableStreamDefaultReader {
58+
constructor(ReadableStream stream);
59+
60+
readonly attribute Promise<void> closed;
61+
62+
Promise<void> cancel(optional any reason);
63+
Promise<any> read();
64+
void releaseLock();
65+
};
66+
67+
[Exposed=(Window,Worker,Worklet)]
68+
interface ReadableStreamBYOBReader {
69+
constructor(ReadableStream stream);
70+
71+
readonly attribute Promise<void> closed;
72+
73+
Promise<void> cancel(optional any reason);
74+
Promise<any> read(ArrayBufferView view);
75+
void releaseLock();
76+
};
77+
78+
[Exposed=(Window,Worker,Worklet)]
79+
interface ReadableStreamDefaultController {
80+
readonly attribute unrestricted double? desiredSize;
81+
82+
void close();
83+
void enqueue(optional any chunk);
84+
void error(optional any e);
85+
};
86+
87+
[Exposed=(Window,Worker,Worklet)]
88+
interface ReadableByteStreamController {
89+
readonly attribute ReadableStreamBYOBRequest? byobRequest;
90+
readonly attribute unrestricted double? desiredSize;
91+
92+
void close();
93+
void enqueue(ArrayBufferView chunk);
94+
void error(optional any e);
95+
};
96+
97+
[Exposed=(Window,Worker,Worklet)]
98+
interface ReadableStreamBYOBRequest {
99+
readonly attribute ArrayBufferView? view;
100+
101+
void respond([EnforceRange] unsigned long long bytesWritten);
102+
void respondWithNewView(ArrayBufferView view);
103+
};
104+
105+
[Exposed=(Window,Worker,Worklet)]
106+
interface WritableStream {
107+
constructor(optional object underlyingSink, optional QueuingStrategy strategy = {});
108+
109+
readonly attribute boolean locked;
110+
111+
Promise<void> abort(optional any reason);
112+
Promise<void> close();
113+
WritableStreamDefaultWriter getWriter();
114+
};
115+
116+
dictionary UnderlyingSink {
117+
UnderlyingSinkStartCallback start;
118+
UnderlyingSinkWriteCallback write;
119+
UnderlyingSinkCloseCallback close;
120+
UnderlyingSinkAbortCallback abort;
121+
any type;
122+
};
123+
124+
callback UnderlyingSinkStartCallback = any (WritableStreamDefaultController controller);
125+
callback UnderlyingSinkWriteCallback = Promise<void> (WritableStreamDefaultController controller, optional any chunk);
126+
callback UnderlyingSinkCloseCallback = Promise<void> ();
127+
callback UnderlyingSinkAbortCallback = Promise<void> (optional any reason);
128+
129+
[Exposed=(Window,Worker,Worklet)]
130+
interface WritableStreamDefaultWriter {
131+
constructor(WritableStream stream);
132+
133+
readonly attribute Promise<void> closed;
134+
readonly attribute unrestricted double? desiredSize;
135+
readonly attribute Promise<void> ready;
136+
137+
Promise<void> abort(optional any reason);
138+
Promise<void> close();
139+
void releaseLock();
140+
Promise<void> write(optional any chunk);
141+
};
142+
143+
[Exposed=(Window,Worker,Worklet)]
144+
interface WritableStreamDefaultController {
145+
void error(optional any e);
146+
};
147+
148+
[Exposed=(Window,Worker,Worklet)]
149+
interface TransformStream {
150+
constructor(optional object transformer,
151+
optional QueuingStrategy writableStrategy = {},
152+
optional QueuingStrategy readableStrategy = {});
153+
154+
readonly attribute ReadableStream readable;
155+
readonly attribute WritableStream writable;
156+
};
157+
158+
dictionary Transformer {
159+
TransformerStartCallback start;
160+
TransformerTransformCallback transform;
161+
TransformerFlushCallback flush;
162+
any readableType;
163+
any writableType;
164+
};
165+
166+
callback TransformerStartCallback = any (TransformStreamDefaultController controller);
167+
callback TransformerFlushCallback = Promise<void> (TransformStreamDefaultController controller);
168+
callback TransformerTransformCallback = Promise<void> (TransformStreamDefaultController controller, optional any chunk);
169+
170+
[Exposed=(Window,Worker,Worklet)]
171+
interface TransformStreamDefaultController {
172+
readonly attribute unrestricted double? desiredSize;
173+
174+
void enqueue(optional any chunk);
175+
void error(optional any reason);
176+
void terminate();
177+
};
178+
179+
dictionary QueuingStrategy {
180+
unrestricted double highWaterMark;
181+
QueuingStrategySize size;
182+
};
183+
184+
callback QueuingStrategySize = unrestricted double (optional any chunk);
185+
186+
dictionary QueuingStrategyInit {
187+
required unrestricted double highWaterMark;
188+
};
189+
190+
[Exposed=(Window,Worker,Worklet)]
191+
interface ByteLengthQueuingStrategy {
192+
constructor(QueuingStrategyInit init);
193+
194+
attribute unrestricted double highWaterMark;
195+
readonly attribute Function size;
196+
};
197+
198+
[Exposed=(Window,Worker,Worklet)]
199+
interface CountQueuingStrategy {
200+
constructor(QueuingStrategyInit init);
201+
202+
readonly attribute unrestricted double highWaterMark;
203+
readonly attribute Function size;
204+
};

streams/byte-length-queuing-strategy.any.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)