From 2f472dd63bebbb12468782b1eb96f59ee300333b Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 11 Sep 2012 01:05:10 -0700 Subject: [PATCH] Bug 788914 - Recompute cross-compartment wrappers when UniversalXPConnect is enabled. r=mrbkap --- caps/src/nsSecurityManagerFactory.cpp | 3 +-- js/xpconnect/src/xpcprivate.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/caps/src/nsSecurityManagerFactory.cpp b/caps/src/nsSecurityManagerFactory.cpp index 2899467fa8c..752a56f7c9a 100644 --- a/caps/src/nsSecurityManagerFactory.cpp +++ b/caps/src/nsSecurityManagerFactory.cpp @@ -45,8 +45,7 @@ NS_IMPL_ISUPPORTS1(nsSecurityNameSet, nsIScriptExternalNameSet) static JSBool netscape_security_enablePrivilege(JSContext *cx, unsigned argc, jsval *vp) { - xpc::EnableUniversalXPConnect(cx); - return JS_TRUE; + return xpc::EnableUniversalXPConnect(cx); } static JSFunctionSpec PrivilegeManager_static_methods[] = { diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index a61983e18b2..b3e8b856376 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -4397,16 +4397,21 @@ inline bool IsUniversalXPConnectEnabled(JSContext *cx) return IsUniversalXPConnectEnabled(compartment); } -inline void EnableUniversalXPConnect(JSContext *cx) +inline bool EnableUniversalXPConnect(JSContext *cx) { JSCompartment *compartment = js::GetContextCompartment(cx); if (!compartment) - return; + return true; CompartmentPrivate *priv = static_cast(JS_GetCompartmentPrivate(compartment)); if (!priv) - return; + return true; priv->universalXPConnectEnabled = true; + + // Recompute all the cross-compartment wrappers leaving the newly-privileged + // compartment. + return js::RecomputeWrappers(cx, js::SingleCompartment(compartment), + js::AllCompartments()); } }