Index: src/js/proxy.js |
diff --git a/src/js/proxy.js b/src/js/proxy.js |
index fc38680a13a8daae96d7df99e3acf839ecb35232..b84e53b20b6771b791f123eeac36caea5e21f8b2 100644 |
--- a/src/js/proxy.js |
+++ b/src/js/proxy.js |
@@ -10,7 +10,7 @@ |
// ---------------------------------------------------------------------------- |
// Imports |
- |
+var GlobalProxy = global.Proxy; |
var GlobalFunction = global.Function; |
var GlobalObject = global.Object; |
var MakeTypeError; |
@@ -24,12 +24,16 @@ utils.Import(function(from) { |
//---------------------------------------------------------------------------- |
function ProxyCreate(handler, proto) { |
- if (!IS_SPEC_OBJECT(handler)) |
+ if (!%_IsConstructCall()) { |
+ throw MakeTypeError(kConstructorNotFunction, "Proxy"); |
+ } else if (!IS_SPEC_OBJECT(handler)) { |
throw MakeTypeError(kProxyHandlerNonObject, "create") |
- if (IS_UNDEFINED(proto)) |
+ } |
+ if (IS_UNDEFINED(proto)) { |
proto = null |
- else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) |
+ } else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto))) { |
throw MakeTypeError(kProxyProtoNonObject) |
+ } |
return %CreateJSProxy(handler, proto) |
} |
@@ -182,16 +186,16 @@ function ProxyEnumerate(proxy) { |
} |
//------------------------------------------------------------------- |
+%SetCode(GlobalProxy, ProxyCreate); |
+%FunctionSetPrototype(GlobalProxy, new GlobalObject()); |
-var Proxy = new GlobalObject(); |
-%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM); |
- |
-//Set up non-enumerable properties of the Proxy object. |
-utils.InstallFunctions(Proxy, DONT_ENUM, [ |
+// //Set up non-enumerable properties of the Proxy object. |
+utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ |
"create", ProxyCreate, |
"createFunction", ProxyCreateFunction |
-]) |
+]); |
+%AddNamedProperty(GlobalProxy.prototype, "constructor", GlobalProxy, DONT_ENUM); |
// ------------------------------------------------------------------- |
// Exports |