Bug 227146

Summary: [WebIDL] Assigning a value outside the float range to a 'float' attribute should throw a TypeError
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: BindingsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, eric.carlson, ews-watchlist, ggaren, glenn, heycam, jer.noble, philipj, sam, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://heycam.github.io/webidl/#es-float
See Also: https://bugs.webkit.org/show_bug.cgi?id=227238
Attachments:
Description Flags
Patch none

Description Chris Dumez 2021-06-17 14:44:27 PDT
Assigning a value outside the float range to a 'float' attribute should throw a TypeError, as per:
https://heycam.github.io/webidl/#es-float

Blink follows the specification but WebKit just casts the double to a float.
Comment 1 Chris Dumez 2021-06-17 14:47:52 PDT
Created attachment 431723 [details]
Patch
Comment 2 Sam Weinig 2021-06-17 20:37:24 PDT
We might want to fix the canvas IDLs still using float that should be double before doing this to avoid accidental fallout.
Comment 3 Cameron McCormack (:heycam) 2021-06-17 21:18:32 PDT
It looks like almost all uses of floats in our canvas IDLs are `unrestricted float`, which will at least saturate out of range Number values to +/-Infinity.
Comment 4 Chris Dumez 2021-06-17 22:25:56 PDT
(In reply to Cameron McCormack (:heycam) from comment #3)
> It looks like almost all uses of floats in our canvas IDLs are `unrestricted
> float`, which will at least saturate out of range Number values to
> +/-Infinity.

Right, the behavior change in this patch for unrestricted float is not large and a strict progression. I would be more concerned about APIs where we use (restricted) float instead of double.
Comment 5 Sam Weinig 2021-06-18 12:54:11 PDT
Fair (just trying to bully people into fixing that because I keep forgetting to).
Comment 6 EWS 2021-06-18 19:16:26 PDT
Committed r279047 (238967@main): <https://commits.webkit.org/238967@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431723 [details].
Comment 7 Radar WebKit Bug Importer 2021-06-18 19:17:30 PDT
<rdar://problem/79516533>