Skip to content

Commit 8e203f1

Browse files
authored
deps: V8: cherry-pick 975ff4dbfd1b
Original commit message: fix GetPropertyNames for proxys with ownKeys trap Added checks to FilterProxyKeys function for when skip_indices is enabled. Bug: v8:13728 Change-Id: Id096e32ef8e6c2344be9682e8222aea8790bd66d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4333698 Reviewed-by: Camillo Bruni <[email protected]> Commit-Queue: Jakob Kummerow <[email protected]> Cr-Commit-Position: refs/heads/main@{#86548} Refs: v8/v8@975ff4d PR-URL: #47209 Fixes: #41714 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Erick Wendel <[email protected]>
1 parent 8c60add commit 8e203f1

File tree

4 files changed

+114
-3
lines changed

4 files changed

+114
-3
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.10',
39+
'v8_embedder_string': '-node.11',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Darshan Sen <[email protected]>
9898
David Carlier <[email protected]>
9999
David Manouchehri <[email protected]>
100100
David Sanders <[email protected]>
101+
Debadree Chatterjee <[email protected]>
101102
Deepak Mohan <[email protected]>
102103
Deon Dior <[email protected]>
103104

deps/v8/src/objects/keys.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ ExceptionStatus KeyAccumulator::AddKeys(Handle<JSObject> array_like,
182182
MaybeHandle<FixedArray> FilterProxyKeys(KeyAccumulator* accumulator,
183183
Handle<JSProxy> owner,
184184
Handle<FixedArray> keys,
185-
PropertyFilter filter) {
185+
PropertyFilter filter,
186+
bool skip_indices) {
186187
if (filter == ALL_PROPERTIES) {
187188
// Nothing to do.
188189
return keys;
@@ -192,6 +193,10 @@ MaybeHandle<FixedArray> FilterProxyKeys(KeyAccumulator* accumulator,
192193
for (int i = 0; i < keys->length(); ++i) {
193194
Handle<Name> key(Name::cast(keys->get(i)), isolate);
194195
if (key->FilterKey(filter)) continue; // Skip this key.
196+
if (skip_indices) {
197+
uint32_t index;
198+
if (key->AsArrayIndex(&index)) continue; // Skip this key.
199+
}
195200
if (filter & ONLY_ENUMERABLE) {
196201
PropertyDescriptor desc;
197202
Maybe<bool> found =
@@ -218,7 +223,8 @@ Maybe<bool> KeyAccumulator::AddKeysFromJSProxy(Handle<JSProxy> proxy,
218223
// Postpone the enumerable check for for-in to the ForInFilter step.
219224
if (!is_for_in_) {
220225
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
221-
isolate_, keys, FilterProxyKeys(this, proxy, keys, filter_),
226+
isolate_, keys,
227+
FilterProxyKeys(this, proxy, keys, filter_, skip_indices_),
222228
Nothing<bool>());
223229
}
224230
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys

deps/v8/test/cctest/test-api.cc

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14425,6 +14425,110 @@ THREADED_TEST(ProxyGetPropertyNames) {
1442514425
CheckIsSymbolAt(isolate, properties, 4, "symbol");
1442614426
}
1442714427

14428+
THREADED_TEST(ProxyGetPropertyNamesWithOwnKeysTrap) {
14429+
LocalContext context;
14430+
v8::Isolate* isolate = context->GetIsolate();
14431+
v8::HandleScope scope(isolate);
14432+
v8::Local<v8::Value> result = CompileRun(
14433+
"var target = {0: 0, 1: 1, a: 2, b: 3};"
14434+
"target[2**32] = '4294967296';"
14435+
"target[2**32-1] = '4294967295';"
14436+
"target[2**32-2] = '4294967294';"
14437+
"target[Symbol('symbol')] = true;"
14438+
"target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};"
14439+
"var result = new Proxy(target, { ownKeys: (t) => Reflect.ownKeys(t) });"
14440+
"result;");
14441+
v8::Local<v8::Object> object = result.As<v8::Object>();
14442+
v8::PropertyFilter default_filter =
14443+
static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS);
14444+
v8::PropertyFilter include_symbols_filter = v8::ONLY_ENUMERABLE;
14445+
14446+
v8::Local<v8::Array> properties =
14447+
object->GetPropertyNames(context.local()).ToLocalChecked();
14448+
const char* expected_properties1[] = {"0", "1", "4294967294", "a",
14449+
"b", "4294967296", "4294967295", "2",
14450+
"3", "c", "d"};
14451+
CheckStringArray(isolate, properties, 11, expected_properties1);
14452+
14453+
properties =
14454+
object
14455+
->GetPropertyNames(context.local(),
14456+
v8::KeyCollectionMode::kIncludePrototypes,
14457+
default_filter, v8::IndexFilter::kIncludeIndices)
14458+
.ToLocalChecked();
14459+
CheckStringArray(isolate, properties, 11, expected_properties1);
14460+
14461+
properties = object
14462+
->GetPropertyNames(context.local(),
14463+
v8::KeyCollectionMode::kIncludePrototypes,
14464+
include_symbols_filter,
14465+
v8::IndexFilter::kIncludeIndices)
14466+
.ToLocalChecked();
14467+
const char* expected_properties1_1[] = {
14468+
"0", "1", "4294967294", "a", "b", "4294967296",
14469+
"4294967295", nullptr, "2", "3", "c", "d"};
14470+
CheckStringArray(isolate, properties, 12, expected_properties1_1);
14471+
CheckIsSymbolAt(isolate, properties, 7, "symbol");
14472+
14473+
properties =
14474+
object
14475+
->GetPropertyNames(context.local(),
14476+
v8::KeyCollectionMode::kIncludePrototypes,
14477+
default_filter, v8::IndexFilter::kSkipIndices)
14478+
.ToLocalChecked();
14479+
const char* expected_properties2[] = {"a", "b", "4294967296",
14480+
"4294967295", "c", "d"};
14481+
CheckStringArray(isolate, properties, 6, expected_properties2);
14482+
14483+
properties = object
14484+
->GetPropertyNames(context.local(),
14485+
v8::KeyCollectionMode::kIncludePrototypes,
14486+
include_symbols_filter,
14487+
v8::IndexFilter::kSkipIndices)
14488+
.ToLocalChecked();
14489+
const char* expected_properties2_1[] = {
14490+
"a", "b", "4294967296", "4294967295", nullptr, "c", "d"};
14491+
CheckStringArray(isolate, properties, 7, expected_properties2_1);
14492+
CheckIsSymbolAt(isolate, properties, 4, "symbol");
14493+
14494+
properties =
14495+
object
14496+
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
14497+
default_filter, v8::IndexFilter::kIncludeIndices)
14498+
.ToLocalChecked();
14499+
const char* expected_properties3[] = {"0", "1", "4294967294", "a",
14500+
"b", "4294967296", "4294967295"};
14501+
CheckStringArray(isolate, properties, 7, expected_properties3);
14502+
14503+
properties = object
14504+
->GetPropertyNames(
14505+
context.local(), v8::KeyCollectionMode::kOwnOnly,
14506+
include_symbols_filter, v8::IndexFilter::kIncludeIndices)
14507+
.ToLocalChecked();
14508+
const char* expected_properties3_1[] = {
14509+
"0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr};
14510+
CheckStringArray(isolate, properties, 8, expected_properties3_1);
14511+
CheckIsSymbolAt(isolate, properties, 7, "symbol");
14512+
14513+
properties =
14514+
object
14515+
->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly,
14516+
default_filter, v8::IndexFilter::kSkipIndices)
14517+
.ToLocalChecked();
14518+
const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"};
14519+
CheckStringArray(isolate, properties, 4, expected_properties4);
14520+
14521+
properties = object
14522+
->GetPropertyNames(
14523+
context.local(), v8::KeyCollectionMode::kOwnOnly,
14524+
include_symbols_filter, v8::IndexFilter::kSkipIndices)
14525+
.ToLocalChecked();
14526+
const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295",
14527+
nullptr};
14528+
CheckStringArray(isolate, properties, 5, expected_properties4_1);
14529+
CheckIsSymbolAt(isolate, properties, 4, "symbol");
14530+
}
14531+
1442814532
THREADED_TEST(AccessChecksReenabledCorrectly) {
1442914533
LocalContext context;
1443014534
v8::Isolate* isolate = context->GetIsolate();

0 commit comments

Comments
 (0)