diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 9feac6178..3d688ec9a 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -19407,20 +19407,32 @@ FactoryOp::CheckPermission(ContentParent* aContentParent, MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mState == State::Initial || mState == State::PermissionRetry); + // TenFourFox issue 451 for Mozilla bug 1410106 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. - aContentParent->KillHard("IndexedDB CheckPermission 1"); - } - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; - } + if (principalInfo.type() != PrincipalInfo::TSystemPrincipalInfo) { + if (principalInfo.type() != PrincipalInfo::TContentPrincipalInfo) { + if (aContentParent) { + // We just want ContentPrincipalInfo or SystemPrincipalInfo. + aContentParent->KillHard("IndexedDB CheckPermission 0"); + } - if (NS_WARN_IF(mCommonParams.privateBrowsingMode())) { - // XXX This is only temporary. - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + } + + if (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. + aContentParent->KillHard("IndexedDB CheckPermission 1"); + } + + return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + } + + if (NS_WARN_IF(mCommonParams.privateBrowsingMode())) { + // IndexedDB is currently disabled in privateBrowsing. + return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + } } mFileHandleDisabled = !Preferences::GetBool(kPrefFileHandleEnabled); diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 80e30b6ad..58a6a52d8 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -199,7 +199,10 @@ IDBFactory::CreateForMainThreadJS(JSContext* aCx, return rv; } - rv = CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo, aFactory); + rv = CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo, aFactory, + /* Only IndexedDatabaseManager::DefineIndexedDB + can call this, which is always chrome, thus ... */ + /* aIsPrivateBrowsing */ false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -224,7 +227,9 @@ IDBFactory::CreateForDatastore(JSContext* aCx, new PrincipalInfo(SystemPrincipalInfo())); nsresult rv = - CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo, aFactory); + CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo, aFactory, + /* Only chrome can get here, therefore ... */ + /* aIsPrivateBrowsing */ false); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -240,7 +245,8 @@ IDBFactory::CreateForWorker(JSContext* aCx, JS::Handle aOwningObject, const PrincipalInfo& aPrincipalInfo, uint64_t aInnerWindowID, - IDBFactory** aFactory) + IDBFactory** aFactory, + bool aIsPrivateBrowsing) { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(aPrincipalInfo.type() != PrincipalInfo::T__None); @@ -252,7 +258,8 @@ IDBFactory::CreateForWorker(JSContext* aCx, aOwningObject, principalInfo, aInnerWindowID, - aFactory); + aFactory, + aIsPrivateBrowsing); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -268,7 +275,8 @@ IDBFactory::CreateForMainThreadJSInternal( JSContext* aCx, JS::Handle aOwningObject, nsAutoPtr& aPrincipalInfo, - IDBFactory** aFactory) + IDBFactory** aFactory, + bool aIsPrivateBrowsing) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aPrincipalInfo); @@ -290,7 +298,8 @@ IDBFactory::CreateForMainThreadJSInternal( aOwningObject, aPrincipalInfo, /* aInnerWindowID */ 0, - aFactory); + aFactory, + aIsPrivateBrowsing); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -304,7 +313,8 @@ IDBFactory::CreateForJSInternal(JSContext* aCx, JS::Handle aOwningObject, nsAutoPtr& aPrincipalInfo, uint64_t aInnerWindowID, - IDBFactory** aFactory) + IDBFactory** aFactory, + bool aIsPrivateBrowsing) { MOZ_ASSERT(aCx); MOZ_ASSERT(aOwningObject); @@ -327,6 +337,7 @@ IDBFactory::CreateForJSInternal(JSContext* aCx, factory->mOwningObject = aOwningObject; mozilla::HoldJSObjects(factory.get()); factory->mInnerWindowID = aInnerWindowID; + factory->mPrivateBrowsingMode = aIsPrivateBrowsing; factory.forget(aFactory); return NS_OK; diff --git a/dom/indexedDB/IDBFactory.h b/dom/indexedDB/IDBFactory.h index f7614de43..98c806f79 100644 --- a/dom/indexedDB/IDBFactory.h +++ b/dom/indexedDB/IDBFactory.h @@ -70,7 +70,7 @@ class IDBFactory final nsTArray> mPendingRequests; BackgroundFactoryChild* mBackgroundActor; - + #ifdef DEBUG PRThread* mOwningThread; #endif @@ -100,7 +100,8 @@ public: JS::Handle aOwningObject, const PrincipalInfo& aPrincipalInfo, uint64_t aInnerWindowID, - IDBFactory** aFactory); + IDBFactory** aFactory, + bool aIsPrivateBrowsing); static bool AllowedForWindow(nsPIDOMWindow* aWindow); @@ -217,14 +218,16 @@ private: CreateForMainThreadJSInternal(JSContext* aCx, JS::Handle aOwningObject, nsAutoPtr& aPrincipalInfo, - IDBFactory** aFactory); + IDBFactory** aFactory, + bool aIsPrivateBrowsing); static nsresult CreateForJSInternal(JSContext* aCx, JS::Handle aOwningObject, nsAutoPtr& aPrincipalInfo, uint64_t aInnerWindowID, - IDBFactory** aFactory); + IDBFactory** aFactory, + bool aIsPrivateBrowsing); static nsresult AllowedForWindowInternal(nsPIDOMWindow* aWindow, diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index cc6c7fe70..cf58fcc82 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -379,7 +379,8 @@ WorkerGlobalScope::GetIndexedDB(ErrorResult& aErrorResult) owningObject, principalInfo, mWorkerPrivate->WindowID(), - getter_AddRefs(indexedDB)); + getter_AddRefs(indexedDB), + mWorkerPrivate->IsInPrivateBrowsing()); if (NS_WARN_IF(NS_FAILED(rv))) { aErrorResult = rv; return nullptr;