Bug 250903

Summary: toLocaleLowerCase and toLocaleUpperCase do not throw on empty string
Product: WebKit Reporter: Robert Flack <flackr>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: karlcow, mmaxfield, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Demonstrates the error thrown with a string passed and none without. none

Description Robert Flack 2023-01-20 08:58:30 PST
Created attachment 464579 [details]
Demonstrates the error thrown with a string passed and none without.

I believe by spec toLocaleLowerCase / toLocaleUpperCase are required to throw a RangeError if you specify an invalid locale per section 9.2.1 CanicalizeLocaleList with the exception thrown in step 7.c.v (https://tc39.es/ecma402/#sec-canonicalizelocalelist)

Firefox throws a RangeError for both of the following:
''.toLocaleLowerCase('');
''.toLocaleUpperCase('');

Chrome throws a RangeError for ''.toLocaleUpperCase('') and before M109 did for ''.toLocaleLowerCase(''), the lack of error for lowercase is tracked as https://crbug.com/1409058

Safari does not throw an error if the string being converted is empty, but does if you have a non-empty string being converted.
Comment 1 Radar WebKit Bug Importer 2023-01-23 12:22:28 PST
<rdar://problem/104568214>
Comment 2 Yusuke Suzuki 2023-01-23 12:24:12 PST
Pull request: https://github.com/WebKit/WebKit/pull/8986
Comment 3 EWS 2023-01-23 14:22:17 PST
Committed 259242@main (e99f5f69bf90): <https://commits.webkit.org/259242@main>

Reviewed commits have been landed. Closing PR #8986 and removing active labels.