Commit e9bdcc0d authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[test] Improve test coverage for Object::GetPropertyNames

- Cover array-indices corner cases around 2**32

Bug: v8:8019
Change-Id: Ic5d81a6944b10067b64ffc596472c076adc49c75
Reviewed-on: https://chromium-review.googlesource.com/1163786Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54936}
parent d28af94b
...@@ -15390,6 +15390,9 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15390,6 +15390,9 @@ THREADED_TEST(GetPropertyNames) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Value> result = CompileRun( v8::Local<v8::Value> result = CompileRun(
"var result = {0: 0, 1: 1, a: 2, b: 3};" "var result = {0: 0, 1: 1, a: 2, b: 3};"
"result[2**32] = '4294967296';"
"result[2**32-1] = '4294967295';"
"result[2**32-2] = '4294967294';"
"result[Symbol('symbol')] = true;" "result[Symbol('symbol')] = true;"
"result.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};" "result.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
"result;"); "result;");
...@@ -15400,8 +15403,10 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15400,8 +15403,10 @@ THREADED_TEST(GetPropertyNames) {
v8::Local<v8::Array> properties = v8::Local<v8::Array> properties =
object->GetPropertyNames(context.local()).ToLocalChecked(); object->GetPropertyNames(context.local()).ToLocalChecked();
const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"}; const char* expected_properties1[] = {"0", "1", "4294967294", "a",
CheckStringArray(isolate, properties, 8, expected_properties1); "b", "4294967296", "4294967295", "2",
"3", "c", "d"};
CheckStringArray(isolate, properties, 11, expected_properties1);
properties = properties =
object object
...@@ -15409,7 +15414,7 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15409,7 +15414,7 @@ THREADED_TEST(GetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes, v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kIncludeIndices) default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
CheckStringArray(isolate, properties, 8, expected_properties1); CheckStringArray(isolate, properties, 11, expected_properties1);
properties = object properties = object
->GetPropertyNames(context.local(), ->GetPropertyNames(context.local(),
...@@ -15417,10 +15422,11 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15417,10 +15422,11 @@ THREADED_TEST(GetPropertyNames) {
include_symbols_filter, include_symbols_filter,
v8::IndexFilter::kIncludeIndices) v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr, const char* expected_properties1_1[] = {
"2", "3", "c", "d"}; "0", "1", "4294967294", "a", "b", "4294967296",
CheckStringArray(isolate, properties, 9, expected_properties1_1); "4294967295", nullptr, "2", "3", "c", "d"};
CheckIsSymbolAt(isolate, properties, 4, "symbol"); CheckStringArray(isolate, properties, 12, expected_properties1_1);
CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties = properties =
object object
...@@ -15428,8 +15434,9 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15428,8 +15434,9 @@ THREADED_TEST(GetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes, v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kSkipIndices) default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties2[] = {"a", "b", "c", "d"}; const char* expected_properties2[] = {"a", "b", "4294967296",
CheckStringArray(isolate, properties, 4, expected_properties2); "4294967295", "c", "d"};
CheckStringArray(isolate, properties, 6, expected_properties2);
properties = object properties = object
->GetPropertyNames(context.local(), ->GetPropertyNames(context.local(),
...@@ -15437,43 +15444,48 @@ THREADED_TEST(GetPropertyNames) { ...@@ -15437,43 +15444,48 @@ THREADED_TEST(GetPropertyNames) {
include_symbols_filter, include_symbols_filter,
v8::IndexFilter::kSkipIndices) v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"}; const char* expected_properties2_1[] = {
CheckStringArray(isolate, properties, 5, expected_properties2_1); "a", "b", "4294967296", "4294967295", nullptr, "c", "d"};
CheckIsSymbolAt(isolate, properties, 2, "symbol"); CheckStringArray(isolate, properties, 7, expected_properties2_1);
CheckIsSymbolAt(isolate, properties, 4, "symbol");
properties = properties =
object object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kIncludeIndices) default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties3[] = {"0", "1", "a", "b"}; const char* expected_properties3[] = {
CheckStringArray(isolate, properties, 4, expected_properties3); "0", "1", "4294967294", "a", "b", "4294967296", "4294967295",
};
CheckStringArray(isolate, properties, 7, expected_properties3);
properties = object properties = object
->GetPropertyNames( ->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly, context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kIncludeIndices) include_symbols_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr}; const char* expected_properties3_1[] = {
CheckStringArray(isolate, properties, 5, expected_properties3_1); "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr};
CheckIsSymbolAt(isolate, properties, 4, "symbol"); CheckStringArray(isolate, properties, 8, expected_properties3_1);
CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties = properties =
object object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kSkipIndices) default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties4[] = {"a", "b"}; const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"};
CheckStringArray(isolate, properties, 2, expected_properties4); CheckStringArray(isolate, properties, 4, expected_properties4);
properties = object properties = object
->GetPropertyNames( ->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly, context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kSkipIndices) include_symbols_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties4_1[] = {"a", "b", nullptr}; const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295",
CheckStringArray(isolate, properties, 3, expected_properties4_1); nullptr};
CheckIsSymbolAt(isolate, properties, 2, "symbol"); CheckStringArray(isolate, properties, 5, expected_properties4_1);
CheckIsSymbolAt(isolate, properties, 4, "symbol");
} }
THREADED_TEST(ProxyGetPropertyNames) { THREADED_TEST(ProxyGetPropertyNames) {
...@@ -15482,6 +15494,9 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15482,6 +15494,9 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Local<v8::Value> result = CompileRun( v8::Local<v8::Value> result = CompileRun(
"var target = {0: 0, 1: 1, a: 2, b: 3};" "var target = {0: 0, 1: 1, a: 2, b: 3};"
"target[2**32] = '4294967296';"
"target[2**32-1] = '4294967295';"
"target[2**32-2] = '4294967294';"
"target[Symbol('symbol')] = true;" "target[Symbol('symbol')] = true;"
"target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};" "target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
"var result = new Proxy(target, {});" "var result = new Proxy(target, {});"
...@@ -15493,8 +15508,10 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15493,8 +15508,10 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::Local<v8::Array> properties = v8::Local<v8::Array> properties =
object->GetPropertyNames(context.local()).ToLocalChecked(); object->GetPropertyNames(context.local()).ToLocalChecked();
const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"}; const char* expected_properties1[] = {"0", "1", "4294967294", "a",
CheckStringArray(isolate, properties, 8, expected_properties1); "b", "4294967296", "4294967295", "2",
"3", "c", "d"};
CheckStringArray(isolate, properties, 11, expected_properties1);
properties = properties =
object object
...@@ -15502,7 +15519,7 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15502,7 +15519,7 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes, v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kIncludeIndices) default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
CheckStringArray(isolate, properties, 8, expected_properties1); CheckStringArray(isolate, properties, 11, expected_properties1);
properties = object properties = object
->GetPropertyNames(context.local(), ->GetPropertyNames(context.local(),
...@@ -15510,10 +15527,11 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15510,10 +15527,11 @@ THREADED_TEST(ProxyGetPropertyNames) {
include_symbols_filter, include_symbols_filter,
v8::IndexFilter::kIncludeIndices) v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr, const char* expected_properties1_1[] = {
"2", "3", "c", "d"}; "0", "1", "4294967294", "a", "b", "4294967296",
CheckStringArray(isolate, properties, 9, expected_properties1_1); "4294967295", nullptr, "2", "3", "c", "d"};
CheckIsSymbolAt(isolate, properties, 4, "symbol"); CheckStringArray(isolate, properties, 12, expected_properties1_1);
CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties = properties =
object object
...@@ -15521,8 +15539,9 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15521,8 +15539,9 @@ THREADED_TEST(ProxyGetPropertyNames) {
v8::KeyCollectionMode::kIncludePrototypes, v8::KeyCollectionMode::kIncludePrototypes,
default_filter, v8::IndexFilter::kSkipIndices) default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties2[] = {"a", "b", "c", "d"}; const char* expected_properties2[] = {"a", "b", "4294967296",
CheckStringArray(isolate, properties, 4, expected_properties2); "4294967295", "c", "d"};
CheckStringArray(isolate, properties, 6, expected_properties2);
properties = object properties = object
->GetPropertyNames(context.local(), ->GetPropertyNames(context.local(),
...@@ -15530,43 +15549,47 @@ THREADED_TEST(ProxyGetPropertyNames) { ...@@ -15530,43 +15549,47 @@ THREADED_TEST(ProxyGetPropertyNames) {
include_symbols_filter, include_symbols_filter,
v8::IndexFilter::kSkipIndices) v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"}; const char* expected_properties2_1[] = {
CheckStringArray(isolate, properties, 5, expected_properties2_1); "a", "b", "4294967296", "4294967295", nullptr, "c", "d"};
CheckIsSymbolAt(isolate, properties, 2, "symbol"); CheckStringArray(isolate, properties, 7, expected_properties2_1);
CheckIsSymbolAt(isolate, properties, 4, "symbol");
properties = properties =
object object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kIncludeIndices) default_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties3[] = {"0", "1", "a", "b"}; const char* expected_properties3[] = {"0", "1", "4294967294", "a",
CheckStringArray(isolate, properties, 4, expected_properties3); "b", "4294967296", "4294967295"};
CheckStringArray(isolate, properties, 7, expected_properties3);
properties = object properties = object
->GetPropertyNames( ->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly, context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kIncludeIndices) include_symbols_filter, v8::IndexFilter::kIncludeIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr}; const char* expected_properties3_1[] = {
CheckStringArray(isolate, properties, 5, expected_properties3_1); "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr};
CheckIsSymbolAt(isolate, properties, 4, "symbol"); CheckStringArray(isolate, properties, 8, expected_properties3_1);
CheckIsSymbolAt(isolate, properties, 7, "symbol");
properties = properties =
object object
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
default_filter, v8::IndexFilter::kSkipIndices) default_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties4[] = {"a", "b"}; const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"};
CheckStringArray(isolate, properties, 2, expected_properties4); CheckStringArray(isolate, properties, 4, expected_properties4);
properties = object properties = object
->GetPropertyNames( ->GetPropertyNames(
context.local(), v8::KeyCollectionMode::kOwnOnly, context.local(), v8::KeyCollectionMode::kOwnOnly,
include_symbols_filter, v8::IndexFilter::kSkipIndices) include_symbols_filter, v8::IndexFilter::kSkipIndices)
.ToLocalChecked(); .ToLocalChecked();
const char* expected_properties4_1[] = {"a", "b", nullptr}; const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295",
CheckStringArray(isolate, properties, 3, expected_properties4_1); nullptr};
CheckIsSymbolAt(isolate, properties, 2, "symbol"); CheckStringArray(isolate, properties, 5, expected_properties4_1);
CheckIsSymbolAt(isolate, properties, 4, "symbol");
} }
THREADED_TEST(AccessChecksReenabledCorrectly) { THREADED_TEST(AccessChecksReenabledCorrectly) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment