@@ -186,34 +186,30 @@ guarded_call(function () {
186
186
} ) ;
187
187
188
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
+ } ;
189
193
var o = [ "test" ] ;
190
194
guarded_call ( function ( ) {
191
- Object . defineProperty ( String . prototype , "toLocaleString" , {
192
- get ( ) {
193
- return function ( ) { return "accessor-value" ; } ;
194
- }
195
- } ) ;
196
195
echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
197
196
} ) ;
197
+ String . prototype . toLocaleString = originalToLocaleString ;
198
198
199
199
scenario ( "Array: toLocaleString should throw TypeError on undefined" ) ;
200
+ var originalToLocaleString = String . prototype . toLocaleString ;
201
+ String . prototype . toLocaleString = undefined ;
200
202
var o = [ "test" ] ;
201
203
guarded_call ( function ( ) {
202
- Object . defineProperty ( String . prototype , "toLocaleString" , {
203
- get ( ) {
204
- return undefined ;
205
- }
206
- } ) ;
207
204
echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
208
205
} ) ;
206
+ String . prototype . toLocaleString = originalToLocaleString ;
209
207
210
208
scenario ( "Array: toLocaleString should throw TypeError on invalid function" ) ;
209
+ var originalToLocaleString = String . prototype . toLocaleString ;
210
+ String . prototype . toLocaleString = 0 ;
211
211
var o = [ "test" ] ;
212
212
guarded_call ( function ( ) {
213
- Object . defineProperty ( String . prototype , "toLocaleString" , {
214
- get ( ) {
215
- return 0 ;
216
- }
217
- } ) ;
218
213
echo ( Array . prototype . toLocaleString . apply ( o ) ) ;
219
214
} ) ;
215
+ String . prototype . toLocaleString = originalToLocaleString ;
0 commit comments