Reviewers: Mads Ager, Lasse Reichstein, sandholm,

Message:
Guys,

may you have a look?

Description:
Make intercepted properties retrievable only by getter to be not enumerable.

Currently if there is no query callback, V8 finds out intercepted properties'
attributes using getter: if getter returns not empty handle V8 treats
such a property as property with NONE attribues which means this property
is enumerable.

However, if there is no enumerator, this property cannot be enumerated.
Thus I think we should treat such properties as not enumerable.

Drawback of this approach is now one has to implement both query and enumerator
callbacks to implement enumerable intercepted properties.

BUG=725

Please review this at http://codereview.chromium.org/2270005/show

Affected files:
  M src/objects.cc
  M test/cctest/test-api.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index e5e1a4e68915ff6defb58d44207a9693bf4ffa03..e2c5bc99a486cc958a44142e2e0f1dc6fc2137cf 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2037,7 +2037,7 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor(
       VMState state(EXTERNAL);
       result = getter(v8::Utils::ToLocal(name_handle), info);
     }
-    if (!result.IsEmpty()) return NONE;
+    if (!result.IsEmpty()) return DONT_ENUM;
   }
return holder_handle->GetPropertyAttributePostInterceptor(*receiver_handle,
                                                             *name_handle,
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 6254eaa708a7dff85c1c2447821b702688939ab4..a33eb949f61fe9cb3645098e3c8a675f0fad9084 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -7228,6 +7228,18 @@ THREADED_TEST(NullIndexedInterceptor) {
 }


+THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
+  v8::HandleScope scope;
+  v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter);
+  LocalContext env;
+  env->Global()->Set(v8_str("obj"),
+                     templ->GetFunction()->NewInstance());
+  ExpectTrue("obj.x === 42");
+  ExpectTrue("!obj.propertyIsEnumerable('x')");
+}
+
+
 static v8::Handle<Value> ParentGetter(Local<String> name,
                                       const AccessorInfo& info) {
   ApiTestFuzzer::Fuzz();


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to