OLD | NEW |
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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 | 1849 |
1850 // base1 and base2 cannot cross reference to each's prototype | 1850 // base1 and base2 cannot cross reference to each's prototype |
1851 CHECK(v8_compile("obj.v2")->Run()->IsUndefined()); | 1851 CHECK(v8_compile("obj.v2")->Run()->IsUndefined()); |
1852 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); | 1852 CHECK(v8_compile("obj2.v1")->Run()->IsUndefined()); |
1853 } | 1853 } |
1854 | 1854 |
1855 | 1855 |
1856 int echo_named_call_count; | 1856 int echo_named_call_count; |
1857 | 1857 |
1858 | 1858 |
1859 static void EchoNamedProperty(Local<String> name, | 1859 static void EchoNamedProperty(Local<Name> name, |
1860 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1860 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1861 ApiTestFuzzer::Fuzz(); | 1861 ApiTestFuzzer::Fuzz(); |
1862 CHECK_EQ(v8_str("data"), info.Data()); | 1862 CHECK_EQ(v8_str("data"), info.Data()); |
1863 echo_named_call_count++; | 1863 echo_named_call_count++; |
1864 info.GetReturnValue().Set(name); | 1864 info.GetReturnValue().Set(name); |
1865 } | 1865 } |
1866 | 1866 |
1867 | 1867 |
1868 // Helper functions for Interceptor/Accessor interaction tests | 1868 // Helper functions for Interceptor/Accessor interaction tests |
1869 | 1869 |
(...skipping 21 matching lines...) Expand all Loading... |
1891 | 1891 |
1892 void SymbolAccessorSetter(Local<Name> name, Local<Value> value, | 1892 void SymbolAccessorSetter(Local<Name> name, Local<Value> value, |
1893 const v8::PropertyCallbackInfo<void>& info) { | 1893 const v8::PropertyCallbackInfo<void>& info) { |
1894 CHECK(name->IsSymbol()); | 1894 CHECK(name->IsSymbol()); |
1895 Local<Symbol> sym = Local<Symbol>::Cast(name); | 1895 Local<Symbol> sym = Local<Symbol>::Cast(name); |
1896 if (sym->Name()->IsUndefined()) | 1896 if (sym->Name()->IsUndefined()) |
1897 return; | 1897 return; |
1898 SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info); | 1898 SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info); |
1899 } | 1899 } |
1900 | 1900 |
1901 void EmptyInterceptorGetter(Local<String> name, | 1901 void EmptyInterceptorGetter(Local<Name> name, |
1902 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1902 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1903 } | 1903 } |
1904 | 1904 |
1905 void EmptyInterceptorSetter(Local<String> name, | 1905 void EmptyInterceptorSetter(Local<Name> name, |
1906 Local<Value> value, | 1906 Local<Value> value, |
1907 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1907 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1908 } | 1908 } |
1909 | 1909 |
1910 void InterceptorGetter(Local<String> name, | 1910 void EmptyGenericInterceptorGetter(Local<Name> name, |
1911 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1911 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1912 } |
| 1913 |
| 1914 void EmptyGenericInterceptorSetter(Local<Name> name, |
| 1915 Local<Value> value, |
| 1916 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1917 } |
| 1918 |
| 1919 void StringInterceptorGetter(Local<String> name, |
| 1920 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1912 // Intercept names that start with 'interceptor_'. | 1921 // Intercept names that start with 'interceptor_'. |
1913 String::Utf8Value utf8(name); | 1922 String::Utf8Value utf8(name); |
1914 char* name_str = *utf8; | 1923 char* name_str = *utf8; |
1915 char prefix[] = "interceptor_"; | 1924 char prefix[] = "interceptor_"; |
1916 int i; | 1925 int i; |
1917 for (i = 0; name_str[i] && prefix[i]; ++i) { | 1926 for (i = 0; name_str[i] && prefix[i]; ++i) { |
1918 if (name_str[i] != prefix[i]) return; | 1927 if (name_str[i] != prefix[i]) return; |
1919 } | 1928 } |
1920 Handle<Object> self = Handle<Object>::Cast(info.This()); | 1929 Handle<Object> self = Handle<Object>::Cast(info.This()); |
1921 info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i))); | 1930 info.GetReturnValue().Set(self->GetHiddenValue(v8_str(name_str + i))); |
1922 } | 1931 } |
1923 | 1932 |
1924 void InterceptorSetter(Local<String> name, | 1933 void StringInterceptorSetter(Local<String> name, |
1925 Local<Value> value, | 1934 Local<Value> value, |
1926 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1935 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1927 // Intercept accesses that set certain integer values, for which the name does | 1936 // Intercept accesses that set certain integer values, for which the name does |
1928 // not start with 'accessor_'. | 1937 // not start with 'accessor_'. |
1929 String::Utf8Value utf8(name); | 1938 String::Utf8Value utf8(name); |
1930 char* name_str = *utf8; | 1939 char* name_str = *utf8; |
1931 char prefix[] = "accessor_"; | 1940 char prefix[] = "accessor_"; |
1932 int i; | 1941 int i; |
1933 for (i = 0; name_str[i] && prefix[i]; ++i) { | 1942 for (i = 0; name_str[i] && prefix[i]; ++i) { |
1934 if (name_str[i] != prefix[i]) break; | 1943 if (name_str[i] != prefix[i]) break; |
1935 } | 1944 } |
1936 if (!prefix[i]) return; | 1945 if (!prefix[i]) return; |
1937 | 1946 |
1938 if (value->IsInt32() && value->Int32Value() < 10000) { | 1947 if (value->IsInt32() && value->Int32Value() < 10000) { |
1939 Handle<Object> self = Handle<Object>::Cast(info.This()); | 1948 Handle<Object> self = Handle<Object>::Cast(info.This()); |
1940 self->SetHiddenValue(name, value); | 1949 self->SetHiddenValue(name, value); |
1941 info.GetReturnValue().Set(value); | 1950 info.GetReturnValue().Set(value); |
1942 } | 1951 } |
1943 } | 1952 } |
1944 | 1953 |
| 1954 void InterceptorGetter(Local<Name> generic_name, |
| 1955 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1956 if (generic_name->IsSymbol()) return; |
| 1957 StringInterceptorGetter(Local<String>::Cast(generic_name), info); |
| 1958 } |
| 1959 |
| 1960 void InterceptorSetter(Local<Name> generic_name, |
| 1961 Local<Value> value, |
| 1962 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1963 if (generic_name->IsSymbol()) return; |
| 1964 StringInterceptorSetter(Local<String>::Cast(generic_name), value, info); |
| 1965 } |
| 1966 |
| 1967 void GenericInterceptorGetter(Local<Name> generic_name, |
| 1968 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1969 Local<String> str; |
| 1970 if (generic_name->IsSymbol()) { |
| 1971 Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); |
| 1972 if (name->IsUndefined()) return; |
| 1973 str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name)); |
| 1974 } else { |
| 1975 Local<String> name = Local<String>::Cast(generic_name); |
| 1976 String::Utf8Value utf8(name); |
| 1977 char* name_str = *utf8; |
| 1978 if (*name_str == '_') return; |
| 1979 str = String::Concat(v8_str("_str_"), name); |
| 1980 } |
| 1981 |
| 1982 Handle<Object> self = Handle<Object>::Cast(info.This()); |
| 1983 info.GetReturnValue().Set(self->Get(str)); |
| 1984 } |
| 1985 |
| 1986 void GenericInterceptorSetter(Local<Name> generic_name, |
| 1987 Local<Value> value, |
| 1988 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1989 Local<String> str; |
| 1990 if (generic_name->IsSymbol()) { |
| 1991 Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); |
| 1992 if (name->IsUndefined()) return; |
| 1993 str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name)); |
| 1994 } else { |
| 1995 Local<String> name = Local<String>::Cast(generic_name); |
| 1996 String::Utf8Value utf8(name); |
| 1997 char* name_str = *utf8; |
| 1998 if (*name_str == '_') return; |
| 1999 str = String::Concat(v8_str("_str_"), name); |
| 2000 } |
| 2001 |
| 2002 Handle<Object> self = Handle<Object>::Cast(info.This()); |
| 2003 self->Set(str, value); |
| 2004 info.GetReturnValue().Set(value); |
| 2005 } |
| 2006 |
1945 void AddAccessor(Handle<FunctionTemplate> templ, | 2007 void AddAccessor(Handle<FunctionTemplate> templ, |
1946 Handle<String> name, | 2008 Handle<String> name, |
1947 v8::AccessorGetterCallback getter, | 2009 v8::AccessorGetterCallback getter, |
1948 v8::AccessorSetterCallback setter) { | 2010 v8::AccessorSetterCallback setter) { |
1949 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); | 2011 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); |
1950 } | 2012 } |
1951 | 2013 |
1952 void AddInterceptor(Handle<FunctionTemplate> templ, | 2014 void AddInterceptor(Handle<FunctionTemplate> templ, |
1953 v8::NamedPropertyGetterCallback getter, | 2015 v8::NamedPropertyGetterCallback getter, |
1954 v8::NamedPropertySetterCallback setter) { | 2016 v8::NamedPropertySetterCallback setter) { |
1955 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 2017 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
1956 } | 2018 } |
1957 | 2019 |
1958 | 2020 |
1959 void AddAccessor(Handle<FunctionTemplate> templ, | 2021 void AddAccessor(Handle<FunctionTemplate> templ, |
1960 Handle<Name> name, | 2022 Handle<Name> name, |
1961 v8::AccessorNameGetterCallback getter, | 2023 v8::AccessorNameGetterCallback getter, |
1962 v8::AccessorNameSetterCallback setter) { | 2024 v8::AccessorNameSetterCallback setter) { |
1963 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); | 2025 templ->PrototypeTemplate()->SetAccessor(name, getter, setter); |
1964 } | 2026 } |
1965 | 2027 |
| 2028 void AddInterceptor(Handle<FunctionTemplate> templ, |
| 2029 v8::GenericNamedPropertyGetterCallback getter, |
| 2030 v8::GenericNamedPropertySetterCallback setter) { |
| 2031 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
| 2032 } |
| 2033 |
1966 | 2034 |
1967 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 2035 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
1968 v8::HandleScope scope(CcTest::isolate()); | 2036 v8::HandleScope scope(CcTest::isolate()); |
1969 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); | 2037 Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); |
1970 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); | 2038 Handle<FunctionTemplate> child = FunctionTemplate::New(CcTest::isolate()); |
1971 child->Inherit(parent); | 2039 child->Inherit(parent); |
1972 AddAccessor(parent, v8_str("age"), | 2040 AddAccessor(parent, v8_str("age"), |
1973 SimpleAccessorGetter, SimpleAccessorSetter); | 2041 SimpleAccessorGetter, SimpleAccessorSetter); |
1974 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 2042 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
1975 LocalContext env; | 2043 LocalContext env; |
1976 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2044 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
1977 CompileRun("var child = new Child;" | 2045 CompileRun("var child = new Child;" |
1978 "child.age = 10;"); | 2046 "child.age = 10;"); |
1979 ExpectBoolean("child.hasOwnProperty('age')", false); | 2047 ExpectBoolean("child.hasOwnProperty('age')", false); |
1980 ExpectInt32("child.age", 10); | 2048 ExpectInt32("child.age", 10); |
1981 ExpectInt32("child.accessor_age", 10); | 2049 ExpectInt32("child.accessor_age", 10); |
1982 } | 2050 } |
1983 | 2051 |
1984 | 2052 |
| 2053 THREADED_TEST(LegacyInterceptorDoesNotSeeSymbols) { |
| 2054 LocalContext env; |
| 2055 v8::Isolate* isolate = CcTest::isolate(); |
| 2056 v8::HandleScope scope(isolate); |
| 2057 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate); |
| 2058 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate); |
| 2059 v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age")); |
| 2060 |
| 2061 child->Inherit(parent); |
| 2062 AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter); |
| 2063 AddInterceptor(child, StringInterceptorGetter, StringInterceptorSetter); |
| 2064 |
| 2065 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2066 env->Global()->Set(v8_str("age"), age); |
| 2067 CompileRun("var child = new Child;" |
| 2068 "child[age] = 10;"); |
| 2069 ExpectInt32("child[age]", 10); |
| 2070 ExpectBoolean("child.hasOwnProperty('age')", false); |
| 2071 ExpectBoolean("child.hasOwnProperty('accessor_age')", true); |
| 2072 } |
| 2073 |
| 2074 |
| 2075 THREADED_TEST(GenericInterceptorDoesSeeSymbols) { |
| 2076 LocalContext env; |
| 2077 v8::Isolate* isolate = CcTest::isolate(); |
| 2078 v8::HandleScope scope(isolate); |
| 2079 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate); |
| 2080 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate); |
| 2081 v8::Local<v8::Symbol> age = v8::Symbol::New(isolate, v8_str("age")); |
| 2082 v8::Local<v8::Symbol> anon = v8::Symbol::New(isolate); |
| 2083 |
| 2084 child->Inherit(parent); |
| 2085 AddAccessor(parent, age, SymbolAccessorGetter, SymbolAccessorSetter); |
| 2086 AddInterceptor(child, GenericInterceptorGetter, GenericInterceptorSetter); |
| 2087 |
| 2088 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2089 env->Global()->Set(v8_str("age"), age); |
| 2090 env->Global()->Set(v8_str("anon"), anon); |
| 2091 CompileRun("var child = new Child;" |
| 2092 "child[age] = 10;"); |
| 2093 ExpectInt32("child[age]", 10); |
| 2094 ExpectInt32("child._sym_age", 10); |
| 2095 |
| 2096 // Check that it also sees strings. |
| 2097 CompileRun("child.foo = 47"); |
| 2098 ExpectInt32("child.foo", 47); |
| 2099 ExpectInt32("child._str_foo", 47); |
| 2100 |
| 2101 // Check that the interceptor can punt (in this case, on anonymous symbols). |
| 2102 CompileRun("child[anon] = 31337"); |
| 2103 ExpectInt32("child[anon]", 31337); |
| 2104 } |
| 2105 |
| 2106 |
1985 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) { | 2107 THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) { |
1986 v8::Isolate* isolate = CcTest::isolate(); | 2108 v8::Isolate* isolate = CcTest::isolate(); |
1987 v8::HandleScope scope(isolate); | 2109 v8::HandleScope scope(isolate); |
1988 LocalContext env; | 2110 LocalContext env; |
1989 v8::Local<v8::Value> res = CompileRun("var a = []; a;"); | 2111 v8::Local<v8::Value> res = CompileRun("var a = []; a;"); |
1990 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res))); | 2112 i::Handle<i::JSObject> a(v8::Utils::OpenHandle(v8::Object::Cast(*res))); |
1991 CHECK(a->map()->instance_descriptors()->IsFixedArray()); | 2113 CHECK(a->map()->instance_descriptors()->IsFixedArray()); |
1992 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); | 2114 CHECK_GT(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); |
1993 CompileRun("Object.defineProperty(a, 'length', { writable: false });"); | 2115 CompileRun("Object.defineProperty(a, 'length', { writable: false });"); |
1994 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); | 2116 CHECK_EQ(i::FixedArray::cast(a->map()->instance_descriptors())->length(), 0); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 | 2402 |
2281 static void CheckThisIndexedPropertyHandler( | 2403 static void CheckThisIndexedPropertyHandler( |
2282 uint32_t index, | 2404 uint32_t index, |
2283 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2405 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2284 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyHandler)); | 2406 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyHandler)); |
2285 ApiTestFuzzer::Fuzz(); | 2407 ApiTestFuzzer::Fuzz(); |
2286 CHECK(info.This()->Equals(bottom)); | 2408 CHECK(info.This()->Equals(bottom)); |
2287 } | 2409 } |
2288 | 2410 |
2289 static void CheckThisNamedPropertyHandler( | 2411 static void CheckThisNamedPropertyHandler( |
2290 Local<String> name, | 2412 Local<Name> name, |
2291 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2413 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2292 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler)); | 2414 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyHandler)); |
2293 ApiTestFuzzer::Fuzz(); | 2415 ApiTestFuzzer::Fuzz(); |
2294 CHECK(info.This()->Equals(bottom)); | 2416 CHECK(info.This()->Equals(bottom)); |
2295 } | 2417 } |
2296 | 2418 |
2297 void CheckThisIndexedPropertySetter( | 2419 void CheckThisIndexedPropertySetter( |
2298 uint32_t index, | 2420 uint32_t index, |
2299 Local<Value> value, | 2421 Local<Value> value, |
2300 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2422 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2301 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertySetter)); | 2423 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertySetter)); |
2302 ApiTestFuzzer::Fuzz(); | 2424 ApiTestFuzzer::Fuzz(); |
2303 CHECK(info.This()->Equals(bottom)); | 2425 CHECK(info.This()->Equals(bottom)); |
2304 } | 2426 } |
2305 | 2427 |
2306 | 2428 |
2307 void CheckThisNamedPropertySetter( | 2429 void CheckThisNamedPropertySetter( |
2308 Local<String> property, | 2430 Local<Name> property, |
2309 Local<Value> value, | 2431 Local<Value> value, |
2310 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2432 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2311 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter)); | 2433 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertySetter)); |
2312 ApiTestFuzzer::Fuzz(); | 2434 ApiTestFuzzer::Fuzz(); |
2313 CHECK(info.This()->Equals(bottom)); | 2435 CHECK(info.This()->Equals(bottom)); |
2314 } | 2436 } |
2315 | 2437 |
2316 void CheckThisIndexedPropertyQuery( | 2438 void CheckThisIndexedPropertyQuery( |
2317 uint32_t index, | 2439 uint32_t index, |
2318 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2440 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
2319 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyQuery)); | 2441 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyQuery)); |
2320 ApiTestFuzzer::Fuzz(); | 2442 ApiTestFuzzer::Fuzz(); |
2321 CHECK(info.This()->Equals(bottom)); | 2443 CHECK(info.This()->Equals(bottom)); |
2322 } | 2444 } |
2323 | 2445 |
2324 | 2446 |
2325 void CheckThisNamedPropertyQuery( | 2447 void CheckThisNamedPropertyQuery( |
2326 Local<String> property, | 2448 Local<Name> property, |
2327 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2449 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
2328 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery)); | 2450 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyQuery)); |
2329 ApiTestFuzzer::Fuzz(); | 2451 ApiTestFuzzer::Fuzz(); |
2330 CHECK(info.This()->Equals(bottom)); | 2452 CHECK(info.This()->Equals(bottom)); |
2331 } | 2453 } |
2332 | 2454 |
2333 | 2455 |
2334 void CheckThisIndexedPropertyDeleter( | 2456 void CheckThisIndexedPropertyDeleter( |
2335 uint32_t index, | 2457 uint32_t index, |
2336 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 2458 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
2337 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDeleter)); | 2459 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyDeleter)); |
2338 ApiTestFuzzer::Fuzz(); | 2460 ApiTestFuzzer::Fuzz(); |
2339 CHECK(info.This()->Equals(bottom)); | 2461 CHECK(info.This()->Equals(bottom)); |
2340 } | 2462 } |
2341 | 2463 |
2342 | 2464 |
2343 void CheckThisNamedPropertyDeleter( | 2465 void CheckThisNamedPropertyDeleter( |
2344 Local<String> property, | 2466 Local<Name> property, |
2345 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 2467 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
2346 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter)); | 2468 CheckReturnValue(info, FUNCTION_ADDR(CheckThisNamedPropertyDeleter)); |
2347 ApiTestFuzzer::Fuzz(); | 2469 ApiTestFuzzer::Fuzz(); |
2348 CHECK(info.This()->Equals(bottom)); | 2470 CHECK(info.This()->Equals(bottom)); |
2349 } | 2471 } |
2350 | 2472 |
2351 | 2473 |
2352 void CheckThisIndexedPropertyEnumerator( | 2474 void CheckThisIndexedPropertyEnumerator( |
2353 const v8::PropertyCallbackInfo<v8::Array>& info) { | 2475 const v8::PropertyCallbackInfo<v8::Array>& info) { |
2354 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyEnumerator)); | 2476 CheckReturnValue(info, FUNCTION_ADDR(CheckThisIndexedPropertyEnumerator)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 // Indexed and named deleter. | 2531 // Indexed and named deleter. |
2410 CompileRun("delete obj[0]"); | 2532 CompileRun("delete obj[0]"); |
2411 CompileRun("delete obj.x"); | 2533 CompileRun("delete obj.x"); |
2412 | 2534 |
2413 // Enumerators. | 2535 // Enumerators. |
2414 CompileRun("for (var p in obj) ;"); | 2536 CompileRun("for (var p in obj) ;"); |
2415 } | 2537 } |
2416 | 2538 |
2417 | 2539 |
2418 static void PrePropertyHandlerGet( | 2540 static void PrePropertyHandlerGet( |
2419 Local<String> key, | 2541 Local<Name> key, |
2420 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2542 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2421 ApiTestFuzzer::Fuzz(); | 2543 ApiTestFuzzer::Fuzz(); |
2422 if (v8_str("pre")->Equals(key)) { | 2544 if (v8_str("pre")->Equals(key)) { |
2423 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre")); | 2545 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre")); |
2424 } | 2546 } |
2425 } | 2547 } |
2426 | 2548 |
2427 | 2549 |
2428 static void PrePropertyHandlerQuery( | 2550 static void PrePropertyHandlerQuery( |
2429 Local<String> key, | 2551 Local<Name> key, |
2430 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2552 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
2431 if (v8_str("pre")->Equals(key)) { | 2553 if (v8_str("pre")->Equals(key)) { |
2432 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); | 2554 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); |
2433 } | 2555 } |
2434 } | 2556 } |
2435 | 2557 |
2436 | 2558 |
2437 THREADED_TEST(PrePropertyHandler) { | 2559 THREADED_TEST(PrePropertyHandler) { |
2438 v8::Isolate* isolate = CcTest::isolate(); | 2560 v8::Isolate* isolate = CcTest::isolate(); |
2439 v8::HandleScope scope(isolate); | 2561 v8::HandleScope scope(isolate); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 call_recursively_script = v8_compile("callScriptRecursively()"); | 2628 call_recursively_script = v8_compile("callScriptRecursively()"); |
2507 call_recursively_script->Run(); | 2629 call_recursively_script->Run(); |
2508 call_recursively_script = v8::Handle<Script>(); | 2630 call_recursively_script = v8::Handle<Script>(); |
2509 | 2631 |
2510 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); | 2632 env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); |
2511 CompileRun("callFunctionRecursively()"); | 2633 CompileRun("callFunctionRecursively()"); |
2512 } | 2634 } |
2513 | 2635 |
2514 | 2636 |
2515 static void ThrowingPropertyHandlerGet( | 2637 static void ThrowingPropertyHandlerGet( |
2516 Local<String> key, | 2638 Local<Name> key, |
2517 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2639 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2640 // Since this interceptor is used on "with" objects, the runtime will look up |
| 2641 // @@unscopables. Punt. |
| 2642 if (key->IsSymbol()) return; |
2518 ApiTestFuzzer::Fuzz(); | 2643 ApiTestFuzzer::Fuzz(); |
2519 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key)); | 2644 info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key)); |
2520 } | 2645 } |
2521 | 2646 |
2522 | 2647 |
2523 static void ThrowingPropertyHandlerSet( | 2648 static void ThrowingPropertyHandlerSet( |
2524 Local<String> key, | 2649 Local<Name> key, |
2525 Local<Value>, | 2650 Local<Value>, |
2526 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2651 const v8::PropertyCallbackInfo<v8::Value>& info) { |
2527 info.GetIsolate()->ThrowException(key); | 2652 info.GetIsolate()->ThrowException(key); |
2528 info.GetReturnValue().SetUndefined(); // not the same as empty handle | 2653 info.GetReturnValue().SetUndefined(); // not the same as empty handle |
2529 } | 2654 } |
2530 | 2655 |
2531 | 2656 |
2532 THREADED_TEST(CallbackExceptionRegression) { | 2657 THREADED_TEST(CallbackExceptionRegression) { |
2533 v8::Isolate* isolate = CcTest::isolate(); | 2658 v8::Isolate* isolate = CcTest::isolate(); |
2534 v8::HandleScope scope(isolate); | 2659 v8::HandleScope scope(isolate); |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3320 // If it did we would have full access to the hidden properties in | 3445 // If it did we would have full access to the hidden properties in |
3321 // the accessor. | 3446 // the accessor. |
3322 CHECK(obj->SetHiddenValue(key, v8::Integer::New(env->GetIsolate(), 42))); | 3447 CHECK(obj->SetHiddenValue(key, v8::Integer::New(env->GetIsolate(), 42))); |
3323 ExpectFalse("set_called"); | 3448 ExpectFalse("set_called"); |
3324 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); | 3449 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); |
3325 } | 3450 } |
3326 | 3451 |
3327 | 3452 |
3328 static bool interceptor_for_hidden_properties_called; | 3453 static bool interceptor_for_hidden_properties_called; |
3329 static void InterceptorForHiddenProperties( | 3454 static void InterceptorForHiddenProperties( |
3330 Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 3455 Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
3331 interceptor_for_hidden_properties_called = true; | 3456 interceptor_for_hidden_properties_called = true; |
3332 } | 3457 } |
3333 | 3458 |
3334 | 3459 |
3335 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 3460 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
3336 LocalContext context; | 3461 LocalContext context; |
3337 v8::Isolate* isolate = context->GetIsolate(); | 3462 v8::Isolate* isolate = context->GetIsolate(); |
3338 v8::HandleScope scope(isolate); | 3463 v8::HandleScope scope(isolate); |
3339 | 3464 |
3340 interceptor_for_hidden_properties_called = false; | 3465 interceptor_for_hidden_properties_called = false; |
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5889 v8_str("donut")); | 6014 v8_str("donut")); |
5890 LocalContext context; | 6015 LocalContext context; |
5891 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6016 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
5892 Local<Script> script = v8_compile("obj.x = 4; obj.x"); | 6017 Local<Script> script = v8_compile("obj.x = 4; obj.x"); |
5893 for (int i = 0; i < 10; i++) { | 6018 for (int i = 0; i < 10; i++) { |
5894 script->Run(); | 6019 script->Run(); |
5895 } | 6020 } |
5896 } | 6021 } |
5897 | 6022 |
5898 | 6023 |
5899 static void XPropertyGetter(Local<String> property, | 6024 static void XPropertyGetter(Local<Name> property, |
5900 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6025 const v8::PropertyCallbackInfo<v8::Value>& info) { |
5901 ApiTestFuzzer::Fuzz(); | 6026 ApiTestFuzzer::Fuzz(); |
5902 CHECK(info.Data()->IsUndefined()); | 6027 CHECK(info.Data()->IsUndefined()); |
5903 info.GetReturnValue().Set(property); | 6028 info.GetReturnValue().Set(property); |
5904 } | 6029 } |
5905 | 6030 |
5906 | 6031 |
5907 THREADED_TEST(NamedInterceptorPropertyRead) { | 6032 THREADED_TEST(NamedInterceptorPropertyRead) { |
5908 v8::Isolate* isolate = CcTest::isolate(); | 6033 v8::Isolate* isolate = CcTest::isolate(); |
5909 v8::HandleScope scope(isolate); | 6034 v8::HandleScope scope(isolate); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5985 | 6110 |
5986 // Return to the original context and force some object to the slow case | 6111 // Return to the original context and force some object to the slow case |
5987 // to cause the NormalizedMapCache to verify. | 6112 // to cause the NormalizedMapCache to verify. |
5988 context1->Enter(); | 6113 context1->Enter(); |
5989 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 6114 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
5990 context1->Exit(); | 6115 context1->Exit(); |
5991 } | 6116 } |
5992 | 6117 |
5993 | 6118 |
5994 static void SetXOnPrototypeGetter( | 6119 static void SetXOnPrototypeGetter( |
5995 Local<String> property, | 6120 Local<Name> property, |
5996 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6121 const v8::PropertyCallbackInfo<v8::Value>& info) { |
5997 // Set x on the prototype object and do not handle the get request. | 6122 // Set x on the prototype object and do not handle the get request. |
5998 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 6123 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
5999 proto.As<v8::Object>()->Set(v8_str("x"), | 6124 proto.As<v8::Object>()->Set(v8_str("x"), |
6000 v8::Integer::New(info.GetIsolate(), 23)); | 6125 v8::Integer::New(info.GetIsolate(), 23)); |
6001 } | 6126 } |
6002 | 6127 |
6003 | 6128 |
6004 // This is a regression test for http://crbug.com/20104. Map | 6129 // This is a regression test for http://crbug.com/20104. Map |
6005 // transitions should not interfere with post interceptor lookup. | 6130 // transitions should not interfere with post interceptor lookup. |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7442 v8::HandleScope scope(isolate); | 7567 v8::HandleScope scope(isolate); |
7443 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); | 7568 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(isolate); |
7444 global->Set(v8_str("f"), | 7569 global->Set(v8_str("f"), |
7445 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); | 7570 v8::FunctionTemplate::New(isolate, ArgumentsTestCallback)); |
7446 LocalContext context(NULL, global); | 7571 LocalContext context(NULL, global); |
7447 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 7572 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
7448 v8_compile("f(1, 2, 3)")->Run(); | 7573 v8_compile("f(1, 2, 3)")->Run(); |
7449 } | 7574 } |
7450 | 7575 |
7451 | 7576 |
7452 static void NoBlockGetterX(Local<String> name, | 7577 static void NoBlockGetterX(Local<Name> name, |
7453 const v8::PropertyCallbackInfo<v8::Value>&) { | 7578 const v8::PropertyCallbackInfo<v8::Value>&) { |
7454 } | 7579 } |
7455 | 7580 |
7456 | 7581 |
7457 static void NoBlockGetterI(uint32_t index, | 7582 static void NoBlockGetterI(uint32_t index, |
7458 const v8::PropertyCallbackInfo<v8::Value>&) { | 7583 const v8::PropertyCallbackInfo<v8::Value>&) { |
7459 } | 7584 } |
7460 | 7585 |
7461 | 7586 |
7462 static void PDeleter(Local<String> name, | 7587 static void PDeleter(Local<Name> name, |
7463 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 7588 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
7464 if (!name->Equals(v8_str("foo"))) { | 7589 if (!name->Equals(v8_str("foo"))) { |
7465 return; // not intercepted | 7590 return; // not intercepted |
7466 } | 7591 } |
7467 | 7592 |
7468 info.GetReturnValue().Set(false); // intercepted, don't delete the property | 7593 info.GetReturnValue().Set(false); // intercepted, don't delete the property |
7469 } | 7594 } |
7470 | 7595 |
7471 | 7596 |
7472 static void IDeleter(uint32_t index, | 7597 static void IDeleter(uint32_t index, |
(...skipping 26 matching lines...) Expand all Loading... |
7499 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); | 7624 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); |
7500 | 7625 |
7501 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); | 7626 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); |
7502 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); | 7627 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); |
7503 | 7628 |
7504 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); | 7629 CHECK_EQ(v8_compile("k[2]")->Run(), v8_num(2)); |
7505 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); | 7630 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); |
7506 } | 7631 } |
7507 | 7632 |
7508 | 7633 |
7509 static void GetK(Local<String> name, | 7634 static void GetK(Local<Name> name, |
7510 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7635 const v8::PropertyCallbackInfo<v8::Value>& info) { |
7511 ApiTestFuzzer::Fuzz(); | 7636 ApiTestFuzzer::Fuzz(); |
7512 if (name->Equals(v8_str("foo")) || | 7637 if (name->Equals(v8_str("foo")) || |
7513 name->Equals(v8_str("bar")) || | 7638 name->Equals(v8_str("bar")) || |
7514 name->Equals(v8_str("baz"))) { | 7639 name->Equals(v8_str("baz"))) { |
7515 info.GetReturnValue().SetUndefined(); | 7640 info.GetReturnValue().SetUndefined(); |
7516 } | 7641 } |
7517 } | 7642 } |
7518 | 7643 |
7519 | 7644 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7633 "var o2 = { __proto__: o1 };" | 7758 "var o2 = { __proto__: o1 };" |
7634 "var o3 = { __proto__: o2 };" | 7759 "var o3 = { __proto__: o2 };" |
7635 "var o4 = { __proto__: o3 };" | 7760 "var o4 = { __proto__: o3 };" |
7636 "for (var i = 0; i < 10; i++) o4.p4;" | 7761 "for (var i = 0; i < 10; i++) o4.p4;" |
7637 "for (var i = 0; i < 10; i++) o3.p3;" | 7762 "for (var i = 0; i < 10; i++) o3.p3;" |
7638 "for (var i = 0; i < 10; i++) o2.p2;" | 7763 "for (var i = 0; i < 10; i++) o2.p2;" |
7639 "for (var i = 0; i < 10; i++) o1.p1;"); | 7764 "for (var i = 0; i < 10; i++) o1.p1;"); |
7640 } | 7765 } |
7641 | 7766 |
7642 | 7767 |
7643 static void PGetter2(Local<String> name, | 7768 static void PGetter2(Local<Name> name, |
7644 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7769 const v8::PropertyCallbackInfo<v8::Value>& info) { |
7645 ApiTestFuzzer::Fuzz(); | 7770 ApiTestFuzzer::Fuzz(); |
7646 p_getter_count2++; | 7771 p_getter_count2++; |
7647 v8::Handle<v8::Object> global = | 7772 v8::Handle<v8::Object> global = |
7648 info.GetIsolate()->GetCurrentContext()->Global(); | 7773 info.GetIsolate()->GetCurrentContext()->Global(); |
7649 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); | 7774 CHECK_EQ(info.Holder(), global->Get(v8_str("o1"))); |
7650 if (name->Equals(v8_str("p1"))) { | 7775 if (name->Equals(v8_str("p1"))) { |
7651 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); | 7776 CHECK_EQ(info.This(), global->Get(v8_str("o1"))); |
7652 } else if (name->Equals(v8_str("p2"))) { | 7777 } else if (name->Equals(v8_str("p2"))) { |
7653 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); | 7778 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9539 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 9664 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
9540 v8::Isolate* isolate = CcTest::isolate(); | 9665 v8::Isolate* isolate = CcTest::isolate(); |
9541 v8::HandleScope handle_scope(isolate); | 9666 v8::HandleScope handle_scope(isolate); |
9542 v8::Handle<v8::ObjectTemplate> obj_template = | 9667 v8::Handle<v8::ObjectTemplate> obj_template = |
9543 v8::ObjectTemplate::New(isolate); | 9668 v8::ObjectTemplate::New(isolate); |
9544 | 9669 |
9545 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); | 9670 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); |
9546 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); | 9671 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); |
9547 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 9672 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, |
9548 IndexedPropertyEnumerator); | 9673 IndexedPropertyEnumerator); |
9549 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, | 9674 // TODO(wingo): Types needed to disambiguate between deprecated and new |
| 9675 // SetNamedPropertyHandler implementations. Go back to just passing NULL |
| 9676 // values once deprecated API is removed. |
| 9677 v8::GenericNamedPropertyGetterCallback getter = NULL; |
| 9678 obj_template->SetNamedPropertyHandler(getter, NULL, NULL, NULL, |
9550 NamedPropertyEnumerator); | 9679 NamedPropertyEnumerator); |
9551 | 9680 |
9552 LocalContext context; | 9681 LocalContext context; |
9553 v8::Handle<v8::Object> global = context->Global(); | 9682 v8::Handle<v8::Object> global = context->Global(); |
9554 global->Set(v8_str("object"), obj_template->NewInstance()); | 9683 global->Set(v8_str("object"), obj_template->NewInstance()); |
9555 | 9684 |
9556 v8::Handle<v8::Value> result = | 9685 v8::Handle<v8::Value> result = |
9557 CompileRun("Object.getOwnPropertyNames(object)"); | 9686 CompileRun("Object.getOwnPropertyNames(object)"); |
9558 CHECK(result->IsArray()); | 9687 CHECK(result->IsArray()); |
9559 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result); | 9688 v8::Handle<v8::Array> result_array = v8::Handle<v8::Array>::Cast(result); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9830 | 9959 |
9831 value = v8_compile("var p = 'as' + 'df';")->Run(); | 9960 value = v8_compile("var p = 'as' + 'df';")->Run(); |
9832 value = v8_compile("obj[p];")->Run(); | 9961 value = v8_compile("obj[p];")->Run(); |
9833 | 9962 |
9834 context1->Exit(); | 9963 context1->Exit(); |
9835 context0->Exit(); | 9964 context0->Exit(); |
9836 } | 9965 } |
9837 | 9966 |
9838 | 9967 |
9839 static void AccessControlNamedGetter( | 9968 static void AccessControlNamedGetter( |
9840 Local<String>, | 9969 Local<Name>, |
9841 const v8::PropertyCallbackInfo<v8::Value>& info) { | 9970 const v8::PropertyCallbackInfo<v8::Value>& info) { |
9842 info.GetReturnValue().Set(42); | 9971 info.GetReturnValue().Set(42); |
9843 } | 9972 } |
9844 | 9973 |
9845 | 9974 |
9846 static void AccessControlNamedSetter( | 9975 static void AccessControlNamedSetter( |
9847 Local<String>, | 9976 Local<Name>, |
9848 Local<Value> value, | 9977 Local<Value> value, |
9849 const v8::PropertyCallbackInfo<v8::Value>& info) { | 9978 const v8::PropertyCallbackInfo<v8::Value>& info) { |
9850 info.GetReturnValue().Set(value); | 9979 info.GetReturnValue().Set(value); |
9851 } | 9980 } |
9852 | 9981 |
9853 | 9982 |
9854 static void AccessControlIndexedGetter( | 9983 static void AccessControlIndexedGetter( |
9855 uint32_t index, | 9984 uint32_t index, |
9856 const v8::PropertyCallbackInfo<v8::Value>& info) { | 9985 const v8::PropertyCallbackInfo<v8::Value>& info) { |
9857 info.GetReturnValue().Set(v8_num(42)); | 9986 info.GetReturnValue().Set(v8_num(42)); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9962 context->Global()->Set(v8_str("i"), o); | 10091 context->Global()->Set(v8_str("i"), o); |
9963 Local<Value> value = CompileRun("i.x"); | 10092 Local<Value> value = CompileRun("i.x"); |
9964 CHECK_EQ(42, value->Int32Value()); | 10093 CHECK_EQ(42, value->Int32Value()); |
9965 | 10094 |
9966 value = CompileRun("i.f()"); | 10095 value = CompileRun("i.f()"); |
9967 CHECK_EQ(12, value->Int32Value()); | 10096 CHECK_EQ(12, value->Int32Value()); |
9968 } | 10097 } |
9969 | 10098 |
9970 | 10099 |
9971 static void GlobalObjectInstancePropertiesGet( | 10100 static void GlobalObjectInstancePropertiesGet( |
9972 Local<String> key, | 10101 Local<Name> key, |
9973 const v8::PropertyCallbackInfo<v8::Value>&) { | 10102 const v8::PropertyCallbackInfo<v8::Value>&) { |
9974 ApiTestFuzzer::Fuzz(); | 10103 ApiTestFuzzer::Fuzz(); |
9975 } | 10104 } |
9976 | 10105 |
9977 | 10106 |
9978 THREADED_TEST(GlobalObjectInstanceProperties) { | 10107 THREADED_TEST(GlobalObjectInstanceProperties) { |
9979 v8::Isolate* isolate = CcTest::isolate(); | 10108 v8::Isolate* isolate = CcTest::isolate(); |
9980 v8::HandleScope handle_scope(isolate); | 10109 v8::HandleScope handle_scope(isolate); |
9981 | 10110 |
9982 Local<Value> global_object; | 10111 Local<Value> global_object; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10100 shadow_y_getter_call_count++; | 10229 shadow_y_getter_call_count++; |
10101 info.GetReturnValue().Set(v8_num(shadow_y)); | 10230 info.GetReturnValue().Set(v8_num(shadow_y)); |
10102 } | 10231 } |
10103 | 10232 |
10104 | 10233 |
10105 static void ShadowIndexedGet(uint32_t index, | 10234 static void ShadowIndexedGet(uint32_t index, |
10106 const v8::PropertyCallbackInfo<v8::Value>&) { | 10235 const v8::PropertyCallbackInfo<v8::Value>&) { |
10107 } | 10236 } |
10108 | 10237 |
10109 | 10238 |
10110 static void ShadowNamedGet(Local<String> key, | 10239 static void ShadowNamedGet(Local<Name> key, |
10111 const v8::PropertyCallbackInfo<v8::Value>&) { | 10240 const v8::PropertyCallbackInfo<v8::Value>&) { |
10112 } | 10241 } |
10113 | 10242 |
10114 | 10243 |
10115 THREADED_TEST(ShadowObject) { | 10244 THREADED_TEST(ShadowObject) { |
10116 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; | 10245 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; |
10117 v8::Isolate* isolate = CcTest::isolate(); | 10246 v8::Isolate* isolate = CcTest::isolate(); |
10118 v8::HandleScope handle_scope(isolate); | 10247 v8::HandleScope handle_scope(isolate); |
10119 | 10248 |
10120 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate); | 10249 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate); |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11223 } | 11352 } |
11224 } | 11353 } |
11225 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate)); | 11354 CHECK_EQ(kIterations, v8::HandleScope::NumberOfHandles(isolate)); |
11226 } | 11355 } |
11227 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); | 11356 CHECK_EQ(0, v8::HandleScope::NumberOfHandles(isolate)); |
11228 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations)); | 11357 CHECK_EQ(kNesting * kIterations, Recurse(isolate, kNesting, kIterations)); |
11229 } | 11358 } |
11230 | 11359 |
11231 | 11360 |
11232 static void InterceptorHasOwnPropertyGetter( | 11361 static void InterceptorHasOwnPropertyGetter( |
11233 Local<String> name, | 11362 Local<Name> name, |
11234 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11363 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11235 ApiTestFuzzer::Fuzz(); | 11364 ApiTestFuzzer::Fuzz(); |
11236 } | 11365 } |
11237 | 11366 |
11238 | 11367 |
11239 THREADED_TEST(InterceptorHasOwnProperty) { | 11368 THREADED_TEST(InterceptorHasOwnProperty) { |
11240 LocalContext context; | 11369 LocalContext context; |
11241 v8::Isolate* isolate = context->GetIsolate(); | 11370 v8::Isolate* isolate = context->GetIsolate(); |
11242 v8::HandleScope scope(isolate); | 11371 v8::HandleScope scope(isolate); |
11243 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); | 11372 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate); |
(...skipping 10 matching lines...) Expand all Loading... |
11254 "o.hasOwnProperty('ostehaps');"); | 11383 "o.hasOwnProperty('ostehaps');"); |
11255 CHECK_EQ(true, value->BooleanValue()); | 11384 CHECK_EQ(true, value->BooleanValue()); |
11256 value = CompileRun( | 11385 value = CompileRun( |
11257 "var p = new constructor();" | 11386 "var p = new constructor();" |
11258 "p.hasOwnProperty('ostehaps');"); | 11387 "p.hasOwnProperty('ostehaps');"); |
11259 CHECK_EQ(false, value->BooleanValue()); | 11388 CHECK_EQ(false, value->BooleanValue()); |
11260 } | 11389 } |
11261 | 11390 |
11262 | 11391 |
11263 static void InterceptorHasOwnPropertyGetterGC( | 11392 static void InterceptorHasOwnPropertyGetterGC( |
11264 Local<String> name, | 11393 Local<Name> name, |
11265 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11394 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11266 ApiTestFuzzer::Fuzz(); | 11395 ApiTestFuzzer::Fuzz(); |
11267 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 11396 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
11268 } | 11397 } |
11269 | 11398 |
11270 | 11399 |
11271 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { | 11400 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { |
11272 LocalContext context; | 11401 LocalContext context; |
11273 v8::Isolate* isolate = context->GetIsolate(); | 11402 v8::Isolate* isolate = context->GetIsolate(); |
11274 v8::HandleScope scope(isolate); | 11403 v8::HandleScope scope(isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
11291 "x = makestr(31415);" | 11420 "x = makestr(31415);" |
11292 "x = makestr(23456);"); | 11421 "x = makestr(23456);"); |
11293 v8::Handle<Value> value = CompileRun( | 11422 v8::Handle<Value> value = CompileRun( |
11294 "var o = new constructor();" | 11423 "var o = new constructor();" |
11295 "o.__proto__ = new String(x);" | 11424 "o.__proto__ = new String(x);" |
11296 "o.hasOwnProperty('ostehaps');"); | 11425 "o.hasOwnProperty('ostehaps');"); |
11297 CHECK_EQ(false, value->BooleanValue()); | 11426 CHECK_EQ(false, value->BooleanValue()); |
11298 } | 11427 } |
11299 | 11428 |
11300 | 11429 |
11301 typedef void (*NamedPropertyGetter)( | 11430 static void CheckInterceptorLoadIC( |
11302 Local<String> property, | 11431 v8::GenericNamedPropertyGetterCallback getter, const char* source, |
11303 const v8::PropertyCallbackInfo<v8::Value>& info); | 11432 int expected) { |
11304 | |
11305 | |
11306 static void CheckInterceptorLoadIC(NamedPropertyGetter getter, | |
11307 const char* source, | |
11308 int expected) { | |
11309 v8::Isolate* isolate = CcTest::isolate(); | 11433 v8::Isolate* isolate = CcTest::isolate(); |
11310 v8::HandleScope scope(isolate); | 11434 v8::HandleScope scope(isolate); |
11311 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); | 11435 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); |
11312 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); | 11436 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); |
11313 LocalContext context; | 11437 LocalContext context; |
11314 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11438 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
11315 v8::Handle<Value> value = CompileRun(source); | 11439 v8::Handle<Value> value = CompileRun(source); |
11316 CHECK_EQ(expected, value->Int32Value()); | 11440 CHECK_EQ(expected, value->Int32Value()); |
11317 } | 11441 } |
11318 | 11442 |
11319 | 11443 |
11320 static void InterceptorLoadICGetter( | 11444 static void InterceptorLoadICGetter( |
11321 Local<String> name, | 11445 Local<Name> name, |
11322 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11446 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11323 ApiTestFuzzer::Fuzz(); | 11447 ApiTestFuzzer::Fuzz(); |
11324 v8::Isolate* isolate = CcTest::isolate(); | 11448 v8::Isolate* isolate = CcTest::isolate(); |
11325 CHECK_EQ(isolate, info.GetIsolate()); | 11449 CHECK_EQ(isolate, info.GetIsolate()); |
11326 CHECK_EQ(v8_str("data"), info.Data()); | 11450 CHECK_EQ(v8_str("data"), info.Data()); |
11327 CHECK_EQ(v8_str("x"), name); | 11451 CHECK_EQ(v8_str("x"), name); |
11328 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); | 11452 info.GetReturnValue().Set(v8::Integer::New(isolate, 42)); |
11329 } | 11453 } |
11330 | 11454 |
11331 | 11455 |
11332 // This test should hit the load IC for the interceptor case. | 11456 // This test should hit the load IC for the interceptor case. |
11333 THREADED_TEST(InterceptorLoadIC) { | 11457 THREADED_TEST(InterceptorLoadIC) { |
11334 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 11458 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
11335 "var result = 0;" | 11459 "var result = 0;" |
11336 "for (var i = 0; i < 1000; i++) {" | 11460 "for (var i = 0; i < 1000; i++) {" |
11337 " result = o.x;" | 11461 " result = o.x;" |
11338 "}", | 11462 "}", |
11339 42); | 11463 42); |
11340 } | 11464 } |
11341 | 11465 |
11342 | 11466 |
11343 // Below go several tests which verify that JITing for various | 11467 // Below go several tests which verify that JITing for various |
11344 // configurations of interceptor and explicit fields works fine | 11468 // configurations of interceptor and explicit fields works fine |
11345 // (those cases are special cased to get better performance). | 11469 // (those cases are special cased to get better performance). |
11346 | 11470 |
11347 static void InterceptorLoadXICGetter( | 11471 static void InterceptorLoadXICGetter( |
11348 Local<String> name, | 11472 Local<Name> name, |
11349 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11473 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11350 ApiTestFuzzer::Fuzz(); | 11474 ApiTestFuzzer::Fuzz(); |
11351 info.GetReturnValue().Set( | 11475 info.GetReturnValue().Set( |
11352 v8_str("x")->Equals(name) ? | 11476 v8_str("x")->Equals(name) ? |
11353 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) : | 11477 v8::Handle<v8::Value>(v8::Integer::New(info.GetIsolate(), 42)) : |
11354 v8::Handle<v8::Value>()); | 11478 v8::Handle<v8::Value>()); |
11355 } | 11479 } |
11356 | 11480 |
11357 | 11481 |
11358 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { | 11482 THREADED_TEST(InterceptorLoadICWithFieldOnHolder) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11454 "for (var i = 0; i < 1000; i++) {" | 11578 "for (var i = 0; i < 1000; i++) {" |
11455 " result += o.y;" | 11579 " result += o.y;" |
11456 "}" | 11580 "}" |
11457 "result;", | 11581 "result;", |
11458 42 * 1000); | 11582 42 * 1000); |
11459 } | 11583 } |
11460 | 11584 |
11461 | 11585 |
11462 static int interceptor_load_not_handled_calls = 0; | 11586 static int interceptor_load_not_handled_calls = 0; |
11463 static void InterceptorLoadNotHandled( | 11587 static void InterceptorLoadNotHandled( |
11464 Local<String> name, | 11588 Local<Name> name, |
11465 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11589 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11466 ++interceptor_load_not_handled_calls; | 11590 ++interceptor_load_not_handled_calls; |
11467 } | 11591 } |
11468 | 11592 |
11469 | 11593 |
11470 // Test how post-interceptor lookups are done in the non-cacheable | 11594 // Test how post-interceptor lookups are done in the non-cacheable |
11471 // case: the interceptor should not be invoked during this lookup. | 11595 // case: the interceptor should not be invoked during this lookup. |
11472 THREADED_TEST(InterceptorLoadICPostInterceptor) { | 11596 THREADED_TEST(InterceptorLoadICPostInterceptor) { |
11473 interceptor_load_not_handled_calls = 0; | 11597 interceptor_load_not_handled_calls = 0; |
11474 CheckInterceptorLoadIC(InterceptorLoadNotHandled, | 11598 CheckInterceptorLoadIC(InterceptorLoadNotHandled, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11697 "var result = 0;" | 11821 "var result = 0;" |
11698 "for (var i = 0; i < 10; i++) {" | 11822 "for (var i = 0; i < 10; i++) {" |
11699 " result += o.y;" | 11823 " result += o.y;" |
11700 "}" | 11824 "}" |
11701 "result"); | 11825 "result"); |
11702 CHECK_EQ(42 * 10, value->Int32Value()); | 11826 CHECK_EQ(42 * 10, value->Int32Value()); |
11703 } | 11827 } |
11704 | 11828 |
11705 | 11829 |
11706 static void InterceptorLoadICGetter0( | 11830 static void InterceptorLoadICGetter0( |
11707 Local<String> name, | 11831 Local<Name> name, |
11708 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11832 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11709 ApiTestFuzzer::Fuzz(); | 11833 ApiTestFuzzer::Fuzz(); |
11710 CHECK(v8_str("x")->Equals(name)); | 11834 CHECK(v8_str("x")->Equals(name)); |
11711 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0)); | 11835 info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), 0)); |
11712 } | 11836 } |
11713 | 11837 |
11714 | 11838 |
11715 THREADED_TEST(InterceptorReturningZero) { | 11839 THREADED_TEST(InterceptorReturningZero) { |
11716 CheckInterceptorLoadIC(InterceptorLoadICGetter0, | 11840 CheckInterceptorLoadIC(InterceptorLoadICGetter0, |
11717 "o.x == undefined ? 1 : 0", | 11841 "o.x == undefined ? 1 : 0", |
11718 0); | 11842 0); |
11719 } | 11843 } |
11720 | 11844 |
11721 | 11845 |
11722 static void InterceptorStoreICSetter( | 11846 static void InterceptorStoreICSetter( |
11723 Local<String> key, | 11847 Local<Name> key, |
11724 Local<Value> value, | 11848 Local<Value> value, |
11725 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11849 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11726 CHECK(v8_str("x")->Equals(key)); | 11850 CHECK(v8_str("x")->Equals(key)); |
11727 CHECK_EQ(42, value->Int32Value()); | 11851 CHECK_EQ(42, value->Int32Value()); |
11728 info.GetReturnValue().Set(value); | 11852 info.GetReturnValue().Set(value); |
11729 } | 11853 } |
11730 | 11854 |
11731 | 11855 |
11732 // This test should hit the store IC for the interceptor case. | 11856 // This test should hit the store IC for the interceptor case. |
11733 THREADED_TEST(InterceptorStoreIC) { | 11857 THREADED_TEST(InterceptorStoreIC) { |
(...skipping 28 matching lines...) Expand all Loading... |
11762 } | 11886 } |
11763 | 11887 |
11764 | 11888 |
11765 | 11889 |
11766 | 11890 |
11767 v8::Handle<Value> call_ic_function; | 11891 v8::Handle<Value> call_ic_function; |
11768 v8::Handle<Value> call_ic_function2; | 11892 v8::Handle<Value> call_ic_function2; |
11769 v8::Handle<Value> call_ic_function3; | 11893 v8::Handle<Value> call_ic_function3; |
11770 | 11894 |
11771 static void InterceptorCallICGetter( | 11895 static void InterceptorCallICGetter( |
11772 Local<String> name, | 11896 Local<Name> name, |
11773 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11897 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11774 ApiTestFuzzer::Fuzz(); | 11898 ApiTestFuzzer::Fuzz(); |
11775 CHECK(v8_str("x")->Equals(name)); | 11899 CHECK(v8_str("x")->Equals(name)); |
11776 info.GetReturnValue().Set(call_ic_function); | 11900 info.GetReturnValue().Set(call_ic_function); |
11777 } | 11901 } |
11778 | 11902 |
11779 | 11903 |
11780 // This test should hit the call IC for the interceptor case. | 11904 // This test should hit the call IC for the interceptor case. |
11781 THREADED_TEST(InterceptorCallIC) { | 11905 THREADED_TEST(InterceptorCallIC) { |
11782 v8::Isolate* isolate = CcTest::isolate(); | 11906 v8::Isolate* isolate = CcTest::isolate(); |
(...skipping 27 matching lines...) Expand all Loading... |
11810 "var result = 0;" | 11934 "var result = 0;" |
11811 "for (var i = 0; i < 7; i++) {" | 11935 "for (var i = 0; i < 7; i++) {" |
11812 " result = o.x(41);" | 11936 " result = o.x(41);" |
11813 "}"); | 11937 "}"); |
11814 CHECK_EQ(42, value->Int32Value()); | 11938 CHECK_EQ(42, value->Int32Value()); |
11815 } | 11939 } |
11816 | 11940 |
11817 | 11941 |
11818 static v8::Handle<Value> call_ic_function4; | 11942 static v8::Handle<Value> call_ic_function4; |
11819 static void InterceptorCallICGetter4( | 11943 static void InterceptorCallICGetter4( |
11820 Local<String> name, | 11944 Local<Name> name, |
11821 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11945 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11822 ApiTestFuzzer::Fuzz(); | 11946 ApiTestFuzzer::Fuzz(); |
11823 CHECK(v8_str("x")->Equals(name)); | 11947 CHECK(v8_str("x")->Equals(name)); |
11824 info.GetReturnValue().Set(call_ic_function4); | 11948 info.GetReturnValue().Set(call_ic_function4); |
11825 } | 11949 } |
11826 | 11950 |
11827 | 11951 |
11828 // This test checks that if interceptor provides a function, | 11952 // This test checks that if interceptor provides a function, |
11829 // even if we cached shadowed variant, interceptor's function | 11953 // even if we cached shadowed variant, interceptor's function |
11830 // is invoked | 11954 // is invoked |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11891 "var result = 0;" | 12015 "var result = 0;" |
11892 "for (var i = 0; i < 1000; i++) {" | 12016 "for (var i = 0; i < 1000; i++) {" |
11893 " result = o.x(42);" | 12017 " result = o.x(42);" |
11894 "}"); | 12018 "}"); |
11895 CHECK_EQ(43, value->Int32Value()); | 12019 CHECK_EQ(43, value->Int32Value()); |
11896 } | 12020 } |
11897 | 12021 |
11898 | 12022 |
11899 static v8::Handle<Value> call_ic_function5; | 12023 static v8::Handle<Value> call_ic_function5; |
11900 static void InterceptorCallICGetter5( | 12024 static void InterceptorCallICGetter5( |
11901 Local<String> name, | 12025 Local<Name> name, |
11902 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12026 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11903 ApiTestFuzzer::Fuzz(); | 12027 ApiTestFuzzer::Fuzz(); |
11904 if (v8_str("x")->Equals(name)) | 12028 if (v8_str("x")->Equals(name)) |
11905 info.GetReturnValue().Set(call_ic_function5); | 12029 info.GetReturnValue().Set(call_ic_function5); |
11906 } | 12030 } |
11907 | 12031 |
11908 | 12032 |
11909 // This test checks that if interceptor provides a function, | 12033 // This test checks that if interceptor provides a function, |
11910 // even if we cached constant function, interceptor's function | 12034 // even if we cached constant function, interceptor's function |
11911 // is invoked | 12035 // is invoked |
(...skipping 13 matching lines...) Expand all Loading... |
11925 "var result = 0;" | 12049 "var result = 0;" |
11926 "for (var i = 0; i < 1000; i++) {" | 12050 "for (var i = 0; i < 1000; i++) {" |
11927 " result = o.x(42);" | 12051 " result = o.x(42);" |
11928 "}"); | 12052 "}"); |
11929 CHECK_EQ(41, value->Int32Value()); | 12053 CHECK_EQ(41, value->Int32Value()); |
11930 } | 12054 } |
11931 | 12055 |
11932 | 12056 |
11933 static v8::Handle<Value> call_ic_function6; | 12057 static v8::Handle<Value> call_ic_function6; |
11934 static void InterceptorCallICGetter6( | 12058 static void InterceptorCallICGetter6( |
11935 Local<String> name, | 12059 Local<Name> name, |
11936 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12060 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11937 ApiTestFuzzer::Fuzz(); | 12061 ApiTestFuzzer::Fuzz(); |
11938 if (v8_str("x")->Equals(name)) | 12062 if (v8_str("x")->Equals(name)) |
11939 info.GetReturnValue().Set(call_ic_function6); | 12063 info.GetReturnValue().Set(call_ic_function6); |
11940 } | 12064 } |
11941 | 12065 |
11942 | 12066 |
11943 // Same test as above, except the code is wrapped in a function | 12067 // Same test as above, except the code is wrapped in a function |
11944 // to test the optimized compiler. | 12068 // to test the optimized compiler. |
11945 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { | 12069 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12053 " result += o.parseFloat('239');" | 12177 " result += o.parseFloat('239');" |
12054 " }" | 12178 " }" |
12055 " result" | 12179 " result" |
12056 "} catch(e) {" | 12180 "} catch(e) {" |
12057 " e" | 12181 " e" |
12058 "};"); | 12182 "};"); |
12059 CHECK_EQ(239 * 10, value->Int32Value()); | 12183 CHECK_EQ(239 * 10, value->Int32Value()); |
12060 } | 12184 } |
12061 | 12185 |
12062 static void InterceptorCallICFastApi( | 12186 static void InterceptorCallICFastApi( |
12063 Local<String> name, | 12187 Local<Name> name, |
12064 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12188 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12065 ApiTestFuzzer::Fuzz(); | 12189 ApiTestFuzzer::Fuzz(); |
12066 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); | 12190 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); |
12067 int* call_count = | 12191 int* call_count = |
12068 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | 12192 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); |
12069 ++(*call_count); | 12193 ++(*call_count); |
12070 if ((*call_count) % 20 == 0) { | 12194 if ((*call_count) % 20 == 0) { |
12071 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 12195 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12072 } | 12196 } |
12073 } | 12197 } |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12629 CHECK(try_catch.HasCaught()); | 12753 CHECK(try_catch.HasCaught()); |
12630 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 12754 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
12631 try_catch.Exception()->ToString()); | 12755 try_catch.Exception()->ToString()); |
12632 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12756 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
12633 } | 12757 } |
12634 | 12758 |
12635 | 12759 |
12636 v8::Handle<Value> keyed_call_ic_function; | 12760 v8::Handle<Value> keyed_call_ic_function; |
12637 | 12761 |
12638 static void InterceptorKeyedCallICGetter( | 12762 static void InterceptorKeyedCallICGetter( |
12639 Local<String> name, | 12763 Local<Name> name, |
12640 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12764 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12641 ApiTestFuzzer::Fuzz(); | 12765 ApiTestFuzzer::Fuzz(); |
12642 if (v8_str("x")->Equals(name)) { | 12766 if (v8_str("x")->Equals(name)) { |
12643 info.GetReturnValue().Set(keyed_call_ic_function); | 12767 info.GetReturnValue().Set(keyed_call_ic_function); |
12644 } | 12768 } |
12645 } | 12769 } |
12646 | 12770 |
12647 | 12771 |
12648 // Test the case when we stored cacheable lookup into | 12772 // Test the case when we stored cacheable lookup into |
12649 // a stub, but the function name changed (to another cacheable function). | 12773 // a stub, but the function name changed (to another cacheable function). |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12793 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" | 12917 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" |
12794 " result += o[m](41);" | 12918 " result += o[m](41);" |
12795 "}"); | 12919 "}"); |
12796 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 12920 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
12797 } | 12921 } |
12798 | 12922 |
12799 | 12923 |
12800 static int interceptor_call_count = 0; | 12924 static int interceptor_call_count = 0; |
12801 | 12925 |
12802 static void InterceptorICRefErrorGetter( | 12926 static void InterceptorICRefErrorGetter( |
12803 Local<String> name, | 12927 Local<Name> name, |
12804 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12928 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12805 ApiTestFuzzer::Fuzz(); | 12929 ApiTestFuzzer::Fuzz(); |
12806 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { | 12930 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { |
12807 info.GetReturnValue().Set(call_ic_function2); | 12931 info.GetReturnValue().Set(call_ic_function2); |
12808 } | 12932 } |
12809 } | 12933 } |
12810 | 12934 |
12811 | 12935 |
12812 // This test should hit load and call ICs for the interceptor case. | 12936 // This test should hit load and call ICs for the interceptor case. |
12813 // Once in a while, the interceptor will reply that a property was not | 12937 // Once in a while, the interceptor will reply that a property was not |
(...skipping 23 matching lines...) Expand all Loading... |
12837 " return false;" | 12961 " return false;" |
12838 "};" | 12962 "};" |
12839 "g();"); | 12963 "g();"); |
12840 CHECK_EQ(true, value->BooleanValue()); | 12964 CHECK_EQ(true, value->BooleanValue()); |
12841 } | 12965 } |
12842 | 12966 |
12843 | 12967 |
12844 static int interceptor_ic_exception_get_count = 0; | 12968 static int interceptor_ic_exception_get_count = 0; |
12845 | 12969 |
12846 static void InterceptorICExceptionGetter( | 12970 static void InterceptorICExceptionGetter( |
12847 Local<String> name, | 12971 Local<Name> name, |
12848 const v8::PropertyCallbackInfo<v8::Value>& info) { | 12972 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12849 ApiTestFuzzer::Fuzz(); | 12973 ApiTestFuzzer::Fuzz(); |
12850 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { | 12974 if (v8_str("x")->Equals(name) && ++interceptor_ic_exception_get_count < 20) { |
12851 info.GetReturnValue().Set(call_ic_function3); | 12975 info.GetReturnValue().Set(call_ic_function3); |
12852 } | 12976 } |
12853 if (interceptor_ic_exception_get_count == 20) { | 12977 if (interceptor_ic_exception_get_count == 20) { |
12854 info.GetIsolate()->ThrowException(v8_num(42)); | 12978 info.GetIsolate()->ThrowException(v8_num(42)); |
12855 return; | 12979 return; |
12856 } | 12980 } |
12857 } | 12981 } |
(...skipping 27 matching lines...) Expand all Loading... |
12885 " return false;" | 13009 " return false;" |
12886 "};" | 13010 "};" |
12887 "f();"); | 13011 "f();"); |
12888 CHECK_EQ(true, value->BooleanValue()); | 13012 CHECK_EQ(true, value->BooleanValue()); |
12889 } | 13013 } |
12890 | 13014 |
12891 | 13015 |
12892 static int interceptor_ic_exception_set_count = 0; | 13016 static int interceptor_ic_exception_set_count = 0; |
12893 | 13017 |
12894 static void InterceptorICExceptionSetter( | 13018 static void InterceptorICExceptionSetter( |
12895 Local<String> key, | 13019 Local<Name> key, |
12896 Local<Value> value, | 13020 Local<Value> value, |
12897 const v8::PropertyCallbackInfo<v8::Value>& info) { | 13021 const v8::PropertyCallbackInfo<v8::Value>& info) { |
12898 ApiTestFuzzer::Fuzz(); | 13022 ApiTestFuzzer::Fuzz(); |
12899 if (++interceptor_ic_exception_set_count > 20) { | 13023 if (++interceptor_ic_exception_set_count > 20) { |
12900 info.GetIsolate()->ThrowException(v8_num(42)); | 13024 info.GetIsolate()->ThrowException(v8_num(42)); |
12901 } | 13025 } |
12902 } | 13026 } |
12903 | 13027 |
12904 | 13028 |
12905 // Test interceptor store IC where the interceptor throws an exception | 13029 // Test interceptor store IC where the interceptor throws an exception |
(...skipping 16 matching lines...) Expand all Loading... |
12922 CHECK_EQ(true, value->BooleanValue()); | 13046 CHECK_EQ(true, value->BooleanValue()); |
12923 } | 13047 } |
12924 | 13048 |
12925 | 13049 |
12926 // Test that we ignore null interceptors. | 13050 // Test that we ignore null interceptors. |
12927 THREADED_TEST(NullNamedInterceptor) { | 13051 THREADED_TEST(NullNamedInterceptor) { |
12928 v8::Isolate* isolate = CcTest::isolate(); | 13052 v8::Isolate* isolate = CcTest::isolate(); |
12929 v8::HandleScope scope(isolate); | 13053 v8::HandleScope scope(isolate); |
12930 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); | 13054 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); |
12931 templ->SetNamedPropertyHandler( | 13055 templ->SetNamedPropertyHandler( |
12932 static_cast<v8::NamedPropertyGetterCallback>(0)); | 13056 static_cast<v8::GenericNamedPropertyGetterCallback>(0)); |
12933 LocalContext context; | 13057 LocalContext context; |
12934 templ->Set(CcTest::isolate(), "x", v8_num(42)); | 13058 templ->Set(CcTest::isolate(), "x", v8_num(42)); |
12935 v8::Handle<v8::Object> obj = templ->NewInstance(); | 13059 v8::Handle<v8::Object> obj = templ->NewInstance(); |
12936 context->Global()->Set(v8_str("obj"), obj); | 13060 context->Global()->Set(v8_str("obj"), obj); |
12937 v8::Handle<Value> value = CompileRun("obj.x"); | 13061 v8::Handle<Value> value = CompileRun("obj.x"); |
12938 CHECK(value->IsInt32()); | 13062 CHECK(value->IsInt32()); |
12939 CHECK_EQ(42, value->Int32Value()); | 13063 CHECK_EQ(42, value->Int32Value()); |
12940 } | 13064 } |
12941 | 13065 |
12942 | 13066 |
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15307 } | 15431 } |
15308 info.GetReturnValue().Set(3); | 15432 info.GetReturnValue().Set(3); |
15309 } | 15433 } |
15310 | 15434 |
15311 static void ForceSetSetter(v8::Local<v8::String> name, | 15435 static void ForceSetSetter(v8::Local<v8::String> name, |
15312 v8::Local<v8::Value> value, | 15436 v8::Local<v8::Value> value, |
15313 const v8::PropertyCallbackInfo<void>& info) { | 15437 const v8::PropertyCallbackInfo<void>& info) { |
15314 force_set_set_count++; | 15438 force_set_set_count++; |
15315 } | 15439 } |
15316 | 15440 |
| 15441 static void ForceSetInterceptGetter( |
| 15442 v8::Local<v8::Name> name, |
| 15443 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 15444 CHECK(name->IsString()); |
| 15445 ForceSetGetter(Local<String>::Cast(name), info); |
| 15446 } |
| 15447 |
15317 static void ForceSetInterceptSetter( | 15448 static void ForceSetInterceptSetter( |
15318 v8::Local<v8::String> name, | 15449 v8::Local<v8::Name> name, |
15319 v8::Local<v8::Value> value, | 15450 v8::Local<v8::Value> value, |
15320 const v8::PropertyCallbackInfo<v8::Value>& info) { | 15451 const v8::PropertyCallbackInfo<v8::Value>& info) { |
15321 force_set_set_count++; | 15452 force_set_set_count++; |
15322 info.GetReturnValue().SetUndefined(); | 15453 info.GetReturnValue().SetUndefined(); |
15323 } | 15454 } |
15324 | 15455 |
15325 | 15456 |
15326 TEST(ForceSet) { | 15457 TEST(ForceSet) { |
15327 force_set_get_count = 0; | 15458 force_set_get_count = 0; |
15328 force_set_set_count = 0; | 15459 force_set_set_count = 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15369 | 15500 |
15370 | 15501 |
15371 TEST(ForceSetWithInterceptor) { | 15502 TEST(ForceSetWithInterceptor) { |
15372 force_set_get_count = 0; | 15503 force_set_get_count = 0; |
15373 force_set_set_count = 0; | 15504 force_set_set_count = 0; |
15374 pass_on_get = false; | 15505 pass_on_get = false; |
15375 | 15506 |
15376 v8::Isolate* isolate = CcTest::isolate(); | 15507 v8::Isolate* isolate = CcTest::isolate(); |
15377 v8::HandleScope scope(isolate); | 15508 v8::HandleScope scope(isolate); |
15378 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); | 15509 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
15379 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); | 15510 templ->SetNamedPropertyHandler(ForceSetInterceptGetter, |
| 15511 ForceSetInterceptSetter); |
15380 LocalContext context(NULL, templ); | 15512 LocalContext context(NULL, templ); |
15381 v8::Handle<v8::Object> global = context->Global(); | 15513 v8::Handle<v8::Object> global = context->Global(); |
15382 | 15514 |
15383 v8::Handle<v8::String> some_property = | 15515 v8::Handle<v8::String> some_property = |
15384 v8::String::NewFromUtf8(isolate, "a"); | 15516 v8::String::NewFromUtf8(isolate, "a"); |
15385 CHECK_EQ(0, force_set_set_count); | 15517 CHECK_EQ(0, force_set_set_count); |
15386 CHECK_EQ(0, force_set_get_count); | 15518 CHECK_EQ(0, force_set_get_count); |
15387 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 15519 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
15388 // Setting the property shouldn't override it, just call the setter | 15520 // Setting the property shouldn't override it, just call the setter |
15389 // which in this case does nothing. | 15521 // which in this case does nothing. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15437 CHECK(global->ForceDelete(simple_property)); | 15569 CHECK(global->ForceDelete(simple_property)); |
15438 CHECK(global->Get(simple_property)->IsUndefined()); | 15570 CHECK(global->Get(simple_property)->IsUndefined()); |
15439 } | 15571 } |
15440 | 15572 |
15441 | 15573 |
15442 static int force_delete_interceptor_count = 0; | 15574 static int force_delete_interceptor_count = 0; |
15443 static bool pass_on_delete = false; | 15575 static bool pass_on_delete = false; |
15444 | 15576 |
15445 | 15577 |
15446 static void ForceDeleteDeleter( | 15578 static void ForceDeleteDeleter( |
15447 v8::Local<v8::String> name, | 15579 v8::Local<v8::Name> name, |
15448 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 15580 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
15449 force_delete_interceptor_count++; | 15581 force_delete_interceptor_count++; |
15450 if (pass_on_delete) return; | 15582 if (pass_on_delete) return; |
15451 info.GetReturnValue().Set(true); | 15583 info.GetReturnValue().Set(true); |
15452 } | 15584 } |
15453 | 15585 |
15454 | 15586 |
15455 THREADED_TEST(ForceDeleteWithInterceptor) { | 15587 THREADED_TEST(ForceDeleteWithInterceptor) { |
15456 force_delete_interceptor_count = 0; | 15588 force_delete_interceptor_count = 0; |
15457 pass_on_delete = false; | 15589 pass_on_delete = false; |
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18530 static void SetterWhichSetsYOnThisTo23( | 18662 static void SetterWhichSetsYOnThisTo23( |
18531 Local<String> name, | 18663 Local<String> name, |
18532 Local<Value> value, | 18664 Local<Value> value, |
18533 const v8::PropertyCallbackInfo<void>& info) { | 18665 const v8::PropertyCallbackInfo<void>& info) { |
18534 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 18666 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
18535 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 18667 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
18536 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); | 18668 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); |
18537 } | 18669 } |
18538 | 18670 |
18539 | 18671 |
18540 void FooGetInterceptor(Local<String> name, | 18672 void FooGetInterceptor(Local<Name> name, |
18541 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18673 const v8::PropertyCallbackInfo<v8::Value>& info) { |
18542 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 18674 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
18543 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 18675 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
18544 if (!name->Equals(v8_str("foo"))) return; | 18676 if (!name->Equals(v8_str("foo"))) return; |
18545 info.GetReturnValue().Set(v8_num(42)); | 18677 info.GetReturnValue().Set(v8_num(42)); |
18546 } | 18678 } |
18547 | 18679 |
18548 | 18680 |
18549 void FooSetInterceptor(Local<String> name, | 18681 void FooSetInterceptor(Local<Name> name, |
18550 Local<Value> value, | 18682 Local<Value> value, |
18551 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18683 const v8::PropertyCallbackInfo<v8::Value>& info) { |
18552 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 18684 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
18553 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 18685 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
18554 if (!name->Equals(v8_str("foo"))) return; | 18686 if (!name->Equals(v8_str("foo"))) return; |
18555 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); | 18687 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); |
18556 info.GetReturnValue().Set(v8_num(23)); | 18688 info.GetReturnValue().Set(v8_num(23)); |
18557 } | 18689 } |
18558 | 18690 |
18559 | 18691 |
(...skipping 26 matching lines...) Expand all Loading... |
18586 script = v8_compile("new C2();"); | 18718 script = v8_compile("new C2();"); |
18587 for (int i = 0; i < 10; i++) { | 18719 for (int i = 0; i < 10; i++) { |
18588 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); | 18720 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); |
18589 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); | 18721 CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); |
18590 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value()); | 18722 CHECK_EQ(23, c2->Get(v8_str("y"))->Int32Value()); |
18591 } | 18723 } |
18592 } | 18724 } |
18593 | 18725 |
18594 | 18726 |
18595 static void NamedPropertyGetterWhichReturns42( | 18727 static void NamedPropertyGetterWhichReturns42( |
18596 Local<String> name, | 18728 Local<Name> name, |
18597 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18729 const v8::PropertyCallbackInfo<v8::Value>& info) { |
18598 info.GetReturnValue().Set(v8_num(42)); | 18730 info.GetReturnValue().Set(v8_num(42)); |
18599 } | 18731 } |
18600 | 18732 |
18601 | 18733 |
18602 static void NamedPropertySetterWhichSetsYOnThisTo23( | 18734 static void NamedPropertySetterWhichSetsYOnThisTo23( |
18603 Local<String> name, | 18735 Local<Name> name, |
18604 Local<Value> value, | 18736 Local<Value> value, |
18605 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18737 const v8::PropertyCallbackInfo<v8::Value>& info) { |
18606 if (name->Equals(v8_str("x"))) { | 18738 if (name->Equals(v8_str("x"))) { |
18607 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); | 18739 Local<Object>::Cast(info.This())->Set(v8_str("y"), v8_num(23)); |
18608 } | 18740 } |
18609 } | 18741 } |
18610 | 18742 |
18611 | 18743 |
18612 THREADED_TEST(InterceptorOnConstructorPrototype) { | 18744 THREADED_TEST(InterceptorOnConstructorPrototype) { |
18613 v8::Isolate* isolate = CcTest::isolate(); | 18745 v8::Isolate* isolate = CcTest::isolate(); |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19901 CHECK(!globalProxy->StrictEquals(global)); | 20033 CHECK(!globalProxy->StrictEquals(global)); |
19902 CHECK(globalProxy->StrictEquals(globalProxy)); | 20034 CHECK(globalProxy->StrictEquals(globalProxy)); |
19903 | 20035 |
19904 CHECK(global->Equals(global)); | 20036 CHECK(global->Equals(global)); |
19905 CHECK(!global->Equals(globalProxy)); | 20037 CHECK(!global->Equals(globalProxy)); |
19906 CHECK(!globalProxy->Equals(global)); | 20038 CHECK(!globalProxy->Equals(global)); |
19907 CHECK(globalProxy->Equals(globalProxy)); | 20039 CHECK(globalProxy->Equals(globalProxy)); |
19908 } | 20040 } |
19909 | 20041 |
19910 | 20042 |
19911 static void Getter(v8::Local<v8::String> property, | 20043 static void Getter(v8::Local<v8::Name> property, |
19912 const v8::PropertyCallbackInfo<v8::Value>& info ) { | 20044 const v8::PropertyCallbackInfo<v8::Value>& info ) { |
19913 info.GetReturnValue().Set(v8_str("42!")); | 20045 info.GetReturnValue().Set(v8_str("42!")); |
19914 } | 20046 } |
19915 | 20047 |
19916 | 20048 |
19917 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { | 20049 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
19918 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate()); | 20050 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate()); |
19919 result->Set(0, v8_str("universalAnswer")); | 20051 result->Set(0, v8_str("universalAnswer")); |
19920 info.GetReturnValue().Set(result); | 20052 info.GetReturnValue().Set(result); |
19921 } | 20053 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20066 | 20198 |
20067 | 20199 |
20068 void HasOwnPropertyIndexedPropertyGetter( | 20200 void HasOwnPropertyIndexedPropertyGetter( |
20069 uint32_t index, | 20201 uint32_t index, |
20070 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20202 const v8::PropertyCallbackInfo<v8::Value>& info) { |
20071 if (index == 42) info.GetReturnValue().Set(v8_str("yes")); | 20203 if (index == 42) info.GetReturnValue().Set(v8_str("yes")); |
20072 } | 20204 } |
20073 | 20205 |
20074 | 20206 |
20075 void HasOwnPropertyNamedPropertyGetter( | 20207 void HasOwnPropertyNamedPropertyGetter( |
20076 Local<String> property, | 20208 Local<Name> property, |
20077 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20209 const v8::PropertyCallbackInfo<v8::Value>& info) { |
20078 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes")); | 20210 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(v8_str("yes")); |
20079 } | 20211 } |
20080 | 20212 |
20081 | 20213 |
20082 void HasOwnPropertyIndexedPropertyQuery( | 20214 void HasOwnPropertyIndexedPropertyQuery( |
20083 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) { | 20215 uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) { |
20084 if (index == 42) info.GetReturnValue().Set(1); | 20216 if (index == 42) info.GetReturnValue().Set(1); |
20085 } | 20217 } |
20086 | 20218 |
20087 | 20219 |
20088 void HasOwnPropertyNamedPropertyQuery( | 20220 void HasOwnPropertyNamedPropertyQuery( |
20089 Local<String> property, | 20221 Local<Name> property, |
20090 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 20222 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
20091 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1); | 20223 if (property->Equals(v8_str("foo"))) info.GetReturnValue().Set(1); |
20092 } | 20224 } |
20093 | 20225 |
20094 | 20226 |
20095 void HasOwnPropertyNamedPropertyQuery2( | 20227 void HasOwnPropertyNamedPropertyQuery2( |
20096 Local<String> property, | 20228 Local<Name> property, |
20097 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 20229 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
20098 if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1); | 20230 if (property->Equals(v8_str("bar"))) info.GetReturnValue().Set(1); |
20099 } | 20231 } |
20100 | 20232 |
20101 | 20233 |
20102 void HasOwnPropertyAccessorGetter( | 20234 void HasOwnPropertyAccessorGetter( |
20103 Local<String> property, | 20235 Local<String> property, |
20104 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20236 const v8::PropertyCallbackInfo<v8::Value>& info) { |
20105 info.GetReturnValue().Set(v8_str("yes")); | 20237 info.GetReturnValue().Set(v8_str("yes")); |
20106 } | 20238 } |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22066 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate(); | 22198 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate(); |
22067 instance_template->SetNamedPropertyHandler(EmptyInterceptor); | 22199 instance_template->SetNamedPropertyHandler(EmptyInterceptor); |
22068 | 22200 |
22069 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); | 22201 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); |
22070 | 22202 |
22071 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); | 22203 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); |
22072 } | 22204 } |
22073 | 22205 |
22074 private: | 22206 private: |
22075 static void EmptyInterceptor( | 22207 static void EmptyInterceptor( |
22076 Local<String> property, | 22208 Local<Name> property, |
22077 const v8::PropertyCallbackInfo<v8::Value>& info) { | 22209 const v8::PropertyCallbackInfo<v8::Value>& info) { |
22078 } | 22210 } |
22079 }; | 22211 }; |
22080 | 22212 |
22081 | 22213 |
22082 class RequestInterruptTestWithMathAbs | 22214 class RequestInterruptTestWithMathAbs |
22083 : public RequestInterruptTestBaseWithSimpleInterrupt { | 22215 : public RequestInterruptTestBaseWithSimpleInterrupt { |
22084 public: | 22216 public: |
22085 virtual void TestBody() { | 22217 virtual void TestBody() { |
22086 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New( | 22218 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New( |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22910 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 23042 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
22911 Local<Function> set = | 23043 Local<Function> set = |
22912 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 23044 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
22913 Local<Function> get = | 23045 Local<Function> get = |
22914 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 23046 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
22915 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); | 23047 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
22916 Handle<Value> args[] = { v8_num(14) }; | 23048 Handle<Value> args[] = { v8_num(14) }; |
22917 set->Call(x, 1, args); | 23049 set->Call(x, 1, args); |
22918 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); | 23050 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
22919 } | 23051 } |
OLD | NEW |