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

Unified Diff: test/cctest/test-api.cc

Issue 467013003: Add interceptor support for symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated to filter out non-symbol keys from for-in enumeration Created 6 years, 4 months 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 | « test/cctest/test-accessors.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index c910f0ec5ea149d7acc38a4254a28e5b8b8a4d04..e8cc7af89cde5533c6f9f66231149b7c9f260eef 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -1905,7 +1905,7 @@ THREADED_TEST(DescriptorInheritance) {
int echo_named_call_count;
-static void EchoNamedProperty(Local<String> name,
+static void EchoNamedProperty(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CHECK_EQ(v8_str("data"), info.Data());
@@ -1947,17 +1947,26 @@ void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
}
-void EmptyInterceptorGetter(Local<String> name,
+void EmptyInterceptorGetter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
}
-void EmptyInterceptorSetter(Local<String> name,
+void EmptyInterceptorSetter(Local<Name> name,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
}
-void InterceptorGetter(Local<String> name,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
+void EmptyGenericInterceptorGetter(Local<Name> name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+}
+
+void EmptyGenericInterceptorSetter(Local<Name> name,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+}
+
+void StringInterceptorGetter(Local<String> name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
// Intercept names that start with 'interceptor_'.
String::Utf8Value utf8(name);
char* name_str = *utf8;
@@ -1970,9 +1979,9 @@ void InterceptorGetter(Local<String> name,
info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i)));
}
-void InterceptorSetter(Local<String> name,
- Local<Value> value,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
+void StringInterceptorSetter(Local<String> name,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
// Intercept accesses that set certain integer values, for which the name does
// not start with 'accessor_'.
String::Utf8Value utf8(name);
@@ -1991,6 +2000,59 @@ void InterceptorSetter(Local<String> name,
}
}
+void InterceptorGetter(Local<Name> generic_name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ if (generic_name->IsSymbol()) return;
+ StringInterceptorGetter(Local<String>::Cast(generic_name), info);
+}
+
+void InterceptorSetter(Local<Name> generic_name,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ if (generic_name->IsSymbol()) return;
+ StringInterceptorSetter(Local<String>::Cast(generic_name), value, info);
+}
+
+void GenericInterceptorGetter(Local<Name> generic_name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ Local<String> str;
+ if (generic_name->IsSymbol()) {
+ Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
+ if (name->IsUndefined()) return;
+ str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name));
+ } else {
+ Local<String> name = Local<String>::Cast(generic_name);
+ String::Utf8Value utf8(name);
+ char* name_str = *utf8;
+ if (*name_str == '_') return;
+ str = String::Concat(v8_str("_str_"), name);
+ }
+
+ Handle<Object> self = Handle<Object>::Cast(info.This());
+ info.GetReturnValue().Set(self->Get(str));
+}
+
+void GenericInterceptorSetter(Local<Name> generic_name,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ Local<String> str;
+ if (generic_name->IsSymbol()) {
+ Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
+ if (name->IsUndefined()) return;
+ str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name));
+ } else {
+ Local<String> name = Local<String>::Cast(generic_name);
+ String::Utf8Value utf8(name);
+ char* name_str = *utf8;
+ if (*name_str == '_') return;
+ str = String::Concat(v8_str("_str_"), name);
+ }
+
+ Handle<Object> self = Handle<Object>::Cast(info.This());
+ self->Set(str, value);
+ info.GetReturnValue().Set(value);
+}
+
void AddAccessor(Handle<FunctionTemplate> templ,
Handle<String> name,
v8::AccessorGetterCallback getter,
@@ -2012,6 +2074,12 @@ void AddAccessor(Handle<FunctionTemplate> templ,
templ->PrototypeTemplate()->SetAccessor(name, getter, setter);
}
+void AddInterceptor(Handle<FunctionTemplate> templ,
+ v8::GenericNamedPropertyGetterCallback getter,
+ v8::GenericNamedPropertySetterCallback setter) {
+ templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter);
+}
+
THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
v8::HandleScope scope(CcTest::isolate());
@@ -2031,6 +2099,60 @@ THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
}
+THREADED_TEST(LegacyInterceptorDoesNotSeeSymbols) {
+ LocalContext env;
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
+ Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
+ v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age"));
+
+ child->Inherit(parent);
+ AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter);
+ AddInterceptor(child, StringInterceptorGetter, StringInterceptorSetter);
+
+ env->Global()->Set(v8_str("Child"), child->GetFunction());
+ env->Global()->Set(v8_str("age"), age);
+ CompileRun("var child = new Child;"
+ "child[age] = 10;");
+ ExpectInt32("child[age]", 10);
+ ExpectBoolean("child.hasOwnProperty('age')", false);
+ ExpectBoolean("child.hasOwnProperty('accessor_age')", true);
+}
+
+
+THREADED_TEST(GenericInterceptorDoesSeeSymbols) {
+ LocalContext env;
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
+ Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
+ v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age"));
+ v8::Local<v8::Symbol> anon = v8::Symbol::New(isolate);
+
+ child->Inherit(parent);
+ AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter);
+ AddInterceptor(child, GenericInterceptorGetter, GenericInterceptorSetter);
+
+ env->Global()->Set(v8_str("Child"), child->GetFunction());
+ env->Global()->Set(v8_str("age"), age);
+ env->Global()->Set(v8_str("anon"), anon);
+ CompileRun("var child = new Child;"
+ "child[age] = 10;");
+ ExpectInt32("child[age]", 10);
+ ExpectInt32("child._sym_age", 10);
+
+ // Check that it also sees strings.
+ CompileRun("child.foo = 47");
+ ExpectInt32("child.foo", 47);
+ ExpectInt32("child._str_foo", 47);
+
+ // Check that the interceptor can punt (in this case, on anonymous symbols).
+ CompileRun("child[anon] = 31337");
+ ExpectInt32("child[anon]", 31337);
+}
+
+
THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
@@ -2335,7 +2457,7 @@ static void CheckThisIndexedPropertyHandler(
}
static void CheckThisNamedPropertyHandler(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler));
ApiTestFuzzer::Fuzz();
@@ -2353,7 +2475,7 @@ void CheckThisIndexedPropertySetter(
void CheckThisNamedPropertySetter(
- Local<String> property,
+ Local<Name> property,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter));
@@ -2371,7 +2493,7 @@ void CheckThisIndexedPropertyQuery(
void CheckThisNamedPropertyQuery(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery));
ApiTestFuzzer::Fuzz();
@@ -2389,7 +2511,7 @@ void CheckThisIndexedPropertyDeleter(
void CheckThisNamedPropertyDeleter(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter));
ApiTestFuzzer::Fuzz();
@@ -2464,7 +2586,7 @@ THREADED_PROFILED_TEST(PropertyHandlerInPrototype) {
static void PrePropertyHandlerGet(
- Local<String> key,
+ Local<Name> key,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("pre")->Equals(key)) {
@@ -2474,7 +2596,7 @@ static void PrePropertyHandlerGet(
static void PrePropertyHandlerQuery(
- Local<String> key,
+ Local<Name> key,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
if (v8_str("pre")->Equals(key)) {
info.GetReturnValue().Set(static_cast<int32_t>(v8::None));
@@ -2561,15 +2683,18 @@ THREADED_TEST(DeepCrossLanguageRecursion) {
static void ThrowingPropertyHandlerGet(
- Local<String> key,
+ Local<Name> key,
const v8::PropertyCallbackInfo<v8::Value>& info) {
+ // Since this interceptor is used on "with" objects, the runtime will look up
+ // @@unscopables. Punt.
+ if (key->IsSymbol()) return;
ApiTestFuzzer::Fuzz();
info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
}
static void ThrowingPropertyHandlerSet(
- Local<String> key,
+ Local<Name> key,
Local<Value>,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetIsolate()->ThrowException(key);
@@ -3412,7 +3537,7 @@ THREADED_TEST(Regress97784) {
static bool interceptor_for_hidden_properties_called;
static void InterceptorForHiddenProperties(
- Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
+ Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
interceptor_for_hidden_properties_called = true;
}
@@ -5981,7 +6106,7 @@ THREADED_TEST(NoAccessors) {
}
-static void XPropertyGetter(Local<String> property,
+static void XPropertyGetter(Local<Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CHECK(info.Data()->IsUndefined());
@@ -6077,7 +6202,7 @@ THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
static void SetXOnPrototypeGetter(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
// Set x on the prototype object and do not handle the get request.
v8::Handle<v8::Value> proto = info.Holder()->GetPrototype();
@@ -7534,7 +7659,7 @@ THREADED_TEST(Arguments) {
}
-static void NoBlockGetterX(Local<String> name,
+static void NoBlockGetterX(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>&) {
}
@@ -7544,7 +7669,7 @@ static void NoBlockGetterI(uint32_t index,
}
-static void PDeleter(Local<String> name,
+static void PDeleter(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
if (!name->Equals(v8_str("foo"))) {
return; // not intercepted
@@ -7591,7 +7716,7 @@ THREADED_TEST(Deleter) {
}
-static void GetK(Local<String> name,
+static void GetK(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (name->Equals(v8_str("foo")) ||
@@ -7725,7 +7850,7 @@ static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) {
}
-static void PGetter2(Local<String> name,
+static void PGetter2(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
p_getter_count2++;
@@ -9614,9 +9739,10 @@ static void IndexedPropertyEnumerator(
static void NamedPropertyEnumerator(
const v8::PropertyCallbackInfo<v8::Array>& info) {
- v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
+ v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
result->Set(0, v8_str("x"));
result->Set(1, v8::Object::New(info.GetIsolate()));
+ result->Set(2, v8::Symbol::GetIterator(info.GetIsolate()));
info.GetReturnValue().Set(result);
}
@@ -9631,7 +9757,11 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL,
IndexedPropertyEnumerator);
- obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL,
+ // TODO(wingo): Types needed to disambiguate between deprecated and new
+ // SetNamedPropertyHandler implementations. Go back to just passing NULL
+ // values once deprecated API is removed.
+ v8::GenericNamedPropertyGetterCallback getter = NULL;
+ obj_template->SetNamedPropertyHandler(getter, NULL, NULL, NULL,
NamedPropertyEnumerator);
LocalContext context;
@@ -9649,6 +9779,23 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
CHECK_EQ(v8_str("7"), result_array->Get(0));
CHECK_EQ(v8_str("[object Object]"), result_array->Get(1));
CHECK_EQ(v8_str("x"), result_array->Get(2));
+
+ result = CompileRun("var ret; for (var k in object) array.push(k); ret");
+ CHECK(result->IsArray());
+ result_array = v8::Handle<v8::Array>::Cast(result);
+ CHECK_EQ(3, result_array->Length());
+ CHECK(result_array->Get(0)->IsString());
+ CHECK(result_array->Get(1)->IsString());
+ CHECK(result_array->Get(2)->IsString());
+ CHECK_EQ(v8_str("7"), result_array->Get(0));
+ CHECK_EQ(v8_str("[object Object]"), result_array->Get(1));
+ CHECK_EQ(v8_str("x"), result_array->Get(2));
+
+ result = CompileRun("Object.getOwnPropertySymbols(object)");
+ CHECK(result->IsArray());
+ result_array = v8::Handle<v8::Array>::Cast(result);
+ CHECK_EQ(1, result_array->Length());
+ CHECK_EQ(result_array->Get(0), v8::Symbol::GetIterator(isolate));
}
@@ -9922,14 +10069,14 @@ THREADED_TEST(AccessControlFlatten) {
static void AccessControlNamedGetter(
- Local<String>,
+ Local<Name>,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(42);
}
static void AccessControlNamedSetter(
- Local<String>,
+ Local<Name>,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(value);
@@ -10054,7 +10201,7 @@ THREADED_TEST(InstanceProperties) {
static void GlobalObjectInstancePropertiesGet(
- Local<String> key,
+ Local<Name> key,
const v8::PropertyCallbackInfo<v8::Value>&) {
ApiTestFuzzer::Fuzz();
}
@@ -10192,7 +10339,7 @@ static void ShadowIndexedGet(uint32_t index,
}
-static void ShadowNamedGet(Local<String> key,
+static void ShadowNamedGet(Local<Name> key,
const v8::PropertyCallbackInfo<v8::Value>&) {
}
@@ -11315,7 +11462,7 @@ THREADED_TEST(HandleIteration) {
static void InterceptorHasOwnPropertyGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
}
@@ -11346,7 +11493,7 @@ THREADED_TEST(InterceptorHasOwnProperty) {
static void InterceptorHasOwnPropertyGetterGC(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
@@ -11383,14 +11530,9 @@ THREADED_TEST(InterceptorHasOwnPropertyCausingGC) {
}
-typedef void (*NamedPropertyGetter)(
- Local<String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
-
-
-static void CheckInterceptorLoadIC(NamedPropertyGetter getter,
- const char* source,
- int expected) {
+static void CheckInterceptorLoadIC(
+ v8::GenericNamedPropertyGetterCallback getter, const char* source,
+ int expected) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
@@ -11403,7 +11545,7 @@ static void CheckInterceptorLoadIC(NamedPropertyGetter getter,
static void InterceptorLoadICGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
v8::Isolate* isolate = CcTest::isolate();
@@ -11430,7 +11572,7 @@ THREADED_TEST(InterceptorLoadIC) {
// (those cases are special cased to get better performance).
static void InterceptorLoadXICGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
info.GetReturnValue().Set(
@@ -11546,7 +11688,7 @@ THREADED_TEST(InterceptorLoadICInvalidatedField) {
static int interceptor_load_not_handled_calls = 0;
static void InterceptorLoadNotHandled(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
++interceptor_load_not_handled_calls;
}
@@ -11789,7 +11931,7 @@ THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) {
static void InterceptorLoadICGetter0(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CHECK(v8_str("x")->Equals(name));
@@ -11805,7 +11947,7 @@ THREADED_TEST(InterceptorReturningZero) {
static void InterceptorStoreICSetter(
- Local<String> key,
+ Local<Name> key,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(v8_str("x")->Equals(key));
@@ -11854,7 +11996,7 @@ v8::Handle<Value> call_ic_function2;
v8::Handle<Value> call_ic_function3;
static void InterceptorCallICGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CHECK(v8_str("x")->Equals(name));
@@ -11902,7 +12044,7 @@ THREADED_TEST(InterceptorCallICSeesOthers) {
static v8::Handle<Value> call_ic_function4;
static void InterceptorCallICGetter4(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CHECK(v8_str("x")->Equals(name));
@@ -11983,7 +12125,7 @@ THREADED_TEST(InterceptorCallICConstantFunctionUsed) {
static v8::Handle<Value> call_ic_function5;
static void InterceptorCallICGetter5(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("x")->Equals(name))
@@ -12017,7 +12159,7 @@ THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) {
static v8::Handle<Value> call_ic_function6;
static void InterceptorCallICGetter6(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("x")->Equals(name))
@@ -12145,7 +12287,7 @@ THREADED_TEST(InterceptorCallICCachedFromGlobal) {
}
static void InterceptorCallICFastApi(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi));
@@ -12721,7 +12863,7 @@ THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
v8::Handle<Value> keyed_call_ic_function;
static void InterceptorKeyedCallICGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("x")->Equals(name)) {
@@ -12885,7 +13027,7 @@ THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) {
static int interceptor_call_count = 0;
static void InterceptorICRefErrorGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) {
@@ -12929,7 +13071,7 @@ THREADED_TEST(InterceptorICReferenceErrors) {
static int interceptor_ic_exception_get_count = 0;
static void InterceptorICExceptionGetter(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) {
@@ -12977,7 +13119,7 @@ THREADED_TEST(InterceptorICGetterExceptions) {
static int interceptor_ic_exception_set_count = 0;
static void InterceptorICExceptionSetter(
- Local<String> key,
+ Local<Name> key,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
@@ -13014,7 +13156,7 @@ THREADED_TEST(NullNamedInterceptor) {
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->SetNamedPropertyHandler(
- static_cast<v8::NamedPropertyGetterCallback>(0));
+ static_cast<v8::GenericNamedPropertyGetterCallback>(0));
LocalContext context;
templ->Set(CcTest::isolate(), "x", v8_num(42));
v8::Handle<v8::Object> obj = templ->NewInstance();
@@ -15399,8 +15541,15 @@ static void ForceSetSetter(v8::Local<v8::String> name,
force_set_set_count++;
}
+static void ForceSetInterceptGetter(
+ v8::Local<v8::Name> name,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ CHECK(name->IsString());
+ ForceSetGetter(Local<String>::Cast(name), info);
+}
+
static void ForceSetInterceptSetter(
- v8::Local<v8::String> name,
+ v8::Local<v8::Name> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
force_set_set_count++;
@@ -15461,7 +15610,8 @@ TEST(ForceSetWithInterceptor) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
- templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter);
+ templ->SetNamedPropertyHandler(ForceSetInterceptGetter,
+ ForceSetInterceptSetter);
LocalContext context(NULL, templ);
v8::Handle<v8::Object> global = context->Global();
@@ -15529,7 +15679,7 @@ static bool pass_on_delete = false;
static void ForceDeleteDeleter(
- v8::Local<v8::String> name,
+ v8::Local<v8::Name> name,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
force_delete_interceptor_count++;
if (pass_on_delete) return;
@@ -18622,7 +18772,7 @@ static void SetterWhichSetsYOnThisTo23(
}
-void FooGetInterceptor(Local<String> name,
+void FooGetInterceptor(Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
@@ -18631,7 +18781,7 @@ void FooGetInterceptor(Local<String> name,
}
-void FooSetInterceptor(Local<String> name,
+void FooSetInterceptor(Local<Name> name,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
@@ -18678,14 +18828,14 @@ script = v8_compile("new C2();");
static void NamedPropertyGetterWhichReturns42(
- Local<String> name,
+ Local<Name> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(v8_num(42));
}
static void NamedPropertySetterWhichSetsYOnThisTo23(
- Local<String> name,
+ Local<Name> name,
Local<Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
if (name->Equals(v8_str("x"))) {
@@ -19993,7 +20143,7 @@ THREADED_TEST(Equals) {
}
-static void Getter(v8::Local<v8::String> property,
+static void Getter(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info ) {
info.GetReturnValue().Set(v8_str("42!"));
}
@@ -20158,7 +20308,7 @@ void HasOwnPropertyIndexedPropertyGetter(
void HasOwnPropertyNamedPropertyGetter(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes"));
}
@@ -20171,14 +20321,14 @@ void HasOwnPropertyIndexedPropertyQuery(
void HasOwnPropertyNamedPropertyQuery(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1);
}
void HasOwnPropertyNamedPropertyQuery2(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1);
}
@@ -22157,7 +22307,7 @@ class RequestInterruptTestWithMethodCallAndInterceptor
private:
static void EmptyInterceptor(
- Local<String> property,
+ Local<Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
}
};
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698