mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912322 - Update semantics of IsChromeOrXBL to return true for remote XUL. r=bz
This brings us into alignment with nsContentUtils::IsCallerXBL(). We also take the opportunity to clean up some comments and invariants that changed with the removal of the XBL bit.
This commit is contained in:
parent
74a8289887
commit
4569f739ee
@ -266,6 +266,15 @@ XPCWrappedNativeScope::EnsureXBLScope(JSContext *cx)
|
||||
return mXBLScope;
|
||||
}
|
||||
|
||||
bool
|
||||
XPCWrappedNativeScope::AllowXBLScope()
|
||||
{
|
||||
// We only disallow XBL scopes in remote XUL situations.
|
||||
MOZ_ASSERT_IF(!mAllowXBLScope,
|
||||
nsContentUtils::AllowXULXBLForPrincipal(GetPrincipal()));
|
||||
return mAllowXBLScope;
|
||||
}
|
||||
|
||||
namespace xpc {
|
||||
JSObject *GetXBLScope(JSContext *cx, JSObject *contentScopeArg)
|
||||
{
|
||||
|
@ -1710,9 +1710,15 @@ bool
|
||||
IsChromeOrXBL(JSContext* cx, JSObject* /* unused */)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
JSCompartment* compartment = js::GetContextCompartment(cx);
|
||||
return AccessCheck::isChrome(compartment) ||
|
||||
IsXBLScope(compartment);
|
||||
JSCompartment* c = js::GetContextCompartment(cx);
|
||||
|
||||
// For remote XUL, we run XBL in the XUL scope. Given that we care about
|
||||
// compat and not security for remote XUL, we just always claim to be XBL.
|
||||
//
|
||||
// Note that, for performance, we don't check AllowXULXBLForPrincipal here,
|
||||
// and instead rely on the fact that AllowXBLScope() only returns false in
|
||||
// remote XUL situations.
|
||||
return AccessCheck::isChrome(c) || IsXBLScope(c) || !AllowXBLScope(c);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -1413,7 +1413,7 @@ public:
|
||||
nsAutoPtr<JSObject2JSObjectMap> mWaiverWrapperMap;
|
||||
|
||||
bool IsXBLScope() { return mIsXBLScope; }
|
||||
bool AllowXBLScope() { return mAllowXBLScope; }
|
||||
bool AllowXBLScope();
|
||||
|
||||
protected:
|
||||
virtual ~XPCWrappedNativeScope();
|
||||
@ -1449,20 +1449,17 @@ private:
|
||||
|
||||
bool mIsXBLScope;
|
||||
|
||||
// There are certain cases where we explicitly disallow XBL scopes: they
|
||||
// can be prefed off, or we might be running in a remote XUL domain where
|
||||
// we want to run all XBL in content to maintain compat. We separately
|
||||
// For remote XUL domains, we run all XBL in the content scope for compat
|
||||
// reasons (though we sometimes pref this off for automation). We separately
|
||||
// track the result of this decision (mAllowXBLScope), from the decision
|
||||
// of whether to actually _use_ an XBL scope (mUseXBLScope), which depends
|
||||
// on the type of global and whether the compartment is system principal
|
||||
// or not.
|
||||
//
|
||||
// This distinction is useful primarily because it tells us whether we
|
||||
// can infer the XBL-ness of a caller by checking that the caller is
|
||||
// running in an XBL scope, or whether we need to check the XBL bit on the
|
||||
// script. The XBL bit is nasty, so we want to consult it only if we
|
||||
// absolutely have to, which should generally happen only in unsupported
|
||||
// pref configurations.
|
||||
// This distinction is useful primarily because, if true, we know that we
|
||||
// have no way of distinguishing XBL script from content script for the
|
||||
// given scope. In these (unsupported) situations, we just always claim to
|
||||
// be XBL.
|
||||
bool mAllowXBLScope;
|
||||
bool mUseXBLScope;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user