Changeset 53239 in webkit
- Timestamp:
- Jan 13, 2010 10:37:13 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r53225 r53239 1 2010-01-13 Kent Hansen <kent.hansen@nokia.com> 2 3 Reviewed by Oliver Hunt. 4 5 JSON.stringify and JSON.parse needlessly process properties in the prototype chain 6 https://bugs.webkit.org/show_bug.cgi?id=33053 7 8 * runtime/JSONObject.cpp: 9 (JSC::Stringifier::Holder::appendNextProperty): 10 (JSC::Walker::walk): 11 1 12 2010-01-13 Gavin Barraclough <barraclough@apple.com> 2 13 -
trunk/JavaScriptCore/runtime/JSONObject.cpp
r52075 r53239 502 502 else { 503 503 PropertyNameArray objectPropertyNames(exec); 504 m_object->get PropertyNames(exec, objectPropertyNames);504 m_object->getOwnPropertyNames(exec, objectPropertyNames); 505 505 m_propertyNames = objectPropertyNames.releaseData(); 506 506 } … … 747 747 indexStack.append(0); 748 748 propertyStack.append(PropertyNameArray(m_exec)); 749 object->get PropertyNames(m_exec, propertyStack.last());749 object->getOwnPropertyNames(m_exec, propertyStack.last()); 750 750 // fallthrough 751 751 } -
trunk/LayoutTests/ChangeLog
r53238 r53239 1 2010-01-13 Kent Hansen <kent.hansen@nokia.com> 2 3 Reviewed by Oliver Hunt. 4 5 JSON.stringify and JSON.parse needlessly process properties in the prototype chain 6 https://bugs.webkit.org/show_bug.cgi?id=33053 7 8 Add tests that verify that properties in the prototype chain are ignored. 9 10 * fast/js/JSON-parse-expected.txt: 11 * fast/js/JSON-stringify-expected.txt: 12 * fast/js/resources/JSON-parse.js: 13 * fast/js/resources/JSON-stringify.js: 14 1 15 2010-01-13 Kenneth Russell <kbr@google.com> 2 16 -
trunk/LayoutTests/fast/js/JSON-parse-expected.txt
r47828 r53239 68 68 PASS JSON.stringify(tests[i](nativeJSON)) is JSON.stringify(tests[i](JSON)) 69 69 function (jsonObject) { 70 return jsonObject.parse('{"__proto__":5}'); 71 } 72 PASS JSON.stringify(tests[i](nativeJSON)) is JSON.stringify(tests[i](JSON)) 73 function (jsonObject) { 70 74 return jsonObject.parse('{"a":5,}'); 71 75 } … … 434 438 function (jsonObject) { 435 439 return jsonObject.parse(JSON.stringify(complexObject), log); 440 } 441 PASS JSON.stringify(tests[i](nativeJSON)) is JSON.stringify(tests[i](JSON)) 442 function (jsonObject) { 443 return jsonObject.parse('{"__proto__":{"a":5}}', log); 436 444 } 437 445 PASS JSON.stringify(tests[i](nativeJSON)) is JSON.stringify(tests[i](JSON)) -
trunk/LayoutTests/fast/js/JSON-stringify-expected.txt
r48093 r53239 165 165 function (jsonObject) { 166 166 var allString = true; 167 var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}]; 168 return jsonObject.stringify(simpleObjectWithProto, array); 169 } 170 PASS tests[i](nativeJSON) is tests[i](JSON) 171 function (jsonObject) { 172 var allString = true; 167 173 var array = [1, new Number(2), NaN, Infinity, -Infinity, new String("str")]; 168 174 return jsonObject.stringify({"1":"1","2":"2","NaN":"NaN","Infinity":"Infinity","-Infinity":"-Infinity","str":"str"}, array); … … 259 265 function (jsonObject) { 260 266 return jsonObject.stringify(complexObject, null, 4); 267 } 268 PASS tests[i](nativeJSON) is tests[i](JSON) 269 function (jsonObject) { 270 var allString = true; 271 var array = ["1","2","3"]; 272 return jsonObject.stringify(simpleArrayWithProto, array); 273 } 274 PASS tests[i](nativeJSON) is tests[i](JSON) 275 function (jsonObject) { 276 return jsonObject.stringify(simpleArrayWithProto, null, " "); 277 } 278 PASS tests[i](nativeJSON) is tests[i](JSON) 279 function (jsonObject) { 280 return jsonObject.stringify(simpleArrayWithProto, null, 4); 281 } 282 PASS tests[i](nativeJSON) is tests[i](JSON) 283 function (jsonObject) { 284 return jsonObject.stringify(simpleArrayWithProto, null, "ab"); 285 } 286 PASS tests[i](nativeJSON) is tests[i](JSON) 287 function (jsonObject) { 288 return jsonObject.stringify(simpleArrayWithProto, null, 4); 289 } 290 PASS tests[i](nativeJSON) is tests[i](JSON) 291 function (jsonObject) { 292 return jsonObject.stringify(simpleObjectWithProto, null, " "); 293 } 294 PASS tests[i](nativeJSON) is tests[i](JSON) 295 function (jsonObject) { 296 return jsonObject.stringify(simpleObjectWithProto, null, 4); 297 } 298 PASS tests[i](nativeJSON) is tests[i](JSON) 299 function (jsonObject) { 300 return jsonObject.stringify(simpleObjectWithProto, null, "ab"); 301 } 302 PASS tests[i](nativeJSON) is tests[i](JSON) 303 function (jsonObject) { 304 return jsonObject.stringify(simpleObjectWithProto, null, 4); 305 } 306 PASS tests[i](nativeJSON) is tests[i](JSON) 307 function (jsonObject) { 308 return jsonObject.stringify(simpleObjectWithProto, null, 10); 309 } 310 PASS tests[i](nativeJSON) is tests[i](JSON) 311 function (jsonObject) { 312 return jsonObject.stringify(simpleObjectWithProto, null, 11); 313 } 314 PASS tests[i](nativeJSON) is tests[i].expected 315 function (jsonObject) { 316 return jsonObject.stringify(simpleObjectWithProto, null, " "); 317 } 318 PASS tests[i](nativeJSON) is tests[i].expected 319 function (jsonObject) { 320 return jsonObject.stringify(simpleObjectWithProto, null, " "); 321 } 322 PASS tests[i](nativeJSON) is tests[i].expected 323 function (jsonObject) { 324 return jsonObject.stringify(complexArrayWithProto, null, " "); 325 } 326 PASS tests[i](nativeJSON) is tests[i](JSON) 327 function (jsonObject) { 328 return jsonObject.stringify(complexArrayWithProto, null, 4); 329 } 330 PASS tests[i](nativeJSON) is tests[i](JSON) 331 function (jsonObject) { 332 return jsonObject.stringify(complexArrayWithProto, null, "ab"); 333 } 334 PASS tests[i](nativeJSON) is tests[i](JSON) 335 function (jsonObject) { 336 return jsonObject.stringify(complexArrayWithProto, null, 4); 337 } 338 PASS tests[i](nativeJSON) is tests[i](JSON) 339 function (jsonObject) { 340 return jsonObject.stringify(complexObjectWithProto, null, " "); 341 } 342 PASS tests[i](nativeJSON) is tests[i](JSON) 343 function (jsonObject) { 344 return jsonObject.stringify(complexObjectWithProto, null, 4); 345 } 346 PASS tests[i](nativeJSON) is tests[i](JSON) 347 function (jsonObject) { 348 return jsonObject.stringify(complexObjectWithProto, null, "ab"); 349 } 350 PASS tests[i](nativeJSON) is tests[i](JSON) 351 function (jsonObject) { 352 return jsonObject.stringify(complexObjectWithProto, null, 4); 353 } 354 PASS tests[i](nativeJSON) is tests[i](JSON) 355 function (jsonObject) { 356 return jsonObject.stringify(objectWithSideEffectGetter); 357 } 358 FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}. 359 function (jsonObject) { 360 return jsonObject.stringify(objectWithSideEffectGetterAndProto); 361 } 362 FAIL tests[i](nativeJSON) should be {"foo":1}. Was {}. 363 function (jsonObject) { 364 return jsonObject.stringify(arrayWithSideEffectGetter); 365 } 366 PASS tests[i](nativeJSON) is tests[i](JSON) 367 function (jsonObject) { 368 return jsonObject.stringify(arrayWithSideEffectGetterAndProto); 261 369 } 262 370 PASS tests[i](nativeJSON) is tests[i](JSON) -
trunk/LayoutTests/fast/js/resources/JSON-parse.js
r47828 r53239 64 64 result.push(function(jsonObject){ 65 65 return jsonObject.parse('{"a":5}'); 66 }); 67 result.push(function(jsonObject){ 68 return jsonObject.parse('{"__proto__":5}'); 66 69 }); 67 70 result.push(function(jsonObject){ … … 396 399 result.push(function(jsonObject){ 397 400 return jsonObject.parse(JSON.stringify(complexObject), log); 401 }); 402 result.push(function(jsonObject){ 403 return jsonObject.parse('{"__proto__":{"a":5}}', log); 398 404 }); 399 405 var logOrderString; -
trunk/LayoutTests/fast/js/resources/JSON-stringify.js
r48083 r53239 5 5 var complexArray = ['a', 'b', 'c',,,simpleObject, simpleArray, [simpleObject,simpleArray]]; 6 6 var complexObject = {a:"1", b:"2", c:"3", d:undefined, e:null, "":12, get f(){ return simpleArray; }, array: complexArray}; 7 var simpleArrayWithProto = ['d', 'e', 'f']; 8 simpleArrayWithProto.__proto__ = simpleObject; 9 var simpleObjectWithProto = {d:"4", e:"5", f:"6", __proto__:simpleObject}; 10 var complexArrayWithProto = ['d', 'e', 'f',,,simpleObjectWithProto, simpleArrayWithProto, [simpleObjectWithProto,simpleArrayWithProto]]; 11 complexArrayWithProto.__proto__ = simpleObjectWithProto; 12 var complexObjectWithProto = {d:"4", e:"5", f:"6", g:undefined, h:null, "":12, get i(){ return simpleArrayWithProto; }, array2: complexArrayWithProto, __proto__:complexObject}; 13 var objectWithSideEffectGetter = {get b() {this.foo=1;}}; 14 var objectWithSideEffectGetterAndProto = {__proto__:{foo:"bar"}, get b() {this.foo=1;}}; 15 var arrayWithSideEffectGetter = []; 16 arrayWithSideEffectGetter.__defineGetter__("b", function(){this.foo=1;}); 17 var arrayWithSideEffectGetterAndProto = []; 18 arrayWithSideEffectGetterAndProto.__defineGetter__("b", function(){this.foo=1;}); 19 arrayWithSideEffectGetterAndProto.__proto__ = {foo:"bar"}; 7 20 var result = []; 8 21 result.push(function(jsonObject){ … … 144 157 result.push(function(jsonObject){ 145 158 var allString = true; 159 var array = [{toString:function(){array[0]='a'; array[1]='c'; array[2]='b'; return 'a'}}]; 160 return jsonObject.stringify(simpleObjectWithProto, array); 161 }); 162 result.push(function(jsonObject){ 163 var allString = true; 146 164 var array = [1, new Number(2), NaN, Infinity, -Infinity, new String("str")]; 147 165 return jsonObject.stringify({"1":"1","2":"2","NaN":"NaN","Infinity":"Infinity","-Infinity":"-Infinity","str":"str"}, array); … … 220 238 result.push(function(jsonObject){ 221 239 return jsonObject.stringify(complexObject, null, 4); 240 }); 241 result.push(function(jsonObject){ 242 var allString = true; 243 var array = ["1","2","3"]; 244 return jsonObject.stringify(simpleArrayWithProto, array); 245 }); 246 result.push(function(jsonObject){ 247 return jsonObject.stringify(simpleArrayWithProto, null, " "); 248 }); 249 result.push(function(jsonObject){ 250 return jsonObject.stringify(simpleArrayWithProto, null, 4); 251 }); 252 result.push(function(jsonObject){ 253 return jsonObject.stringify(simpleArrayWithProto, null, "ab"); 254 }); 255 result.push(function(jsonObject){ 256 return jsonObject.stringify(simpleArrayWithProto, null, 4); 257 }); 258 result.push(function(jsonObject){ 259 return jsonObject.stringify(simpleObjectWithProto, null, " "); 260 }); 261 result.push(function(jsonObject){ 262 return jsonObject.stringify(simpleObjectWithProto, null, 4); 263 }); 264 result.push(function(jsonObject){ 265 return jsonObject.stringify(simpleObjectWithProto, null, "ab"); 266 }); 267 result.push(function(jsonObject){ 268 return jsonObject.stringify(simpleObjectWithProto, null, 4); 269 }); 270 result.push(function(jsonObject){ 271 return jsonObject.stringify(simpleObjectWithProto, null, 10); 272 }); 273 result.push(function(jsonObject){ 274 return jsonObject.stringify(simpleObjectWithProto, null, 11); 275 }); 276 result[result.length - 1].expected = JSON.stringify(simpleObjectWithProto, null, 10); 277 result.push(function(jsonObject){ 278 return jsonObject.stringify(simpleObjectWithProto, null, " "); 279 }); 280 result[result.length - 1].expected = JSON.stringify(simpleObjectWithProto, null, 10); 281 result.push(function(jsonObject){ 282 return jsonObject.stringify(simpleObjectWithProto, null, " "); 283 }); 284 result[result.length - 1].expected = JSON.stringify(simpleObjectWithProto, null, 10); 285 result.push(function(jsonObject){ 286 return jsonObject.stringify(complexArrayWithProto, null, " "); 287 }); 288 result.push(function(jsonObject){ 289 return jsonObject.stringify(complexArrayWithProto, null, 4); 290 }); 291 result.push(function(jsonObject){ 292 return jsonObject.stringify(complexArrayWithProto, null, "ab"); 293 }); 294 result.push(function(jsonObject){ 295 return jsonObject.stringify(complexArrayWithProto, null, 4); 296 }); 297 result.push(function(jsonObject){ 298 return jsonObject.stringify(complexObjectWithProto, null, " "); 299 }); 300 result.push(function(jsonObject){ 301 return jsonObject.stringify(complexObjectWithProto, null, 4); 302 }); 303 result.push(function(jsonObject){ 304 return jsonObject.stringify(complexObjectWithProto, null, "ab"); 305 }); 306 result.push(function(jsonObject){ 307 return jsonObject.stringify(complexObjectWithProto, null, 4); 308 }); 309 result.push(function(jsonObject){ 310 return jsonObject.stringify(objectWithSideEffectGetter); 311 }); 312 result.push(function(jsonObject){ 313 return jsonObject.stringify(objectWithSideEffectGetterAndProto); 314 }); 315 result.push(function(jsonObject){ 316 return jsonObject.stringify(arrayWithSideEffectGetter); 317 }); 318 result.push(function(jsonObject){ 319 return jsonObject.stringify(arrayWithSideEffectGetterAndProto); 222 320 }); 223 321 var replaceTracker;
Note: See TracChangeset
for help on using the changeset viewer.