Commit 6ad42e85 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[proxies][keys] Do not filter ownKeys when defaulting to the target

Previously the KeyAccumulator incorrectly reused the filter properties when
collecting the keys of a proxy target. This led to incorect behavior where for
instance non-enumerable properties were filtered too early.


Bug: v8:7818
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I9b43b65be168ef0975fea9245d433a54338d228e
Reviewed-on: https://chromium-review.googlesource.com/1113743
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54008}
parent 2df4ba02
...@@ -942,7 +942,8 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyTargetKeys( ...@@ -942,7 +942,8 @@ Maybe<bool> KeyAccumulator::CollectOwnJSProxyTargetKeys(
Handle<FixedArray> keys; Handle<FixedArray> keys;
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate_, keys, isolate_, keys,
KeyAccumulator::GetKeys(target, KeyCollectionMode::kOwnOnly, filter_, KeyAccumulator::GetKeys(target, KeyCollectionMode::kOwnOnly,
ALL_PROPERTIES,
GetKeysConversion::kConvertToString, is_for_in_), GetKeysConversion::kConvertToString, is_for_in_),
Nothing<bool>()); Nothing<bool>());
Maybe<bool> result = AddKeysFromJSProxy(proxy, keys); Maybe<bool> result = AddKeysFromJSProxy(proxy, keys);
......
...@@ -32,3 +32,61 @@ ...@@ -32,3 +32,61 @@
k.shift(); k.shift();
assertEquals(0, k.length); assertEquals(0, k.length);
})(); })();
// Ensure we invoke all steps on proxies.
(function ObjectKeysProxy() {
let log = [];
let result = Object.keys(new Proxy({}, {
ownKeys(target) {
log.push('ownKeys');
return ['a', 'b', 'c'];
},
getOwnPropertyDescriptor(target, key) {
log.push('getOwnPropertyDescriptor-' + key);
if (key === 'b') return {enumerable: false, configurable: true};
return {enumerable: true, configurable: true};
}
}));
assertEquals(['a', 'c'], result);
assertEquals(
[
'ownKeys', 'getOwnPropertyDescriptor-a', 'getOwnPropertyDescriptor-b',
'getOwnPropertyDescriptor-c'
],
log);
// Test normal target.
log = [];
let target = {a: 1, b: 1, c: 1};
let handler = {
getOwnPropertyDescriptor(target, key) {
log.push('getOwnPropertyDescriptor-' + key);
if (key === 'b') return {enumerable: false, configurable: true};
return {enumerable: true, configurable: true};
}
};
result = Object.keys(new Proxy(target, handler));
assertEquals(['a', 'c'], result);
assertEquals(
[
'getOwnPropertyDescriptor-a', 'getOwnPropertyDescriptor-b',
'getOwnPropertyDescriptor-c'
],
log);
// Test trap invocation with non-enumerable target properties.
log = [];
target = Object.create(Object.prototype, {
a: {enumerable: true, configurable: true},
b: {enumerable: false, configurable: true},
c: {enumerable: true, configurable: true}
});
result = Object.keys(new Proxy(target, handler));
assertEquals(['a', 'c'], result);
assertEquals(
[
'getOwnPropertyDescriptor-a', 'getOwnPropertyDescriptor-b',
'getOwnPropertyDescriptor-c'
],
log);
})();
...@@ -614,9 +614,6 @@ ...@@ -614,9 +614,6 @@
# https://bugs.chromium.org/p/v8/issues/detail?id=6705 # https://bugs.chromium.org/p/v8/issues/detail?id=6705
'built-ins/Object/assign/strings-and-symbol-order': [FAIL], 'built-ins/Object/assign/strings-and-symbol-order': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=7818
'built-ins/Object/keys/property-traps-order-with-proxied-array': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=7781 # https://bugs.chromium.org/p/v8/issues/detail?id=7781
'built-ins/Date/parse/time-value-maximum-range': [FAIL], 'built-ins/Date/parse/time-value-maximum-range': [FAIL],
......
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