Bug 780712 - Allow RegExp objects to be visible across compartments (r=billm,a=lsblakk)
authorLuke Wagner <luke@mozilla.com>
Thu, 09 Aug 2012 17:13:01 -0700
changeset 100471 ac9af7f6b0d10075c2f7de9ee486a8b988d42d49
parent 100470 9004df40d089875d533645a17edc25fabea2b72a
child 100474 6bc2cad5a3b48f45c16c6c22ef61cc9b2b5cce2d
push id1255
push userlwagner@mozilla.com
push dateFri, 10 Aug 2012 00:14:09 +0000
treeherdermozilla-beta@ac9af7f6b0d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, lsblakk
bugs780712
milestone15.0
Bug 780712 - Allow RegExp objects to be visible across compartments (r=billm,a=lsblakk)
js/src/jswrapper.cpp
js/src/jswrapper.h
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -758,16 +758,26 @@ CrossCompartmentWrapper::fun_toString(JS
 
     call.leave();
     if (!cx->compartment->wrap(cx, &str))
         return NULL;
     return str;
 }
 
 bool
+CrossCompartmentWrapper::regexp_toShared(JSContext *cx, JSObject *wrapper, RegExpGuard *g)
+{
+    AutoCompartment call(cx, wrappedObject(wrapper));
+    if (!call.enter())
+        return NULL;
+
+    return DirectWrapper::regexp_toShared(cx, wrapper, g);
+}
+
+bool
 CrossCompartmentWrapper::defaultValue(JSContext *cx, JSObject *wrapper, JSType hint, Value *vp)
 {
     AutoCompartment call(cx, wrappedObject(wrapper));
     if (!call.enter())
         return false;
 
     if (!IndirectProxyHandler::defaultValue(cx, wrapper, hint, vp))
         return false;
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -158,16 +158,17 @@ class JS_FRIEND_API(CrossCompartmentWrap
 
     /* Spidermonkey extensions. */
     virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp) MOZ_OVERRIDE;
     virtual bool construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *rval) MOZ_OVERRIDE;
     virtual bool nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args) MOZ_OVERRIDE;
     virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp) MOZ_OVERRIDE;
     virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE;
     virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, unsigned indent) MOZ_OVERRIDE;
+    virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) MOZ_OVERRIDE;
     virtual bool defaultValue(JSContext *cx, JSObject *wrapper, JSType hint, Value *vp) MOZ_OVERRIDE;
     virtual bool iteratorNext(JSContext *cx, JSObject *wrapper, Value *vp);
 
     static CrossCompartmentWrapper singleton;
 };
 
 /*
  * Base class for security wrappers. A security wrapper is potentially hiding