Commit df36d046 authored by cbruni's avatar cbruni Committed by Commit bot

[runtime] [proxy] Fix Object.prototype.PropertyIsEnumerable to support

proxies.

BUG=v8:1543
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#32473}
parent 8948e08e
...@@ -207,16 +207,9 @@ function ObjectIsPrototypeOf(V) { ...@@ -207,16 +207,9 @@ function ObjectIsPrototypeOf(V) {
} }
// ECMA-262 - 15.2.4.6 // ES6 19.1.3.4
function ObjectPropertyIsEnumerable(V) { function ObjectPropertyIsEnumerable(V) {
var P = TO_NAME(V); var P = TO_NAME(V);
if (%_IsJSProxy(this)) {
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (IS_SYMBOL(V)) return false;
var desc = GetOwnPropertyJS(this, P);
return IS_UNDEFINED(desc) ? false : desc.isEnumerable();
}
return %IsPropertyEnumerable(TO_OBJECT(this), P); return %IsPropertyEnumerable(TO_OBJECT(this), P);
} }
......
...@@ -755,13 +755,13 @@ RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { ...@@ -755,13 +755,13 @@ RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK(args.length() == 2); DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
Maybe<PropertyAttributes> maybe = Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnPropertyAttributes(object, key); JSReceiver::GetOwnPropertyAttributes(object, key);
if (!maybe.IsJust()) return isolate->heap()->exception(); if (!maybe.IsJust()) return isolate->heap()->exception();
if (maybe.FromJust() == ABSENT) maybe = Just(DONT_ENUM); if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value();
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
} }
......
// Copyright 2015 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.
// Flags: --harmony-proxies
var handler = {};
var target = { a: 1 };
var proxy = new Proxy(target, handler);
assertTrue(target.propertyIsEnumerable('a'));
assertTrue(proxy.propertyIsEnumerable('a'));
assertFalse(target.propertyIsEnumerable('b'));
assertFalse(proxy.propertyIsEnumerable('b'));
handler.getOwnPropertyDescriptor = function(target, prop) {
return { configurable: true, enumerable: true, value: 10 };
}
assertTrue(target.propertyIsEnumerable('a'));
assertTrue(proxy.propertyIsEnumerable('a'));
assertFalse(target.propertyIsEnumerable('b'));
assertTrue(proxy.propertyIsEnumerable('b'));
handler.getOwnPropertyDescriptor = function(target, prop) {
return { configurable: true, enumerable: false, value: 10 };
}
assertTrue(target.propertyIsEnumerable('a'));
assertFalse(proxy.propertyIsEnumerable('a'));
assertFalse(target.propertyIsEnumerable('b'));
assertFalse(proxy.propertyIsEnumerable('b'));
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