Bug 1555189 - Enable partitioning of DOM cache in the third-party context; r=baku

Differential Revision: https://phabricator.services.mozilla.com/D32922

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2019-05-29 15:42:43 +00:00
parent 97fc0e9aaf
commit 56221ac188
4 changed files with 21 additions and 9 deletions

View File

@ -4594,9 +4594,9 @@ already_AddRefed<CacheStorage> nsGlobalWindowInner::GetCaches(
if (!mCacheStorage) {
bool forceTrustedOrigin =
GetOuterWindow()->GetServiceWorkersTestingEnabled();
mCacheStorage = CacheStorage::CreateOnMainThread(cache::DEFAULT_NAMESPACE,
this, GetPrincipal(),
forceTrustedOrigin, aRv);
mCacheStorage = CacheStorage::CreateOnMainThread(
cache::DEFAULT_NAMESPACE, this, GetEffectiveStoragePrincipal(),
forceTrustedOrigin, aRv);
}
RefPtr<CacheStorage> ref = mCacheStorage;
@ -6984,6 +6984,9 @@ void nsGlobalWindowInner::StorageAccessGranted() {
// Reset the IndexedDB factory.
mIndexedDB = nullptr;
// Reset DOM Cache
mCacheStorage = nullptr;
}
mozilla::dom::TabGroup* nsPIDOMWindowInner::TabGroup() {

View File

@ -197,7 +197,8 @@ already_AddRefed<CacheStorage> CacheStorage::CreateOnWorker(
return nullptr;
}
const PrincipalInfo& principalInfo = aWorkerPrivate->GetPrincipalInfo();
const PrincipalInfo& principalInfo =
aWorkerPrivate->GetEffectiveStoragePrincipalInfo();
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(principalInfo))) {
aRv.Throw(NS_ERROR_FAILURE);

View File

@ -507,7 +507,11 @@ WorkerGlobalScope::GetOrCreateServiceWorkerRegistration(
}
void WorkerGlobalScope::FirstPartyStorageAccessGranted() {
// Reset the IndexedDB factory.
mIndexedDB = nullptr;
// Reset DOM Cache
mCacheStorage = nullptr;
}
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(

View File

@ -1,6 +1,6 @@
/* import-globals-from storageprincipal_head.js */
/* import-globals-from partitionedstorage_head.js */
StoragePrincipalHelper.runTest("DOMCache",
PartitionedStorageHelper.runTest("DOMCache",
async (win3rdParty, win1stParty, allowed) => {
// DOM Cache is not supported. Always blocked.
await win3rdParty.caches.open("wow").then(
@ -9,8 +9,8 @@ StoragePrincipalHelper.runTest("DOMCache",
);
await win1stParty.caches.open("wow").then(
_ => { ok(true, "DOM Cache shoulw be available"); },
_ => { ok(false, "DOM Cache shoulw be available"); },
_ => { ok(true, "DOM Cache should be available"); },
_ => { ok(false, "DOM Cache should be available"); },
);
},
@ -18,4 +18,8 @@ StoragePrincipalHelper.runTest("DOMCache",
await new Promise(resolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve());
});
});
},
[
["dom.caches.testing.enabled", true],
]);