mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1017310 - Rename *XBLScope to *ContentXBLScope in xpconnect (r=bholley)
This commit is contained in:
parent
1d1a56c87a
commit
9157c8fd4d
@ -1039,7 +1039,7 @@ nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We give remote-XUL whitelisted domains a free pass here. See bug 932906.
|
// We give remote-XUL whitelisted domains a free pass here. See bug 932906.
|
||||||
if (!xpc::AllowXBLScope(js::GetContextCompartment(cx)))
|
if (!xpc::AllowContentXBLScope(js::GetContextCompartment(cx)))
|
||||||
{
|
{
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ public:
|
|||||||
|
|
||||||
static bool IsCallerChrome();
|
static bool IsCallerChrome();
|
||||||
static bool ThreadsafeIsCallerChrome();
|
static bool ThreadsafeIsCallerChrome();
|
||||||
static bool IsCallerXBL();
|
static bool IsCallerContentXBL();
|
||||||
|
|
||||||
static bool IsImageSrcSetDisabled();
|
static bool IsImageSrcSetDisabled();
|
||||||
|
|
||||||
|
@ -1714,7 +1714,7 @@ nsContentUtils::ThreadsafeIsCallerChrome()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsContentUtils::IsCallerXBL()
|
nsContentUtils::IsCallerContentXBL()
|
||||||
{
|
{
|
||||||
JSContext *cx = GetCurrentJSContext();
|
JSContext *cx = GetCurrentJSContext();
|
||||||
if (!cx)
|
if (!cx)
|
||||||
@ -1724,12 +1724,12 @@ nsContentUtils::IsCallerXBL()
|
|||||||
|
|
||||||
// For remote XUL, we run XBL in the XUL scope. Given that we care about
|
// 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.
|
// compat and not security for remote XUL, just always claim to be XBL.
|
||||||
if (!xpc::AllowXBLScope(c)) {
|
if (!xpc::AllowContentXBLScope(c)) {
|
||||||
MOZ_ASSERT(nsContentUtils::AllowXULXBLForPrincipal(xpc::GetCompartmentPrincipal(c)));
|
MOZ_ASSERT(nsContentUtils::AllowXULXBLForPrincipal(xpc::GetCompartmentPrincipal(c)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xpc::IsXBLScope(c);
|
return xpc::IsContentXBLScope(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5585,7 +5585,7 @@ nsContentTypeParser::GetParameter(const char* aParameterName, nsAString& aResult
|
|||||||
bool
|
bool
|
||||||
nsContentUtils::CanAccessNativeAnon()
|
nsContentUtils::CanAccessNativeAnon()
|
||||||
{
|
{
|
||||||
return IsCallerChrome() || IsCallerXBL();
|
return IsCallerChrome() || IsCallerContentXBL();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ nsresult
|
/* static */ nsresult
|
||||||
|
@ -2660,7 +2660,7 @@ nsINode::WrapObject(JSContext *aCx)
|
|||||||
|
|
||||||
JS::Rooted<JSObject*> obj(aCx, WrapNode(aCx));
|
JS::Rooted<JSObject*> obj(aCx, WrapNode(aCx));
|
||||||
MOZ_ASSERT_IF(ChromeOnlyAccess(),
|
MOZ_ASSERT_IF(ChromeOnlyAccess(),
|
||||||
xpc::IsInXBLScope(obj) || !xpc::UseXBLScope(js::GetObjectCompartment(obj)));
|
xpc::IsInContentXBLScope(obj) || !xpc::UseContentXBLScope(js::GetObjectCompartment(obj)));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2650,7 +2650,7 @@ nsObjectLoadingContent::ScriptRequestPluginInstance(JSContext* aCx,
|
|||||||
MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(),
|
MOZ_ASSERT_IF(nsContentUtils::GetCurrentJSContext(),
|
||||||
aCx == nsContentUtils::GetCurrentJSContext());
|
aCx == nsContentUtils::GetCurrentJSContext());
|
||||||
bool callerIsContentJS = (!nsContentUtils::IsCallerChrome() &&
|
bool callerIsContentJS = (!nsContentUtils::IsCallerChrome() &&
|
||||||
!nsContentUtils::IsCallerXBL() &&
|
!nsContentUtils::IsCallerContentXBL() &&
|
||||||
js::IsContextRunningJS(aCx));
|
js::IsContextRunningJS(aCx));
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> thisContent =
|
nsCOMPtr<nsIContent> thisContent =
|
||||||
|
@ -1405,7 +1405,7 @@ WrapNativeParent(JSContext* cx, T* p, nsWrapperCache* cache,
|
|||||||
|
|
||||||
// If useXBLScope is true, it means that the canonical reflector for this
|
// If useXBLScope is true, it means that the canonical reflector for this
|
||||||
// native object should live in the XBL scope.
|
// native object should live in the XBL scope.
|
||||||
if (xpc::IsInXBLScope(parent)) {
|
if (xpc::IsInContentXBLScope(parent)) {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
JS::Rooted<JSObject*> rootedParent(cx, parent);
|
JS::Rooted<JSObject*> rootedParent(cx, parent);
|
||||||
|
@ -104,7 +104,7 @@ static const JSClass gPrototypeJSClass = {
|
|||||||
// Constructors/Destructors
|
// Constructors/Destructors
|
||||||
nsXBLBinding::nsXBLBinding(nsXBLPrototypeBinding* aBinding)
|
nsXBLBinding::nsXBLBinding(nsXBLPrototypeBinding* aBinding)
|
||||||
: mMarkedForDeath(false)
|
: mMarkedForDeath(false)
|
||||||
, mUsingXBLScope(false)
|
, mUsingContentXBLScope(false)
|
||||||
, mPrototypeBinding(aBinding)
|
, mPrototypeBinding(aBinding)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mPrototypeBinding, "Must have a prototype binding!");
|
NS_ASSERTION(mPrototypeBinding, "Must have a prototype binding!");
|
||||||
@ -115,7 +115,7 @@ nsXBLBinding::nsXBLBinding(nsXBLPrototypeBinding* aBinding)
|
|||||||
// Constructor used by web components.
|
// Constructor used by web components.
|
||||||
nsXBLBinding::nsXBLBinding(ShadowRoot* aShadowRoot, nsXBLPrototypeBinding* aBinding)
|
nsXBLBinding::nsXBLBinding(ShadowRoot* aShadowRoot, nsXBLPrototypeBinding* aBinding)
|
||||||
: mMarkedForDeath(false),
|
: mMarkedForDeath(false),
|
||||||
mUsingXBLScope(false),
|
mUsingContentXBLScope(false),
|
||||||
mPrototypeBinding(aBinding),
|
mPrototypeBinding(aBinding),
|
||||||
mContent(aShadowRoot)
|
mContent(aShadowRoot)
|
||||||
{
|
{
|
||||||
@ -278,7 +278,7 @@ nsXBLBinding::SetBoundElement(nsIContent* aElement)
|
|||||||
// is not given in the handler declaration.
|
// is not given in the handler declaration.
|
||||||
nsCOMPtr<nsIGlobalObject> go = mBoundElement->OwnerDoc()->GetScopeObject();
|
nsCOMPtr<nsIGlobalObject> go = mBoundElement->OwnerDoc()->GetScopeObject();
|
||||||
NS_ENSURE_TRUE_VOID(go && go->GetGlobalJSObject());
|
NS_ENSURE_TRUE_VOID(go && go->GetGlobalJSObject());
|
||||||
mUsingXBLScope = xpc::UseXBLScope(js::GetObjectCompartment(go->GetGlobalJSObject()));
|
mUsingContentXBLScope = xpc::UseContentXBLScope(js::GetObjectCompartment(go->GetGlobalJSObject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -512,7 +512,7 @@ nsXBLBinding::InstallEventHandlers()
|
|||||||
|
|
||||||
bool hasAllowUntrustedAttr = curr->HasAllowUntrustedAttr();
|
bool hasAllowUntrustedAttr = curr->HasAllowUntrustedAttr();
|
||||||
if ((hasAllowUntrustedAttr && curr->AllowUntrustedEvents()) ||
|
if ((hasAllowUntrustedAttr && curr->AllowUntrustedEvents()) ||
|
||||||
(!hasAllowUntrustedAttr && !isChromeDoc && !mUsingXBLScope)) {
|
(!hasAllowUntrustedAttr && !isChromeDoc && !mUsingContentXBLScope)) {
|
||||||
flags.mAllowUntrustedEvents = true;
|
flags.mAllowUntrustedEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ nsXBLBinding::InstallEventHandlers()
|
|||||||
for (i = 0; i < keyHandlers->Count(); ++i) {
|
for (i = 0; i < keyHandlers->Count(); ++i) {
|
||||||
nsXBLKeyEventHandler* handler = keyHandlers->ObjectAt(i);
|
nsXBLKeyEventHandler* handler = keyHandlers->ObjectAt(i);
|
||||||
handler->SetIsBoundToChrome(isChromeDoc);
|
handler->SetIsBoundToChrome(isChromeDoc);
|
||||||
handler->SetUsingXBLScope(mUsingXBLScope);
|
handler->SetUsingContentXBLScope(mUsingContentXBLScope);
|
||||||
|
|
||||||
nsAutoString type;
|
nsAutoString type;
|
||||||
handler->GetEventName(type);
|
handler->GetEventName(type);
|
||||||
@ -920,8 +920,8 @@ GetOrCreateMapEntryForPrototype(JSContext *cx, JS::Handle<JSObject*> proto)
|
|||||||
// So we define two maps - one class objects that live in content (prototyped
|
// So we define two maps - one class objects that live in content (prototyped
|
||||||
// to content prototypes), and the other for class objects that live in the
|
// to content prototypes), and the other for class objects that live in the
|
||||||
// XBL scope (prototyped to cross-compartment-wrapped content prototypes).
|
// XBL scope (prototyped to cross-compartment-wrapped content prototypes).
|
||||||
const char* name = xpc::IsInXBLScope(proto) ? "__ContentClassObjectMap__"
|
const char* name = xpc::IsInContentXBLScope(proto) ? "__ContentClassObjectMap__"
|
||||||
: "__XBLClassObjectMap__";
|
: "__XBLClassObjectMap__";
|
||||||
|
|
||||||
// Now, enter the XBL scope, since that's where we need to operate, and wrap
|
// Now, enter the XBL scope, since that's where we need to operate, and wrap
|
||||||
// the proto accordingly.
|
// the proto accordingly.
|
||||||
@ -1116,7 +1116,7 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::Handle<jsid> aId,
|
|||||||
// We do a release-mode assertion here to be extra safe.
|
// We do a release-mode assertion here to be extra safe.
|
||||||
JS::Rooted<JSObject*> boundScope(aCx,
|
JS::Rooted<JSObject*> boundScope(aCx,
|
||||||
js::GetGlobalForObjectCrossCompartment(mBoundElement->GetWrapper()));
|
js::GetGlobalForObjectCrossCompartment(mBoundElement->GetWrapper()));
|
||||||
MOZ_RELEASE_ASSERT(!xpc::IsInXBLScope(boundScope));
|
MOZ_RELEASE_ASSERT(!xpc::IsInContentXBLScope(boundScope));
|
||||||
JS::Rooted<JSObject*> xblScope(aCx, xpc::GetXBLScope(aCx, boundScope));
|
JS::Rooted<JSObject*> xblScope(aCx, xpc::GetXBLScope(aCx, boundScope));
|
||||||
NS_ENSURE_TRUE(xblScope, false);
|
NS_ENSURE_TRUE(xblScope, false);
|
||||||
MOZ_ASSERT(boundScope != xblScope);
|
MOZ_ASSERT(boundScope != xblScope);
|
||||||
|
@ -160,7 +160,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool mMarkedForDeath;
|
bool mMarkedForDeath;
|
||||||
bool mUsingXBLScope;
|
bool mUsingContentXBLScope;
|
||||||
|
|
||||||
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
|
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
|
||||||
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
|
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
|
||||||
|
@ -71,7 +71,7 @@ nsXBLKeyEventHandler::nsXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase,
|
|||||||
mPhase(aPhase),
|
mPhase(aPhase),
|
||||||
mType(aType),
|
mType(aType),
|
||||||
mIsBoundToChrome(false),
|
mIsBoundToChrome(false),
|
||||||
mUsingXBLScope(false)
|
mUsingContentXBLScope(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ nsXBLKeyEventHandler::ExecuteMatchedHandlers(nsIDOMKeyEvent* aKeyEvent,
|
|||||||
bool hasAllowUntrustedAttr = handler->HasAllowUntrustedAttr();
|
bool hasAllowUntrustedAttr = handler->HasAllowUntrustedAttr();
|
||||||
if ((trustedEvent ||
|
if ((trustedEvent ||
|
||||||
(hasAllowUntrustedAttr && handler->AllowUntrustedEvents()) ||
|
(hasAllowUntrustedAttr && handler->AllowUntrustedEvents()) ||
|
||||||
(!hasAllowUntrustedAttr && !mIsBoundToChrome && !mUsingXBLScope)) &&
|
(!hasAllowUntrustedAttr && !mIsBoundToChrome && !mUsingContentXBLScope)) &&
|
||||||
handler->KeyEventMatched(aKeyEvent, aCharCode, aIgnoreShiftKey)) {
|
handler->KeyEventMatched(aKeyEvent, aCharCode, aIgnoreShiftKey)) {
|
||||||
handler->ExecuteHandler(target, aKeyEvent);
|
handler->ExecuteHandler(target, aKeyEvent);
|
||||||
executed = true;
|
executed = true;
|
||||||
|
@ -86,9 +86,9 @@ public:
|
|||||||
mIsBoundToChrome = aIsBoundToChrome;
|
mIsBoundToChrome = aIsBoundToChrome;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUsingXBLScope(bool aUsingXBLScope)
|
void SetUsingContentXBLScope(bool aUsingContentXBLScope)
|
||||||
{
|
{
|
||||||
mUsingXBLScope = aUsingXBLScope;
|
mUsingContentXBLScope = aUsingContentXBLScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -101,7 +101,7 @@ private:
|
|||||||
uint8_t mPhase;
|
uint8_t mPhase;
|
||||||
uint8_t mType;
|
uint8_t mType;
|
||||||
bool mIsBoundToChrome;
|
bool mIsBoundToChrome;
|
||||||
bool mUsingXBLScope;
|
bool mUsingContentXBLScope;
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -104,7 +104,7 @@ nsXBLProtoImplMethod::InstallMember(JSContext* aCx,
|
|||||||
MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
|
MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
|
||||||
|
|
||||||
JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
|
JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
|
||||||
MOZ_ASSERT(xpc::IsInXBLScope(globalObject) ||
|
MOZ_ASSERT(xpc::IsInContentXBLScope(globalObject) ||
|
||||||
globalObject == xpc::GetXBLScope(aCx, globalObject));
|
globalObject == xpc::GetXBLScope(aCx, globalObject));
|
||||||
|
|
||||||
JS::Rooted<JSObject*> jsMethodObject(aCx, GetCompiledMethod());
|
JS::Rooted<JSObject*> jsMethodObject(aCx, GetCompiledMethod());
|
||||||
|
@ -129,7 +129,7 @@ nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
|
|||||||
MOZ_ASSERT(mGetter.IsCompiled() && mSetter.IsCompiled());
|
MOZ_ASSERT(mGetter.IsCompiled() && mSetter.IsCompiled());
|
||||||
MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
|
MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
|
||||||
JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
|
JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
|
||||||
MOZ_ASSERT(xpc::IsInXBLScope(globalObject) ||
|
MOZ_ASSERT(xpc::IsInContentXBLScope(globalObject) ||
|
||||||
globalObject == xpc::GetXBLScope(aCx, globalObject));
|
globalObject == xpc::GetXBLScope(aCx, globalObject));
|
||||||
|
|
||||||
JS::Rooted<JSObject*> getter(aCx, mGetter.GetJSFunction());
|
JS::Rooted<JSObject*> getter(aCx, mGetter.GetJSFunction());
|
||||||
|
@ -503,19 +503,19 @@ Scriptability::Get(JSObject *aScope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsXBLScope(JSCompartment *compartment)
|
IsContentXBLScope(JSCompartment *compartment)
|
||||||
{
|
{
|
||||||
// We always eagerly create compartment privates for XBL scopes.
|
// We always eagerly create compartment privates for XBL scopes.
|
||||||
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
|
CompartmentPrivate *priv = GetCompartmentPrivate(compartment);
|
||||||
if (!priv || !priv->scope)
|
if (!priv || !priv->scope)
|
||||||
return false;
|
return false;
|
||||||
return priv->scope->IsXBLScope();
|
return priv->scope->IsContentXBLScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsInXBLScope(JSObject *obj)
|
IsInContentXBLScope(JSObject *obj)
|
||||||
{
|
{
|
||||||
return IsXBLScope(js::GetObjectCompartment(obj));
|
return IsContentXBLScope(js::GetObjectCompartment(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -73,7 +73,7 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext *cx,
|
|||||||
mComponents(nullptr),
|
mComponents(nullptr),
|
||||||
mNext(nullptr),
|
mNext(nullptr),
|
||||||
mGlobalJSObject(aGlobal),
|
mGlobalJSObject(aGlobal),
|
||||||
mIsXBLScope(false)
|
mIsContentXBLScope(false)
|
||||||
{
|
{
|
||||||
// add ourselves to the scopes list
|
// add ourselves to the scopes list
|
||||||
{
|
{
|
||||||
@ -101,18 +101,18 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext *cx,
|
|||||||
// In addition to being pref-controlled, we also disable XBL scopes for
|
// In addition to being pref-controlled, we also disable XBL scopes for
|
||||||
// remote XUL domains, _except_ if we have an additional pref override set.
|
// remote XUL domains, _except_ if we have an additional pref override set.
|
||||||
nsIPrincipal *principal = GetPrincipal();
|
nsIPrincipal *principal = GetPrincipal();
|
||||||
mAllowXBLScope = !RemoteXULForbidsXBLScope(principal, aGlobal);
|
mAllowContentXBLScope = !RemoteXULForbidsXBLScope(principal, aGlobal);
|
||||||
|
|
||||||
// Determine whether to use an XBL scope.
|
// Determine whether to use an XBL scope.
|
||||||
mUseXBLScope = mAllowXBLScope;
|
mUseContentXBLScope = mAllowContentXBLScope;
|
||||||
if (mUseXBLScope) {
|
if (mUseContentXBLScope) {
|
||||||
const js::Class *clasp = js::GetObjectClass(mGlobalJSObject);
|
const js::Class *clasp = js::GetObjectClass(mGlobalJSObject);
|
||||||
mUseXBLScope = !strcmp(clasp->name, "Window") ||
|
mUseContentXBLScope = !strcmp(clasp->name, "Window") ||
|
||||||
!strcmp(clasp->name, "ChromeWindow") ||
|
!strcmp(clasp->name, "ChromeWindow") ||
|
||||||
!strcmp(clasp->name, "ModalContentWindow");
|
!strcmp(clasp->name, "ModalContentWindow");
|
||||||
}
|
}
|
||||||
if (mUseXBLScope) {
|
if (mUseContentXBLScope) {
|
||||||
mUseXBLScope = principal && !nsContentUtils::IsSystemPrincipal(principal);
|
mUseContentXBLScope = principal && !nsContentUtils::IsSystemPrincipal(principal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,20 +186,20 @@ XPCWrappedNativeScope::AttachComponentsObject(JSContext* aCx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSObject*
|
JSObject*
|
||||||
XPCWrappedNativeScope::EnsureXBLScope(JSContext *cx)
|
XPCWrappedNativeScope::EnsureContentXBLScope(JSContext *cx)
|
||||||
{
|
{
|
||||||
JS::RootedObject global(cx, GetGlobalJSObject());
|
JS::RootedObject global(cx, GetGlobalJSObject());
|
||||||
MOZ_ASSERT(js::IsObjectInContextCompartment(global, cx));
|
MOZ_ASSERT(js::IsObjectInContextCompartment(global, cx));
|
||||||
MOZ_ASSERT(!mIsXBLScope);
|
MOZ_ASSERT(!mIsContentXBLScope);
|
||||||
MOZ_ASSERT(strcmp(js::GetObjectClass(global)->name,
|
MOZ_ASSERT(strcmp(js::GetObjectClass(global)->name,
|
||||||
"nsXBLPrototypeScript compilation scope"));
|
"nsXBLPrototypeScript compilation scope"));
|
||||||
|
|
||||||
// If we already have a special XBL scope object, we know what to use.
|
// If we already have a special XBL scope object, we know what to use.
|
||||||
if (mXBLScope)
|
if (mContentXBLScope)
|
||||||
return mXBLScope;
|
return mContentXBLScope;
|
||||||
|
|
||||||
// If this scope doesn't need an XBL scope, just return the global.
|
// If this scope doesn't need an XBL scope, just return the global.
|
||||||
if (!mUseXBLScope)
|
if (!mUseContentXBLScope)
|
||||||
return global;
|
return global;
|
||||||
|
|
||||||
// Set up the sandbox options. Note that we use the DOM global as the
|
// Set up the sandbox options. Note that we use the DOM global as the
|
||||||
@ -228,22 +228,22 @@ XPCWrappedNativeScope::EnsureXBLScope(JSContext *cx)
|
|||||||
RootedValue v(cx);
|
RootedValue v(cx);
|
||||||
nsresult rv = CreateSandboxObject(cx, &v, ep, options);
|
nsresult rv = CreateSandboxObject(cx, &v, ep, options);
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
mXBLScope = &v.toObject();
|
mContentXBLScope = &v.toObject();
|
||||||
|
|
||||||
// Tag it.
|
// Tag it.
|
||||||
EnsureCompartmentPrivate(js::UncheckedUnwrap(mXBLScope))->scope->mIsXBLScope = true;
|
EnsureCompartmentPrivate(js::UncheckedUnwrap(mContentXBLScope))->scope->mIsContentXBLScope = true;
|
||||||
|
|
||||||
// Good to go!
|
// Good to go!
|
||||||
return mXBLScope;
|
return mContentXBLScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
XPCWrappedNativeScope::AllowXBLScope()
|
XPCWrappedNativeScope::AllowContentXBLScope()
|
||||||
{
|
{
|
||||||
// We only disallow XBL scopes in remote XUL situations.
|
// We only disallow XBL scopes in remote XUL situations.
|
||||||
MOZ_ASSERT_IF(!mAllowXBLScope,
|
MOZ_ASSERT_IF(!mAllowContentXBLScope,
|
||||||
nsContentUtils::AllowXULXBLForPrincipal(GetPrincipal()));
|
nsContentUtils::AllowXULXBLForPrincipal(GetPrincipal()));
|
||||||
return mAllowXBLScope;
|
return mAllowContentXBLScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace xpc {
|
namespace xpc {
|
||||||
@ -251,23 +251,25 @@ JSObject *GetXBLScope(JSContext *cx, JSObject *contentScopeArg)
|
|||||||
{
|
{
|
||||||
JS::RootedObject contentScope(cx, contentScopeArg);
|
JS::RootedObject contentScope(cx, contentScopeArg);
|
||||||
JSAutoCompartment ac(cx, contentScope);
|
JSAutoCompartment ac(cx, contentScope);
|
||||||
JSObject *scope = EnsureCompartmentPrivate(contentScope)->scope->EnsureXBLScope(cx);
|
JSObject *scope = EnsureCompartmentPrivate(contentScope)->scope->EnsureContentXBLScope(cx);
|
||||||
NS_ENSURE_TRUE(scope, nullptr); // See bug 858642.
|
NS_ENSURE_TRUE(scope, nullptr); // See bug 858642.
|
||||||
scope = js::UncheckedUnwrap(scope);
|
scope = js::UncheckedUnwrap(scope);
|
||||||
JS::ExposeObjectToActiveJS(scope);
|
JS::ExposeObjectToActiveJS(scope);
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AllowXBLScope(JSCompartment *c)
|
bool
|
||||||
|
AllowContentXBLScope(JSCompartment *c)
|
||||||
{
|
{
|
||||||
XPCWrappedNativeScope *scope = EnsureCompartmentPrivate(c)->scope;
|
XPCWrappedNativeScope *scope = EnsureCompartmentPrivate(c)->scope;
|
||||||
return scope && scope->AllowXBLScope();
|
return scope && scope->AllowContentXBLScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UseXBLScope(JSCompartment *c)
|
bool
|
||||||
|
UseContentXBLScope(JSCompartment *c)
|
||||||
{
|
{
|
||||||
XPCWrappedNativeScope *scope = EnsureCompartmentPrivate(c)->scope;
|
XPCWrappedNativeScope *scope = EnsureCompartmentPrivate(c)->scope;
|
||||||
return scope && scope->UseXBLScope();
|
return scope && scope->UseContentXBLScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace xpc */
|
} /* namespace xpc */
|
||||||
@ -301,7 +303,7 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
|
|||||||
mXrayExpandos.destroy();
|
mXrayExpandos.destroy();
|
||||||
|
|
||||||
JSRuntime *rt = XPCJSRuntime::Get()->Runtime();
|
JSRuntime *rt = XPCJSRuntime::Get()->Runtime();
|
||||||
mXBLScope.finalize(rt);
|
mContentXBLScope.finalize(rt);
|
||||||
mGlobalJSObject.finalize(rt);
|
mGlobalJSObject.finalize(rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1577,9 +1577,9 @@ IsChromeOrXBL(JSContext* cx, JSObject* /* unused */)
|
|||||||
// compat and not security for remote XUL, we just always claim to be XBL.
|
// compat and not security for remote XUL, we just always claim to be XBL.
|
||||||
//
|
//
|
||||||
// Note that, for performance, we don't check AllowXULXBLForPrincipal here,
|
// Note that, for performance, we don't check AllowXULXBLForPrincipal here,
|
||||||
// and instead rely on the fact that AllowXBLScope() only returns false in
|
// and instead rely on the fact that AllowContentXBLScope() only returns false in
|
||||||
// remote XUL situations.
|
// remote XUL situations.
|
||||||
return AccessCheck::isChrome(c) || IsXBLScope(c) || !AllowXBLScope(c);
|
return AccessCheck::isChrome(c) || IsContentXBLScope(c) || !AllowContentXBLScope(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
@ -1020,8 +1020,8 @@ public:
|
|||||||
void TraceSelf(JSTracer *trc) {
|
void TraceSelf(JSTracer *trc) {
|
||||||
MOZ_ASSERT(mGlobalJSObject);
|
MOZ_ASSERT(mGlobalJSObject);
|
||||||
mGlobalJSObject.trace(trc, "XPCWrappedNativeScope::mGlobalJSObject");
|
mGlobalJSObject.trace(trc, "XPCWrappedNativeScope::mGlobalJSObject");
|
||||||
if (mXBLScope)
|
if (mContentXBLScope)
|
||||||
mXBLScope.trace(trc, "XPCWrappedNativeScope::mXBLScope");
|
mContentXBLScope.trace(trc, "XPCWrappedNativeScope::mXBLScope");
|
||||||
if (mXrayExpandos.initialized())
|
if (mXrayExpandos.initialized())
|
||||||
mXrayExpandos.trace(trc);
|
mXrayExpandos.trace(trc);
|
||||||
}
|
}
|
||||||
@ -1097,15 +1097,15 @@ public:
|
|||||||
// Gets the appropriate scope object for XBL in this scope. The context
|
// Gets the appropriate scope object for XBL in this scope. The context
|
||||||
// must be same-compartment with the global upon entering, and the scope
|
// must be same-compartment with the global upon entering, and the scope
|
||||||
// object is wrapped into the compartment of the global.
|
// object is wrapped into the compartment of the global.
|
||||||
JSObject *EnsureXBLScope(JSContext *cx);
|
JSObject *EnsureContentXBLScope(JSContext *cx);
|
||||||
|
|
||||||
XPCWrappedNativeScope(JSContext *cx, JS::HandleObject aGlobal);
|
XPCWrappedNativeScope(JSContext *cx, JS::HandleObject aGlobal);
|
||||||
|
|
||||||
nsAutoPtr<JSObject2JSObjectMap> mWaiverWrapperMap;
|
nsAutoPtr<JSObject2JSObjectMap> mWaiverWrapperMap;
|
||||||
|
|
||||||
bool IsXBLScope() { return mIsXBLScope; }
|
bool IsContentXBLScope() { return mIsContentXBLScope; }
|
||||||
bool AllowXBLScope();
|
bool AllowContentXBLScope();
|
||||||
bool UseXBLScope() { return mUseXBLScope; }
|
bool UseContentXBLScope() { return mUseContentXBLScope; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~XPCWrappedNativeScope();
|
virtual ~XPCWrappedNativeScope();
|
||||||
@ -1130,20 +1130,20 @@ private:
|
|||||||
JS::ObjectPtr mGlobalJSObject;
|
JS::ObjectPtr mGlobalJSObject;
|
||||||
|
|
||||||
// XBL Scope. This is is a lazily-created sandbox for non-system scopes.
|
// XBL Scope. This is is a lazily-created sandbox for non-system scopes.
|
||||||
// EnsureXBLScope() decides whether it needs to be created or not.
|
// EnsureContentXBLScope() decides whether it needs to be created or not.
|
||||||
// This reference is wrapped into the compartment of mGlobalJSObject.
|
// This reference is wrapped into the compartment of mGlobalJSObject.
|
||||||
JS::ObjectPtr mXBLScope;
|
JS::ObjectPtr mContentXBLScope;
|
||||||
|
|
||||||
nsAutoPtr<DOMExpandoSet> mDOMExpandoSet;
|
nsAutoPtr<DOMExpandoSet> mDOMExpandoSet;
|
||||||
|
|
||||||
JS::WeakMapPtr<JSObject*, JSObject*> mXrayExpandos;
|
JS::WeakMapPtr<JSObject*, JSObject*> mXrayExpandos;
|
||||||
|
|
||||||
bool mIsXBLScope;
|
bool mIsContentXBLScope;
|
||||||
|
|
||||||
// For remote XUL domains, we run all XBL in the content scope for compat
|
// 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
|
// reasons (though we sometimes pref this off for automation). We separately
|
||||||
// track the result of this decision (mAllowXBLScope), from the decision
|
// track the result of this decision (mAllowContentXBLScope), from the decision
|
||||||
// of whether to actually _use_ an XBL scope (mUseXBLScope), which depends
|
// of whether to actually _use_ an XBL scope (mUseContentXBLScope), which depends
|
||||||
// on the type of global and whether the compartment is system principal
|
// on the type of global and whether the compartment is system principal
|
||||||
// or not.
|
// or not.
|
||||||
//
|
//
|
||||||
@ -1151,8 +1151,8 @@ private:
|
|||||||
// have no way of distinguishing XBL script from content script for the
|
// have no way of distinguishing XBL script from content script for the
|
||||||
// given scope. In these (unsupported) situations, we just always claim to
|
// given scope. In these (unsupported) situations, we just always claim to
|
||||||
// be XBL.
|
// be XBL.
|
||||||
bool mAllowXBLScope;
|
bool mAllowContentXBLScope;
|
||||||
bool mUseXBLScope;
|
bool mUseContentXBLScope;
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
@ -70,8 +70,8 @@ private:
|
|||||||
JSObject *
|
JSObject *
|
||||||
TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target);
|
TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target);
|
||||||
|
|
||||||
bool IsXBLScope(JSCompartment *compartment);
|
bool IsContentXBLScope(JSCompartment *compartment);
|
||||||
bool IsInXBLScope(JSObject *obj);
|
bool IsInContentXBLScope(JSObject *obj);
|
||||||
|
|
||||||
// Return a raw XBL scope object corresponding to contentScope, which must
|
// Return a raw XBL scope object corresponding to contentScope, which must
|
||||||
// be an object whose global is a DOM window.
|
// be an object whose global is a DOM window.
|
||||||
@ -90,23 +90,24 @@ JSObject *
|
|||||||
GetXBLScope(JSContext *cx, JSObject *contentScope);
|
GetXBLScope(JSContext *cx, JSObject *contentScope);
|
||||||
|
|
||||||
inline JSObject *
|
inline JSObject *
|
||||||
GetXBLScopeOrGlobal(JSContext *cx, JSObject *obj) {
|
GetXBLScopeOrGlobal(JSContext *cx, JSObject *obj)
|
||||||
if (IsInXBLScope(obj))
|
{
|
||||||
|
if (IsInContentXBLScope(obj))
|
||||||
return js::GetGlobalForObjectCrossCompartment(obj);
|
return js::GetGlobalForObjectCrossCompartment(obj);
|
||||||
return GetXBLScope(cx, obj);
|
return GetXBLScope(cx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether XBL scopes have been explicitly disabled for code running
|
// Returns whether XBL scopes have been explicitly disabled for code running
|
||||||
// in this compartment. See the comment around mAllowXBLScope.
|
// in this compartment. See the comment around mAllowContentXBLScope.
|
||||||
bool
|
bool
|
||||||
AllowXBLScope(JSCompartment *c);
|
AllowContentXBLScope(JSCompartment *c);
|
||||||
|
|
||||||
// Returns whether we will use an XBL scope for this compartment. This is
|
// Returns whether we will use an XBL scope for this compartment. This is
|
||||||
// semantically equivalent to comparing global != GetXBLScope(global), but it
|
// semantically equivalent to comparing global != GetXBLScope(global), but it
|
||||||
// does not have the side-effect of eagerly creating the XBL scope if it does
|
// does not have the side-effect of eagerly creating the XBL scope if it does
|
||||||
// not already exist.
|
// not already exist.
|
||||||
bool
|
bool
|
||||||
UseXBLScope(JSCompartment *c);
|
UseContentXBLScope(JSCompartment *c);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsSandboxPrototypeProxy(JSObject *obj);
|
IsSandboxPrototypeProxy(JSObject *obj);
|
||||||
|
@ -431,7 +431,7 @@ WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj,
|
|||||||
// See bug 843829.
|
// See bug 843829.
|
||||||
else if (targetSubsumesOrigin && !originSubsumesTarget &&
|
else if (targetSubsumesOrigin && !originSubsumesTarget &&
|
||||||
!waiveXrayFlag && xrayType == NotXray &&
|
!waiveXrayFlag && xrayType == NotXray &&
|
||||||
IsXBLScope(target))
|
IsContentXBLScope(target))
|
||||||
{
|
{
|
||||||
wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, GentlyOpaque>::singleton;
|
wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper, GentlyOpaque>::singleton;
|
||||||
}
|
}
|
||||||
@ -462,10 +462,10 @@ WrapperFactory::Rewrap(JSContext *cx, HandleObject existing, HandleObject obj,
|
|||||||
|
|
||||||
// We have slightly different behavior for the case when the object
|
// We have slightly different behavior for the case when the object
|
||||||
// being wrapped is in an XBL scope.
|
// being wrapped is in an XBL scope.
|
||||||
bool originIsXBLScope = IsXBLScope(origin);
|
bool originIsContentXBLScope = IsContentXBLScope(origin);
|
||||||
|
|
||||||
wrapper = SelectWrapper(securityWrapper, wantXrays, xrayType, waiveXrays,
|
wrapper = SelectWrapper(securityWrapper, wantXrays, xrayType, waiveXrays,
|
||||||
originIsXBLScope);
|
originIsContentXBLScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetSubsumesOrigin) {
|
if (!targetSubsumesOrigin) {
|
||||||
|
@ -1775,7 +1775,7 @@ DEBUG_CheckXBLCallable(JSContext *cx, JSObject *obj)
|
|||||||
// has been adopted into another compartment, those prototypes will now point
|
// has been adopted into another compartment, those prototypes will now point
|
||||||
// to a different XBL scope (which is ok).
|
// to a different XBL scope (which is ok).
|
||||||
MOZ_ASSERT_IF(js::IsCrossCompartmentWrapper(obj),
|
MOZ_ASSERT_IF(js::IsCrossCompartmentWrapper(obj),
|
||||||
xpc::IsXBLScope(js::GetObjectCompartment(js::UncheckedUnwrap(obj))));
|
xpc::IsContentXBLScope(js::GetObjectCompartment(js::UncheckedUnwrap(obj))));
|
||||||
MOZ_ASSERT(JS_ObjectIsCallable(cx, obj));
|
MOZ_ASSERT(JS_ObjectIsCallable(cx, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1930,7 +1930,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
|
|||||||
// Make sure to assert this.
|
// Make sure to assert this.
|
||||||
nsCOMPtr<nsIContent> content;
|
nsCOMPtr<nsIContent> content;
|
||||||
if (!desc.object() &&
|
if (!desc.object() &&
|
||||||
EnsureCompartmentPrivate(wrapper)->scope->IsXBLScope() &&
|
EnsureCompartmentPrivate(wrapper)->scope->IsContentXBLScope() &&
|
||||||
(content = do_QueryInterfaceNative(cx, wrapper)))
|
(content = do_QueryInterfaceNative(cx, wrapper)))
|
||||||
{
|
{
|
||||||
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc))
|
if (!nsContentUtils::LookupBindingMember(cx, content, id, desc))
|
||||||
|
Loading…
Reference in New Issue
Block a user