From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/indexedDB/IDBFactory.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'dom/indexedDB/IDBFactory.cpp') diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index be34e1914d..81dce07d7e 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -242,6 +242,12 @@ Result, nsresult> IDBFactory::CreateForMainThreadJSInternal( return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } + nsresult rv = mgr->EnsureLocale(); + if (NS_WARN_IF(NS_FAILED(rv))) { + IDB_REPORT_INTERNAL_ERR(); + return Err(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + }; + return CreateInternal(aGlobal, std::move(aPrincipalInfo), /* aInnerWindowID */ 0); } @@ -283,10 +289,17 @@ nsresult IDBFactory::AllowedForWindowInternal( MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aWindow); - if (NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate())) { + IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate(); + if (NS_WARN_IF(!mgr)) { return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } + nsresult rv = mgr->EnsureLocale(); + if (NS_WARN_IF(NS_FAILED(rv))) { + IDB_REPORT_INTERNAL_ERR(); + return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + }; + StorageAccess access = StorageAllowedForWindow(aWindow); // the factory callsite records whether the browser is in private browsing. @@ -341,10 +354,16 @@ bool IDBFactory::AllowedForPrincipal(nsIPrincipal* aPrincipal, MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aPrincipal); - if (NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate())) { + IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate(); + if (NS_WARN_IF(!mgr)) { return false; } + nsresult rv = mgr->EnsureLocale(); + if (NS_WARN_IF(NS_FAILED(rv))) { + return false; + }; + if (aPrincipal->IsSystemPrincipal()) { if (aIsSystemPrincipal) { *aIsSystemPrincipal = true; @@ -573,19 +592,20 @@ RefPtr IDBFactory::OpenInternal( PersistenceType persistenceType; - bool isInternal = principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo; - if (!isInternal && + bool isPersistent = + principalInfo.type() == PrincipalInfo::TSystemPrincipalInfo; + if (!isPersistent && principalInfo.type() == PrincipalInfo::TContentPrincipalInfo) { nsCString origin = principalInfo.get_ContentPrincipalInfo().originNoSuffix(); - isInternal = QuotaManager::IsOriginInternal(origin); + isPersistent = QuotaManager::IsOriginInternal(origin); } const bool isPrivate = principalInfo.type() == PrincipalInfo::TContentPrincipalInfo && principalInfo.get_ContentPrincipalInfo().attrs().mPrivateBrowsingId > 0; - if (isInternal) { + if (isPersistent) { // Chrome privilege and internal origins always get persistent storage. persistenceType = PERSISTENCE_TYPE_PERSISTENT; } else if (isPrivate) { @@ -641,7 +661,8 @@ RefPtr IDBFactory::OpenInternal( mBackgroundActor = static_cast( backgroundActor->SendPBackgroundIDBFactoryConstructor( - actor, idbThreadLocal->GetLoggingInfo())); + actor, idbThreadLocal->GetLoggingInfo(), + IndexedDatabaseManager::GetLocale())); if (NS_WARN_IF(!mBackgroundActor)) { mBackgroundActorFailed = true; -- cgit v1.2.3