Bug 226759 - CountQueuingStrategy.constructor misses checking the type of init param
Summary: CountQueuingStrategy.constructor misses checking the type of init param
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Linux
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-07 23:27 PDT by zyscoder@gmail.com
Modified: 2021-06-10 10:07 PDT (History)
9 users (show)

See Also:


Attachments
Patch (6.60 KB, patch)
2021-06-09 01:54 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (6.55 KB, patch)
2021-06-10 01:36 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zyscoder@gmail.com 2021-06-07 23:27:42 PDT
Steps to reproduce:

(1) Open a tab and navigate to any URL;
(2) Run the following code in the Console of Devtools:
```
new CountQueuingStrategy('any');
```
(3) Then this code would be evaluated successfully without throwing any exceptions.

Actual results:

Then this code would be evaluated successfully without throwing any exceptions.

Expected results:

As https://streams.spec.whatwg.org/#cqs-constructor says, the init param is of {highWaterMark: double} type. Webkit should throw a TypeError exception when evaluating this code.

In my test, Chrome and Firefox throw exceptions:
Chrome: `TypeError: Failed to construct 'CountQueuingStrategy': cannot convert to dictionary`
Firefox: `'highWaterMark' must not be undefined.`
Comment 1 youenn fablet 2021-06-09 01:54:17 PDT
Created attachment 430947 [details]
Patch
Comment 2 Chris Dumez 2021-06-09 08:32:23 PDT
Comment on attachment 430947 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430947&action=review

> Source/WebCore/Modules/streams/CountQueuingStrategy.js:44
> +        value: @toNumber(parameters.highWaterMark),

Likely not a good idea to access parameters.highWaterMark twice as it is web observable and it could return different values for each call. I think it'd be better to cache the result of parameters.highWaterMark.
Comment 3 youenn fablet 2021-06-10 01:36:29 PDT
Created attachment 431053 [details]
Patch
Comment 4 youenn fablet 2021-06-10 05:51:07 PDT
Comment on attachment 431053 [details]
Patch

AS debug wk2 error is unrelated
Comment 5 EWS 2021-06-10 10:06:12 PDT
Committed r278710 (238678@main): <https://commits.webkit.org/238678@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431053 [details].
Comment 6 Radar WebKit Bug Importer 2021-06-10 10:07:18 PDT
<rdar://problem/79145929>