mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 868122 - Calculate the JS_SaveFrameChain optimization by directly examining the principal of the default compartment. r=mrbkap,gabor
This commit is contained in:
parent
2fcf1ab53b
commit
c9228b2c97
@ -16,6 +16,8 @@
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace JS;
|
||||
using namespace xpc;
|
||||
using mozilla::dom::DestroyProtoAndIfaceCache;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -75,18 +77,20 @@ XPCJSContextStack::Push(JSContext *cx)
|
||||
|
||||
XPCJSContextInfo &e = mStack[mStack.Length() - 1];
|
||||
if (e.cx) {
|
||||
if (e.cx == cx) {
|
||||
nsIScriptSecurityManager* ssm = XPCWrapper::GetSecurityManager();
|
||||
if (ssm) {
|
||||
if (nsIPrincipal* globalObjectPrincipal = GetPrincipalFromCx(cx)) {
|
||||
nsIPrincipal* subjectPrincipal = ssm->GetCxSubjectPrincipal(cx);
|
||||
bool equals = false;
|
||||
globalObjectPrincipal->Equals(subjectPrincipal, &equals);
|
||||
if (equals) {
|
||||
mStack.AppendElement(cx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// The cx we're pushing is also stack-top. In general we still need to
|
||||
// call JS_SaveFrameChain here. But if that would put us in a
|
||||
// compartment that's same-origin with the current one, we can skip it.
|
||||
nsIScriptSecurityManager* ssm = XPCWrapper::GetSecurityManager();
|
||||
if ((e.cx == cx) && ssm) {
|
||||
RootedObject defaultGlobal(cx, JS_GetGlobalObject(cx));
|
||||
nsIPrincipal *currentPrincipal =
|
||||
GetCompartmentPrincipal(js::GetContextCompartment(cx));
|
||||
nsIPrincipal *defaultPrincipal = GetObjectPrincipal(defaultGlobal);
|
||||
bool equal = false;
|
||||
currentPrincipal->Equals(defaultPrincipal, &equal);
|
||||
if (equal) {
|
||||
mStack.AppendElement(cx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,6 +363,7 @@ bool StringToJsval(JSContext* cx, mozilla::dom::DOMString& str,
|
||||
}
|
||||
|
||||
nsIPrincipal *GetCompartmentPrincipal(JSCompartment *compartment);
|
||||
nsIPrincipal *GetObjectPrincipal(JSObject *obj);
|
||||
|
||||
bool IsXBLScope(JSCompartment *compartment);
|
||||
|
||||
|
@ -35,6 +35,12 @@ GetCompartmentPrincipal(JSCompartment *compartment)
|
||||
return nsJSPrincipals::get(JS_GetCompartmentPrincipals(compartment));
|
||||
}
|
||||
|
||||
nsIPrincipal *
|
||||
GetObjectPrincipal(JSObject *obj)
|
||||
{
|
||||
return GetCompartmentPrincipal(js::GetObjectCompartment(obj));
|
||||
}
|
||||
|
||||
// Does the principal of compartment a subsume the principal of compartment b?
|
||||
bool
|
||||
AccessCheck::subsumes(JSCompartment *a, JSCompartment *b)
|
||||
|
Loading…
Reference in New Issue
Block a user