Revision: 23269
Author:   [email protected]
Date:     Thu Aug 21 11:55:46 2014 UTC
Log:      Fix symbol-named function template properties in the API

Thanks to Yutaka Hirano <[email protected]> for finding the bug and
providing the test case.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/496663002
http://code.google.com/p/v8/source/detail?r=23269

Modified:
 /branches/bleeding_edge/src/apinatives.js
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/src/apinatives.js   Mon Aug 11 14:00:58 2014 UTC
+++ /branches/bleeding_edge/src/apinatives.js   Thu Aug 21 11:55:46 2014 UTC
@@ -72,7 +72,7 @@
         }
       }
       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);
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Aug 21 08:26:42 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Aug 21 11:55:46 2014 UTC
@@ -2884,6 +2884,20 @@
       v8::Integer::New(isolate, 42)));
   CHECK_EQ(0, child->GetOwnPropertyNames()->Length());
 }
+
+
+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) {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to