mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
fix: pass some more WHATWG streams WPT (#10970)
This commit is contained in:
parent
49ec3d10ad
commit
b6fd39377e
2 changed files with 28 additions and 27 deletions
|
@ -366,10 +366,10 @@
|
||||||
* @param {number} defaultHWM
|
* @param {number} defaultHWM
|
||||||
*/
|
*/
|
||||||
function extractHighWaterMark(strategy, defaultHWM) {
|
function extractHighWaterMark(strategy, defaultHWM) {
|
||||||
if (!("highWaterMark" in strategy)) {
|
if (strategy.highWaterMark === undefined) {
|
||||||
return defaultHWM;
|
return defaultHWM;
|
||||||
}
|
}
|
||||||
const highWaterMark = Number(strategy.highWaterMark);
|
const highWaterMark = strategy.highWaterMark;
|
||||||
if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
|
if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
|
||||||
throw RangeError(
|
throw RangeError(
|
||||||
`Expected highWaterMark to be a positive number or Infinity, got "${highWaterMark}".`,
|
`Expected highWaterMark to be a positive number or Infinity, got "${highWaterMark}".`,
|
||||||
|
@ -384,12 +384,17 @@
|
||||||
* @return {(chunk: T) => number}
|
* @return {(chunk: T) => number}
|
||||||
*/
|
*/
|
||||||
function extractSizeAlgorithm(strategy) {
|
function extractSizeAlgorithm(strategy) {
|
||||||
const { size } = strategy;
|
if (strategy.size === undefined) {
|
||||||
|
|
||||||
if (!size) {
|
|
||||||
return () => 1;
|
return () => 1;
|
||||||
}
|
}
|
||||||
return (chunk) => size(chunk);
|
return (chunk) =>
|
||||||
|
webidl.invokeCallbackFunction(
|
||||||
|
strategy.size,
|
||||||
|
[chunk],
|
||||||
|
undefined,
|
||||||
|
webidl.converters["unrestricted double"],
|
||||||
|
{ prefix: "Failed to call `sizeAlgorithm`" },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1031,6 +1036,10 @@
|
||||||
if (reader === undefined) {
|
if (reader === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/** @type {Deferred<void>} */
|
||||||
|
const closedPromise = reader[_closedPromise];
|
||||||
|
closedPromise.reject(e);
|
||||||
|
setPromiseIsHandledToTrue(closedPromise.promise);
|
||||||
if (isReadableStreamDefaultReader(reader)) {
|
if (isReadableStreamDefaultReader(reader)) {
|
||||||
/** @type {Array<ReadRequest<R>>} */
|
/** @type {Array<ReadRequest<R>>} */
|
||||||
const readRequests = reader[_readRequests];
|
const readRequests = reader[_readRequests];
|
||||||
|
@ -1040,10 +1049,6 @@
|
||||||
reader[_readRequests] = [];
|
reader[_readRequests] = [];
|
||||||
}
|
}
|
||||||
// 3.5.6.8 Otherwise, support BYOB Reader
|
// 3.5.6.8 Otherwise, support BYOB Reader
|
||||||
/** @type {Deferred<void>} */
|
|
||||||
const closedPromise = reader[_closedPromise];
|
|
||||||
closedPromise.reject(e);
|
|
||||||
setPromiseIsHandledToTrue(closedPromise.promise);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3158,7 +3163,9 @@
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
}
|
}
|
||||||
if (isReadableStreamLocked(this)) {
|
if (isReadableStreamLocked(this)) {
|
||||||
Promise.reject(new TypeError("Cannot cancel a locked ReadableStream."));
|
return Promise.reject(
|
||||||
|
new TypeError("Cannot cancel a locked ReadableStream."),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return readableStreamCancel(this, reason);
|
return readableStreamCancel(this, reason);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,11 @@
|
||||||
"queuing-strategies.any.html": true,
|
"queuing-strategies.any.html": true,
|
||||||
"readable-byte-streams": {
|
"readable-byte-streams": {
|
||||||
"bad-buffers-and-views.any.html": [
|
"bad-buffers-and-views.any.html": [
|
||||||
|
"ReadableStream with byte source: read()ing from a closed stream still transfers the buffer",
|
||||||
|
"ReadableStream with byte source: read()ing from a stream with queued chunks still transfers the buffer",
|
||||||
|
"ReadableStream with byte source: reading into an already-detached buffer rejects",
|
||||||
|
"ReadableStream with byte source: reading into a zero-length buffer rejects",
|
||||||
|
"ReadableStream with byte source: reading into a zero-length view on a non-zero-length buffer rejects",
|
||||||
"ReadableStream with byte source: respond() throws if the BYOB request's buffer has been detached (in the readable state)",
|
"ReadableStream with byte source: respond() throws if the BYOB request's buffer has been detached (in the readable state)",
|
||||||
"ReadableStream with byte source: respond() throws if the BYOB request's buffer has been detached (in the closed state)",
|
"ReadableStream with byte source: respond() throws if the BYOB request's buffer has been detached (in the closed state)",
|
||||||
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer has been detached (in the readable state)",
|
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer has been detached (in the readable state)",
|
||||||
|
@ -321,12 +326,7 @@
|
||||||
"ReadableStream with byte source: respondWithNewView() throws if the supplied view is non-zero-length (in the closed state)",
|
"ReadableStream with byte source: respondWithNewView() throws if the supplied view is non-zero-length (in the closed state)",
|
||||||
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer has a different length (in the closed state)",
|
"ReadableStream with byte source: respondWithNewView() throws if the supplied view's buffer has a different length (in the closed state)",
|
||||||
"ReadableStream with byte source: enqueue() throws if the BYOB request's buffer has been detached (in the readable state)",
|
"ReadableStream with byte source: enqueue() throws if the BYOB request's buffer has been detached (in the readable state)",
|
||||||
"ReadableStream with byte source: enqueue() throws if the BYOB request's buffer has been detached (in the closed state)",
|
"ReadableStream with byte source: enqueue() throws if the BYOB request's buffer has been detached (in the closed state)"
|
||||||
"ReadableStream with byte source: read()ing from a closed stream still transfers the buffer",
|
|
||||||
"ReadableStream with byte source: read()ing from a stream with queued chunks still transfers the buffer",
|
|
||||||
"ReadableStream with byte source: reading into an already-detached buffer rejects",
|
|
||||||
"ReadableStream with byte source: reading into a zero-length buffer rejects",
|
|
||||||
"ReadableStream with byte source: reading into a zero-length view on a non-zero-length buffer rejects"
|
|
||||||
],
|
],
|
||||||
"construct-byob-request.any.html": false,
|
"construct-byob-request.any.html": false,
|
||||||
"general.any.html": [
|
"general.any.html": [
|
||||||
|
@ -402,21 +402,17 @@
|
||||||
],
|
],
|
||||||
"bad-strategies.any.html": true,
|
"bad-strategies.any.html": true,
|
||||||
"bad-underlying-sources.any.html": true,
|
"bad-underlying-sources.any.html": true,
|
||||||
"cancel.any.html": false,
|
"cancel.any.html": true,
|
||||||
"constructor.any.html": true,
|
"constructor.any.html": true,
|
||||||
"count-queuing-strategy-integration.any.html": true,
|
"count-queuing-strategy-integration.any.html": true,
|
||||||
"default-reader.any.html": true,
|
"default-reader.any.html": true,
|
||||||
"floating-point-total-queue-size.any.html": true,
|
"floating-point-total-queue-size.any.html": true,
|
||||||
"garbage-collection.any.html": true,
|
"garbage-collection.any.html": true,
|
||||||
"general.any.html": [
|
"general.any.html": true,
|
||||||
"ReadableStream: if pull rejects, it should error the stream"
|
|
||||||
],
|
|
||||||
"patched-global.any.html": true,
|
"patched-global.any.html": true,
|
||||||
"reentrant-strategies.any.html": true,
|
"reentrant-strategies.any.html": true,
|
||||||
"tee.any.html": false,
|
"tee.any.html": false,
|
||||||
"templated.any.html": [
|
"templated.any.html": true
|
||||||
"ReadableStream (empty) reader: canceling via the stream should fail"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"transform-streams": {
|
"transform-streams": {
|
||||||
"backpressure.any.html": true,
|
"backpressure.any.html": true,
|
||||||
|
@ -424,9 +420,7 @@
|
||||||
"flush.any.html": true,
|
"flush.any.html": true,
|
||||||
"general.any.html": true,
|
"general.any.html": true,
|
||||||
"lipfuzz.any.html": true,
|
"lipfuzz.any.html": true,
|
||||||
"patched-global.any.html": [
|
"patched-global.any.html": true,
|
||||||
"TransformStream constructor should not call setters for highWaterMark or size"
|
|
||||||
],
|
|
||||||
"properties.any.html": true,
|
"properties.any.html": true,
|
||||||
"reentrant-strategies.any.html": true,
|
"reentrant-strategies.any.html": true,
|
||||||
"strategies.any.html": true,
|
"strategies.any.html": true,
|
||||||
|
|
Loading…
Reference in a new issue