Commit 453e1dfa authored by jkummerow's avatar jkummerow Committed by Commit bot

[proxies] Fix HasProperty and getOwnPropertySymbols

JSProxy::HasProperty was missing an early "return Nothing<bool>".
KeyAccumulator's FilterProxyKeys() didn't handle SKIP_STRINGS correctly.

BUG=v8:1543
LOG=n
R=cbruni@chromium.org

Review URL: https://codereview.chromium.org/1505253002

Cr-Commit-Position: refs/heads/master@{#32699}
parent c51e4f1b
...@@ -231,12 +231,7 @@ MaybeHandle<FixedArray> FilterProxyKeys(Isolate* isolate, Handle<JSProxy> owner, ...@@ -231,12 +231,7 @@ MaybeHandle<FixedArray> FilterProxyKeys(Isolate* isolate, Handle<JSProxy> owner,
int store_position = 0; int store_position = 0;
for (int i = 0; i < keys->length(); ++i) { for (int i = 0; i < keys->length(); ++i) {
Handle<Name> key(Name::cast(keys->get(i)), isolate); Handle<Name> key(Name::cast(keys->get(i)), isolate);
if (key->IsSymbol()) { if (key->FilterKey(filter)) continue; // Skip this key.
if ((filter & SKIP_SYMBOLS) || Handle<Symbol>::cast(key)->is_private()) {
continue; // Skip this key.
}
}
if (filter & SKIP_STRINGS) continue; // Skip this key.
if (filter & ONLY_ENUMERABLE) { if (filter & ONLY_ENUMERABLE) {
PropertyDescriptor desc; PropertyDescriptor desc;
bool found = bool found =
......
...@@ -292,9 +292,9 @@ bool Object::FilterKey(PropertyFilter filter) { ...@@ -292,9 +292,9 @@ bool Object::FilterKey(PropertyFilter filter) {
if (IsSymbol()) { if (IsSymbol()) {
if (filter & SKIP_SYMBOLS) return true; if (filter & SKIP_SYMBOLS) return true;
if (Symbol::cast(this)->is_private()) return true; if (Symbol::cast(this)->is_private()) return true;
} else {
if (filter & SKIP_STRINGS) return true;
} }
if ((filter & SKIP_STRINGS) && !IsSymbol()) return true;
return false; return false;
} }
......
...@@ -4669,6 +4669,7 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy, ...@@ -4669,6 +4669,7 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
if (!extensible_target) { if (!extensible_target) {
isolate->Throw(*isolate->factory()->NewTypeError( isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxyTargetNotExtensible)); MessageTemplate::kProxyTargetNotExtensible));
return Nothing<bool>();
} }
} }
} }
......
...@@ -50,7 +50,7 @@ assertThrows("Object.defineProperty(proxy, 'foo', desc)", TypeError); ...@@ -50,7 +50,7 @@ assertThrows("Object.defineProperty(proxy, 'foo', desc)", TypeError);
// Step 15a: Trap returns true for adding a property to a non-extensible target. // Step 15a: Trap returns true for adding a property to a non-extensible target.
handler.defineProperty = function(t, n, d) { return true; } handler.defineProperty = function(t, n, d) { return true; }
Object.freeze(target); Object.preventExtensions(target);
assertThrows("Object.defineProperty(proxy, 'foo', desc)", TypeError); assertThrows("Object.defineProperty(proxy, 'foo', desc)", TypeError);
// Step 15b: Trap returns true for adding a non-configurable property. // Step 15b: Trap returns true for adding a non-configurable property.
......
...@@ -49,7 +49,7 @@ assertThrows("'nonconf' in proxy", TypeError); ...@@ -49,7 +49,7 @@ assertThrows("'nonconf' in proxy", TypeError);
// Step 9b iii. Trap result must confirm presence of all own properties of // Step 9b iii. Trap result must confirm presence of all own properties of
// non-extensible targets. // non-extensible targets.
Object.freeze(target); Object.preventExtensions(target);
assertThrows("'nonconf' in proxy", TypeError); assertThrows("'nonconf' in proxy", TypeError);
assertThrows("'target_one' in proxy", TypeError); assertThrows("'target_one' in proxy", TypeError);
assertFalse("target_two" in proxy); assertFalse("target_two" in proxy);
......
...@@ -74,7 +74,7 @@ keys = ["nonconf"]; ...@@ -74,7 +74,7 @@ keys = ["nonconf"];
assertEquals(keys, Reflect.ownKeys(proxy)); assertEquals(keys, Reflect.ownKeys(proxy));
// Step 19a: The trap result must all keys of a non-extensible target. // Step 19a: The trap result must all keys of a non-extensible target.
Object.freeze(target); Object.preventExtensions(target);
assertThrows("Reflect.ownKeys(proxy)", TypeError); assertThrows("Reflect.ownKeys(proxy)", TypeError);
keys = ["nonconf", "target_one"]; keys = ["nonconf", "target_one"];
assertEquals(keys, Reflect.ownKeys(proxy)); assertEquals(keys, Reflect.ownKeys(proxy));
......
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