Bug 821850 - Check for XBL scopes in nsContentUtils::IsCallerXBL(). r=bz

This commit is contained in:
Bobby Holley 2013-02-08 14:24:20 +00:00
parent b757981155
commit 032bee38ff
3 changed files with 19 additions and 1 deletions

View File

@ -1752,7 +1752,13 @@ nsContentUtils::IsCallerXBL()
{
JSScript *script;
JSContext *cx = GetCurrentJSContext();
if (!cx || !JS_DescribeScriptedCaller(cx, &script, nullptr) || !script)
if (!cx)
return false;
// New Hotness.
if (xpc::IsXBLScope(js::GetContextCompartment(cx)))
return true;
// 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);
}

View File

@ -237,6 +237,16 @@ EnsureCompartmentPrivate(JSCompartment *c)
return priv;
}
bool
IsXBLScope(JSCompartment *compartment)
{
// We always eagerly create compartment privates for XBL scopes.
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
if (!priv || !priv->scope)
return false;
return priv->scope->IsXBLScope();
}
bool
IsUniversalXPConnectEnabled(JSCompartment *compartment)
{

View File

@ -333,6 +333,8 @@ bool StringToJsval(JSContext* cx, mozilla::dom::DOMString& str,
nsIPrincipal *GetCompartmentPrincipal(JSCompartment *compartment);
bool IsXBLScope(JSCompartment *compartment);
void DumpJSHeap(FILE* file);
void SetLocationForGlobal(JSObject *global, const nsACString& location);