Changeset 47086 in webkit
- Timestamp:
- Aug 11, 2009 9:56:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r47062 r47086 1 2009-08-11 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Native JSON.stringify does not omit functions 6 https://bugs.webkit.org/show_bug.cgi?id=28117 7 8 Objects that are callable should be treated as undefined when 9 serialising to JSON. 10 11 * runtime/JSONObject.cpp: 12 (JSC::Stringifier::appendStringifiedValue): 13 1 14 2009-08-11 Oliver Hunt <oliver@apple.com> 2 15 -
trunk/JavaScriptCore/runtime/JSONObject.cpp
r47022 r47086 381 381 382 382 JSObject* object = asObject(value); 383 384 CallData callData; 385 if (object->getCallData(callData) != CallTypeNone) { 386 if (holder->inherits(&JSArray::info)) { 387 builder.append("null"); 388 return StringifySucceeded; 389 } 390 return StringifyFailedDueToUndefinedValue; 391 } 383 392 384 393 // Handle cycle detection, and put the holder on the stack. -
trunk/LayoutTests/ChangeLog
r47083 r47086 1 2009-08-11 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Native JSON.stringify does not omit functions 6 https://bugs.webkit.org/show_bug.cgi?id=28117 7 8 Test serialisation of function objects. 9 10 * fast/js/JSON-stringify-expected.txt: 11 * fast/js/JSON-stringify-replacer-expected.txt: 12 * fast/js/resources/JSON-stringify-replacer.js: 13 * fast/js/resources/JSON-stringify.js: 14 (createTests.result.push.): 15 1 16 2009-08-11 Brady Eidson <beidson@apple.com> 2 17 -
trunk/LayoutTests/fast/js/JSON-stringify-expected.txt
r46967 r47086 350 350 function (jsonObject) { 351 351 return jsonObject.stringify({a:{toJSON:function(){ return null; }}}); 352 } 353 PASS tests[i](nativeJSON) is tests[i](JSON) 354 function (jsonObject) { 355 return jsonObject.stringify({a:{toJSON:function(){ return function(){}; }}}); 356 } 357 PASS tests[i](nativeJSON) is tests[i](JSON) 358 function (jsonObject) { 359 return jsonObject.stringify({a:function(){}}); 352 360 } 353 361 PASS tests[i](nativeJSON) is tests[i](JSON) -
trunk/LayoutTests/fast/js/JSON-stringify-replacer-expected.txt
r46967 r47086 12 12 PASS JSON.stringify(object, returnUndefinedFor1) is '{"0":0,"2":2}' 13 13 PASS JSON.stringify(array, returnUndefinedFor1) is '[0,null,2,null]' 14 PASS JSON.stringify(object, returnFunctionFor1) is '{"0":0,"2":2}' 15 PASS JSON.stringify(array, returnFunctionFor1) is '[0,null,2,null]' 14 16 PASS JSON.stringify(object, returnNullFor1) is '{"0":0,"1":null,"2":2}' 15 17 PASS JSON.stringify(array, returnNullFor1) is '[0,null,2,null]' -
trunk/LayoutTests/fast/js/resources/JSON-stringify-replacer.js
r46967 r47086 34 34 return v; 35 35 } 36 function returnFunctionFor1(k, v) { 37 if (k == "1") 38 return function(){}; 39 return v; 40 } 36 41 function returnStringForUndefined(k, v) { 37 42 if (v === undefined) … … 52 57 shouldBe("JSON.stringify(array, returnUndefinedFor1)", '\'[0,null,2,null]\''); 53 58 59 shouldBe("JSON.stringify(object, returnFunctionFor1)", '\'{"0":0,"2":2}\''); 60 shouldBe("JSON.stringify(array, returnFunctionFor1)", '\'[0,null,2,null]\''); 61 54 62 shouldBe("JSON.stringify(object, returnNullFor1)", '\'{"0":0,"1":null,"2":2}\''); 55 63 shouldBe("JSON.stringify(array, returnNullFor1)", '\'[0,null,2,null]\''); -
trunk/LayoutTests/fast/js/resources/JSON-stringify.js
r44974 r47086 315 315 result.push(function(jsonObject){ 316 316 return jsonObject.stringify({a:{toJSON:function(){ return null; }}}); 317 }); 318 result.push(function(jsonObject){ 319 return jsonObject.stringify({a:{toJSON:function(){ return function(){}; }}}); 320 }); 321 result.push(function(jsonObject){ 322 return jsonObject.stringify({a:function(){}}); 317 323 }); 318 324 result.push(function(jsonObject){
Note: See TracChangeset
for help on using the changeset viewer.