summaryrefslogtreecommitdiffstats
path: root/dom/workers/WorkerScope.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/WorkerScope.cpp')
-rw-r--r--dom/workers/WorkerScope.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp
index 2121a99cb3..cbb61c7055 100644
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -468,6 +468,7 @@ already_AddRefed<CacheStorage> WorkerGlobalScope::GetCaches(ErrorResult& aRv) {
if (!mCacheStorage) {
mCacheStorage = CacheStorage::CreateOnWorker(cache::DEFAULT_NAMESPACE, this,
mWorkerPrivate, aRv);
+ mWorkerPrivate->NotifyStorageKeyUsed();
}
RefPtr<CacheStorage> ref = mCacheStorage;
@@ -735,25 +736,28 @@ already_AddRefed<IDBFactory> WorkerGlobalScope::GetIndexedDB(
if (!indexedDB) {
StorageAccess access = mWorkerPrivate->StorageAccess();
+ bool allowed = true;
if (access == StorageAccess::eDeny) {
NS_WARNING("IndexedDB is not allowed in this worker!");
- aErrorResult = NS_ERROR_DOM_SECURITY_ERR;
- return nullptr;
+ allowed = false;
}
if (ShouldPartitionStorage(access) &&
!StoragePartitioningEnabled(access,
mWorkerPrivate->CookieJarSettings())) {
NS_WARNING("IndexedDB is not allowed in this worker!");
- aErrorResult = NS_ERROR_DOM_SECURITY_ERR;
- return nullptr;
+ allowed = false;
}
- const PrincipalInfo& principalInfo =
- mWorkerPrivate->GetEffectiveStoragePrincipalInfo();
+ auto windowID = mWorkerPrivate->WindowID();
+
+ auto principalInfoPtr =
+ allowed ? MakeUnique<PrincipalInfo>(
+ mWorkerPrivate->GetEffectiveStoragePrincipalInfo())
+ : nullptr;
+ auto res = IDBFactory::CreateForWorker(this, std::move(principalInfoPtr),
+ windowID);
- auto res = IDBFactory::CreateForWorker(this, principalInfo,
- mWorkerPrivate->WindowID());
if (NS_WARN_IF(res.isErr())) {
aErrorResult = res.unwrapErr();
return nullptr;
@@ -763,6 +767,8 @@ already_AddRefed<IDBFactory> WorkerGlobalScope::GetIndexedDB(
mIndexedDB = indexedDB;
}
+ mWorkerPrivate->NotifyStorageKeyUsed();
+
return indexedDB.forget();
}