Fix symbol-named function template properties in the API
authorwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 21 Aug 2014 11:55:46 +0000 (11:55 +0000)
committerwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 21 Aug 2014 11:55:46 +0000 (11:55 +0000)
Thanks to Yutaka Hirano <yhirano@chromium.org> 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
test/cctest/test-api.cc

index dda1d24..3e38d10 100644 (file)
@@ -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);
index 48106bc..1a292fc 100644 (file)
@@ -2886,6 +2886,20 @@ THREADED_TEST(SymbolProperties) {
 }
 
 
+THREADED_TEST(SymbolTemplateProperties) {
+  LocalContext env;
+  v8::Isolate* isolate = env->GetIsolate();
+  v8::HandleScope scope(isolate);
+  v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate);
+  v8::Local<v8::Name> name = v8::Symbol::New(isolate);
+  CHECK(!name.IsEmpty());
+  foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate));
+  v8::Local<v8::Object> new_instance = foo->InstanceTemplate()->NewInstance();
+  CHECK(!new_instance.IsEmpty());
+  CHECK(new_instance->Has(name));
+}
+
+
 THREADED_TEST(PrivateProperties) {
   LocalContext env;
   v8::Isolate* isolate = env->GetIsolate();