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

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

Issue 1159433003: Use GetProperty for getting elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 6 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
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/enumeration-order.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "test/cctest/test-api.h" 7 #include "test/cctest/test-api.h"
8 8
9 #include "include/v8-util.h" 9 #include "include/v8-util.h"
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 v8::NamedPropertyHandlerConfiguration(GetK, NULL, NULL, NULL, NamedEnum)); 2014 v8::NamedPropertyHandlerConfiguration(GetK, NULL, NULL, NULL, NamedEnum));
2015 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( 2015 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration(
2016 IndexedGetK, NULL, NULL, NULL, IndexedEnum)); 2016 IndexedGetK, NULL, NULL, NULL, IndexedEnum));
2017 LocalContext context; 2017 LocalContext context;
2018 context->Global()->Set(v8_str("k"), obj->NewInstance()); 2018 context->Global()->Set(v8_str("k"), obj->NewInstance());
2019 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 2019 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
2020 "k[10] = 0;" 2020 "k[10] = 0;"
2021 "k.a = 0;" 2021 "k.a = 0;"
2022 "k[5] = 0;" 2022 "k[5] = 0;"
2023 "k.b = 0;" 2023 "k.b = 0;"
2024 "k[4294967294] = 0;"
2025 "k.c = 0;"
2024 "k[4294967295] = 0;" 2026 "k[4294967295] = 0;"
2025 "k.c = 0;"
2026 "k[4294967296] = 0;"
2027 "k.d = 0;" 2027 "k.d = 0;"
2028 "k[140000] = 0;" 2028 "k[140000] = 0;"
2029 "k.e = 0;" 2029 "k.e = 0;"
2030 "k[30000000000] = 0;" 2030 "k[30000000000] = 0;"
2031 "k.f = 0;" 2031 "k.f = 0;"
2032 "var result = [];" 2032 "var result = [];"
2033 "for (var prop in k) {" 2033 "for (var prop in k) {"
2034 " result.push(prop);" 2034 " result.push(prop);"
2035 "}" 2035 "}"
2036 "result")); 2036 "result"));
2037 // Check that we get all the property names returned including the 2037 // Check that we get all the property names returned including the
2038 // ones from the enumerators in the right order: indexed properties 2038 // ones from the enumerators in the right order: indexed properties
2039 // in numerical order, indexed interceptor properties, named 2039 // in numerical order, indexed interceptor properties, named
2040 // properties in insertion order, named interceptor properties. 2040 // properties in insertion order, named interceptor properties.
2041 // This order is not mandated by the spec, so this test is just 2041 // This order is not mandated by the spec, so this test is just
2042 // documenting our behavior. 2042 // documenting our behavior.
2043 CHECK_EQ(17u, result->Length()); 2043 CHECK_EQ(17u, result->Length());
2044 // Indexed properties in numerical order. 2044 // Indexed properties in numerical order.
2045 CHECK(v8_str("5")->Equals(result->Get(v8::Integer::New(isolate, 0)))); 2045 CHECK(v8_str("5")->Equals(result->Get(v8::Integer::New(isolate, 0))));
2046 CHECK(v8_str("10")->Equals(result->Get(v8::Integer::New(isolate, 1)))); 2046 CHECK(v8_str("10")->Equals(result->Get(v8::Integer::New(isolate, 1))));
2047 CHECK(v8_str("140000")->Equals(result->Get(v8::Integer::New(isolate, 2)))); 2047 CHECK(v8_str("140000")->Equals(result->Get(v8::Integer::New(isolate, 2))));
2048 CHECK( 2048 CHECK(
2049 v8_str("4294967295")->Equals(result->Get(v8::Integer::New(isolate, 3)))); 2049 v8_str("4294967294")->Equals(result->Get(v8::Integer::New(isolate, 3))));
2050 // Indexed interceptor properties in the order they are returned 2050 // Indexed interceptor properties in the order they are returned
2051 // from the enumerator interceptor. 2051 // from the enumerator interceptor.
2052 CHECK(v8_str("0")->Equals(result->Get(v8::Integer::New(isolate, 4)))); 2052 CHECK(v8_str("0")->Equals(result->Get(v8::Integer::New(isolate, 4))));
2053 CHECK(v8_str("1")->Equals(result->Get(v8::Integer::New(isolate, 5)))); 2053 CHECK(v8_str("1")->Equals(result->Get(v8::Integer::New(isolate, 5))));
2054 // Named properties in insertion order. 2054 // Named properties in insertion order.
2055 CHECK(v8_str("a")->Equals(result->Get(v8::Integer::New(isolate, 6)))); 2055 CHECK(v8_str("a")->Equals(result->Get(v8::Integer::New(isolate, 6))));
2056 CHECK(v8_str("b")->Equals(result->Get(v8::Integer::New(isolate, 7)))); 2056 CHECK(v8_str("b")->Equals(result->Get(v8::Integer::New(isolate, 7))));
2057 CHECK(v8_str("c")->Equals(result->Get(v8::Integer::New(isolate, 8)))); 2057 CHECK(v8_str("c")->Equals(result->Get(v8::Integer::New(isolate, 8))));
2058 CHECK( 2058 CHECK(
2059 v8_str("4294967296")->Equals(result->Get(v8::Integer::New(isolate, 9)))); 2059 v8_str("4294967295")->Equals(result->Get(v8::Integer::New(isolate, 9))));
2060 CHECK(v8_str("d")->Equals(result->Get(v8::Integer::New(isolate, 10)))); 2060 CHECK(v8_str("d")->Equals(result->Get(v8::Integer::New(isolate, 10))));
2061 CHECK(v8_str("e")->Equals(result->Get(v8::Integer::New(isolate, 11)))); 2061 CHECK(v8_str("e")->Equals(result->Get(v8::Integer::New(isolate, 11))));
2062 CHECK(v8_str("30000000000") 2062 CHECK(v8_str("30000000000")
2063 ->Equals(result->Get(v8::Integer::New(isolate, 12)))); 2063 ->Equals(result->Get(v8::Integer::New(isolate, 12))));
2064 CHECK(v8_str("f")->Equals(result->Get(v8::Integer::New(isolate, 13)))); 2064 CHECK(v8_str("f")->Equals(result->Get(v8::Integer::New(isolate, 13))));
2065 // Named interceptor properties. 2065 // Named interceptor properties.
2066 CHECK(v8_str("foo")->Equals(result->Get(v8::Integer::New(isolate, 14)))); 2066 CHECK(v8_str("foo")->Equals(result->Get(v8::Integer::New(isolate, 14))));
2067 CHECK(v8_str("bar")->Equals(result->Get(v8::Integer::New(isolate, 15)))); 2067 CHECK(v8_str("bar")->Equals(result->Get(v8::Integer::New(isolate, 15))));
2068 CHECK(v8_str("baz")->Equals(result->Get(v8::Integer::New(isolate, 16)))); 2068 CHECK(v8_str("baz")->Equals(result->Get(v8::Integer::New(isolate, 16))));
2069 } 2069 }
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 "var obj = intercepted_1;" 3302 "var obj = intercepted_1;"
3303 "obj.x = 4;" 3303 "obj.x = 4;"
3304 "eval('obj.x');" 3304 "eval('obj.x');"
3305 "eval('obj.x');" 3305 "eval('obj.x');"
3306 "eval('obj.x');" 3306 "eval('obj.x');"
3307 "obj = intercepted_2;" 3307 "obj = intercepted_2;"
3308 "obj.x = 9;" 3308 "obj.x = 9;"
3309 "eval('obj.x');", 3309 "eval('obj.x');",
3310 9); 3310 9);
3311 } 3311 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/enumeration-order.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698