[keys] propagate PropertyFilter to proxy targets in KeyAccumulator
BUG=v8:5174, v8:1543 R=cbruni@chromium.org, littledan@chromium.org Review-Url: https://codereview.chromium.org/2129193003 Cr-Commit-Position: refs/heads/master@{#37634}
This commit is contained in:
parent
3e2085eba4
commit
08d0012dda
@ -853,7 +853,11 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyTargetKeys(
|
||||
// TODO(cbruni): avoid creating another KeyAccumulator
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate_, keys, JSReceiver::OwnPropertyKeys(target), Nothing<bool>());
|
||||
isolate_, keys,
|
||||
KeyAccumulator::GetKeys(target, KeyCollectionMode::kOwnOnly, filter_,
|
||||
GetKeysConversion::kConvertToString,
|
||||
filter_proxy_keys_, is_for_in_),
|
||||
Nothing<bool>());
|
||||
bool prev_filter_proxy_keys_ = filter_proxy_keys_;
|
||||
filter_proxy_keys_ = false;
|
||||
Maybe<bool> result = AddKeysFromJSProxy(proxy, keys);
|
||||
|
@ -8308,11 +8308,13 @@ MaybeHandle<FixedArray> GetOwnValuesOrEntries(Isolate* isolate,
|
||||
|
||||
PropertyFilter key_filter =
|
||||
static_cast<PropertyFilter>(filter & ~ONLY_ENUMERABLE);
|
||||
KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly, key_filter);
|
||||
MAYBE_RETURN(accumulator.CollectKeys(object, object),
|
||||
|
||||
Handle<FixedArray> keys;
|
||||
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
||||
isolate, keys,
|
||||
KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, key_filter,
|
||||
GetKeysConversion::kConvertToString),
|
||||
MaybeHandle<FixedArray>());
|
||||
Handle<FixedArray> keys =
|
||||
accumulator.GetKeys(GetKeysConversion::kConvertToString);
|
||||
|
||||
values_or_entries = isolate->factory()->NewFixedArray(keys->length());
|
||||
int length = 0;
|
||||
|
@ -48,3 +48,31 @@ assertEquals(["target"], Object.keys(proxy2));
|
||||
assertEquals(["1","2"], Object.getOwnPropertyNames(p));
|
||||
assertEquals([symbol], Object.getOwnPropertySymbols(p));
|
||||
})();
|
||||
|
||||
(function testNoProxyTraps() {
|
||||
var test_sym = Symbol("sym1");
|
||||
var test_sym2 = Symbol("sym2");
|
||||
var target = {
|
||||
one: 1,
|
||||
two: 2,
|
||||
[test_sym]: 4,
|
||||
0: 0,
|
||||
};
|
||||
Object.defineProperty(
|
||||
target, "non-enum",
|
||||
{ enumerable: false, value: "nope", configurable: true, writable: true });
|
||||
target.__proto__ = {
|
||||
target_proto: 3,
|
||||
1: 1,
|
||||
[test_sym2]: 5
|
||||
};
|
||||
Object.defineProperty(
|
||||
target.__proto__, "non-enum2",
|
||||
{ enumerable: false, value: "nope", configurable: true, writable: true });
|
||||
var proxy = new Proxy(target, {});
|
||||
|
||||
assertEquals(["0", "one", "two"], Object.keys(proxy));
|
||||
assertEquals(["0", "one", "two", "non-enum"],
|
||||
Object.getOwnPropertyNames(proxy));
|
||||
assertEquals([test_sym], Object.getOwnPropertySymbols(proxy));
|
||||
})();
|
||||
|
6
test/mjsunit/regress/regress-5174.js
Normal file
6
test/mjsunit/regress/regress-5174.js
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||
// // Use of this source code is governed by a BSD-style license that can be
|
||||
// // found in the LICENSE file.
|
||||
|
||||
assertEquals([], Object.keys(new Proxy([], {})));
|
||||
assertEquals([], Object.keys(new Proxy(/regex/, {})));
|
Loading…
Reference in New Issue
Block a user