#451: M1410106 (thanks to Andrew Sutherland)

This commit is contained in:
Cameron Kaiser 2017-11-30 20:09:30 -08:00
parent fe74dde015
commit 8247519187
4 changed files with 51 additions and 24 deletions

View File

@ -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);

View File

@ -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<JSObject*> 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<JSObject*> aOwningObject,
nsAutoPtr<PrincipalInfo>& 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<JSObject*> aOwningObject,
nsAutoPtr<PrincipalInfo>& 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;

View File

@ -70,7 +70,7 @@ class IDBFactory final
nsTArray<nsAutoPtr<PendingRequestInfo>> mPendingRequests;
BackgroundFactoryChild* mBackgroundActor;
#ifdef DEBUG
PRThread* mOwningThread;
#endif
@ -100,7 +100,8 @@ public:
JS::Handle<JSObject*> 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<JSObject*> aOwningObject,
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
IDBFactory** aFactory);
IDBFactory** aFactory,
bool aIsPrivateBrowsing);
static nsresult
CreateForJSInternal(JSContext* aCx,
JS::Handle<JSObject*> aOwningObject,
nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
uint64_t aInnerWindowID,
IDBFactory** aFactory);
IDBFactory** aFactory,
bool aIsPrivateBrowsing);
static nsresult
AllowedForWindowInternal(nsPIDOMWindow* aWindow,

View File

@ -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;