mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 824864 - Implement nsContentUtils::GetObjectPrincipal. r=bz
The SSM interface is super awkward.
This commit is contained in:
parent
85b3a83b16
commit
1d5c9aeac3
@ -438,6 +438,13 @@ public:
|
||||
// be called when nsContentUtils is initialized.
|
||||
static nsIPrincipal* GetSubjectPrincipal();
|
||||
|
||||
// Returns the principal of the given JS object. This should never be null
|
||||
// for any object in the XPConnect runtime.
|
||||
//
|
||||
// In general, being interested in the principal of an object is enough to
|
||||
// guarantee that the return value is non-null.
|
||||
static nsIPrincipal* GetObjectPrincipal(JSObject* aObj);
|
||||
|
||||
static nsresult GenerateStateKey(nsIContent* aContent,
|
||||
const nsIDocument* aDocument,
|
||||
nsACString& aKey);
|
||||
|
@ -2330,6 +2330,17 @@ nsContentUtils::GetSubjectPrincipal()
|
||||
return subject;
|
||||
}
|
||||
|
||||
// static
|
||||
nsIPrincipal*
|
||||
nsContentUtils::GetObjectPrincipal(JSObject* aObj)
|
||||
{
|
||||
// This is duplicated from nsScriptSecurityManager. We don't call through there
|
||||
// because the API unnecessarily requires a JSContext for historical reasons.
|
||||
JSCompartment *compartment = js::GetObjectCompartment(aObj);
|
||||
JSPrincipals *principals = JS_GetCompartmentPrincipals(compartment);
|
||||
return nsJSPrincipals::get(principals);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::NewURIWithDocumentCharset(nsIURI** aResult,
|
||||
|
@ -1061,6 +1061,7 @@ CreateGlobalObject(JSContext *cx, JSClass *clasp, nsIPrincipal *principal)
|
||||
CheckTypeInference(cx, clasp, principal);
|
||||
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "using a principal off the main thread?");
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
JSObject *global = JS_NewGlobalObject(cx, clasp, nsJSPrincipals::get(principal));
|
||||
if (!global)
|
||||
|
Loading…
Reference in New Issue
Block a user