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
nsContentUtils::IsCallerXBL()
{
JSScript *script;
JSContext *cx = GetCurrentJSContext();
if (!cx)
return false;
// New Hotness.
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.
if (!JS_DescribeScriptedCaller(cx, &script, nullptr) || !script)
return false;
return JS_GetScriptUserBit(script);
// For remote XUL, we run XBL in the XUL scope. Given that we care about
// compat and not security for remote XUL, just always claim to be XBL.
if (!xpc::AllowXBLScope(c)) {
MOZ_ASSERT(nsContentUtils::AllowXULXBLForPrincipal(xpc::GetCompartmentPrincipal(c)));
return true;
}
return xpc::IsXBLScope(c);
}