File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -701,9 +701,6 @@ using namespace Js;
701
701
case TypeIds_Number:
702
702
return JavascriptNumber::ToLocaleString (JavascriptNumber::GetValue (aValue), scriptContext);
703
703
704
- case TypeIds_String:
705
- return UnsafeVarTo<JavascriptString>(aValue);
706
-
707
704
case TypeIds_VariantDate:
708
705
// Legacy behavior was to create an empty object and call toLocaleString on it, which would result in this value
709
706
return scriptContext->GetLibrary ()->GetObjectDisplayString ();
Original file line number Diff line number Diff line change @@ -43,3 +43,15 @@ TypeError : The value of the property 'toLocaleString' is not a Function object
43
43
44
44
9. Array: toLocaleString should use length property
45
45
10.00, 20.00, 30.00, , ,
46
+
47
+
48
+ 10. Array: toLocaleString should use toLocaleString accessor on element
49
+ accessor-value
50
+
51
+
52
+ 11. Array: toLocaleString should throw TypeError on undefined
53
+ TypeError : The value of the property 'toLocaleString' is not a Function object
54
+
55
+
56
+ 12. Array: toLocaleString should throw TypeError on invalid function
57
+ TypeError : The value of the property 'toLocaleString' is not a Function object
Original file line number Diff line number Diff line change @@ -184,3 +184,32 @@ guarded_call(function () {
184
184
echo ( output ) ;
185
185
}
186
186
} ) ;
187
+
188
+ scenario ( "Array: toLocaleString should use toLocaleString accessor on element" ) ;
189
+ var originalToLocaleString = String . prototype . toLocaleString ;
190
+ String . prototype . toLocaleString = function ( ) {
191
+ return "accessor-value" ;
192
+ } ;
193
+ var o = [ "test" ] ;
194
+ guarded_call ( function ( ) {
195
+ echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
196
+ } ) ;
197
+ String . prototype . toLocaleString = originalToLocaleString ;
198
+
199
+ scenario ( "Array: toLocaleString should throw TypeError on undefined" ) ;
200
+ var originalToLocaleString = String . prototype . toLocaleString ;
201
+ String . prototype . toLocaleString = undefined ;
202
+ var o = [ "test" ] ;
203
+ guarded_call ( function ( ) {
204
+ echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
205
+ } ) ;
206
+ String . prototype . toLocaleString = originalToLocaleString ;
207
+
208
+ scenario ( "Array: toLocaleString should throw TypeError on invalid function" ) ;
209
+ var originalToLocaleString = String . prototype . toLocaleString ;
210
+ String . prototype . toLocaleString = 0 ;
211
+ var o = [ "test" ] ;
212
+ guarded_call ( function ( ) {
213
+ echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
214
+ } ) ;
215
+ String . prototype . toLocaleString = originalToLocaleString ;
You can’t perform that action at this time.
0 commit comments