@@ -15356,14 +15356,107 @@ THREADED_TEST(PropertyEnumeration2) {
15356
15356
}
15357
15357
}
15358
15358
15359
- THREADED_TEST(PropertyNames ) {
15359
+ THREADED_TEST(GetPropertyNames ) {
15360
15360
LocalContext context;
15361
15361
v8::Isolate* isolate = context->GetIsolate();
15362
15362
v8::HandleScope scope(isolate);
15363
15363
v8::Local<v8::Value> result = CompileRun(
15364
15364
"var result = {0: 0, 1: 1, a: 2, b: 3};"
15365
15365
"result[Symbol('symbol')] = true;"
15366
- "result.__proto__ = {2: 4, 3: 5, c: 6, d: 7};"
15366
+ "result.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
15367
+ "result;");
15368
+ v8::Local<v8::Object> object = result.As<v8::Object>();
15369
+ v8::PropertyFilter default_filter =
15370
+ static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS);
15371
+ v8::PropertyFilter include_symbols_filter = v8::ONLY_ENUMERABLE;
15372
+
15373
+ v8::Local<v8::Array> properties =
15374
+ object->GetPropertyNames(context.local()).ToLocalChecked();
15375
+ const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"};
15376
+ CheckStringArray(isolate, properties, 8, expected_properties1);
15377
+
15378
+ properties =
15379
+ object
15380
+ ->GetPropertyNames(context.local(),
15381
+ v8::KeyCollectionMode::kIncludePrototypes,
15382
+ default_filter, v8::IndexFilter::kIncludeIndices)
15383
+ .ToLocalChecked();
15384
+ CheckStringArray(isolate, properties, 8, expected_properties1);
15385
+
15386
+ properties = object
15387
+ ->GetPropertyNames(context.local(),
15388
+ v8::KeyCollectionMode::kIncludePrototypes,
15389
+ include_symbols_filter,
15390
+ v8::IndexFilter::kIncludeIndices)
15391
+ .ToLocalChecked();
15392
+ const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr,
15393
+ "2", "3", "c", "d"};
15394
+ CheckStringArray(isolate, properties, 9, expected_properties1_1);
15395
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
15396
+
15397
+ properties =
15398
+ object
15399
+ ->GetPropertyNames(context.local(),
15400
+ v8::KeyCollectionMode::kIncludePrototypes,
15401
+ default_filter, v8::IndexFilter::kSkipIndices)
15402
+ .ToLocalChecked();
15403
+ const char* expected_properties2[] = {"a", "b", "c", "d"};
15404
+ CheckStringArray(isolate, properties, 4, expected_properties2);
15405
+
15406
+ properties = object
15407
+ ->GetPropertyNames(context.local(),
15408
+ v8::KeyCollectionMode::kIncludePrototypes,
15409
+ include_symbols_filter,
15410
+ v8::IndexFilter::kSkipIndices)
15411
+ .ToLocalChecked();
15412
+ const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"};
15413
+ CheckStringArray(isolate, properties, 5, expected_properties2_1);
15414
+ CheckIsSymbolAt(isolate, properties, 2, "symbol");
15415
+
15416
+ properties =
15417
+ object
15418
+ ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
15419
+ default_filter, v8::IndexFilter::kIncludeIndices)
15420
+ .ToLocalChecked();
15421
+ const char* expected_properties3[] = {"0", "1", "a", "b"};
15422
+ CheckStringArray(isolate, properties, 4, expected_properties3);
15423
+
15424
+ properties = object
15425
+ ->GetPropertyNames(
15426
+ context.local(), v8::KeyCollectionMode::kOwnOnly,
15427
+ include_symbols_filter, v8::IndexFilter::kIncludeIndices)
15428
+ .ToLocalChecked();
15429
+ const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr};
15430
+ CheckStringArray(isolate, properties, 5, expected_properties3_1);
15431
+ CheckIsSymbolAt(isolate, properties, 4, "symbol");
15432
+
15433
+ properties =
15434
+ object
15435
+ ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
15436
+ default_filter, v8::IndexFilter::kSkipIndices)
15437
+ .ToLocalChecked();
15438
+ const char* expected_properties4[] = {"a", "b"};
15439
+ CheckStringArray(isolate, properties, 2, expected_properties4);
15440
+
15441
+ properties = object
15442
+ ->GetPropertyNames(
15443
+ context.local(), v8::KeyCollectionMode::kOwnOnly,
15444
+ include_symbols_filter, v8::IndexFilter::kSkipIndices)
15445
+ .ToLocalChecked();
15446
+ const char* expected_properties4_1[] = {"a", "b", nullptr};
15447
+ CheckStringArray(isolate, properties, 3, expected_properties4_1);
15448
+ CheckIsSymbolAt(isolate, properties, 2, "symbol");
15449
+ }
15450
+
15451
+ THREADED_TEST(ProxyGetPropertyNames) {
15452
+ LocalContext context;
15453
+ v8::Isolate* isolate = context->GetIsolate();
15454
+ v8::HandleScope scope(isolate);
15455
+ v8::Local<v8::Value> result = CompileRun(
15456
+ "var target = {0: 0, 1: 1, a: 2, b: 3};"
15457
+ "target[Symbol('symbol')] = true;"
15458
+ "target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
15459
+ "var result = new Proxy(target, {});"
15367
15460
"result;");
15368
15461
v8::Local<v8::Object> object = result.As<v8::Object>();
15369
15462
v8::PropertyFilter default_filter =
0 commit comments