Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: test/cctest/test-accessors.cc

Issue 11348209: Fix JSON.stringify for objects with interceptor handlers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/json-stringifier.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 obj->SetAccessor(v8_str("xxx"), AllocateHandles); 446 obj->SetAccessor(v8_str("xxx"), AllocateHandles);
447 LocalContext env; 447 LocalContext env;
448 env->Global()->Set(v8_str("obj"), obj->NewInstance()); 448 env->Global()->Set(v8_str("obj"), obj->NewInstance());
449 v8::Handle<v8::Value> result = Script::Compile(String::New( 449 v8::Handle<v8::Value> result = Script::Compile(String::New(
450 "var result;" 450 "var result;"
451 "for (var i = 0; i < 4; i++)" 451 "for (var i = 0; i < 4; i++)"
452 " result = obj.xxx;" 452 " result = obj.xxx;"
453 "result;"))->Run(); 453 "result;"))->Run();
454 CHECK_EQ(100, result->Int32Value()); 454 CHECK_EQ(100, result->Int32Value());
455 } 455 }
456
457
458 v8::Handle<v8::Array> JSONStringifyEnumerator(const AccessorInfo& info) {
459 v8::Handle<v8::Array> array = v8::Array::New(1);
460 array->Set(0, v8_str("regress"));
461 return array;
462 }
463
464
465 v8::Handle<v8::Value> JSONStringifyGetter(Local<String> name,
466 const AccessorInfo& info) {
467 return v8_str("crbug-161028");
468 }
469
470
471 THREADED_TEST(JSONStringifyNamedInterceptorObject) {
472 v8::HandleScope scope;
473 LocalContext env;
474
475 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
476 obj->SetNamedPropertyHandler(
477 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator);
478 env->Global()->Set(v8_str("obj"), obj->NewInstance());
479 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}");
480 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected));
481 }
OLDNEW
« no previous file with comments | « src/json-stringifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698