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