Skip to content

Commit 8c2d0f9

Browse files
daeyeondanielleadams
authored andcommitted
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 <daeyeon.dev@gmail.com> PR-URL: #44867 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b4cc30e commit 8c2d0f9

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

lib/internal/webstreams/queuingstrategies.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ObjectDefineProperties,
5+
ObjectDefineProperty,
56
SymbolToStringTag,
67
} = primordials;
78

@@ -47,11 +48,13 @@ const isCountQueuingStrategy =
4748
* }} QueuingStrategy
4849
*/
4950

50-
// eslint-disable-next-line func-name-matching,func-style
51-
const byteSizeFunction = function size(chunk) { return chunk.byteLength; };
52-
53-
// eslint-disable-next-line func-name-matching,func-style
54-
const countSizeFunction = function size() { return 1; };
51+
const nameDescriptor = { __proto__: null, value: 'size' };
52+
const byteSizeFunction = ObjectDefineProperty(
53+
(chunk) => chunk.byteLength,
54+
'name',
55+
nameDescriptor
56+
);
57+
const countSizeFunction = ObjectDefineProperty(() => 1, 'name', nameDescriptor);
5558

5659
/**
5760
* @type {QueuingStrategy}

test/wpt/status/streams.json

-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
"queuing-strategies-size-function-per-global.window.js": {
33
"skip": "Browser-specific test"
44
},
5-
"queuing-strategies.any.js": {
6-
"fail": {
7-
"expected": [
8-
"CountQueuingStrategy: size should not have a prototype property",
9-
"ByteLengthQueuingStrategy: size should not have a prototype property",
10-
"CountQueuingStrategy: size should not be a constructor",
11-
"ByteLengthQueuingStrategy: size should not be a constructor"
12-
]
13-
}
14-
},
155
"readable-streams/cross-realm-crash.window.js": {
166
"skip": "Browser-specific test"
177
},

0 commit comments

Comments
 (0)