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

Side by Side Diff: test/cctest/test-api.cc

Issue 1642223003: [api] Make ObjectTemplate::SetNativeDataProperty() work even if the ObjectTemplate does not have a … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
« src/builtins.cc ('K') | « src/x87/builtins-x87.cc ('k') | no next file » | 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 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 v8::Local<v8::String> class_name = v8_str("the_class_name"); 1895 v8::Local<v8::String> class_name = v8_str("the_class_name");
1896 fun->SetClassName(class_name); 1896 fun->SetClassName(class_name);
1897 Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate, fun); 1897 Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate, fun);
1898 templ1->Set(isolate, "x", v8_num(10)); 1898 templ1->Set(isolate, "x", v8_num(10));
1899 templ1->Set(isolate, "y", v8_num(13)); 1899 templ1->Set(isolate, "y", v8_num(13));
1900 LocalContext env; 1900 LocalContext env;
1901 Local<v8::Object> instance1 = 1901 Local<v8::Object> instance1 =
1902 templ1->NewInstance(env.local()).ToLocalChecked(); 1902 templ1->NewInstance(env.local()).ToLocalChecked();
1903 CHECK(class_name->StrictEquals(instance1->GetConstructorName())); 1903 CHECK(class_name->StrictEquals(instance1->GetConstructorName()));
1904 CHECK(env->Global()->Set(env.local(), v8_str("p"), instance1).FromJust()); 1904 CHECK(env->Global()->Set(env.local(), v8_str("p"), instance1).FromJust());
1905 CHECK(v8_compile("(p.x == 10)") 1905 CHECK(CompileRun("(p.x == 10)")->BooleanValue(env.local()).FromJust());
1906 ->Run(env.local()) 1906 CHECK(CompileRun("(p.y == 13)")->BooleanValue(env.local()).FromJust());
1907 .ToLocalChecked()
1908 ->BooleanValue(env.local())
1909 .FromJust());
1910 CHECK(v8_compile("(p.y == 13)")
1911 ->Run(env.local())
1912 .ToLocalChecked()
1913 ->BooleanValue(env.local())
1914 .FromJust());
1915 Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate); 1907 Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate);
1916 fun2->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123)); 1908 fun2->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123));
1917 Local<ObjectTemplate> templ2 = fun2->InstanceTemplate(); 1909 Local<ObjectTemplate> templ2 = fun2->InstanceTemplate();
1918 templ2->Set(isolate, "a", v8_num(12)); 1910 templ2->Set(isolate, "a", v8_num(12));
1919 templ2->Set(isolate, "b", templ1); 1911 templ2->Set(isolate, "b", templ1);
1920 Local<v8::Object> instance2 = 1912 Local<v8::Object> instance2 =
1921 templ2->NewInstance(env.local()).ToLocalChecked(); 1913 templ2->NewInstance(env.local()).ToLocalChecked();
1922 CHECK(env->Global()->Set(env.local(), v8_str("q"), instance2).FromJust()); 1914 CHECK(env->Global()->Set(env.local(), v8_str("q"), instance2).FromJust());
1923 CHECK(v8_compile("(q.nirk == 123)") 1915 CHECK(CompileRun("(q.nirk == 123)")->BooleanValue(env.local()).FromJust());
1924 ->Run(env.local()) 1916 CHECK(CompileRun("(q.a == 12)")->BooleanValue(env.local()).FromJust());
1925 .ToLocalChecked() 1917 CHECK(CompileRun("(q.b.x == 10)")->BooleanValue(env.local()).FromJust());
1926 ->BooleanValue(env.local()) 1918 CHECK(CompileRun("(q.b.y == 13)")->BooleanValue(env.local()).FromJust());
1927 .FromJust());
1928 CHECK(v8_compile("(q.a == 12)")
1929 ->Run(env.local())
1930 .ToLocalChecked()
1931 ->BooleanValue(env.local())
1932 .FromJust());
1933 CHECK(v8_compile("(q.b.x == 10)")
1934 ->Run(env.local())
1935 .ToLocalChecked()
1936 ->BooleanValue(env.local())
1937 .FromJust());
1938 CHECK(v8_compile("(q.b.y == 13)")
1939 ->Run(env.local())
1940 .ToLocalChecked()
1941 ->BooleanValue(env.local())
1942 .FromJust());
1943 } 1919 }
1944 1920
1921 THREADED_TEST(IntegerValue) {
1922 LocalContext env;
1923 v8::Isolate* isolate = CcTest::isolate();
1924 v8::HandleScope scope(isolate);
1925
1926 CHECK_EQ(0, CompileRun("undefined")->IntegerValue(env.local()).FromJust());
1927 }
1928
1929 static void GetNirk(Local<String> name,
1930 const v8::PropertyCallbackInfo<v8::Value>& info) {
1931 ApiTestFuzzer::Fuzz();
1932 info.GetReturnValue().Set(v8_num(900));
1933 }
1934
1935 static void GetRino(Local<String> name,
1936 const v8::PropertyCallbackInfo<v8::Value>& info) {
1937 ApiTestFuzzer::Fuzz();
1938 info.GetReturnValue().Set(v8_num(560));
1939 }
1940
1941 enum ObjectInstantiationMode {
1942 // Create object using ObjectTemplate::NewInstance.
1943 ObjectTemplate_NewInstance,
1944 // Create object using FunctionTemplate::NewInstance on constructor.
1945 Constructor_GetFunction_NewInstance,
1946 // Create object using new operator on constructor.
1947 Constructor_GetFunction_New
1948 };
1949
1950 // Test object instance creation using a function template with an instance
1951 // template inherited from another function template with accessors and data
1952 // properties in prototype template.
1953 static void TestObjectTemplateInheritedWithPrototype(
1954 ObjectInstantiationMode mode) {
1955 LocalContext env;
1956 v8::Isolate* isolate = CcTest::isolate();
1957 v8::HandleScope scope(isolate);
1958
1959 Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
1960 fun_A->SetClassName(v8_str("A"));
1961 v8::Local<v8::ObjectTemplate> prototype_templ = fun_A->PrototypeTemplate();
1962 prototype_templ->Set(isolate, "a", v8_num(113));
1963 prototype_templ->SetNativeDataProperty(v8_str("nirk"), GetNirk);
1964 prototype_templ->Set(isolate, "b", v8_num(153));
1965
1966 Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
1967 v8::Local<v8::String> class_name = v8_str("B");
1968 fun_B->SetClassName(class_name);
1969 fun_B->Inherit(fun_A);
1970 prototype_templ = fun_B->PrototypeTemplate();
1971 prototype_templ->Set(isolate, "c", v8_num(713));
1972 prototype_templ->SetNativeDataProperty(v8_str("rino"), GetRino);
1973 prototype_templ->Set(isolate, "d", v8_num(753));
1974
1975 Local<ObjectTemplate> templ = fun_B->InstanceTemplate();
1976 templ->Set(isolate, "x", v8_num(10));
1977 templ->Set(isolate, "y", v8_num(13));
1978
1979 // Perform several iterations to trigger creation from cached boilerplate.
1980 for (int i = 0; i < 3; i++) {
1981 Local<v8::Object> instance;
1982 switch (mode) {
1983 case ObjectTemplate_NewInstance:
1984 instance = templ->NewInstance(env.local()).ToLocalChecked();
1985 break;
1986
1987 case Constructor_GetFunction_NewInstance: {
1988 Local<v8::Function> function_B =
1989 fun_B->GetFunction(env.local()).ToLocalChecked();
1990 instance = function_B->NewInstance(env.local()).ToLocalChecked();
1991 break;
1992 }
1993 case Constructor_GetFunction_New: {
1994 Local<v8::Function> function_B =
1995 fun_B->GetFunction(env.local()).ToLocalChecked();
1996 if (i == 0) {
1997 CHECK(env->Global()
1998 ->Set(env.local(), class_name, function_B)
1999 .FromJust());
2000 }
2001 instance =
2002 CompileRun("new B()")->ToObject(env.local()).ToLocalChecked();
2003 break;
2004 }
2005 default:
2006 UNREACHABLE();
2007 }
2008
2009 CHECK(class_name->StrictEquals(instance->GetConstructorName()));
2010 CHECK(env->Global()->Set(env.local(), v8_str("o"), instance).FromJust());
2011
2012 CHECK_EQ(10, CompileRun("o.x")->IntegerValue(env.local()).FromJust());
2013 CHECK_EQ(13, CompileRun("o.y")->IntegerValue(env.local()).FromJust());
2014
2015 CHECK_EQ(113, CompileRun("o.a")->IntegerValue(env.local()).FromJust());
2016 CHECK_EQ(900, CompileRun("o.nirk")->IntegerValue(env.local()).FromJust());
2017 CHECK_EQ(153, CompileRun("o.b")->IntegerValue(env.local()).FromJust());
2018 CHECK_EQ(713, CompileRun("o.c")->IntegerValue(env.local()).FromJust());
2019 CHECK_EQ(560, CompileRun("o.rino")->IntegerValue(env.local()).FromJust());
2020 CHECK_EQ(753, CompileRun("o.d")->IntegerValue(env.local()).FromJust());
2021 }
2022 }
2023
2024 THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype1) {
2025 TestObjectTemplateInheritedWithPrototype(ObjectTemplate_NewInstance);
2026 }
2027
2028 THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype2) {
2029 TestObjectTemplateInheritedWithPrototype(Constructor_GetFunction_NewInstance);
2030 }
2031
2032 THREADED_TEST(TestObjectTemplateInheritedWithAccessorsInPrototype3) {
2033 TestObjectTemplateInheritedWithPrototype(Constructor_GetFunction_New);
2034 }
2035
2036 // Test object instance creation using a function template without an instance
2037 // template inherited from another function template.
2038 static void TestObjectTemplateInheritedWithoutInstanceTemplate(
2039 ObjectInstantiationMode mode) {
2040 LocalContext env;
2041 v8::Isolate* isolate = CcTest::isolate();
2042 v8::HandleScope scope(isolate);
2043
2044 Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
2045 fun_A->SetClassName(v8_str("A"));
2046
2047 Local<ObjectTemplate> templ_A = fun_A->InstanceTemplate();
2048 templ_A->SetNativeDataProperty(v8_str("nirk"), GetNirk);
2049 templ_A->SetNativeDataProperty(v8_str("rino"), GetRino);
2050
2051 Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
2052 v8::Local<v8::String> class_name = v8_str("B");
2053 fun_B->SetClassName(class_name);
2054 fun_B->Inherit(fun_A);
2055
2056 // Perform several iterations to trigger creation from cached boilerplate.
2057 for (int i = 0; i < 3; i++) {
2058 Local<v8::Object> instance;
2059 switch (mode) {
2060 case Constructor_GetFunction_NewInstance: {
2061 Local<v8::Function> function_B =
2062 fun_B->GetFunction(env.local()).ToLocalChecked();
2063 instance = function_B->NewInstance(env.local()).ToLocalChecked();
2064 break;
2065 }
2066 case Constructor_GetFunction_New: {
2067 Local<v8::Function> function_B =
2068 fun_B->GetFunction(env.local()).ToLocalChecked();
2069 if (i == 0) {
2070 CHECK(env->Global()
2071 ->Set(env.local(), class_name, function_B)
2072 .FromJust());
2073 }
2074 instance =
2075 CompileRun("new B()")->ToObject(env.local()).ToLocalChecked();
2076 break;
2077 }
2078 default:
2079 UNREACHABLE();
2080 }
2081
2082 CHECK(class_name->StrictEquals(instance->GetConstructorName()));
2083 CHECK(env->Global()->Set(env.local(), v8_str("o"), instance).FromJust());
2084
2085 CHECK_EQ(900, CompileRun("o.nirk")->IntegerValue(env.local()).FromJust());
2086 CHECK_EQ(560, CompileRun("o.rino")->IntegerValue(env.local()).FromJust());
2087 }
2088 }
2089
2090 THREADED_TEST(TestObjectTemplateInheritedWithPrototype1) {
2091 TestObjectTemplateInheritedWithoutInstanceTemplate(
2092 Constructor_GetFunction_NewInstance);
2093 }
2094
2095 THREADED_TEST(TestObjectTemplateInheritedWithPrototype2) {
2096 TestObjectTemplateInheritedWithoutInstanceTemplate(
2097 Constructor_GetFunction_New);
2098 }
1945 2099
1946 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { 2100 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) {
1947 ApiTestFuzzer::Fuzz(); 2101 ApiTestFuzzer::Fuzz();
1948 args.GetReturnValue().Set(v8_num(17.2)); 2102 args.GetReturnValue().Set(v8_num(17.2));
1949 } 2103 }
1950 2104
1951 2105
1952 static void GetKnurd(Local<String> property, 2106 static void GetKnurd(Local<String> property,
1953 const v8::PropertyCallbackInfo<v8::Value>& info) { 2107 const v8::PropertyCallbackInfo<v8::Value>& info) {
1954 ApiTestFuzzer::Fuzz(); 2108 ApiTestFuzzer::Fuzz();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 CHECK(CompileRun("base1.prototype.knurd == undefined") 2167 CHECK(CompileRun("base1.prototype.knurd == undefined")
2014 ->BooleanValue(env.local()) 2168 ->BooleanValue(env.local())
2015 .FromJust()); 2169 .FromJust());
2016 2170
2017 CHECK(env->Global() 2171 CHECK(env->Global()
2018 ->Set(env.local(), v8_str("obj"), base1->GetFunction(env.local()) 2172 ->Set(env.local(), v8_str("obj"), base1->GetFunction(env.local())
2019 .ToLocalChecked() 2173 .ToLocalChecked()
2020 ->NewInstance(env.local()) 2174 ->NewInstance(env.local())
2021 .ToLocalChecked()) 2175 .ToLocalChecked())
2022 .FromJust()); 2176 .FromJust());
2023 CHECK_EQ(17.2, v8_compile("obj.flabby()") 2177 CHECK_EQ(17.2,
2024 ->Run(env.local()) 2178 CompileRun("obj.flabby()")->NumberValue(env.local()).FromJust());
2025 .ToLocalChecked() 2179 CHECK(CompileRun("'flabby' in obj")->BooleanValue(env.local()).FromJust());
2026 ->NumberValue(env.local()) 2180 CHECK_EQ(15.2, CompileRun("obj.knurd")->NumberValue(env.local()).FromJust());
2027 .FromJust()); 2181 CHECK(CompileRun("'knurd' in obj")->BooleanValue(env.local()).FromJust());
2028 CHECK(v8_compile("'flabby' in obj") 2182 CHECK_EQ(20.1, CompileRun("obj.v1")->NumberValue(env.local()).FromJust());
2029 ->Run(env.local())
2030 .ToLocalChecked()
2031 ->BooleanValue(env.local())
2032 .FromJust());
2033 CHECK_EQ(15.2, v8_compile("obj.knurd")
2034 ->Run(env.local())
2035 .ToLocalChecked()
2036 ->NumberValue(env.local())
2037 .FromJust());
2038 CHECK(v8_compile("'knurd' in obj")
2039 ->Run(env.local())
2040 .ToLocalChecked()
2041 ->BooleanValue(env.local())
2042 .FromJust());
2043 CHECK_EQ(20.1, v8_compile("obj.v1")
2044 ->Run(env.local())
2045 .ToLocalChecked()
2046 ->NumberValue(env.local())
2047 .FromJust());
2048 2183
2049 CHECK(env->Global() 2184 CHECK(env->Global()
2050 ->Set(env.local(), v8_str("obj2"), base2->GetFunction(env.local()) 2185 ->Set(env.local(), v8_str("obj2"), base2->GetFunction(env.local())
2051 .ToLocalChecked() 2186 .ToLocalChecked()
2052 ->NewInstance(env.local()) 2187 ->NewInstance(env.local())
2053 .ToLocalChecked()) 2188 .ToLocalChecked())
2054 .FromJust()); 2189 .FromJust());
2055 CHECK_EQ(17.2, v8_compile("obj2.flabby()") 2190 CHECK_EQ(17.2,
2056 ->Run(env.local()) 2191 CompileRun("obj2.flabby()")->NumberValue(env.local()).FromJust());
2057 .ToLocalChecked() 2192 CHECK(CompileRun("'flabby' in obj2")->BooleanValue(env.local()).FromJust());
2058 ->NumberValue(env.local()) 2193 CHECK_EQ(15.2, CompileRun("obj2.knurd")->NumberValue(env.local()).FromJust());
2059 .FromJust()); 2194 CHECK(CompileRun("'knurd' in obj2")->BooleanValue(env.local()).FromJust());
2060 CHECK(v8_compile("'flabby' in obj2") 2195 CHECK_EQ(10.1, CompileRun("obj2.v2")->NumberValue(env.local()).FromJust());
2061 ->Run(env.local())
2062 .ToLocalChecked()
2063 ->BooleanValue(env.local())
2064 .FromJust());
2065 CHECK_EQ(15.2, v8_compile("obj2.knurd")
2066 ->Run(env.local())
2067 .ToLocalChecked()
2068 ->NumberValue(env.local())
2069 .FromJust());
2070 CHECK(v8_compile("'knurd' in obj2")
2071 ->Run(env.local())
2072 .ToLocalChecked()
2073 ->BooleanValue(env.local())
2074 .FromJust());
2075 CHECK_EQ(10.1, v8_compile("obj2.v2")
2076 ->Run(env.local())
2077 .ToLocalChecked()
2078 ->NumberValue(env.local())
2079 .FromJust());
2080 2196
2081 // base1 and base2 cannot cross reference to each's prototype 2197 // base1 and base2 cannot cross reference to each's prototype
2082 CHECK(v8_compile("obj.v2")->Run(env.local()).ToLocalChecked()->IsUndefined()); 2198 CHECK(CompileRun("obj.v2")->IsUndefined());
2083 CHECK( 2199 CHECK(CompileRun("obj2.v1")->IsUndefined());
2084 v8_compile("obj2.v1")->Run(env.local()).ToLocalChecked()->IsUndefined()); 2200 }
2201
2202 THREADED_TEST(DescriptorInheritance2) {
2203 LocalContext env;
2204 v8::Isolate* isolate = CcTest::isolate();
2205 v8::HandleScope scope(isolate);
2206 v8::Local<v8::FunctionTemplate> fun_A = v8::FunctionTemplate::New(isolate);
2207 fun_A->SetClassName(v8_str("A"));
2208 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd1"), GetKnurd);
2209 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk1"), GetNirk);
2210 fun_A->InstanceTemplate()->SetNativeDataProperty(v8_str("rino1"), GetRino);
2211
2212 v8::Local<v8::FunctionTemplate> fun_B = v8::FunctionTemplate::New(isolate);
2213 fun_B->SetClassName(v8_str("B"));
2214 fun_B->Inherit(fun_A);
2215
2216 v8::Local<v8::FunctionTemplate> fun_C = v8::FunctionTemplate::New(isolate);
2217 fun_C->SetClassName(v8_str("C"));
2218 fun_C->Inherit(fun_B);
2219 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd2"), GetKnurd);
2220 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk2"), GetNirk);
2221 fun_C->InstanceTemplate()->SetNativeDataProperty(v8_str("rino2"), GetRino);
2222
2223 v8::Local<v8::FunctionTemplate> fun_D = v8::FunctionTemplate::New(isolate);
2224 fun_D->SetClassName(v8_str("D"));
2225 fun_D->Inherit(fun_C);
2226
2227 v8::Local<v8::FunctionTemplate> fun_E = v8::FunctionTemplate::New(isolate);
2228 fun_E->SetClassName(v8_str("E"));
2229 fun_E->Inherit(fun_D);
2230 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("knurd3"), GetKnurd);
2231 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("nirk3"), GetNirk);
2232 fun_E->InstanceTemplate()->SetNativeDataProperty(v8_str("rino3"), GetRino);
2233
2234 v8::Local<v8::FunctionTemplate> fun_F = v8::FunctionTemplate::New(isolate);
2235 fun_F->SetClassName(v8_str("F"));
2236 fun_F->Inherit(fun_E);
2237 v8::Local<v8::ObjectTemplate> templ = fun_F->InstanceTemplate();
2238 const int kDataPropertiesNumber = 100;
2239 for (int i = 0; i < kDataPropertiesNumber; i++) {
2240 v8::Local<v8::Value> val = v8_num(i);
2241 v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
2242 v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
2243
2244 templ->Set(name, val);
2245 templ->Set(val_str, val);
2246 }
2247
2248 CHECK(env->Global()
2249 ->Set(env.local(), v8_str("F"),
2250 fun_F->GetFunction(env.local()).ToLocalChecked())
2251 .FromJust());
2252
2253 v8::Local<v8::Script> script = v8_compile("o = new F()");
2254
2255 for (int i = 0; i < 100; i++) {
2256 v8::HandleScope scope(isolate);
2257 script->Run(env.local()).ToLocalChecked();
2258 }
2259 v8::Local<v8::Value> result = script->Run(env.local()).ToLocalChecked();
2260
2261 CHECK_EQ(15.2, CompileRun("o.knurd1")->NumberValue(env.local()).FromJust());
2262 CHECK_EQ(15.2, CompileRun("o.knurd2")->NumberValue(env.local()).FromJust());
2263 CHECK_EQ(15.2, CompileRun("o.knurd3")->NumberValue(env.local()).FromJust());
2264
2265 CHECK_EQ(900, CompileRun("o.nirk1")->IntegerValue(env.local()).FromJust());
2266 CHECK_EQ(900, CompileRun("o.nirk2")->IntegerValue(env.local()).FromJust());
2267 CHECK_EQ(900, CompileRun("o.nirk3")->IntegerValue(env.local()).FromJust());
2268
2269 CHECK_EQ(560, CompileRun("o.rino1")->IntegerValue(env.local()).FromJust());
2270 CHECK_EQ(560, CompileRun("o.rino2")->IntegerValue(env.local()).FromJust());
2271 CHECK_EQ(560, CompileRun("o.rino3")->IntegerValue(env.local()).FromJust());
2272
2273 v8::Local<v8::Object> object = result->ToObject(env.local()).ToLocalChecked();
2274 for (int i = 0; i < kDataPropertiesNumber; i++) {
2275 v8::Local<v8::Value> val = v8_num(i);
2276 v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked();
2277 v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str);
2278
2279 CHECK_EQ(i, object->Get(env.local(), name)
2280 .ToLocalChecked()
2281 ->IntegerValue(env.local())
2282 .FromJust());
2283 CHECK_EQ(i, object->Get(env.local(), val)
2284 .ToLocalChecked()
2285 ->IntegerValue(env.local())
2286 .FromJust());
2287 }
2085 } 2288 }
2086 2289
2087 2290
2088 // Helper functions for Interceptor/Accessor interaction tests 2291 // Helper functions for Interceptor/Accessor interaction tests
2089 2292
2090 void SimpleAccessorGetter(Local<String> name, 2293 void SimpleAccessorGetter(Local<String> name,
2091 const v8::PropertyCallbackInfo<v8::Value>& info) { 2294 const v8::PropertyCallbackInfo<v8::Value>& info) {
2092 Local<Object> self = Local<Object>::Cast(info.This()); 2295 Local<Object> self = Local<Object>::Cast(info.This());
2093 info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(), 2296 info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(),
2094 String::Concat(v8_str("accessor_"), name)) 2297 String::Concat(v8_str("accessor_"), name))
(...skipping 20046 matching lines...) Expand 10 before | Expand all | Expand 10 after
22141 Local<Value> result = CompileRun("func();"); 22344 Local<Value> result = CompileRun("func();");
22142 CHECK(v8::Integer::New(isolate, 17)->Equals(env.local(), result).FromJust()); 22345 CHECK(v8::Integer::New(isolate, 17)->Equals(env.local(), result).FromJust());
22143 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 22346 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
22144 // Verify function not cached 22347 // Verify function not cached
22145 auto serial_number = handle( 22348 auto serial_number = handle(
22146 i::Smi::cast(i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*func)) 22349 i::Smi::cast(i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*func))
22147 ->shared() 22350 ->shared()
22148 ->get_api_func_data() 22351 ->get_api_func_data()
22149 ->serial_number()), 22352 ->serial_number()),
22150 i_isolate); 22353 i_isolate);
22151 auto cache = i_isolate->function_cache(); 22354 auto cache = i_isolate->template_instantiations_cache();
22152 CHECK(cache->Lookup(serial_number)->IsTheHole()); 22355 CHECK(cache->Lookup(serial_number)->IsTheHole());
22153 // Verify that each Function::New creates a new function instance 22356 // Verify that each Function::New creates a new function instance
22154 Local<Object> data2 = v8::Object::New(isolate); 22357 Local<Object> data2 = v8::Object::New(isolate);
22155 function_new_expected_env = data2; 22358 function_new_expected_env = data2;
22156 Local<Function> func2 = 22359 Local<Function> func2 =
22157 Function::New(env.local(), FunctionNewCallback, data2).ToLocalChecked(); 22360 Function::New(env.local(), FunctionNewCallback, data2).ToLocalChecked();
22158 CHECK(!func2->IsNull()); 22361 CHECK(!func2->IsNull());
22159 CHECK(!func->Equals(env.local(), func2).FromJust()); 22362 CHECK(!func->Equals(env.local(), func2).FromJust());
22160 CHECK(env->Global()->Set(env.local(), v8_str("func2"), func2).FromJust()); 22363 CHECK(env->Global()->Set(env.local(), v8_str("func2"), func2).FromJust());
22161 Local<Value> result2 = CompileRun("func2();"); 22364 Local<Value> result2 = CompileRun("func2();");
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after
24639 CHECK(proxy->GetTarget()->SameValue(target)); 24842 CHECK(proxy->GetTarget()->SameValue(target));
24640 CHECK(proxy->GetHandler()->SameValue(handler)); 24843 CHECK(proxy->GetHandler()->SameValue(handler));
24641 24844
24642 proxy->Revoke(); 24845 proxy->Revoke();
24643 CHECK(proxy->IsProxy()); 24846 CHECK(proxy->IsProxy());
24644 CHECK(!target->IsProxy()); 24847 CHECK(!target->IsProxy());
24645 CHECK(proxy->IsRevoked()); 24848 CHECK(proxy->IsRevoked());
24646 CHECK(proxy->GetTarget()->SameValue(target)); 24849 CHECK(proxy->GetTarget()->SameValue(target));
24647 CHECK(proxy->GetHandler()->IsNull()); 24850 CHECK(proxy->GetHandler()->IsNull());
24648 } 24851 }
OLDNEW
« src/builtins.cc ('K') | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698