From 3fdf6cfad9a1b7f9acc4a0161b449afcdbecbb93 Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Wed, 12 Oct 2022 19:26:35 +0900 Subject: [PATCH] stream: fix `size` function returned from QueuingStrategies The `size` function returned from the `size` getter of `ByteLengthQueuingStrategy` or `CountQueuingStrategy` should not have a prototype property, nor be a constructor. Refs: https://streams.spec.whatwg.org/#blqs-size Refs: https://streams.spec.whatwg.org/#cqs-size Signed-off-by: Daeyeon Jeong PR-URL: https://github.com/nodejs/node/pull/44867 Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Minwoo Jung Reviewed-By: Antoine du Hamel --- lib/internal/webstreams/queuingstrategies.js | 13 ++++++++----- test/wpt/status/streams.json | 10 ---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/internal/webstreams/queuingstrategies.js b/lib/internal/webstreams/queuingstrategies.js index 78cec0c35559d3..32d58af1dfad19 100644 --- a/lib/internal/webstreams/queuingstrategies.js +++ b/lib/internal/webstreams/queuingstrategies.js @@ -2,6 +2,7 @@ const { ObjectDefineProperties, + ObjectDefineProperty, SymbolToStringTag, } = primordials; @@ -47,11 +48,13 @@ const isCountQueuingStrategy = * }} QueuingStrategy */ -// eslint-disable-next-line func-name-matching,func-style -const byteSizeFunction = function size(chunk) { return chunk.byteLength; }; - -// eslint-disable-next-line func-name-matching,func-style -const countSizeFunction = function size() { return 1; }; +const nameDescriptor = { __proto__: null, value: 'size' }; +const byteSizeFunction = ObjectDefineProperty( + (chunk) => chunk.byteLength, + 'name', + nameDescriptor +); +const countSizeFunction = ObjectDefineProperty(() => 1, 'name', nameDescriptor); /** * @type {QueuingStrategy} diff --git a/test/wpt/status/streams.json b/test/wpt/status/streams.json index 166bcf869080d2..9899c581d9f96e 100644 --- a/test/wpt/status/streams.json +++ b/test/wpt/status/streams.json @@ -2,16 +2,6 @@ "queuing-strategies-size-function-per-global.window.js": { "skip": "Browser-specific test" }, - "queuing-strategies.any.js": { - "fail": { - "expected": [ - "CountQueuingStrategy: size should not have a prototype property", - "ByteLengthQueuingStrategy: size should not have a prototype property", - "CountQueuingStrategy: size should not be a constructor", - "ByteLengthQueuingStrategy: size should not be a constructor" - ] - } - }, "readable-streams/cross-realm-crash.window.js": { "skip": "Browser-specific test" },