Bug 788914 - Recompute cross-compartment wrappers when UniversalXPConnect is enabled. r=mrbkap

This commit is contained in:
Bobby Holley 2012-09-11 01:05:10 -07:00
parent a3e2696480
commit 2f472dd63b
2 changed files with 9 additions and 5 deletions

View File

@ -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[] = {

View File

@ -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<CompartmentPrivate*>(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());
}
}