-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableStream { | ||
constructor(optional object underlyingSource, optional QueuingStrategy strategy = {}); | ||
|
||
readonly attribute boolean locked; | ||
|
||
Promise<void> cancel(optional any reason); | ||
ReadableStreamReader getReader(optional ReadableStreamGetReaderOptions options = {}); | ||
ReadableStream pipeThrough(ReadableWritablePair transform, optional StreamPipeOptions options = {}); | ||
Promise<void> pipeTo(WritableStream destination, optional StreamPipeOptions options = {}); | ||
sequence<ReadableStream> tee(); | ||
|
||
// async iterable<any>(optional ReadableStreamIteratorOptions options = {}); | ||
}; | ||
|
||
typedef (ReadableStreamDefaultReader or ReadableStreamBYOBReader) ReadableStreamReader; | ||
|
||
enum ReadableStreamReaderMode { "byob" }; | ||
|
||
dictionary ReadableStreamGetReaderOptions { | ||
ReadableStreamReaderMode mode; | ||
}; | ||
|
||
dictionary ReadableStreamIteratorOptions { | ||
boolean preventCancel = false; | ||
}; | ||
|
||
dictionary ReadableWritablePair { | ||
required ReadableStream readable; | ||
required WritableStream writable; | ||
}; | ||
|
||
dictionary StreamPipeOptions { | ||
boolean preventClose = false; | ||
boolean preventAbort = false; | ||
boolean preventCancel = false; | ||
AbortSignal signal; | ||
}; | ||
|
||
dictionary UnderlyingSource { | ||
UnderlyingSourceStartCallback start; | ||
UnderlyingSourcePullCallback pull; | ||
UnderlyingSourceCancelCallback cancel; | ||
ReadableStreamType type; | ||
[EnforceRange] unsigned long long autoAllocateChunkSize; | ||
}; | ||
|
||
typedef (ReadableStreamDefaultController or ReadableByteStreamController) ReadableStreamController; | ||
|
||
callback UnderlyingSourceStartCallback = any (ReadableStreamController controller); | ||
callback UnderlyingSourcePullCallback = Promise<void> (ReadableStreamController controller); | ||
callback UnderlyingSourceCancelCallback = Promise<void> (optional any reason); | ||
|
||
enum ReadableStreamType { "bytes" }; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableStreamDefaultReader { | ||
constructor(ReadableStream stream); | ||
|
||
readonly attribute Promise<void> closed; | ||
|
||
Promise<void> cancel(optional any reason); | ||
Promise<any> read(); | ||
void releaseLock(); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableStreamBYOBReader { | ||
constructor(ReadableStream stream); | ||
|
||
readonly attribute Promise<void> closed; | ||
|
||
Promise<void> cancel(optional any reason); | ||
Promise<any> read(ArrayBufferView view); | ||
void releaseLock(); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableStreamDefaultController { | ||
readonly attribute unrestricted double? desiredSize; | ||
|
||
void close(); | ||
void enqueue(optional any chunk); | ||
void error(optional any e); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableByteStreamController { | ||
readonly attribute ReadableStreamBYOBRequest? byobRequest; | ||
readonly attribute unrestricted double? desiredSize; | ||
|
||
void close(); | ||
void enqueue(ArrayBufferView chunk); | ||
void error(optional any e); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ReadableStreamBYOBRequest { | ||
readonly attribute ArrayBufferView? view; | ||
|
||
void respond([EnforceRange] unsigned long long bytesWritten); | ||
void respondWithNewView(ArrayBufferView view); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface WritableStream { | ||
constructor(optional object underlyingSink, optional QueuingStrategy strategy = {}); | ||
|
||
readonly attribute boolean locked; | ||
|
||
Promise<void> abort(optional any reason); | ||
Promise<void> close(); | ||
WritableStreamDefaultWriter getWriter(); | ||
}; | ||
|
||
dictionary UnderlyingSink { | ||
UnderlyingSinkStartCallback start; | ||
UnderlyingSinkWriteCallback write; | ||
UnderlyingSinkCloseCallback close; | ||
UnderlyingSinkAbortCallback abort; | ||
any type; | ||
}; | ||
|
||
callback UnderlyingSinkStartCallback = any (WritableStreamDefaultController controller); | ||
callback UnderlyingSinkWriteCallback = Promise<void> (WritableStreamDefaultController controller, optional any chunk); | ||
callback UnderlyingSinkCloseCallback = Promise<void> (); | ||
callback UnderlyingSinkAbortCallback = Promise<void> (optional any reason); | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface WritableStreamDefaultWriter { | ||
constructor(WritableStream stream); | ||
|
||
readonly attribute Promise<void> closed; | ||
readonly attribute unrestricted double? desiredSize; | ||
readonly attribute Promise<void> ready; | ||
|
||
Promise<void> abort(optional any reason); | ||
Promise<void> close(); | ||
void releaseLock(); | ||
Promise<void> write(optional any chunk); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface WritableStreamDefaultController { | ||
void error(optional any e); | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface TransformStream { | ||
constructor(optional object transformer, | ||
optional QueuingStrategy writableStrategy = {}, | ||
optional QueuingStrategy readableStrategy = {}); | ||
|
||
readonly attribute ReadableStream readable; | ||
readonly attribute WritableStream writable; | ||
}; | ||
|
||
dictionary Transformer { | ||
TransformerStartCallback start; | ||
TransformerTransformCallback transform; | ||
TransformerFlushCallback flush; | ||
any readableType; | ||
any writableType; | ||
}; | ||
|
||
callback TransformerStartCallback = any (TransformStreamDefaultController controller); | ||
callback TransformerFlushCallback = Promise<void> (TransformStreamDefaultController controller); | ||
callback TransformerTransformCallback = Promise<void> (TransformStreamDefaultController controller, optional any chunk); | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface TransformStreamDefaultController { | ||
readonly attribute unrestricted double? desiredSize; | ||
|
||
void enqueue(optional any chunk); | ||
void error(optional any reason); | ||
void terminate(); | ||
}; | ||
|
||
dictionary QueuingStrategy { | ||
unrestricted double highWaterMark; | ||
QueuingStrategySize size; | ||
}; | ||
|
||
callback QueuingStrategySize = unrestricted double (optional any chunk); | ||
|
||
dictionary QueuingStrategyInit { | ||
required unrestricted double highWaterMark; | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface ByteLengthQueuingStrategy { | ||
constructor(QueuingStrategyInit init); | ||
|
||
attribute unrestricted double highWaterMark; | ||
readonly attribute Function size; | ||
}; | ||
|
||
[Exposed=(Window,Worker,Worklet)] | ||
interface CountQueuingStrategy { | ||
constructor(QueuingStrategyInit init); | ||
|
||
attribute unrestricted double highWaterMark; | ||
readonly attribute Function size; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// META: global=window,worker | ||
// META: script=/resources/WebIDLParser.js | ||
// META: script=/resources/idlharness.js | ||
|
||
idl_test( | ||
['streams'], | ||
['dom'], // for AbortSignal | ||
idl_array => { | ||
// Empty try/catches ensure that if something isn't implemented (e.g., readable byte streams, or writable streams) | ||
// the harness still sets things up correctly. Note that the corresponding interface tests will still fail. | ||
|
||
try { | ||
new ReadableStream({ | ||
start(c) { | ||
self.readableStreamDefaultController = c; | ||
} | ||
}); | ||
} catch {} | ||
|
||
try { | ||
new ReadableStream({ | ||
start(c) { | ||
self.readableByteStreamController = c; | ||
}, | ||
type: 'bytes' | ||
}); | ||
} catch {} | ||
|
||
try { | ||
new WritableStream({ | ||
start(c) { | ||
self.writableStreamDefaultController = c; | ||
} | ||
}); | ||
} catch {} | ||
|
||
try { | ||
new TransformStream({ | ||
start(c) { | ||
self.transformStreamDefaultController = c; | ||
} | ||
}); | ||
} catch {} | ||
|
||
idl_array.add_objects({ | ||
ReadableStream: ["new ReadableStream()"], | ||
ReadableStreamDefaultReader: ["(new ReadableStream()).getReader()"], | ||
ReadableStreamBYOBReader: ["(new ReadableStream({ type: 'bytes' })).getReader('byob')"], | ||
ReadableStreamDefaultController: ["self.readableStreamDefaultController"], | ||
ReadableByteStreamController: ["self.readableByteStreamController"], | ||
ReadableStreamBYOBRequest: [/* TODO can these be async? */], | ||
WritableStream: ["new WritableStream()"], | ||
WritableStreamDefaultWriter: ["(new WritableStream()).getWriter()"], | ||
WritableStreamDefaultController: ["self.writableStreamDefaultController"], | ||
TransformStream: ["new TransformStream()"], | ||
TransformStreamDefaultController: ["self.transformStreamDefaultController"], | ||
ByteLengthQueuingStrategy: ["new ByteLengthQueuingStrategy({ highWaterMark: 5 })"], | ||
CountQueuingStrategy: ["new CountQueuingStrategy({ highWaterMark: 5 })"] | ||
}); | ||
} | ||
); |