Bug 1079355 - indexedDB pref should only apply for content pages, not chrome ones, r=bent

This commit is contained in:
Gijs Kruitbosch 2015-01-05 23:08:12 +00:00
Родитель 93ffc33cf1
Коммит 69488b712d
2 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -10748,7 +10748,9 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mState == State_Initial || mState == State_PermissionRetry);
if (NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
const PrincipalInfo& principalInfo = mCommonParams.principalInfo();
if (principalInfo.type() != PrincipalInfo::TSystemPrincipalInfo &&
NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
if (aContentParent) {
// The DOM in the other process should have kept us from receiving any
// indexedDB messages so assume that the child is misbehaving.
@ -10764,7 +10766,6 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
PersistenceType persistenceType = mCommonParams.metadata().persistenceType();
const PrincipalInfo& principalInfo = mCommonParams.principalInfo();
MOZ_ASSERT(principalInfo.type() != PrincipalInfo::TNullPrincipalInfo);
if (principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {

Просмотреть файл

@ -129,13 +129,15 @@ IDBFactory::CreateForWindow(nsPIDOMWindow* aWindow,
MOZ_ASSERT(aWindow->IsInnerWindow());
MOZ_ASSERT(aFactory);
if (NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = AllowedForWindowInternal(aWindow, getter_AddRefs(principal));
if (!(NS_SUCCEEDED(rv) && nsContentUtils::IsSystemPrincipal(principal)) &&
NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
*aFactory = nullptr;
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = AllowedForWindowInternal(aWindow, getter_AddRefs(principal));
if (rv == NS_ERROR_DOM_NOT_SUPPORTED_ERR) {
NS_WARNING("IndexedDB is not permitted in a third-party window.");
*aFactory = nullptr;
@ -261,8 +263,10 @@ IDBFactory::CreateForMainThreadJSInternal(
IDBFactory** aFactory)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPrincipalInfo);
if (NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
if (aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo &&
NS_WARN_IF(!Preferences::GetBool(kPrefIndexedDBEnabled, false))) {
*aFactory = nullptr;
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}