Skip to content

Commit

Permalink
stream: fix size function returned from QueuingStrategies
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
daeyeon authored and danielleadams committed Jan 3, 2023
1 parent b4cc30e commit 8c2d0f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
13 changes: 8 additions & 5 deletions lib/internal/webstreams/queuingstrategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ObjectDefineProperties,
ObjectDefineProperty,
SymbolToStringTag,
} = primordials;

Expand Down Expand Up @@ -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}
Expand Down
10 changes: 0 additions & 10 deletions test/wpt/status/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 8c2d0f9

Please sign in to comment.