Bug 979481 - Prepare the cx stack machinery for a world where a cx has no default compartment object. r=bz

This commit is contained in:
Bobby Holley 2014-03-06 08:55:00 -08:00
Родитель cacdca44ee
Коммит b016448582
1 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -79,19 +79,19 @@ XPCJSContextStack::Push(JSContext *cx)
if ((e.cx == cx) && ssm) {
// DOM JSContexts don't store their default compartment object on
// the cx, so in those cases we need to fetch it via the scx
// instead.
// instead. And in some cases (i.e. the SafeJSContext), we have no
// default compartment object at all.
RootedObject defaultScope(cx, GetDefaultScopeFromJSContext(cx));
if (defaultScope) {
nsIPrincipal *currentPrincipal =
GetCompartmentPrincipal(js::GetContextCompartment(cx));
nsIPrincipal *defaultPrincipal = GetObjectPrincipal(defaultScope);
bool equal = false;
currentPrincipal->Equals(defaultPrincipal, &equal);
if (equal) {
if (currentPrincipal->Equals(defaultPrincipal)) {
mStack.AppendElement(cx);
return true;
}
}
}
{
// Push() can be called outside any request for e.cx.