Bug 834701 - Stop depending on the XBL bit in IsCallerXBL. r=bz

This commit is contained in:
Bobby Holley 2013-05-20 22:34:17 -06:00
parent ba4133d1ab
commit a457b1a245

View File

@ -1725,20 +1725,20 @@ nsContentUtils::IsCallerChrome()
bool bool
nsContentUtils::IsCallerXBL() nsContentUtils::IsCallerXBL()
{ {
JSScript *script;
JSContext *cx = GetCurrentJSContext(); JSContext *cx = GetCurrentJSContext();
if (!cx) if (!cx)
return false; return false;
// New Hotness.
JSCompartment *c = js::GetContextCompartment(cx); JSCompartment *c = js::GetContextCompartment(cx);
if (xpc::AllowXBLScope(c))
return xpc::IsXBLScope(c);
// XBL scopes are behind a pref, so check the XBL bit as well. // For remote XUL, we run XBL in the XUL scope. Given that we care about
if (!JS_DescribeScriptedCaller(cx, &script, nullptr) || !script) // compat and not security for remote XUL, just always claim to be XBL.
return false; if (!xpc::AllowXBLScope(c)) {
return JS_GetScriptUserBit(script); MOZ_ASSERT(nsContentUtils::AllowXULXBLForPrincipal(xpc::GetCompartmentPrincipal(c)));
return true;
}
return xpc::IsXBLScope(c);
} }