summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2021-06-15 17:48:25 +0200
committerGitHub <noreply@github.com>2021-06-15 17:48:25 +0200
commitb6fd39377ee68dda0a5d82ed7f5dba9c61583a43 (patch)
treebc232cb8c439ce93389ab4133dc297e57ce6faea
parent49ec3d10ad90851f4d28274a3f0fe96c642204ac (diff)
fix: pass some more WHATWG streams WPT (#10970)
-rw-r--r--extensions/web/06_streams.js29
-rw-r--r--tools/wpt/expectation.json26
2 files changed, 28 insertions, 27 deletions
diff --git a/extensions/web/06_streams.js b/extensions/web/06_streams.js
index b3c55fa85..b24ab21a0 100644
--- a/extensions/web/06_streams.js
+++ b/extensions/web/06_streams.js
@@ -366,10 +366,10 @@
* @param {number} defaultHWM
*/
function extractHighWaterMark(strategy, defaultHWM) {
- if (!("highWaterMark" in strategy)) {
+ if (strategy.highWaterMark === undefined) {
return defaultHWM;
}
- const highWaterMark = Number(strategy.highWaterMark);
+ const highWaterMark = strategy.highWaterMark;
if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
throw RangeError(
`Expected highWaterMark to be a positive number or Infinity, got "${highWaterMark}".`,
@@ -384,12 +384,17 @@
* @return {(chunk: T) => number}
*/
function extractSizeAlgorithm(strategy) {
- const { size } = strategy;
-
- if (!size) {
+ if (strategy.size === undefined) {
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) {
return;
}
+ /** @type {Deferred<void>} */
+ const closedPromise = reader[_closedPromise];
+ closedPromise.reject(e);
+ setPromiseIsHandledToTrue(closedPromise.promise);
if (isReadableStreamDefaultReader(reader)) {
/** @type {Array<ReadRequest<R>>} */
const readRequests = reader[_readRequests];
@@ -1040,10 +1049,6 @@
reader[_readRequests] = [];
}
// 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);
}
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);
}
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index 2c1690181..44b19cd5b 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -309,6 +309,11 @@
"queuing-strategies.any.html": true,
"readable-byte-streams": {
"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 closed 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'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 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"
+ "ReadableStream with byte source: enqueue() throws if the BYOB request's buffer has been detached (in the closed state)"
],
"construct-byob-request.any.html": false,
"general.any.html": [
@@ -402,21 +402,17 @@
],
"bad-strategies.any.html": true,
"bad-underlying-sources.any.html": true,
- "cancel.any.html": false,
+ "cancel.any.html": true,
"constructor.any.html": true,
"count-queuing-strategy-integration.any.html": true,
"default-reader.any.html": true,
"floating-point-total-queue-size.any.html": true,
"garbage-collection.any.html": true,
- "general.any.html": [
- "ReadableStream: if pull rejects, it should error the stream"
- ],
+ "general.any.html": true,
"patched-global.any.html": true,
"reentrant-strategies.any.html": true,
"tee.any.html": false,
- "templated.any.html": [
- "ReadableStream (empty) reader: canceling via the stream should fail"
- ]
+ "templated.any.html": true
},
"transform-streams": {
"backpressure.any.html": true,
@@ -424,9 +420,7 @@
"flush.any.html": true,
"general.any.html": true,
"lipfuzz.any.html": true,
- "patched-global.any.html": [
- "TransformStream constructor should not call setters for highWaterMark or size"
- ],
+ "patched-global.any.html": true,
"properties.any.html": true,
"reentrant-strategies.any.html": true,
"strategies.any.html": true,