Index: src/proxy.js |
diff --git a/src/proxy.js b/src/proxy.js |
index a51f09ae50ff3eee75840e970413ddd75909d9a9..b4cc2613596044e3d9d5e32a477c3127741fbe17 100644 |
--- a/src/proxy.js |
+++ b/src/proxy.js |
@@ -153,9 +153,32 @@ function DerivedKeysTrap() { |
var enumerableNames = [] |
for (var i = 0, count = 0; i < names.length; ++i) { |
var name = names[i] |
- if (this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)).enumerable) { |
+ var desc = this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)) |
+ if (!IS_UNDEFINED(desc) && desc.enumerable) { |
enumerableNames[count++] = names[i] |
} |
} |
return enumerableNames |
} |
+ |
+function DerivedEnumerateTrap() { |
+ var names = this.getPropertyNames() |
+ var enumerableNames = [] |
+ for (var i = 0, count = 0; i < names.length; ++i) { |
+ var name = names[i] |
+ var desc = this.getPropertyDescriptor(TO_STRING_INLINE(name)) |
+ if (!IS_UNDEFINED(desc) && desc.enumerable) { |
+ enumerableNames[count++] = names[i] |
+ } |
+ } |
+ return enumerableNames |
+} |
+ |
+function ProxyEnumerate(proxy) { |
+ var handler = %GetHandler(proxy) |
+ if (IS_UNDEFINED(handler.enumerate)) { |
+ return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) |
+ } else { |
+ return ToStringArray(handler.enumerate(), "enumerate") |
+ } |
+} |