Bug 803068 - Manually grab the BaseProxyHandler derived traps in SandboxProxyHandler. r=ejpbruel
authorBobby Holley <bobbyholley@gmail.com>
Mon, 29 Oct 2012 16:52:53 +0100
changeset 111807 1413ce44a30fc597cb1affa9b60f3cc32bbadbba
parent 111806 461978f9a844c3418db9d639d27739951be433e6
child 111808 4a812a19c2671a28006f3c0f6ded4591b15c2ea3
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersejpbruel
bugs803068
milestone19.0a1
Bug 803068 - Manually grab the BaseProxyHandler derived traps in SandboxProxyHandler. r=ejpbruel Let's just bite the bullet and do this here. It will let us get rid of IndirectProxyHandler, which has really overcomplicated our proxy hierarchy.
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/wrappers/XrayWrapper.h
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3214,16 +3214,61 @@ xpc::SandboxProxyHandler::getOwnProperty
         return false;
 
     if (desc->obj != wrappedObject(proxy))
         desc->obj = nullptr;
 
     return true;
 }
 
+/*
+ * Reuse the BaseProxyHandler versions of the derived traps that are implemented
+ * in terms of the fundamental traps.
+ */
+
+bool
+xpc::SandboxProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
+{
+    return BaseProxyHandler::has(cx, proxy, id, bp);
+}
+bool
+xpc::SandboxProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id,
+                                 bool *bp)
+{
+    return BaseProxyHandler::hasOwn(cx, proxy, id, bp);
+}
+
+bool
+xpc::SandboxProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver,
+                              jsid id, Value *vp)
+{
+    return BaseProxyHandler::get(cx, proxy, receiver, id, vp);
+}
+
+bool
+xpc::SandboxProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver,
+                              jsid id, bool strict, Value *vp)
+{
+    return BaseProxyHandler::set(cx, proxy, receiver, id, strict, vp);
+}
+
+bool
+xpc::SandboxProxyHandler::keys(JSContext *cx, JSObject *proxy,
+                               AutoIdVector &props)
+{
+    return BaseProxyHandler::keys(cx, proxy, props);
+}
+
+bool
+xpc::SandboxProxyHandler::iterate(JSContext *cx, JSObject *proxy, unsigned flags,
+                                  Value *vp)
+{
+    return BaseProxyHandler::iterate(cx, proxy, flags, vp);
+}
+
 nsresult
 xpc_CreateSandboxObject(JSContext *cx, jsval *vp, nsISupports *prinOrSop, SandboxOptions& options)
 {
     // Create the sandbox global object
     nsresult rv;
     nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
     if (NS_FAILED(rv))
         return NS_ERROR_XPC_UNEXPECTED;
--- a/js/xpconnect/wrappers/XrayWrapper.h
+++ b/js/xpconnect/wrappers/XrayWrapper.h
@@ -90,27 +90,39 @@ class XrayWrapper : public Base {
 
   private:
     bool enumerate(JSContext *cx, JSObject *wrapper, unsigned flags,
                    JS::AutoIdVector &props);
 };
 
 typedef XrayWrapper<js::CrossCompartmentWrapper, DOMXrayTraits > XrayDOM;
 
-class SandboxProxyHandler : public js::IndirectWrapper {
+class SandboxProxyHandler : public js::DirectWrapper {
 public:
-    SandboxProxyHandler() : js::IndirectWrapper(0)
+    SandboxProxyHandler() : js::DirectWrapper(0)
     {
     }
 
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
-                                       bool set, js::PropertyDescriptor *desc);
+                                       bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
                                           jsid id, bool set,
-                                          js::PropertyDescriptor *desc);
+                                          js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+
+    // We just forward the derived traps to the BaseProxyHandler versions which
+    // implement them in terms of the fundamental traps.
+    virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
+    virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
+    virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver,
+                     jsid id, JS::Value *vp) MOZ_OVERRIDE;
+    virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver,
+                     jsid id, bool strict, JS::Value *vp) MOZ_OVERRIDE;
+    virtual bool keys(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props) MOZ_OVERRIDE;
+    virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags,
+                         JS::Value *vp) MOZ_OVERRIDE;
 };
 
 extern SandboxProxyHandler sandboxProxyHandler;
 
 class AutoSetWrapperNotShadowing;
 class XPCWrappedNativeXrayTraits;
 
 class ResolvingId {