mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 790732 - Omit Components object for content scopes. r=mrbkap
This commit is contained in:
parent
ef903247ce
commit
5a05b3aa90
@ -1971,6 +1971,17 @@ nsGlobalWindow::SetOuterObject(JSContext* aCx, JSObject* aOuterObject)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We need certain special behavior for remote XUL whitelisted domains, but we
|
||||
// don't want that behavior to take effect in automation, because we whitelist
|
||||
// all the mochitest domains. So we need to check a pref here.
|
||||
static bool
|
||||
TreatAsRemoteXUL(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(aPrincipal));
|
||||
return nsContentUtils::AllowXULXBLForPrincipal(aPrincipal) &&
|
||||
!Preferences::GetBool("dom.use_xbl_scopes_for_remote_xul", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new global object that will be used for an inner window.
|
||||
* Return the native global and an nsISupports 'holder' that can be used
|
||||
@ -2004,10 +2015,19 @@ CreateNativeGlobalForInner(JSContext* aCx,
|
||||
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
|
||||
// Determine if we need the Components object.
|
||||
bool componentsInContent =
|
||||
!Preferences::GetBool("dom.omit_components_in_content", true) ||
|
||||
!Preferences::GetBool("dom.xbl_scopes", true);
|
||||
bool needComponents = componentsInContent ||
|
||||
nsContentUtils::IsSystemPrincipal(aPrincipal) ||
|
||||
TreatAsRemoteXUL(aPrincipal);
|
||||
uint32_t flags = needComponents ? 0 : nsIXPConnect::OMIT_COMPONENTS_OBJECT;
|
||||
|
||||
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
|
||||
nsresult rv = xpc->InitClassesWithNewWrappedGlobal(
|
||||
aCx, ToSupports(aNewInner),
|
||||
aPrincipal, 0, zoneSpec, getter_AddRefs(jsholder));
|
||||
aPrincipal, flags, zoneSpec, getter_AddRefs(jsholder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MOZ_ASSERT(jsholder);
|
||||
|
@ -282,8 +282,18 @@ EnableUniversalXPConnect(JSContext *cx)
|
||||
|
||||
// Recompute all the cross-compartment wrappers leaving the newly-privileged
|
||||
// compartment.
|
||||
return js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
|
||||
js::AllCompartments());
|
||||
bool ok = js::RecomputeWrappers(cx, js::SingleCompartment(compartment),
|
||||
js::AllCompartments());
|
||||
NS_ENSURE_TRUE(ok, false);
|
||||
|
||||
// The Components object normally isn't defined for unprivileged web content,
|
||||
// but we define it when UniversalXPConnect is enabled to support legacy
|
||||
// tests.
|
||||
XPCWrappedNativeScope *scope = priv->scope;
|
||||
if (!scope)
|
||||
return true;
|
||||
XPCCallContext ccx(NATIVE_CALLER, cx);
|
||||
return nsXPCComponents::AttachComponentsObject(ccx, scope);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -715,6 +715,9 @@ pref("dom.min_background_timeout_value", 1000);
|
||||
// Run content XBL in a separate scope.
|
||||
pref("dom.xbl_scopes", true);
|
||||
|
||||
// Stop defining the Components object in content.
|
||||
pref("dom.omit_components_in_content", false);
|
||||
|
||||
// Don't use new input types
|
||||
pref("dom.experimental_forms", false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user