Bug 101783 - WebIDL: number type conversions should throw TypeError for Infinity and NaN
Summary: WebIDL: number type conversions should throw TypeError for Infinity and NaN
Status: RESOLVED LATER
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Erik Arvidsson
URL:
Keywords:
Depends on: 96798
Blocks: 101764 110243
  Show dependency treegraph
 
Reported: 2012-11-09 12:51 PST by Erik Arvidsson
Modified: 2022-09-04 13:41 PDT (History)
10 users (show)

See Also:


Attachments
WIP (3.44 KB, patch)
2012-11-09 13:37 PST, Erik Arvidsson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Arvidsson 2012-11-09 12:51:35 PST
When a JS value is supposed to be converted to one of the following IDL types

byte
octet
short
unsigned short
long
unsigned long
long long
unsigned long long
float
double

we should throw a TypeError if the value is NaN or Infinity.

The only ones that accept NaN are the "restricted float" and "restricted double" (which we are not using anywhere)
Comment 1 Joshua Bell 2012-11-09 13:12:55 PST
I linked this to https://bugs.webkit.org/show_bug.cgi?id=96798 which has at least part of this logic implemented, but is blocked on a V8 bug that is, in turn, blocked on a Chromium bug (which is getting worked on now).

It's been a while since I looked at the patch so I'm not sure if I tackled all the 32/64/signed/unsigned permutations or just the subset I needed at the time.

Feel free to steal some/all of the patch.
Comment 2 Joshua Bell 2012-11-09 13:15:06 PST
(In reply to comment #1)
> I linked this to https://bugs.webkit.org/show_bug.cgi?id=96798

... which is focused on [EnforceRange] specifically, not on NaNs/Infinities, but the conversion for all cases could use an overhaul.
Comment 3 Erik Arvidsson 2012-11-09 13:37:28 PST
Created attachment 173355 [details]
WIP
Comment 4 Adam Barth 2012-11-09 13:48:42 PST
How does this affect performance?
Comment 5 Erik Arvidsson 2012-11-09 13:57:05 PST
(In reply to comment #4)
> How does this affect performance?

Adding more tests and branching is going to be unavoidable. Once this gets closer to complete I will have to do some perf tests. I expect some slow down, hopefully it will be small enough.
Comment 6 Ahmad Saleem 2022-09-03 04:33:39 PDT
rniwa@webkit.org - Is this needed because attached WIP seems to have v8 (JS engine of Chrome) specific bits I think? Is this needed in JSC? Thanks!
Comment 7 Ryosuke Niwa 2022-09-03 11:34:21 PDT
This is Later at this point.