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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1898
1899 // base1 and base2 cannot cross reference to each's prototype 1899 // base1 and base2 cannot cross reference to each's prototype
1900 CHECK(v8_compile("obj.v2")->Run()->IsUndefined()); 1900 CHECK(v8_compile("obj.v2")->Run()->IsUndefined());
1901 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); 1901 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined());
1902 } 1902 }
1903 1903
1904 1904
1905 int echo_named_call_count; 1905 int echo_named_call_count;
1906 1906
1907 1907
1908 static void EchoNamedProperty(Local<String> name, 1908 static void EchoNamedProperty(Local<Name> name,
1909 const v8::PropertyCallbackInfo<v8::Value>& info) { 1909 const v8::PropertyCallbackInfo<v8::Value>& info) {
1910 ApiTestFuzzer::Fuzz(); 1910 ApiTestFuzzer::Fuzz();
1911 CHECK_EQ(v8_str("data"), info.Data()); 1911 CHECK_EQ(v8_str("data"), info.Data());
1912 echo_named_call_count++; 1912 echo_named_call_count++;
1913 info.GetReturnValue().Set(name); 1913 info.GetReturnValue().Set(name);
1914 } 1914 }
1915 1915
1916 1916
1917 // Helper functions for Interceptor/Accessor interaction tests 1917 // Helper functions for Interceptor/Accessor interaction tests
1918 1918
(...skipping 21 matching lines...) Expand all
1940 1940
1941 void SymbolAccessorSetter(Local<Name> name, Local<Value> value, 1941 void SymbolAccessorSetter(Local<Name> name, Local<Value> value,
1942 const v8::PropertyCallbackInfo<void>& info) { 1942 const v8::PropertyCallbackInfo<void>& info) {
1943 CHECK(name->IsSymbol()); 1943 CHECK(name->IsSymbol());
1944 Local<Symbol> sym = Local<Symbol>::Cast(name); 1944 Local<Symbol> sym = Local<Symbol>::Cast(name);
1945 if (sym->Name()->IsUndefined()) 1945 if (sym->Name()->IsUndefined())
1946 return; 1946 return;
1947 SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info); 1947 SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info);
1948 } 1948 }
1949 1949
1950 void EmptyInterceptorGetter(Local<String> name, 1950 void EmptyInterceptorGetter(Local<Name> name,
1951 const v8::PropertyCallbackInfo<v8::Value>& info) { 1951 const v8::PropertyCallbackInfo<v8::Value>& info) {
1952 } 1952 }
1953 1953
1954 void EmptyInterceptorSetter(Local<String> name, 1954 void EmptyInterceptorSetter(Local<Name> name,
1955 Local<Value> value, 1955 Local<Value> value,
1956 const v8::PropertyCallbackInfo<v8::Value>& info) { 1956 const v8::PropertyCallbackInfo<v8::Value>& info) {
1957 } 1957 }
1958 1958
1959 void InterceptorGetter(Local<String> name, 1959 void EmptyGenericInterceptorGetter(Local<Name> name,
1960 const v8::PropertyCallbackInfo<v8::Value>& info) { 1960 const v8::PropertyCallbackInfo<v8::Value>& info) {
1961 }
1962
1963 void EmptyGenericInterceptorSetter(Local<Name> name,
1964 Local<Value> value,
1965 const v8::PropertyCallbackInfo<v8::Value>& info) {
1966 }
1967
1968 void StringInterceptorGetter(Local<String> name,
1969 const v8::PropertyCallbackInfo<v8::Value>& info) {
1961 // Intercept names that start with 'interceptor_'. 1970 // Intercept names that start with 'interceptor_'.
1962 String::Utf8Value utf8(name); 1971 String::Utf8Value utf8(name);
1963 char* name_str = *utf8; 1972 char* name_str = *utf8;
1964 char prefix[] = "interceptor_"; 1973 char prefix[] = "interceptor_";
1965 int i; 1974 int i;
1966 for (i = 0; name_str[i] && prefix[i]; ++i) { 1975 for (i = 0; name_str[i] && prefix[i]; ++i) {
1967 if (name_str[i] != prefix[i]) return; 1976 if (name_str[i] != prefix[i]) return;
1968 } 1977 }
1969 Handle<Object> self = Handle<Object>::Cast(info.This()); 1978 Handle<Object> self = Handle<Object>::Cast(info.This());
1970 info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i))); 1979 info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i)));
1971 } 1980 }
1972 1981
1973 void InterceptorSetter(Local<String> name, 1982 void StringInterceptorSetter(Local<String> name,
1974 Local<Value> value, 1983 Local<Value> value,
1975 const v8::PropertyCallbackInfo<v8::Value>& info) { 1984 const v8::PropertyCallbackInfo<v8::Value>& info) {
1976 // Intercept accesses that set certain integer values, for which the name does 1985 // Intercept accesses that set certain integer values, for which the name does
1977 // not start with 'accessor_'. 1986 // not start with 'accessor_'.
1978 String::Utf8Value utf8(name); 1987 String::Utf8Value utf8(name);
1979 char* name_str = *utf8; 1988 char* name_str = *utf8;
1980 char prefix[] = "accessor_"; 1989 char prefix[] = "accessor_";
1981 int i; 1990 int i;
1982 for (i = 0; name_str[i] && prefix[i]; ++i) { 1991 for (i = 0; name_str[i] && prefix[i]; ++i) {
1983 if (name_str[i] != prefix[i]) break; 1992 if (name_str[i] != prefix[i]) break;
1984 } 1993 }
1985 if (!prefix[i]) return; 1994 if (!prefix[i]) return;
1986 1995
1987 if (value->IsInt32() && value->Int32Value() < 10000) { 1996 if (value->IsInt32() && value->Int32Value() < 10000) {
1988 Handle<Object> self = Handle<Object>::Cast(info.This()); 1997 Handle<Object> self = Handle<Object>::Cast(info.This());
1989 self->SetHiddenValue(name, value); 1998 self->SetHiddenValue(name, value);
1990 info.GetReturnValue().Set(value); 1999 info.GetReturnValue().Set(value);
1991 } 2000 }
1992 } 2001 }
1993 2002
2003 void InterceptorGetter(Local<Name> generic_name,
2004 const v8::PropertyCallbackInfo<v8::Value>& info) {
2005 if (generic_name->IsSymbol()) return;
2006 StringInterceptorGetter(Local<String>::Cast(generic_name), info);
2007 }
2008
2009 void InterceptorSetter(Local<Name> generic_name,
2010 Local<Value> value,
2011 const v8::PropertyCallbackInfo<v8::Value>& info) {
2012 if (generic_name->IsSymbol()) return;
2013 StringInterceptorSetter(Local<String>::Cast(generic_name), value, info);
2014 }
2015
2016 void GenericInterceptorGetter(Local<Name> generic_name,
2017 const v8::PropertyCallbackInfo<v8::Value>& info) {
2018 Local<String> str;
2019 if (generic_name->IsSymbol()) {
2020 Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
2021 if (name->IsUndefined()) return;
2022 str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name));
2023 } else {
2024 Local<String> name = Local<String>::Cast(generic_name);
2025 String::Utf8Value utf8(name);
2026 char* name_str = *utf8;
2027 if (*name_str == '_') return;
2028 str = String::Concat(v8_str("_str_"), name);
2029 }
2030
2031 Handle<Object> self = Handle<Object>::Cast(info.This());
2032 info.GetReturnValue().Set(self->Get(str));
2033 }
2034
2035 void GenericInterceptorSetter(Local<Name> generic_name,
2036 Local<Value> value,
2037 const v8::PropertyCallbackInfo<v8::Value>& info) {
2038 Local<String> str;
2039 if (generic_name->IsSymbol()) {
2040 Local<Value> name = Local<Symbol>::Cast(generic_name)->Name();
2041 if (name->IsUndefined()) return;
2042 str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name));
2043 } else {
2044 Local<String> name = Local<String>::Cast(generic_name);
2045 String::Utf8Value utf8(name);
2046 char* name_str = *utf8;
2047 if (*name_str == '_') return;
2048 str = String::Concat(v8_str("_str_"), name);
2049 }
2050
2051 Handle<Object> self = Handle<Object>::Cast(info.This());
2052 self->Set(str, value);
2053 info.GetReturnValue().Set(value);
2054 }
2055
1994 void AddAccessor(Handle<FunctionTemplate> templ, 2056 void AddAccessor(Handle<FunctionTemplate> templ,
1995 Handle<String> name, 2057 Handle<String> name,
1996 v8::AccessorGetterCallback getter, 2058 v8::AccessorGetterCallback getter,
1997 v8::AccessorSetterCallback setter) { 2059 v8::AccessorSetterCallback setter) {
1998 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); 2060 templ->PrototypeTemplate()->SetAccessor(name, getter, setter);
1999 } 2061 }
2000 2062
2001 void AddInterceptor(Handle<FunctionTemplate> templ, 2063 void AddInterceptor(Handle<FunctionTemplate> templ,
2002 v8::NamedPropertyGetterCallback getter, 2064 v8::NamedPropertyGetterCallback getter,
2003 v8::NamedPropertySetterCallback setter) { 2065 v8::NamedPropertySetterCallback setter) {
2004 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); 2066 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter);
2005 } 2067 }
2006 2068
2007 2069
2008 void AddAccessor(Handle<FunctionTemplate> templ, 2070 void AddAccessor(Handle<FunctionTemplate> templ,
2009 Handle<Name> name, 2071 Handle<Name> name,
2010 v8::AccessorNameGetterCallback getter, 2072 v8::AccessorNameGetterCallback getter,
2011 v8::AccessorNameSetterCallback setter) { 2073 v8::AccessorNameSetterCallback setter) {
2012 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); 2074 templ->PrototypeTemplate()->SetAccessor(name, getter, setter);
2013 } 2075 }
2014 2076
2077 void AddInterceptor(Handle<FunctionTemplate> templ,
2078 v8::GenericNamedPropertyGetterCallback getter,
2079 v8::GenericNamedPropertySetterCallback setter) {
2080 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter);
2081 }
2082
2015 2083
2016 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { 2084 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
2017 v8::HandleScope scope(CcTest::isolate()); 2085 v8::HandleScope scope(CcTest::isolate());
2018 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); 2086 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate());
2019 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); 2087 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate());
2020 child->Inherit(parent); 2088 child->Inherit(parent);
2021 AddAccessor(parent, v8_str("age"), 2089 AddAccessor(parent, v8_str("age"),
2022 SimpleAccessorGetter, SimpleAccessorSetter); 2090 SimpleAccessorGetter, SimpleAccessorSetter);
2023 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); 2091 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter);
2024 LocalContext env; 2092 LocalContext env;
2025 env->Global()->Set(v8_str("Child"), child->GetFunction()); 2093 env->Global()->Set(v8_str("Child"), child->GetFunction());
2026 CompileRun("var child = new Child;" 2094 CompileRun("var child = new Child;"
2027 "child.age = 10;"); 2095 "child.age = 10;");
2028 ExpectBoolean("child.hasOwnProperty('age')", false); 2096 ExpectBoolean("child.hasOwnProperty('age')", false);
2029 ExpectInt32("child.age", 10); 2097 ExpectInt32("child.age", 10);
2030 ExpectInt32("child.accessor_age", 10); 2098 ExpectInt32("child.accessor_age", 10);
2031 } 2099 }
2032 2100
2033 2101
2102 THREADED_TEST(LegacyInterceptorDoesNotSeeSymbols) {
2103 LocalContext env;
2104 v8::Isolate* isolate = CcTest::isolate();
2105 v8::HandleScope scope(isolate);
2106 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
2107 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
2108 v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age"));
2109
2110 child->Inherit(parent);
2111 AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter);
2112 AddInterceptor(child, StringInterceptorGetter, StringInterceptorSetter);
2113
2114 env->Global()->Set(v8_str("Child"), child->GetFunction());
2115 env->Global()->Set(v8_str("age"), age);
2116 CompileRun("var child = new Child;"
2117 "child[age] = 10;");
2118 ExpectInt32("child[age]", 10);
2119 ExpectBoolean("child.hasOwnProperty('age')", false);
2120 ExpectBoolean("child.hasOwnProperty('accessor_age')", true);
2121 }
2122
2123
2124 THREADED_TEST(GenericInterceptorDoesSeeSymbols) {
2125 LocalContext env;
2126 v8::Isolate* isolate = CcTest::isolate();
2127 v8::HandleScope scope(isolate);
2128 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
2129 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
2130 v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age"));
2131 v8::Local<v8::Symbol> anon = v8::Symbol::New(isolate);
2132
2133 child->Inherit(parent);
2134 AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter);
2135 AddInterceptor(child, GenericInterceptorGetter, GenericInterceptorSetter);
2136
2137 env->Global()->Set(v8_str("Child"), child->GetFunction());
2138 env->Global()->Set(v8_str("age"), age);
2139 env->Global()->Set(v8_str("anon"), anon);
2140 CompileRun("var child = new Child;"
2141 "child[age] = 10;");
2142 ExpectInt32("child[age]", 10);
2143 ExpectInt32("child._sym_age", 10);
2144
2145 // Check that it also sees strings.
2146 CompileRun("child.foo = 47");
2147 ExpectInt32("child.foo", 47);
2148 ExpectInt32("child._str_foo", 47);
2149
2150 // Check that the interceptor can punt (in this case, on anonymous symbols).
2151 CompileRun("child[anon] = 31337");
2152 ExpectInt32("child[anon]", 31337);
2153 }
2154
2155
2034 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) { 2156 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) {
2035 v8::Isolate* isolate = CcTest::isolate(); 2157 v8::Isolate* isolate = CcTest::isolate();
2036 v8::HandleScope scope(isolate); 2158 v8::HandleScope scope(isolate);
2037 LocalContext env; 2159 LocalContext env;
2038 v8::Local<v8::Value> res = CompileRun("var a = []; a;"); 2160 v8::Local<v8::Value> res = CompileRun("var a = []; a;");
2039 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res))); 2161 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res)));
2040 CHECK(a->map()->instance_descriptors()->IsFixedArray()); 2162 CHECK(a->map()->instance_descriptors()->IsFixedArray());
2041 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); 2163 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
2042 CompileRun("Object.defineProperty(a, 'length', { writable: false });"); 2164 CompileRun("Object.defineProperty(a, 'length', { writable: false });");
2043 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); 2165 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 2450
2329 static void CheckThisIndexedPropertyHandler( 2451 static void CheckThisIndexedPropertyHandler(
2330 uint32_t index, 2452 uint32_t index,
2331 const v8::PropertyCallbackInfo<v8::Value>& info) { 2453 const v8::PropertyCallbackInfo<v8::Value>& info) {
2332 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyHandler)); 2454 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyHandler));
2333 ApiTestFuzzer::Fuzz(); 2455 ApiTestFuzzer::Fuzz();
2334 CHECK(info.This()->Equals(bottom)); 2456 CHECK(info.This()->Equals(bottom));
2335 } 2457 }
2336 2458
2337 static void CheckThisNamedPropertyHandler( 2459 static void CheckThisNamedPropertyHandler(
2338 Local<String> name, 2460 Local<Name> name,
2339 const v8::PropertyCallbackInfo<v8::Value>& info) { 2461 const v8::PropertyCallbackInfo<v8::Value>& info) {
2340 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler)); 2462 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler));
2341 ApiTestFuzzer::Fuzz(); 2463 ApiTestFuzzer::Fuzz();
2342 CHECK(info.This()->Equals(bottom)); 2464 CHECK(info.This()->Equals(bottom));
2343 } 2465 }
2344 2466
2345 void CheckThisIndexedPropertySetter( 2467 void CheckThisIndexedPropertySetter(
2346 uint32_t index, 2468 uint32_t index,
2347 Local<Value> value, 2469 Local<Value> value,
2348 const v8::PropertyCallbackInfo<v8::Value>& info) { 2470 const v8::PropertyCallbackInfo<v8::Value>& info) {
2349 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertySetter)); 2471 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertySetter));
2350 ApiTestFuzzer::Fuzz(); 2472 ApiTestFuzzer::Fuzz();
2351 CHECK(info.This()->Equals(bottom)); 2473 CHECK(info.This()->Equals(bottom));
2352 } 2474 }
2353 2475
2354 2476
2355 void CheckThisNamedPropertySetter( 2477 void CheckThisNamedPropertySetter(
2356 Local<String> property, 2478 Local<Name> property,
2357 Local<Value> value, 2479 Local<Value> value,
2358 const v8::PropertyCallbackInfo<v8::Value>& info) { 2480 const v8::PropertyCallbackInfo<v8::Value>& info) {
2359 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter)); 2481 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter));
2360 ApiTestFuzzer::Fuzz(); 2482 ApiTestFuzzer::Fuzz();
2361 CHECK(info.This()->Equals(bottom)); 2483 CHECK(info.This()->Equals(bottom));
2362 } 2484 }
2363 2485
2364 void CheckThisIndexedPropertyQuery( 2486 void CheckThisIndexedPropertyQuery(
2365 uint32_t index, 2487 uint32_t index,
2366 const v8::PropertyCallbackInfo<v8::Integer>& info) { 2488 const v8::PropertyCallbackInfo<v8::Integer>& info) {
2367 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyQuery)); 2489 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyQuery));
2368 ApiTestFuzzer::Fuzz(); 2490 ApiTestFuzzer::Fuzz();
2369 CHECK(info.This()->Equals(bottom)); 2491 CHECK(info.This()->Equals(bottom));
2370 } 2492 }
2371 2493
2372 2494
2373 void CheckThisNamedPropertyQuery( 2495 void CheckThisNamedPropertyQuery(
2374 Local<String> property, 2496 Local<Name> property,
2375 const v8::PropertyCallbackInfo<v8::Integer>& info) { 2497 const v8::PropertyCallbackInfo<v8::Integer>& info) {
2376 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery)); 2498 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery));
2377 ApiTestFuzzer::Fuzz(); 2499 ApiTestFuzzer::Fuzz();
2378 CHECK(info.This()->Equals(bottom)); 2500 CHECK(info.This()->Equals(bottom));
2379 } 2501 }
2380 2502
2381 2503
2382 void CheckThisIndexedPropertyDeleter( 2504 void CheckThisIndexedPropertyDeleter(
2383 uint32_t index, 2505 uint32_t index,
2384 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 2506 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
2385 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDeleter)); 2507 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDeleter));
2386 ApiTestFuzzer::Fuzz(); 2508 ApiTestFuzzer::Fuzz();
2387 CHECK(info.This()->Equals(bottom)); 2509 CHECK(info.This()->Equals(bottom));
2388 } 2510 }
2389 2511
2390 2512
2391 void CheckThisNamedPropertyDeleter( 2513 void CheckThisNamedPropertyDeleter(
2392 Local<String> property, 2514 Local<Name> property,
2393 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 2515 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
2394 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter)); 2516 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter));
2395 ApiTestFuzzer::Fuzz(); 2517 ApiTestFuzzer::Fuzz();
2396 CHECK(info.This()->Equals(bottom)); 2518 CHECK(info.This()->Equals(bottom));
2397 } 2519 }
2398 2520
2399 2521
2400 void CheckThisIndexedPropertyEnumerator( 2522 void CheckThisIndexedPropertyEnumerator(
2401 const v8::PropertyCallbackInfo<v8::Array>& info) { 2523 const v8::PropertyCallbackInfo<v8::Array>& info) {
2402 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyEnumerator)); 2524 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyEnumerator));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 // Indexed and named deleter. 2579 // Indexed and named deleter.
2458 CompileRun("delete obj[0]"); 2580 CompileRun("delete obj[0]");
2459 CompileRun("delete obj.x"); 2581 CompileRun("delete obj.x");
2460 2582
2461 // Enumerators. 2583 // Enumerators.
2462 CompileRun("for (var p in obj) ;"); 2584 CompileRun("for (var p in obj) ;");
2463 } 2585 }
2464 2586
2465 2587
2466 static void PrePropertyHandlerGet( 2588 static void PrePropertyHandlerGet(
2467 Local<String> key, 2589 Local<Name> key,
2468 const v8::PropertyCallbackInfo<v8::Value>& info) { 2590 const v8::PropertyCallbackInfo<v8::Value>& info) {
2469 ApiTestFuzzer::Fuzz(); 2591 ApiTestFuzzer::Fuzz();
2470 if (v8_str("pre")->Equals(key)) { 2592 if (v8_str("pre")->Equals(key)) {
2471 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre")); 2593 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre"));
2472 } 2594 }
2473 } 2595 }
2474 2596
2475 2597
2476 static void PrePropertyHandlerQuery( 2598 static void PrePropertyHandlerQuery(
2477 Local<String> key, 2599 Local<Name> key,
2478 const v8::PropertyCallbackInfo<v8::Integer>& info) { 2600 const v8::PropertyCallbackInfo<v8::Integer>& info) {
2479 if (v8_str("pre")->Equals(key)) { 2601 if (v8_str("pre")->Equals(key)) {
2480 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); 2602 info.GetReturnValue().Set(static_cast<int32_t>(v8::None));
2481 } 2603 }
2482 } 2604 }
2483 2605
2484 2606
2485 THREADED_TEST(PrePropertyHandler) { 2607 THREADED_TEST(PrePropertyHandler) {
2486 v8::Isolate* isolate = CcTest::isolate(); 2608 v8::Isolate* isolate = CcTest::isolate();
2487 v8::HandleScope scope(isolate); 2609 v8::HandleScope scope(isolate);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 call_recursively_script = v8_compile("callScriptRecursively()"); 2676 call_recursively_script = v8_compile("callScriptRecursively()");
2555 call_recursively_script->Run(); 2677 call_recursively_script->Run();
2556 call_recursively_script = v8::Handle<Script>(); 2678 call_recursively_script = v8::Handle<Script>();
2557 2679
2558 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); 2680 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0));
2559 CompileRun("callFunctionRecursively()"); 2681 CompileRun("callFunctionRecursively()");
2560 } 2682 }
2561 2683
2562 2684
2563 static void ThrowingPropertyHandlerGet( 2685 static void ThrowingPropertyHandlerGet(
2564 Local<String> key, 2686 Local<Name> key,
2565 const v8::PropertyCallbackInfo<v8::Value>& info) { 2687 const v8::PropertyCallbackInfo<v8::Value>& info) {
2688 // Since this interceptor is used on "with" objects, the runtime will look up
2689 // @@unscopables. Punt.
2690 if (key->IsSymbol()) return;
2566 ApiTestFuzzer::Fuzz(); 2691 ApiTestFuzzer::Fuzz();
2567 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key)); 2692 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
2568 } 2693 }
2569 2694
2570 2695
2571 static void ThrowingPropertyHandlerSet( 2696 static void ThrowingPropertyHandlerSet(
2572 Local<String> key, 2697 Local<Name> key,
2573 Local<Value>, 2698 Local<Value>,
2574 const v8::PropertyCallbackInfo<v8::Value>& info) { 2699 const v8::PropertyCallbackInfo<v8::Value>& info) {
2575 info.GetIsolate()->ThrowException(key); 2700 info.GetIsolate()->ThrowException(key);
2576 info.GetReturnValue().SetUndefined(); // not the same as empty handle 2701 info.GetReturnValue().SetUndefined(); // not the same as empty handle
2577 } 2702 }
2578 2703
2579 2704
2580 THREADED_TEST(CallbackExceptionRegression) { 2705 THREADED_TEST(CallbackExceptionRegression) {
2581 v8::Isolate* isolate = CcTest::isolate(); 2706 v8::Isolate* isolate = CcTest::isolate();
2582 v8::HandleScope scope(isolate); 2707 v8::HandleScope scope(isolate);
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 // If it did we would have full access to the hidden properties in 3530 // If it did we would have full access to the hidden properties in
3406 // the accessor. 3531 // the accessor.
3407 CHECK(obj->SetHiddenValue(key, v8::Integer::New(env->GetIsolate(), 42))); 3532 CHECK(obj->SetHiddenValue(key, v8::Integer::New(env->GetIsolate(), 42)));
3408 ExpectFalse("set_called"); 3533 ExpectFalse("set_called");
3409 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); 3534 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value());
3410 } 3535 }
3411 3536
3412 3537
3413 static bool interceptor_for_hidden_properties_called; 3538 static bool interceptor_for_hidden_properties_called;
3414 static void InterceptorForHiddenProperties( 3539 static void InterceptorForHiddenProperties(
3415 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { 3540 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
3416 interceptor_for_hidden_properties_called = true; 3541 interceptor_for_hidden_properties_called = true;
3417 } 3542 }
3418 3543
3419 3544
3420 THREADED_TEST(HiddenPropertiesWithInterceptors) { 3545 THREADED_TEST(HiddenPropertiesWithInterceptors) {
3421 LocalContext context; 3546 LocalContext context;
3422 v8::Isolate* isolate = context->GetIsolate(); 3547 v8::Isolate* isolate = context->GetIsolate();
3423 v8::HandleScope scope(isolate); 3548 v8::HandleScope scope(isolate);
3424 3549
3425 interceptor_for_hidden_properties_called = false; 3550 interceptor_for_hidden_properties_called = false;
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 v8_str("donut")); 6099 v8_str("donut"));
5975 LocalContext context; 6100 LocalContext context;
5976 context->Global()->Set(v8_str("obj"), templ->NewInstance()); 6101 context->Global()->Set(v8_str("obj"), templ->NewInstance());
5977 Local<Script> script = v8_compile("obj.x = 4; obj.x"); 6102 Local<Script> script = v8_compile("obj.x = 4; obj.x");
5978 for (int i = 0; i < 10; i++) { 6103 for (int i = 0; i < 10; i++) {
5979 script->Run(); 6104 script->Run();
5980 } 6105 }
5981 } 6106 }
5982 6107
5983 6108
5984 static void XPropertyGetter(Local<String> property, 6109 static void XPropertyGetter(Local<Name> property,
5985 const v8::PropertyCallbackInfo<v8::Value>& info) { 6110 const v8::PropertyCallbackInfo<v8::Value>& info) {
5986 ApiTestFuzzer::Fuzz(); 6111 ApiTestFuzzer::Fuzz();
5987 CHECK(info.Data()->IsUndefined()); 6112 CHECK(info.Data()->IsUndefined());
5988 info.GetReturnValue().Set(property); 6113 info.GetReturnValue().Set(property);
5989 } 6114 }
5990 6115
5991 6116
5992 THREADED_TEST(NamedInterceptorPropertyRead) { 6117 THREADED_TEST(NamedInterceptorPropertyRead) {
5993 v8::Isolate* isolate = CcTest::isolate(); 6118 v8::Isolate* isolate = CcTest::isolate();
5994 v8::HandleScope scope(isolate); 6119 v8::HandleScope scope(isolate);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
6070 6195
6071 // Return to the original context and force some object to the slow case 6196 // Return to the original context and force some object to the slow case
6072 // to cause the NormalizedMapCache to verify. 6197 // to cause the NormalizedMapCache to verify.
6073 context1->Enter(); 6198 context1->Enter();
6074 CompileRun("var obj = { x : 0 }; delete obj.x;"); 6199 CompileRun("var obj = { x : 0 }; delete obj.x;");
6075 context1->Exit(); 6200 context1->Exit();
6076 } 6201 }
6077 6202
6078 6203
6079 static void SetXOnPrototypeGetter( 6204 static void SetXOnPrototypeGetter(
6080 Local<String> property, 6205 Local<Name> property,
6081 const v8::PropertyCallbackInfo<v8::Value>& info) { 6206 const v8::PropertyCallbackInfo<v8::Value>& info) {
6082 // Set x on the prototype object and do not handle the get request. 6207 // Set x on the prototype object and do not handle the get request.
6083 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); 6208 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype();
6084 proto.As<v8::Object>()->Set(v8_str("x"), 6209 proto.As<v8::Object>()->Set(v8_str("x"),
6085 v8::Integer::New(info.GetIsolate(), 23)); 6210 v8::Integer::New(info.GetIsolate(), 23));
6086 } 6211 }
6087 6212
6088 6213
6089 // This is a regression test for http://crbug.com/20104. Map 6214 // This is a regression test for http://crbug.com/20104. Map
6090 // transitions should not interfere with post interceptor lookup. 6215 // transitions should not interfere with post interceptor lookup.
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
7527 v8::HandleScope scope(isolate); 7652 v8::HandleScope scope(isolate);
7528 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); 7653 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate);
7529 global->Set(v8_str("f"), 7654 global->Set(v8_str("f"),
7530 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); 7655 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback));
7531 LocalContext context(NULL, global); 7656 LocalContext context(NULL, global);
7532 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); 7657 args_fun = context->Global()->Get(v8_str("f")).As<Function>();
7533 v8_compile("f(1, 2, 3)")->Run(); 7658 v8_compile("f(1, 2, 3)")->Run();
7534 } 7659 }
7535 7660
7536 7661
7537 static void NoBlockGetterX(Local<String> name, 7662 static void NoBlockGetterX(Local<Name> name,
7538 const v8::PropertyCallbackInfo<v8::Value>&) { 7663 const v8::PropertyCallbackInfo<v8::Value>&) {
7539 } 7664 }
7540 7665
7541 7666
7542 static void NoBlockGetterI(uint32_t index, 7667 static void NoBlockGetterI(uint32_t index,
7543 const v8::PropertyCallbackInfo<v8::Value>&) { 7668 const v8::PropertyCallbackInfo<v8::Value>&) {
7544 } 7669 }
7545 7670
7546 7671
7547 static void PDeleter(Local<String> name, 7672 static void PDeleter(Local<Name> name,
7548 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 7673 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
7549 if (!name->Equals(v8_str("foo"))) { 7674 if (!name->Equals(v8_str("foo"))) {
7550 return; // not intercepted 7675 return; // not intercepted
7551 } 7676 }
7552 7677
7553 info.GetReturnValue().Set(false); // intercepted, don't delete the property 7678 info.GetReturnValue().Set(false); // intercepted, don't delete the property
7554 } 7679 }
7555 7680
7556 7681
7557 static void IDeleter(uint32_t index, 7682 static void IDeleter(uint32_t index,
(...skipping 26 matching lines...) Expand all
7584 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); 7709 CHECK(v8_compile("k.bar")->Run()->IsUndefined());
7585 7710
7586 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); 7711 CHECK(v8_compile("delete k[2]")->Run()->IsFalse());
7587 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); 7712 CHECK(v8_compile("delete k[4]")->Run()->IsTrue());
7588 7713
7589 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); 7714 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2));
7590 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); 7715 CHECK(v8_compile("k[4]")->Run()->IsUndefined());
7591 } 7716 }
7592 7717
7593 7718
7594 static void GetK(Local<String> name, 7719 static void GetK(Local<Name> name,
7595 const v8::PropertyCallbackInfo<v8::Value>& info) { 7720 const v8::PropertyCallbackInfo<v8::Value>& info) {
7596 ApiTestFuzzer::Fuzz(); 7721 ApiTestFuzzer::Fuzz();
7597 if (name->Equals(v8_str("foo")) || 7722 if (name->Equals(v8_str("foo")) ||
7598 name->Equals(v8_str("bar")) || 7723 name->Equals(v8_str("bar")) ||
7599 name->Equals(v8_str("baz"))) { 7724 name->Equals(v8_str("baz"))) {
7600 info.GetReturnValue().SetUndefined(); 7725 info.GetReturnValue().SetUndefined();
7601 } 7726 }
7602 } 7727 }
7603 7728
7604 7729
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
7718 "var o2 = { __proto__: o1 };" 7843 "var o2 = { __proto__: o1 };"
7719 "var o3 = { __proto__: o2 };" 7844 "var o3 = { __proto__: o2 };"
7720 "var o4 = { __proto__: o3 };" 7845 "var o4 = { __proto__: o3 };"
7721 "for (var i = 0; i < 10; i++) o4.p4;" 7846 "for (var i = 0; i < 10; i++) o4.p4;"
7722 "for (var i = 0; i < 10; i++) o3.p3;" 7847 "for (var i = 0; i < 10; i++) o3.p3;"
7723 "for (var i = 0; i < 10; i++) o2.p2;" 7848 "for (var i = 0; i < 10; i++) o2.p2;"
7724 "for (var i = 0; i < 10; i++) o1.p1;"); 7849 "for (var i = 0; i < 10; i++) o1.p1;");
7725 } 7850 }
7726 7851
7727 7852
7728 static void PGetter2(Local<String> name, 7853 static void PGetter2(Local<Name> name,
7729 const v8::PropertyCallbackInfo<v8::Value>& info) { 7854 const v8::PropertyCallbackInfo<v8::Value>& info) {
7730 ApiTestFuzzer::Fuzz(); 7855 ApiTestFuzzer::Fuzz();
7731 p_getter_count2++; 7856 p_getter_count2++;
7732 v8::Handle<v8::Object> global = 7857 v8::Handle<v8::Object> global =
7733 info.GetIsolate()->GetCurrentContext()->Global(); 7858 info.GetIsolate()->GetCurrentContext()->Global();
7734 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); 7859 CHECK_EQ(info.Holder(), global->Get(v8_str("o1")));
7735 if (name->Equals(v8_str("p1"))) { 7860 if (name->Equals(v8_str("p1"))) {
7736 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); 7861 CHECK_EQ(info.This(), global->Get(v8_str("o1")));
7737 } else if (name->Equals(v8_str("p2"))) { 7862 } else if (name->Equals(v8_str("p2"))) {
7738 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); 7863 CHECK_EQ(info.This(), global->Get(v8_str("o2")));
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after
9607 const v8::PropertyCallbackInfo<v8::Array>& info) { 9732 const v8::PropertyCallbackInfo<v8::Array>& info) {
9608 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); 9733 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
9609 result->Set(0, v8::Integer::New(info.GetIsolate(), 7)); 9734 result->Set(0, v8::Integer::New(info.GetIsolate(), 7));
9610 result->Set(1, v8::Object::New(info.GetIsolate())); 9735 result->Set(1, v8::Object::New(info.GetIsolate()));
9611 info.GetReturnValue().Set(result); 9736 info.GetReturnValue().Set(result);
9612 } 9737 }
9613 9738
9614 9739
9615 static void NamedPropertyEnumerator( 9740 static void NamedPropertyEnumerator(
9616 const v8::PropertyCallbackInfo<v8::Array>& info) { 9741 const v8::PropertyCallbackInfo<v8::Array>& info) {
9617 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); 9742 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
9618 result->Set(0, v8_str("x")); 9743 result->Set(0, v8_str("x"));
9619 result->Set(1, v8::Object::New(info.GetIsolate())); 9744 result->Set(1, v8::Object::New(info.GetIsolate()));
9745 result->Set(2, v8::Symbol::GetIterator(info.GetIsolate()));
9620 info.GetReturnValue().Set(result); 9746 info.GetReturnValue().Set(result);
9621 } 9747 }
9622 9748
9623 9749
9624 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { 9750 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
9625 v8::Isolate* isolate = CcTest::isolate(); 9751 v8::Isolate* isolate = CcTest::isolate();
9626 v8::HandleScope handle_scope(isolate); 9752 v8::HandleScope handle_scope(isolate);
9627 v8::Handle<v8::ObjectTemplate> obj_template = 9753 v8::Handle<v8::ObjectTemplate> obj_template =
9628 v8::ObjectTemplate::New(isolate); 9754 v8::ObjectTemplate::New(isolate);
9629 9755
9630 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); 9756 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
9631 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); 9757 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
9632 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, 9758 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL,
9633 IndexedPropertyEnumerator); 9759 IndexedPropertyEnumerator);
9634 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, 9760 // TODO(wingo): Types needed to disambiguate between deprecated and new
9761 // SetNamedPropertyHandler implementations. Go back to just passing NULL
9762 // values once deprecated API is removed.
9763 v8::GenericNamedPropertyGetterCallback getter = NULL;
9764 obj_template->SetNamedPropertyHandler(getter, NULL, NULL, NULL,
9635 NamedPropertyEnumerator); 9765 NamedPropertyEnumerator);
9636 9766
9637 LocalContext context; 9767 LocalContext context;
9638 v8::Handle<v8::Object> global = context->Global(); 9768 v8::Handle<v8::Object> global = context->Global();
9639 global->Set(v8_str("object"), obj_template->NewInstance()); 9769 global->Set(v8_str("object"), obj_template->NewInstance());
9640 9770
9641 v8::Handle<v8::Value> result = 9771 v8::Handle<v8::Value> result =
9642 CompileRun("Object.getOwnPropertyNames(object)"); 9772 CompileRun("Object.getOwnPropertyNames(object)");
9643 CHECK(result->IsArray()); 9773 CHECK(result->IsArray());
9644 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result); 9774 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result);
9645 CHECK_EQ(3, result_array->Length()); 9775 CHECK_EQ(3, result_array->Length());
9646 CHECK(result_array->Get(0)->IsString()); 9776 CHECK(result_array->Get(0)->IsString());
9647 CHECK(result_array->Get(1)->IsString()); 9777 CHECK(result_array->Get(1)->IsString());
9648 CHECK(result_array->Get(2)->IsString()); 9778 CHECK(result_array->Get(2)->IsString());
9649 CHECK_EQ(v8_str("7"), result_array->Get(0)); 9779 CHECK_EQ(v8_str("7"), result_array->Get(0));
9650 CHECK_EQ(v8_str("[object Object]"), result_array->Get(1)); 9780 CHECK_EQ(v8_str("[object Object]"), result_array->Get(1));
9651 CHECK_EQ(v8_str("x"), result_array->Get(2)); 9781 CHECK_EQ(v8_str("x"), result_array->Get(2));
9782
9783 result = CompileRun("var ret; for (var k in object) array.push(k); ret");
9784 CHECK(result->IsArray());
9785 result_array = v8::Handle<v8::Array>::Cast(result);
9786 CHECK_EQ(3, result_array->Length());
9787 CHECK(result_array->Get(0)->IsString());
9788 CHECK(result_array->Get(1)->IsString());
9789 CHECK(result_array->Get(2)->IsString());
9790 CHECK_EQ(v8_str("7"), result_array->Get(0));
9791 CHECK_EQ(v8_str("[object Object]"), result_array->Get(1));
9792 CHECK_EQ(v8_str("x"), result_array->Get(2));
9793
9794 result = CompileRun("Object.getOwnPropertySymbols(object)");
9795 CHECK(result->IsArray());
9796 result_array = v8::Handle<v8::Array>::Cast(result);
9797 CHECK_EQ(1, result_array->Length());
9798 CHECK_EQ(result_array->Get(0), v8::Symbol::GetIterator(isolate));
9652 } 9799 }
9653 9800
9654 9801
9655 static void ConstTenGetter(Local<String> name, 9802 static void ConstTenGetter(Local<String> name,
9656 const v8::PropertyCallbackInfo<v8::Value>& info) { 9803 const v8::PropertyCallbackInfo<v8::Value>& info) {
9657 info.GetReturnValue().Set(v8_num(10)); 9804 info.GetReturnValue().Set(v8_num(10));
9658 } 9805 }
9659 9806
9660 9807
9661 THREADED_TEST(CrossDomainAccessors) { 9808 THREADED_TEST(CrossDomainAccessors) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
9915 10062
9916 value = v8_compile("var p = 'as' + 'df';")->Run(); 10063 value = v8_compile("var p = 'as' + 'df';")->Run();
9917 value = v8_compile("obj[p];")->Run(); 10064 value = v8_compile("obj[p];")->Run();
9918 10065
9919 context1->Exit(); 10066 context1->Exit();
9920 context0->Exit(); 10067 context0->Exit();
9921 } 10068 }
9922 10069
9923 10070
9924 static void AccessControlNamedGetter( 10071 static void AccessControlNamedGetter(
9925 Local<String>, 10072 Local<Name>,
9926 const v8::PropertyCallbackInfo<v8::Value>& info) { 10073 const v8::PropertyCallbackInfo<v8::Value>& info) {
9927 info.GetReturnValue().Set(42); 10074 info.GetReturnValue().Set(42);
9928 } 10075 }
9929 10076
9930 10077
9931 static void AccessControlNamedSetter( 10078 static void AccessControlNamedSetter(
9932 Local<String>, 10079 Local<Name>,
9933 Local<Value> value, 10080 Local<Value> value,
9934 const v8::PropertyCallbackInfo<v8::Value>& info) { 10081 const v8::PropertyCallbackInfo<v8::Value>& info) {
9935 info.GetReturnValue().Set(value); 10082 info.GetReturnValue().Set(value);
9936 } 10083 }
9937 10084
9938 10085
9939 static void AccessControlIndexedGetter( 10086 static void AccessControlIndexedGetter(
9940 uint32_t index, 10087 uint32_t index,
9941 const v8::PropertyCallbackInfo<v8::Value>& info) { 10088 const v8::PropertyCallbackInfo<v8::Value>& info) {
9942 info.GetReturnValue().Set(v8_num(42)); 10089 info.GetReturnValue().Set(v8_num(42));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10047 context->Global()->Set(v8_str("i"), o); 10194 context->Global()->Set(v8_str("i"), o);
10048 Local<Value> value = CompileRun("i.x"); 10195 Local<Value> value = CompileRun("i.x");
10049 CHECK_EQ(42, value->Int32Value()); 10196 CHECK_EQ(42, value->Int32Value());
10050 10197
10051 value = CompileRun("i.f()"); 10198 value = CompileRun("i.f()");
10052 CHECK_EQ(12, value->Int32Value()); 10199 CHECK_EQ(12, value->Int32Value());
10053 } 10200 }
10054 10201
10055 10202
10056 static void GlobalObjectInstancePropertiesGet( 10203 static void GlobalObjectInstancePropertiesGet(
10057 Local<String> key, 10204 Local<Name> key,
10058 const v8::PropertyCallbackInfo<v8::Value>&) { 10205 const v8::PropertyCallbackInfo<v8::Value>&) {
10059 ApiTestFuzzer::Fuzz(); 10206 ApiTestFuzzer::Fuzz();
10060 } 10207 }
10061 10208
10062 10209
10063 THREADED_TEST(GlobalObjectInstanceProperties) { 10210 THREADED_TEST(GlobalObjectInstanceProperties) {
10064 v8::Isolate* isolate = CcTest::isolate(); 10211 v8::Isolate* isolate = CcTest::isolate();
10065 v8::HandleScope handle_scope(isolate); 10212 v8::HandleScope handle_scope(isolate);
10066 10213
10067 Local<Value> global_object; 10214 Local<Value> global_object;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
10185 shadow_y_getter_call_count++; 10332 shadow_y_getter_call_count++;
10186 info.GetReturnValue().Set(v8_num(shadow_y)); 10333 info.GetReturnValue().Set(v8_num(shadow_y));
10187 } 10334 }
10188 10335
10189 10336
10190 static void ShadowIndexedGet(uint32_t index, 10337 static void ShadowIndexedGet(uint32_t index,
10191 const v8::PropertyCallbackInfo<v8::Value>&) { 10338 const v8::PropertyCallbackInfo<v8::Value>&) {
10192 } 10339 }
10193 10340
10194 10341
10195 static void ShadowNamedGet(Local<String> key, 10342 static void ShadowNamedGet(Local<Name> key,
10196 const v8::PropertyCallbackInfo<v8::Value>&) { 10343 const v8::PropertyCallbackInfo<v8::Value>&) {
10197 } 10344 }
10198 10345
10199 10346
10200 THREADED_TEST(ShadowObject) { 10347 THREADED_TEST(ShadowObject) {
10201 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; 10348 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0;
10202 v8::Isolate* isolate = CcTest::isolate(); 10349 v8::Isolate* isolate = CcTest::isolate();
10203 v8::HandleScope handle_scope(isolate); 10350 v8::HandleScope handle_scope(isolate);
10204 10351
10205 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate); 10352 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
11308 } 11455 }
11309 } 11456 }
11310 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate)); 11457 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate));
11311 } 11458 }
11312 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); 11459 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate));
11313 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations)); 11460 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations));
11314 } 11461 }
11315 11462
11316 11463
11317 static void InterceptorHasOwnPropertyGetter( 11464 static void InterceptorHasOwnPropertyGetter(
11318 Local<String> name, 11465 Local<Name> name,
11319 const v8::PropertyCallbackInfo<v8::Value>& info) { 11466 const v8::PropertyCallbackInfo<v8::Value>& info) {
11320 ApiTestFuzzer::Fuzz(); 11467 ApiTestFuzzer::Fuzz();
11321 } 11468 }
11322 11469
11323 11470
11324 THREADED_TEST(InterceptorHasOwnProperty) { 11471 THREADED_TEST(InterceptorHasOwnProperty) {
11325 LocalContext context; 11472 LocalContext context;
11326 v8::Isolate* isolate = context->GetIsolate(); 11473 v8::Isolate* isolate = context->GetIsolate();
11327 v8::HandleScope scope(isolate); 11474 v8::HandleScope scope(isolate);
11328 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); 11475 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
(...skipping 10 matching lines...) Expand all
11339 "o.hasOwnProperty('ostehaps');"); 11486 "o.hasOwnProperty('ostehaps');");
11340 CHECK_EQ(true, value->BooleanValue()); 11487 CHECK_EQ(true, value->BooleanValue());
11341 value = CompileRun( 11488 value = CompileRun(
11342 "var p = new constructor();" 11489 "var p = new constructor();"
11343 "p.hasOwnProperty('ostehaps');"); 11490 "p.hasOwnProperty('ostehaps');");
11344 CHECK_EQ(false, value->BooleanValue()); 11491 CHECK_EQ(false, value->BooleanValue());
11345 } 11492 }
11346 11493
11347 11494
11348 static void InterceptorHasOwnPropertyGetterGC( 11495 static void InterceptorHasOwnPropertyGetterGC(
11349 Local<String> name, 11496 Local<Name> name,
11350 const v8::PropertyCallbackInfo<v8::Value>& info) { 11497 const v8::PropertyCallbackInfo<v8::Value>& info) {
11351 ApiTestFuzzer::Fuzz(); 11498 ApiTestFuzzer::Fuzz();
11352 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 11499 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
11353 } 11500 }
11354 11501
11355 11502
11356 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { 11503 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) {
11357 LocalContext context; 11504 LocalContext context;
11358 v8::Isolate* isolate = context->GetIsolate(); 11505 v8::Isolate* isolate = context->GetIsolate();
11359 v8::HandleScope scope(isolate); 11506 v8::HandleScope scope(isolate);
(...skipping 16 matching lines...) Expand all
11376 "x = makestr(31415);" 11523 "x = makestr(31415);"
11377 "x = makestr(23456);"); 11524 "x = makestr(23456);");
11378 v8::Handle<Value> value = CompileRun( 11525 v8::Handle<Value> value = CompileRun(
11379 "var o = new constructor();" 11526 "var o = new constructor();"
11380 "o.__proto__ = new String(x);" 11527 "o.__proto__ = new String(x);"
11381 "o.hasOwnProperty('ostehaps');"); 11528 "o.hasOwnProperty('ostehaps');");
11382 CHECK_EQ(false, value->BooleanValue()); 11529 CHECK_EQ(false, value->BooleanValue());
11383 } 11530 }
11384 11531
11385 11532
11386 typedef void (*NamedPropertyGetter)( 11533 static void CheckInterceptorLoadIC(
11387 Local<String> property, 11534 v8::GenericNamedPropertyGetterCallback getter, const char* source,
11388 const v8::PropertyCallbackInfo<v8::Value>& info); 11535 int expected) {
11389
11390
11391 static void CheckInterceptorLoadIC(NamedPropertyGetter getter,
11392 const char* source,
11393 int expected) {
11394 v8::Isolate* isolate = CcTest::isolate(); 11536 v8::Isolate* isolate = CcTest::isolate();
11395 v8::HandleScope scope(isolate); 11537 v8::HandleScope scope(isolate);
11396 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); 11538 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
11397 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); 11539 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data"));
11398 LocalContext context; 11540 LocalContext context;
11399 context->Global()->Set(v8_str("o"), templ->NewInstance()); 11541 context->Global()->Set(v8_str("o"), templ->NewInstance());
11400 v8::Handle<Value> value = CompileRun(source); 11542 v8::Handle<Value> value = CompileRun(source);
11401 CHECK_EQ(expected, value->Int32Value()); 11543 CHECK_EQ(expected, value->Int32Value());
11402 } 11544 }
11403 11545
11404 11546
11405 static void InterceptorLoadICGetter( 11547 static void InterceptorLoadICGetter(
11406 Local<String> name, 11548 Local<Name> name,
11407 const v8::PropertyCallbackInfo<v8::Value>& info) { 11549 const v8::PropertyCallbackInfo<v8::Value>& info) {
11408 ApiTestFuzzer::Fuzz(); 11550 ApiTestFuzzer::Fuzz();
11409 v8::Isolate* isolate = CcTest::isolate(); 11551 v8::Isolate* isolate = CcTest::isolate();
11410 CHECK_EQ(isolate, info.GetIsolate()); 11552 CHECK_EQ(isolate, info.GetIsolate());
11411 CHECK_EQ(v8_str("data"), info.Data()); 11553 CHECK_EQ(v8_str("data"), info.Data());
11412 CHECK_EQ(v8_str("x"), name); 11554 CHECK_EQ(v8_str("x"), name);
11413 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); 11555 info.GetReturnValue().Set(v8::Integer::New(isolate, 42));
11414 } 11556 }
11415 11557
11416 11558
11417 // This test should hit the load IC for the interceptor case. 11559 // This test should hit the load IC for the interceptor case.
11418 THREADED_TEST(InterceptorLoadIC) { 11560 THREADED_TEST(InterceptorLoadIC) {
11419 CheckInterceptorLoadIC(InterceptorLoadICGetter, 11561 CheckInterceptorLoadIC(InterceptorLoadICGetter,
11420 "var result = 0;" 11562 "var result = 0;"
11421 "for (var i = 0; i < 1000; i++) {" 11563 "for (var i = 0; i < 1000; i++) {"
11422 " result = o.x;" 11564 " result = o.x;"
11423 "}", 11565 "}",
11424 42); 11566 42);
11425 } 11567 }
11426 11568
11427 11569
11428 // Below go several tests which verify that JITing for various 11570 // Below go several tests which verify that JITing for various
11429 // configurations of interceptor and explicit fields works fine 11571 // configurations of interceptor and explicit fields works fine
11430 // (those cases are special cased to get better performance). 11572 // (those cases are special cased to get better performance).
11431 11573
11432 static void InterceptorLoadXICGetter( 11574 static void InterceptorLoadXICGetter(
11433 Local<String> name, 11575 Local<Name> name,
11434 const v8::PropertyCallbackInfo<v8::Value>& info) { 11576 const v8::PropertyCallbackInfo<v8::Value>& info) {
11435 ApiTestFuzzer::Fuzz(); 11577 ApiTestFuzzer::Fuzz();
11436 info.GetReturnValue().Set( 11578 info.GetReturnValue().Set(
11437 v8_str("x")->Equals(name) ? 11579 v8_str("x")->Equals(name) ?
11438 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) : 11580 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) :
11439 v8::Handle<v8::Value>()); 11581 v8::Handle<v8::Value>());
11440 } 11582 }
11441 11583
11442 11584
11443 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { 11585 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
11539 "for (var i = 0; i < 1000; i++) {" 11681 "for (var i = 0; i < 1000; i++) {"
11540 " result += o.y;" 11682 " result += o.y;"
11541 "}" 11683 "}"
11542 "result;", 11684 "result;",
11543 42 * 1000); 11685 42 * 1000);
11544 } 11686 }
11545 11687
11546 11688
11547 static int interceptor_load_not_handled_calls = 0; 11689 static int interceptor_load_not_handled_calls = 0;
11548 static void InterceptorLoadNotHandled( 11690 static void InterceptorLoadNotHandled(
11549 Local<String> name, 11691 Local<Name> name,
11550 const v8::PropertyCallbackInfo<v8::Value>& info) { 11692 const v8::PropertyCallbackInfo<v8::Value>& info) {
11551 ++interceptor_load_not_handled_calls; 11693 ++interceptor_load_not_handled_calls;
11552 } 11694 }
11553 11695
11554 11696
11555 // Test how post-interceptor lookups are done in the non-cacheable 11697 // Test how post-interceptor lookups are done in the non-cacheable
11556 // case: the interceptor should not be invoked during this lookup. 11698 // case: the interceptor should not be invoked during this lookup.
11557 THREADED_TEST(InterceptorLoadICPostInterceptor) { 11699 THREADED_TEST(InterceptorLoadICPostInterceptor) {
11558 interceptor_load_not_handled_calls = 0; 11700 interceptor_load_not_handled_calls = 0;
11559 CheckInterceptorLoadIC(InterceptorLoadNotHandled, 11701 CheckInterceptorLoadIC(InterceptorLoadNotHandled,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
11782 "var result = 0;" 11924 "var result = 0;"
11783 "for (var i = 0; i < 10; i++) {" 11925 "for (var i = 0; i < 10; i++) {"
11784 " result += o.y;" 11926 " result += o.y;"
11785 "}" 11927 "}"
11786 "result"); 11928 "result");
11787 CHECK_EQ(42 * 10, value->Int32Value()); 11929 CHECK_EQ(42 * 10, value->Int32Value());
11788 } 11930 }
11789 11931
11790 11932
11791 static void InterceptorLoadICGetter0( 11933 static void InterceptorLoadICGetter0(
11792 Local<String> name, 11934 Local<Name> name,
11793 const v8::PropertyCallbackInfo<v8::Value>& info) { 11935 const v8::PropertyCallbackInfo<v8::Value>& info) {
11794 ApiTestFuzzer::Fuzz(); 11936 ApiTestFuzzer::Fuzz();
11795 CHECK(v8_str("x")->Equals(name)); 11937 CHECK(v8_str("x")->Equals(name));
11796 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0)); 11938 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0));
11797 } 11939 }
11798 11940
11799 11941
11800 THREADED_TEST(InterceptorReturningZero) { 11942 THREADED_TEST(InterceptorReturningZero) {
11801 CheckInterceptorLoadIC(InterceptorLoadICGetter0, 11943 CheckInterceptorLoadIC(InterceptorLoadICGetter0,
11802 "o.x == undefined ? 1 : 0", 11944 "o.x == undefined ? 1 : 0",
11803 0); 11945 0);
11804 } 11946 }
11805 11947
11806 11948
11807 static void InterceptorStoreICSetter( 11949 static void InterceptorStoreICSetter(
11808 Local<String> key, 11950 Local<Name> key,
11809 Local<Value> value, 11951 Local<Value> value,
11810 const v8::PropertyCallbackInfo<v8::Value>& info) { 11952 const v8::PropertyCallbackInfo<v8::Value>& info) {
11811 CHECK(v8_str("x")->Equals(key)); 11953 CHECK(v8_str("x")->Equals(key));
11812 CHECK_EQ(42, value->Int32Value()); 11954 CHECK_EQ(42, value->Int32Value());
11813 info.GetReturnValue().Set(value); 11955 info.GetReturnValue().Set(value);
11814 } 11956 }
11815 11957
11816 11958
11817 // This test should hit the store IC for the interceptor case. 11959 // This test should hit the store IC for the interceptor case.
11818 THREADED_TEST(InterceptorStoreIC) { 11960 THREADED_TEST(InterceptorStoreIC) {
(...skipping 28 matching lines...) Expand all
11847 } 11989 }
11848 11990
11849 11991
11850 11992
11851 11993
11852 v8::Handle<Value> call_ic_function; 11994 v8::Handle<Value> call_ic_function;
11853 v8::Handle<Value> call_ic_function2; 11995 v8::Handle<Value> call_ic_function2;
11854 v8::Handle<Value> call_ic_function3; 11996 v8::Handle<Value> call_ic_function3;
11855 11997
11856 static void InterceptorCallICGetter( 11998 static void InterceptorCallICGetter(
11857 Local<String> name, 11999 Local<Name> name,
11858 const v8::PropertyCallbackInfo<v8::Value>& info) { 12000 const v8::PropertyCallbackInfo<v8::Value>& info) {
11859 ApiTestFuzzer::Fuzz(); 12001 ApiTestFuzzer::Fuzz();
11860 CHECK(v8_str("x")->Equals(name)); 12002 CHECK(v8_str("x")->Equals(name));
11861 info.GetReturnValue().Set(call_ic_function); 12003 info.GetReturnValue().Set(call_ic_function);
11862 } 12004 }
11863 12005
11864 12006
11865 // This test should hit the call IC for the interceptor case. 12007 // This test should hit the call IC for the interceptor case.
11866 THREADED_TEST(InterceptorCallIC) { 12008 THREADED_TEST(InterceptorCallIC) {
11867 v8::Isolate* isolate = CcTest::isolate(); 12009 v8::Isolate* isolate = CcTest::isolate();
(...skipping 27 matching lines...) Expand all
11895 "var result = 0;" 12037 "var result = 0;"
11896 "for (var i = 0; i < 7; i++) {" 12038 "for (var i = 0; i < 7; i++) {"
11897 " result = o.x(41);" 12039 " result = o.x(41);"
11898 "}"); 12040 "}");
11899 CHECK_EQ(42, value->Int32Value()); 12041 CHECK_EQ(42, value->Int32Value());
11900 } 12042 }
11901 12043
11902 12044
11903 static v8::Handle<Value> call_ic_function4; 12045 static v8::Handle<Value> call_ic_function4;
11904 static void InterceptorCallICGetter4( 12046 static void InterceptorCallICGetter4(
11905 Local<String> name, 12047 Local<Name> name,
11906 const v8::PropertyCallbackInfo<v8::Value>& info) { 12048 const v8::PropertyCallbackInfo<v8::Value>& info) {
11907 ApiTestFuzzer::Fuzz(); 12049 ApiTestFuzzer::Fuzz();
11908 CHECK(v8_str("x")->Equals(name)); 12050 CHECK(v8_str("x")->Equals(name));
11909 info.GetReturnValue().Set(call_ic_function4); 12051 info.GetReturnValue().Set(call_ic_function4);
11910 } 12052 }
11911 12053
11912 12054
11913 // This test checks that if interceptor provides a function, 12055 // This test checks that if interceptor provides a function,
11914 // even if we cached shadowed variant, interceptor's function 12056 // even if we cached shadowed variant, interceptor's function
11915 // is invoked 12057 // is invoked
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
11976 "var result = 0;" 12118 "var result = 0;"
11977 "for (var i = 0; i < 1000; i++) {" 12119 "for (var i = 0; i < 1000; i++) {"
11978 " result = o.x(42);" 12120 " result = o.x(42);"
11979 "}"); 12121 "}");
11980 CHECK_EQ(43, value->Int32Value()); 12122 CHECK_EQ(43, value->Int32Value());
11981 } 12123 }
11982 12124
11983 12125
11984 static v8::Handle<Value> call_ic_function5; 12126 static v8::Handle<Value> call_ic_function5;
11985 static void InterceptorCallICGetter5( 12127 static void InterceptorCallICGetter5(
11986 Local<String> name, 12128 Local<Name> name,
11987 const v8::PropertyCallbackInfo<v8::Value>& info) { 12129 const v8::PropertyCallbackInfo<v8::Value>& info) {
11988 ApiTestFuzzer::Fuzz(); 12130 ApiTestFuzzer::Fuzz();
11989 if (v8_str("x")->Equals(name)) 12131 if (v8_str("x")->Equals(name))
11990 info.GetReturnValue().Set(call_ic_function5); 12132 info.GetReturnValue().Set(call_ic_function5);
11991 } 12133 }
11992 12134
11993 12135
11994 // This test checks that if interceptor provides a function, 12136 // This test checks that if interceptor provides a function,
11995 // even if we cached constant function, interceptor's function 12137 // even if we cached constant function, interceptor's function
11996 // is invoked 12138 // is invoked
(...skipping 13 matching lines...) Expand all
12010 "var result = 0;" 12152 "var result = 0;"
12011 "for (var i = 0; i < 1000; i++) {" 12153 "for (var i = 0; i < 1000; i++) {"
12012 " result = o.x(42);" 12154 " result = o.x(42);"
12013 "}"); 12155 "}");
12014 CHECK_EQ(41, value->Int32Value()); 12156 CHECK_EQ(41, value->Int32Value());
12015 } 12157 }
12016 12158
12017 12159
12018 static v8::Handle<Value> call_ic_function6; 12160 static v8::Handle<Value> call_ic_function6;
12019 static void InterceptorCallICGetter6( 12161 static void InterceptorCallICGetter6(
12020 Local<String> name, 12162 Local<Name> name,
12021 const v8::PropertyCallbackInfo<v8::Value>& info) { 12163 const v8::PropertyCallbackInfo<v8::Value>& info) {
12022 ApiTestFuzzer::Fuzz(); 12164 ApiTestFuzzer::Fuzz();
12023 if (v8_str("x")->Equals(name)) 12165 if (v8_str("x")->Equals(name))
12024 info.GetReturnValue().Set(call_ic_function6); 12166 info.GetReturnValue().Set(call_ic_function6);
12025 } 12167 }
12026 12168
12027 12169
12028 // Same test as above, except the code is wrapped in a function 12170 // Same test as above, except the code is wrapped in a function
12029 // to test the optimized compiler. 12171 // to test the optimized compiler.
12030 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { 12172 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
12138 " result += o.parseFloat('239');" 12280 " result += o.parseFloat('239');"
12139 " }" 12281 " }"
12140 " result" 12282 " result"
12141 "} catch(e) {" 12283 "} catch(e) {"
12142 " e" 12284 " e"
12143 "};"); 12285 "};");
12144 CHECK_EQ(239 * 10, value->Int32Value()); 12286 CHECK_EQ(239 * 10, value->Int32Value());
12145 } 12287 }
12146 12288
12147 static void InterceptorCallICFastApi( 12289 static void InterceptorCallICFastApi(
12148 Local<String> name, 12290 Local<Name> name,
12149 const v8::PropertyCallbackInfo<v8::Value>& info) { 12291 const v8::PropertyCallbackInfo<v8::Value>& info) {
12150 ApiTestFuzzer::Fuzz(); 12292 ApiTestFuzzer::Fuzz();
12151 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); 12293 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi));
12152 int* call_count = 12294 int* call_count =
12153 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); 12295 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value());
12154 ++(*call_count); 12296 ++(*call_count);
12155 if ((*call_count) % 20 == 0) { 12297 if ((*call_count) % 20 == 0) {
12156 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 12298 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
12157 } 12299 }
12158 } 12300 }
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
12714 CHECK(try_catch.HasCaught()); 12856 CHECK(try_catch.HasCaught());
12715 CHECK_EQ(v8_str("TypeError: Illegal invocation"), 12857 CHECK_EQ(v8_str("TypeError: Illegal invocation"),
12716 try_catch.Exception()->ToString()); 12858 try_catch.Exception()->ToString());
12717 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 12859 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
12718 } 12860 }
12719 12861
12720 12862
12721 v8::Handle<Value> keyed_call_ic_function; 12863 v8::Handle<Value> keyed_call_ic_function;
12722 12864
12723 static void InterceptorKeyedCallICGetter( 12865 static void InterceptorKeyedCallICGetter(
12724 Local<String> name, 12866 Local<Name> name,
12725 const v8::PropertyCallbackInfo<v8::Value>& info) { 12867 const v8::PropertyCallbackInfo<v8::Value>& info) {
12726 ApiTestFuzzer::Fuzz(); 12868 ApiTestFuzzer::Fuzz();
12727 if (v8_str("x")->Equals(name)) { 12869 if (v8_str("x")->Equals(name)) {
12728 info.GetReturnValue().Set(keyed_call_ic_function); 12870 info.GetReturnValue().Set(keyed_call_ic_function);
12729 } 12871 }
12730 } 12872 }
12731 12873
12732 12874
12733 // Test the case when we stored cacheable lookup into 12875 // Test the case when we stored cacheable lookup into
12734 // a stub, but the function name changed (to another cacheable function). 12876 // a stub, but the function name changed (to another cacheable function).
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
12878 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" 13020 " if (i == 5) { proto.method = function(x) { return x - 1; }; };"
12879 " result += o[m](41);" 13021 " result += o[m](41);"
12880 "}"); 13022 "}");
12881 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 13023 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
12882 } 13024 }
12883 13025
12884 13026
12885 static int interceptor_call_count = 0; 13027 static int interceptor_call_count = 0;
12886 13028
12887 static void InterceptorICRefErrorGetter( 13029 static void InterceptorICRefErrorGetter(
12888 Local<String> name, 13030 Local<Name> name,
12889 const v8::PropertyCallbackInfo<v8::Value>& info) { 13031 const v8::PropertyCallbackInfo<v8::Value>& info) {
12890 ApiTestFuzzer::Fuzz(); 13032 ApiTestFuzzer::Fuzz();
12891 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { 13033 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) {
12892 info.GetReturnValue().Set(call_ic_function2); 13034 info.GetReturnValue().Set(call_ic_function2);
12893 } 13035 }
12894 } 13036 }
12895 13037
12896 13038
12897 // This test should hit load and call ICs for the interceptor case. 13039 // This test should hit load and call ICs for the interceptor case.
12898 // Once in a while, the interceptor will reply that a property was not 13040 // Once in a while, the interceptor will reply that a property was not
(...skipping 23 matching lines...) Expand all
12922 " return false;" 13064 " return false;"
12923 "};" 13065 "};"
12924 "g();"); 13066 "g();");
12925 CHECK_EQ(true, value->BooleanValue()); 13067 CHECK_EQ(true, value->BooleanValue());
12926 } 13068 }
12927 13069
12928 13070
12929 static int interceptor_ic_exception_get_count = 0; 13071 static int interceptor_ic_exception_get_count = 0;
12930 13072
12931 static void InterceptorICExceptionGetter( 13073 static void InterceptorICExceptionGetter(
12932 Local<String> name, 13074 Local<Name> name,
12933 const v8::PropertyCallbackInfo<v8::Value>& info) { 13075 const v8::PropertyCallbackInfo<v8::Value>& info) {
12934 ApiTestFuzzer::Fuzz(); 13076 ApiTestFuzzer::Fuzz();
12935 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { 13077 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) {
12936 info.GetReturnValue().Set(call_ic_function3); 13078 info.GetReturnValue().Set(call_ic_function3);
12937 } 13079 }
12938 if (interceptor_ic_exception_get_count == 20) { 13080 if (interceptor_ic_exception_get_count == 20) {
12939 info.GetIsolate()->ThrowException(v8_num(42)); 13081 info.GetIsolate()->ThrowException(v8_num(42));
12940 return; 13082 return;
12941 } 13083 }
12942 } 13084 }
(...skipping 27 matching lines...) Expand all
12970 " return false;" 13112 " return false;"
12971 "};" 13113 "};"
12972 "f();"); 13114 "f();");
12973 CHECK_EQ(true, value->BooleanValue()); 13115 CHECK_EQ(true, value->BooleanValue());
12974 } 13116 }
12975 13117
12976 13118
12977 static int interceptor_ic_exception_set_count = 0; 13119 static int interceptor_ic_exception_set_count = 0;
12978 13120
12979 static void InterceptorICExceptionSetter( 13121 static void InterceptorICExceptionSetter(
12980 Local<String> key, 13122 Local<Name> key,
12981 Local<Value> value, 13123 Local<Value> value,
12982 const v8::PropertyCallbackInfo<v8::Value>& info) { 13124 const v8::PropertyCallbackInfo<v8::Value>& info) {
12983 ApiTestFuzzer::Fuzz(); 13125 ApiTestFuzzer::Fuzz();
12984 if (++interceptor_ic_exception_set_count > 20) { 13126 if (++interceptor_ic_exception_set_count > 20) {
12985 info.GetIsolate()->ThrowException(v8_num(42)); 13127 info.GetIsolate()->ThrowException(v8_num(42));
12986 } 13128 }
12987 } 13129 }
12988 13130
12989 13131
12990 // Test interceptor store IC where the interceptor throws an exception 13132 // Test interceptor store IC where the interceptor throws an exception
(...skipping 16 matching lines...) Expand all
13007 CHECK_EQ(true, value->BooleanValue()); 13149 CHECK_EQ(true, value->BooleanValue());
13008 } 13150 }
13009 13151
13010 13152
13011 // Test that we ignore null interceptors. 13153 // Test that we ignore null interceptors.
13012 THREADED_TEST(NullNamedInterceptor) { 13154 THREADED_TEST(NullNamedInterceptor) {
13013 v8::Isolate* isolate = CcTest::isolate(); 13155 v8::Isolate* isolate = CcTest::isolate();
13014 v8::HandleScope scope(isolate); 13156 v8::HandleScope scope(isolate);
13015 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); 13157 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
13016 templ->SetNamedPropertyHandler( 13158 templ->SetNamedPropertyHandler(
13017 static_cast<v8::NamedPropertyGetterCallback>(0)); 13159 static_cast<v8::GenericNamedPropertyGetterCallback>(0));
13018 LocalContext context; 13160 LocalContext context;
13019 templ->Set(CcTest::isolate(), "x", v8_num(42)); 13161 templ->Set(CcTest::isolate(), "x", v8_num(42));
13020 v8::Handle<v8::Object> obj = templ->NewInstance(); 13162 v8::Handle<v8::Object> obj = templ->NewInstance();
13021 context->Global()->Set(v8_str("obj"), obj); 13163 context->Global()->Set(v8_str("obj"), obj);
13022 v8::Handle<Value> value = CompileRun("obj.x"); 13164 v8::Handle<Value> value = CompileRun("obj.x");
13023 CHECK(value->IsInt32()); 13165 CHECK(value->IsInt32());
13024 CHECK_EQ(42, value->Int32Value()); 13166 CHECK_EQ(42, value->Int32Value());
13025 } 13167 }
13026 13168
13027 13169
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after
15392 } 15534 }
15393 info.GetReturnValue().Set(3); 15535 info.GetReturnValue().Set(3);
15394 } 15536 }
15395 15537
15396 static void ForceSetSetter(v8::Local<v8::String> name, 15538 static void ForceSetSetter(v8::Local<v8::String> name,
15397 v8::Local<v8::Value> value, 15539 v8::Local<v8::Value> value,
15398 const v8::PropertyCallbackInfo<void>& info) { 15540 const v8::PropertyCallbackInfo<void>& info) {
15399 force_set_set_count++; 15541 force_set_set_count++;
15400 } 15542 }
15401 15543
15544 static void ForceSetInterceptGetter(
15545 v8::Local<v8::Name> name,
15546 const v8::PropertyCallbackInfo<v8::Value>& info) {
15547 CHECK(name->IsString());
15548 ForceSetGetter(Local<String>::Cast(name), info);
15549 }
15550
15402 static void ForceSetInterceptSetter( 15551 static void ForceSetInterceptSetter(
15403 v8::Local<v8::String> name, 15552 v8::Local<v8::Name> name,
15404 v8::Local<v8::Value> value, 15553 v8::Local<v8::Value> value,
15405 const v8::PropertyCallbackInfo<v8::Value>& info) { 15554 const v8::PropertyCallbackInfo<v8::Value>& info) {
15406 force_set_set_count++; 15555 force_set_set_count++;
15407 info.GetReturnValue().SetUndefined(); 15556 info.GetReturnValue().SetUndefined();
15408 } 15557 }
15409 15558
15410 15559
15411 TEST(ForceSet) { 15560 TEST(ForceSet) {
15412 force_set_get_count = 0; 15561 force_set_get_count = 0;
15413 force_set_set_count = 0; 15562 force_set_set_count = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
15454 15603
15455 15604
15456 TEST(ForceSetWithInterceptor) { 15605 TEST(ForceSetWithInterceptor) {
15457 force_set_get_count = 0; 15606 force_set_get_count = 0;
15458 force_set_set_count = 0; 15607 force_set_set_count = 0;
15459 pass_on_get = false; 15608 pass_on_get = false;
15460 15609
15461 v8::Isolate* isolate = CcTest::isolate(); 15610 v8::Isolate* isolate = CcTest::isolate();
15462 v8::HandleScope scope(isolate); 15611 v8::HandleScope scope(isolate);
15463 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); 15612 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
15464 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); 15613 templ->SetNamedPropertyHandler(ForceSetInterceptGetter,
15614 ForceSetInterceptSetter);
15465 LocalContext context(NULL, templ); 15615 LocalContext context(NULL, templ);
15466 v8::Handle<v8::Object> global = context->Global(); 15616 v8::Handle<v8::Object> global = context->Global();
15467 15617
15468 v8::Handle<v8::String> some_property = 15618 v8::Handle<v8::String> some_property =
15469 v8::String::NewFromUtf8(isolate, "a"); 15619 v8::String::NewFromUtf8(isolate, "a");
15470 CHECK_EQ(0, force_set_set_count); 15620 CHECK_EQ(0, force_set_set_count);
15471 CHECK_EQ(0, force_set_get_count); 15621 CHECK_EQ(0, force_set_get_count);
15472 CHECK_EQ(3, global->Get(some_property)->Int32Value()); 15622 CHECK_EQ(3, global->Get(some_property)->Int32Value());
15473 // Setting the property shouldn't override it, just call the setter 15623 // Setting the property shouldn't override it, just call the setter
15474 // which in this case does nothing. 15624 // which in this case does nothing.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
15522 CHECK(global->ForceDelete(simple_property)); 15672 CHECK(global->ForceDelete(simple_property));
15523 CHECK(global->Get(simple_property)->IsUndefined()); 15673 CHECK(global->Get(simple_property)->IsUndefined());
15524 } 15674 }
15525 15675
15526 15676
15527 static int force_delete_interceptor_count = 0; 15677 static int force_delete_interceptor_count = 0;
15528 static bool pass_on_delete = false; 15678 static bool pass_on_delete = false;
15529 15679
15530 15680
15531 static void ForceDeleteDeleter( 15681 static void ForceDeleteDeleter(
15532 v8::Local<v8::String> name, 15682 v8::Local<v8::Name> name,
15533 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 15683 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
15534 force_delete_interceptor_count++; 15684 force_delete_interceptor_count++;
15535 if (pass_on_delete) return; 15685 if (pass_on_delete) return;
15536 info.GetReturnValue().Set(true); 15686 info.GetReturnValue().Set(true);
15537 } 15687 }
15538 15688
15539 15689
15540 THREADED_TEST(ForceDeleteWithInterceptor) { 15690 THREADED_TEST(ForceDeleteWithInterceptor) {
15541 force_delete_interceptor_count = 0; 15691 force_delete_interceptor_count = 0;
15542 pass_on_delete = false; 15692 pass_on_delete = false;
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after
18615 static void SetterWhichSetsYOnThisTo23( 18765 static void SetterWhichSetsYOnThisTo23(
18616 Local<String> name, 18766 Local<String> name,
18617 Local<Value> value, 18767 Local<Value> value,
18618 const v8::PropertyCallbackInfo<void>& info) { 18768 const v8::PropertyCallbackInfo<void>& info) {
18619 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); 18769 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
18620 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); 18770 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
18621 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); 18771 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
18622 } 18772 }
18623 18773
18624 18774
18625 void FooGetInterceptor(Local<String> name, 18775 void FooGetInterceptor(Local<Name> name,
18626 const v8::PropertyCallbackInfo<v8::Value>& info) { 18776 const v8::PropertyCallbackInfo<v8::Value>& info) {
18627 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); 18777 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
18628 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); 18778 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
18629 if (!name->Equals(v8_str("foo"))) return; 18779 if (!name->Equals(v8_str("foo"))) return;
18630 info.GetReturnValue().Set(v8_num(42)); 18780 info.GetReturnValue().Set(v8_num(42));
18631 } 18781 }
18632 18782
18633 18783
18634 void FooSetInterceptor(Local<String> name, 18784 void FooSetInterceptor(Local<Name> name,
18635 Local<Value> value, 18785 Local<Value> value,
18636 const v8::PropertyCallbackInfo<v8::Value>& info) { 18786 const v8::PropertyCallbackInfo<v8::Value>& info) {
18637 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); 18787 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject());
18638 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); 18788 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject());
18639 if (!name->Equals(v8_str("foo"))) return; 18789 if (!name->Equals(v8_str("foo"))) return;
18640 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); 18790 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
18641 info.GetReturnValue().Set(v8_num(23)); 18791 info.GetReturnValue().Set(v8_num(23));
18642 } 18792 }
18643 18793
18644 18794
(...skipping 26 matching lines...) Expand all
18671 script = v8_compile("new C2();"); 18821 script = v8_compile("new C2();");
18672 for (int i = 0; i < 10; i++) { 18822 for (int i = 0; i < 10; i++) {
18673 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); 18823 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
18674 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); 18824 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value());
18675 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value()); 18825 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value());
18676 } 18826 }
18677 } 18827 }
18678 18828
18679 18829
18680 static void NamedPropertyGetterWhichReturns42( 18830 static void NamedPropertyGetterWhichReturns42(
18681 Local<String> name, 18831 Local<Name> name,
18682 const v8::PropertyCallbackInfo<v8::Value>& info) { 18832 const v8::PropertyCallbackInfo<v8::Value>& info) {
18683 info.GetReturnValue().Set(v8_num(42)); 18833 info.GetReturnValue().Set(v8_num(42));
18684 } 18834 }
18685 18835
18686 18836
18687 static void NamedPropertySetterWhichSetsYOnThisTo23( 18837 static void NamedPropertySetterWhichSetsYOnThisTo23(
18688 Local<String> name, 18838 Local<Name> name,
18689 Local<Value> value, 18839 Local<Value> value,
18690 const v8::PropertyCallbackInfo<v8::Value>& info) { 18840 const v8::PropertyCallbackInfo<v8::Value>& info) {
18691 if (name->Equals(v8_str("x"))) { 18841 if (name->Equals(v8_str("x"))) {
18692 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); 18842 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23));
18693 } 18843 }
18694 } 18844 }
18695 18845
18696 18846
18697 THREADED_TEST(InterceptorOnConstructorPrototype) { 18847 THREADED_TEST(InterceptorOnConstructorPrototype) {
18698 v8::Isolate* isolate = CcTest::isolate(); 18848 v8::Isolate* isolate = CcTest::isolate();
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
19986 CHECK(!globalProxy->StrictEquals(global)); 20136 CHECK(!globalProxy->StrictEquals(global));
19987 CHECK(globalProxy->StrictEquals(globalProxy)); 20137 CHECK(globalProxy->StrictEquals(globalProxy));
19988 20138
19989 CHECK(global->Equals(global)); 20139 CHECK(global->Equals(global));
19990 CHECK(!global->Equals(globalProxy)); 20140 CHECK(!global->Equals(globalProxy));
19991 CHECK(!globalProxy->Equals(global)); 20141 CHECK(!globalProxy->Equals(global));
19992 CHECK(globalProxy->Equals(globalProxy)); 20142 CHECK(globalProxy->Equals(globalProxy));
19993 } 20143 }
19994 20144
19995 20145
19996 static void Getter(v8::Local<v8::String> property, 20146 static void Getter(v8::Local<v8::Name> property,
19997 const v8::PropertyCallbackInfo<v8::Value>& info ) { 20147 const v8::PropertyCallbackInfo<v8::Value>& info ) {
19998 info.GetReturnValue().Set(v8_str("42!")); 20148 info.GetReturnValue().Set(v8_str("42!"));
19999 } 20149 }
20000 20150
20001 20151
20002 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { 20152 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
20003 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate()); 20153 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate());
20004 result->Set(0, v8_str("universalAnswer")); 20154 result->Set(0, v8_str("universalAnswer"));
20005 info.GetReturnValue().Set(result); 20155 info.GetReturnValue().Set(result);
20006 } 20156 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
20151 20301
20152 20302
20153 void HasOwnPropertyIndexedPropertyGetter( 20303 void HasOwnPropertyIndexedPropertyGetter(
20154 uint32_t index, 20304 uint32_t index,
20155 const v8::PropertyCallbackInfo<v8::Value>& info) { 20305 const v8::PropertyCallbackInfo<v8::Value>& info) {
20156 if (index == 42) info.GetReturnValue().Set(v8_str("yes")); 20306 if (index == 42) info.GetReturnValue().Set(v8_str("yes"));
20157 } 20307 }
20158 20308
20159 20309
20160 void HasOwnPropertyNamedPropertyGetter( 20310 void HasOwnPropertyNamedPropertyGetter(
20161 Local<String> property, 20311 Local<Name> property,
20162 const v8::PropertyCallbackInfo<v8::Value>& info) { 20312 const v8::PropertyCallbackInfo<v8::Value>& info) {
20163 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes")); 20313 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes"));
20164 } 20314 }
20165 20315
20166 20316
20167 void HasOwnPropertyIndexedPropertyQuery( 20317 void HasOwnPropertyIndexedPropertyQuery(
20168 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) { 20318 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) {
20169 if (index == 42) info.GetReturnValue().Set(1); 20319 if (index == 42) info.GetReturnValue().Set(1);
20170 } 20320 }
20171 20321
20172 20322
20173 void HasOwnPropertyNamedPropertyQuery( 20323 void HasOwnPropertyNamedPropertyQuery(
20174 Local<String> property, 20324 Local<Name> property,
20175 const v8::PropertyCallbackInfo<v8::Integer>& info) { 20325 const v8::PropertyCallbackInfo<v8::Integer>& info) {
20176 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1); 20326 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1);
20177 } 20327 }
20178 20328
20179 20329
20180 void HasOwnPropertyNamedPropertyQuery2( 20330 void HasOwnPropertyNamedPropertyQuery2(
20181 Local<String> property, 20331 Local<Name> property,
20182 const v8::PropertyCallbackInfo<v8::Integer>& info) { 20332 const v8::PropertyCallbackInfo<v8::Integer>& info) {
20183 if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1); 20333 if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1);
20184 } 20334 }
20185 20335
20186 20336
20187 void HasOwnPropertyAccessorGetter( 20337 void HasOwnPropertyAccessorGetter(
20188 Local<String> property, 20338 Local<String> property,
20189 const v8::PropertyCallbackInfo<v8::Value>& info) { 20339 const v8::PropertyCallbackInfo<v8::Value>& info) {
20190 info.GetReturnValue().Set(v8_str("yes")); 20340 info.GetReturnValue().Set(v8_str("yes"));
20191 } 20341 }
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
22150 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate(); 22300 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate();
22151 instance_template->SetNamedPropertyHandler(EmptyInterceptor); 22301 instance_template->SetNamedPropertyHandler(EmptyInterceptor);
22152 22302
22153 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); 22303 env_->Global()->Set(v8_str("Klass"), t->GetFunction());
22154 22304
22155 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); 22305 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }");
22156 } 22306 }
22157 22307
22158 private: 22308 private:
22159 static void EmptyInterceptor( 22309 static void EmptyInterceptor(
22160 Local<String> property, 22310 Local<Name> property,
22161 const v8::PropertyCallbackInfo<v8::Value>& info) { 22311 const v8::PropertyCallbackInfo<v8::Value>& info) {
22162 } 22312 }
22163 }; 22313 };
22164 22314
22165 22315
22166 class RequestInterruptTestWithMathAbs 22316 class RequestInterruptTestWithMathAbs
22167 : public RequestInterruptTestBaseWithSimpleInterrupt { 22317 : public RequestInterruptTestBaseWithSimpleInterrupt {
22168 public: 22318 public:
22169 virtual void TestBody() { 22319 virtual void TestBody() {
22170 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New( 22320 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New(
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
22994 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); 23144 desc = x->GetOwnPropertyDescriptor(v8_str("p1"));
22995 Local<Function> set = 23145 Local<Function> set =
22996 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); 23146 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set")));
22997 Local<Function> get = 23147 Local<Function> get =
22998 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); 23148 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get")));
22999 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); 23149 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL));
23000 Handle<Value> args[] = { v8_num(14) }; 23150 Handle<Value> args[] = { v8_num(14) };
23001 set->Call(x, 1, args); 23151 set->Call(x, 1, args);
23002 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); 23152 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL));
23003 } 23153 }
OLDNEW
« 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