| Index: src/proxy.js
|
| ===================================================================
|
| --- src/proxy.js (revision 9808)
|
| +++ src/proxy.js (working copy)
|
| @@ -32,7 +32,10 @@
|
| $Proxy.create = function(handler, proto) {
|
| if (!IS_SPEC_OBJECT(handler))
|
| throw MakeTypeError("handler_non_object", ["create"])
|
| - if (!IS_SPEC_OBJECT(proto)) proto = null // Mozilla does this...
|
| + if (IS_UNDEFINED(proto))
|
| + proto = null
|
| + else if (!(IS_SPEC_OBJECT(proto) || proto === null))
|
| + throw MakeTypeError("proto_non_object", ["create"])
|
| return %CreateJSProxy(handler, proto)
|
| }
|
|
|
| @@ -41,20 +44,20 @@
|
| throw MakeTypeError("handler_non_object", ["create"])
|
| if (!IS_SPEC_FUNCTION(callTrap))
|
| throw MakeTypeError("trap_function_expected", ["createFunction", "call"])
|
| - var construct
|
| if (IS_UNDEFINED(constructTrap)) {
|
| - construct = DerivedConstructTrap(callTrap)
|
| + constructTrap = DerivedConstructTrap(callTrap)
|
| } else if (IS_SPEC_FUNCTION(constructTrap)) {
|
| - construct = function() {
|
| - // Make sure the trap receives 'undefined' as this.
|
| - return %Apply(constructTrap, void 0, arguments, 0, %_ArgumentsLength());
|
| + // Make sure the trap receives 'undefined' as this.
|
| + var construct = constructTrap
|
| + constructTrap = function() {
|
| + return %Apply(construct, void 0, arguments, 0, %_ArgumentsLength());
|
| }
|
| } else {
|
| throw MakeTypeError("trap_function_expected",
|
| ["createFunction", "construct"])
|
| }
|
| return %CreateJSFunctionProxy(
|
| - handler, callTrap, construct, $Function.prototype)
|
| + handler, callTrap, constructTrap, $Function.prototype)
|
| }
|
|
|
|
|
| @@ -153,9 +156,32 @@
|
| 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")
|
| + }
|
| +}
|
|
|