Skip to content

Commit

Permalink
#451: M1410106 (thanks to Andrew Sutherland)
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Dec 1, 2017
1 parent fe74dde commit 8247519
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
34 changes: 23 additions & 11 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
if (principalInfo.type() != PrincipalInfo::TSystemPrincipalInfo) {
if (principalInfo.type() != PrincipalInfo::TContentPrincipalInfo) {
if (aContentParent) {
// We just want ContentPrincipalInfo or SystemPrincipalInfo.
aContentParent->KillHard("IndexedDB CheckPermission 0");
}

return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}

if (NS_WARN_IF(mCommonParams.privateBrowsingMode())) {
// XXX This is only temporary.
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);
Expand Down
25 changes: 18 additions & 7 deletions dom/indexedDB/IDBFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -252,7 +258,8 @@ IDBFactory::CreateForWorker(JSContext* aCx,
aOwningObject,
principalInfo,
aInnerWindowID,
aFactory);
aFactory,
aIsPrivateBrowsing);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand All @@ -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);
Expand All @@ -290,7 +298,8 @@ IDBFactory::CreateForMainThreadJSInternal(
aOwningObject,
aPrincipalInfo,
/* aInnerWindowID */ 0,
aFactory);
aFactory,
aIsPrivateBrowsing);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Expand All @@ -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);
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions dom/indexedDB/IDBFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class IDBFactory final
nsTArray<nsAutoPtr<PendingRequestInfo>> mPendingRequests;

BackgroundFactoryChild* mBackgroundActor;

#ifdef DEBUG
PRThread* mOwningThread;
#endif
Expand Down Expand Up @@ -100,7 +100,8 @@ class IDBFactory final
JS::Handle<JSObject*> aOwningObject,
const PrincipalInfo& aPrincipalInfo,
uint64_t aInnerWindowID,
IDBFactory** aFactory);
IDBFactory** aFactory,
bool aIsPrivateBrowsing);

static bool
AllowedForWindow(nsPIDOMWindow* aWindow);
Expand Down Expand Up @@ -217,14 +218,16 @@ class IDBFactory final
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,
Expand Down
3 changes: 2 additions & 1 deletion dom/workers/WorkerScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8247519

Please sign in to comment.