From 558a05bfcf6ea8e57ea88fa605525d9501a34287 Mon Sep 17 00:00:00 2001 From: "wingo@igalia.com" Date: Thu, 21 Aug 2014 11:55:46 +0000 Subject: [PATCH] Fix symbol-named function template properties in the API Thanks to Yutaka Hirano for finding the bug and providing the test case. R=rossberg@chromium.org BUG= Review URL: https://codereview.chromium.org/496663002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23269 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/apinatives.js | 2 +- test/cctest/test-api.cc | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/apinatives.js b/src/apinatives.js index dda1d24..3e38d10 100644 --- a/src/apinatives.js +++ b/src/apinatives.js @@ -72,7 +72,7 @@ function InstantiateFunction(data, name) { } } var fun = %CreateApiFunction(data, prototype); - if (name) %FunctionSetName(fun, name); + if (IS_STRING(name)) %FunctionSetName(fun, name); var doNotCache = flags & (1 << kDoNotCacheBit); if (!doNotCache) cache[serialNumber] = fun; ConfigureTemplateInstance(fun, data); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 48106bc..1a292fc 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -2886,6 +2886,20 @@ THREADED_TEST(SymbolProperties) { } +THREADED_TEST(SymbolTemplateProperties) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::Local foo = v8::FunctionTemplate::New(isolate); + v8::Local name = v8::Symbol::New(isolate); + CHECK(!name.IsEmpty()); + foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate)); + v8::Local new_instance = foo->InstanceTemplate()->NewInstance(); + CHECK(!new_instance.IsEmpty()); + CHECK(new_instance->Has(name)); +} + + THREADED_TEST(PrivateProperties) { LocalContext env; v8::Isolate* isolate = env->GetIsolate(); -- 2.7.4