mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 764389 - Add an API to change the principals of a compartment. r=luke
This commit is contained in:
parent
a3f69ac10a
commit
19f0a769ef
@ -161,6 +161,31 @@ JS_GetCompartmentPrincipals(JSCompartment *compartment)
|
||||
return compartment->principals;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals)
|
||||
{
|
||||
// Short circuit if there's no change.
|
||||
if (principals == compartment->principals)
|
||||
return;
|
||||
|
||||
// Clear out the old principals, if any.
|
||||
if (compartment->principals) {
|
||||
JS_DropPrincipals(compartment->rt, compartment->principals);
|
||||
compartment->principals = NULL;
|
||||
}
|
||||
|
||||
// Set up the new principals.
|
||||
if (principals) {
|
||||
JS_HoldPrincipals(principals);
|
||||
compartment->principals = principals;
|
||||
}
|
||||
|
||||
// Any compartment with the trusted principals -- and there can be
|
||||
// multiple -- is a system compartment.
|
||||
JSPrincipals *trusted = compartment->rt->trustedPrincipals();
|
||||
compartment->isSystemCompartment = principals && principals == trusted;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc)
|
||||
{
|
||||
|
@ -84,6 +84,9 @@ JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallba
|
||||
extern JS_FRIEND_API(JSPrincipals *)
|
||||
JS_GetCompartmentPrincipals(JSCompartment *compartment);
|
||||
|
||||
extern JS_FRIEND_API(void)
|
||||
JS_SetCompartmentPrincipals(JSCompartment *compartment, JSPrincipals *principals);
|
||||
|
||||
/* Safe to call with input obj == NULL. Returns non-NULL iff obj != NULL. */
|
||||
extern JS_FRIEND_API(JSObject *)
|
||||
JS_ObjectToInnerObject(JSContext *cx, JSObject *obj);
|
||||
|
@ -4043,13 +4043,9 @@ NewCompartment(JSContext *cx, JSPrincipals *principals)
|
||||
|
||||
JSCompartment *compartment = cx->new_<JSCompartment>(rt);
|
||||
if (compartment && compartment->init(cx)) {
|
||||
// Any compartment with the trusted principals -- and there can be
|
||||
// multiple -- is a system compartment.
|
||||
compartment->isSystemCompartment = principals && rt->trustedPrincipals() == principals;
|
||||
if (principals) {
|
||||
compartment->principals = principals;
|
||||
JS_HoldPrincipals(principals);
|
||||
}
|
||||
|
||||
// Set up the principals.
|
||||
JS_SetCompartmentPrincipals(compartment, principals);
|
||||
|
||||
compartment->setGCLastBytes(8192, 8192, GC_NORMAL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user