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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/json-stringifier.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-accessors.cc
diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc
index 0b342ff3d920fd5a4bf91504c082336d9dac8e4c..d44503534fb6b5b4479fd2b37e2d763bfde4f9c5 100644
--- a/test/cctest/test-accessors.cc
+++ b/test/cctest/test-accessors.cc
@@ -453,3 +453,29 @@ THREADED_TEST(HandleScopeSegment) {
"result;"))->Run();
CHECK_EQ(100, result->Int32Value());
}
+
+
+v8::Handle<v8::Array> JSONStringifyEnumerator(const AccessorInfo& info) {
+ v8::Handle<v8::Array> array = v8::Array::New(1);
+ array->Set(0, v8_str("regress"));
+ return array;
+}
+
+
+v8::Handle<v8::Value> JSONStringifyGetter(Local<String> name,
+ const AccessorInfo& info) {
+ return v8_str("crbug-161028");
+}
+
+
+THREADED_TEST(JSONStringifyNamedInterceptorObject) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
+ obj->SetNamedPropertyHandler(
+ JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator);
+ env->Global()->Set(v8_str("obj"), obj->NewInstance());
+ v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}");
+ CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected));
+}
« 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