зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619592 - Replace EnsureStorageAndOriginIsInitialized with EnsurePersistentOriginIsInitialized and EnsureTemporaryOriginIsInitialized in dom/indexedDB; r=dom-workers-and-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D97257
This commit is contained in:
Родитель
a959e7ff80
Коммит
fc8f82ce8a
|
@ -16301,9 +16301,22 @@ nsresult OpenDatabaseOp::DoDatabaseWork() {
|
||||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||||
MOZ_ASSERT(quotaManager);
|
MOZ_ASSERT(quotaManager);
|
||||||
|
|
||||||
IDB_TRY_INSPECT(const auto& dbDirectory,
|
IDB_TRY(quotaManager->EnsureStorageIsInitialized());
|
||||||
quotaManager->EnsureStorageAndOriginIsInitialized(
|
|
||||||
|
IDB_TRY_INSPECT(
|
||||||
|
const auto& dbDirectory,
|
||||||
|
([persistenceType, "aManager, this]()
|
||||||
|
-> mozilla::Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult> {
|
||||||
|
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT) {
|
||||||
|
IDB_TRY_RETURN(
|
||||||
|
quotaManager->EnsurePersistentOriginIsInitialized(mQuotaInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
IDB_TRY(quotaManager->EnsureTemporaryStorageIsInitialized());
|
||||||
|
IDB_TRY_RETURN(quotaManager->EnsureTemporaryOriginIsInitialized(
|
||||||
persistenceType, mQuotaInfo));
|
persistenceType, mQuotaInfo));
|
||||||
|
}()
|
||||||
|
.map([](const auto& res) { return res.first; })));
|
||||||
|
|
||||||
IDB_TRY(
|
IDB_TRY(
|
||||||
dbDirectory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME)));
|
dbDirectory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME)));
|
||||||
|
|
|
@ -56,9 +56,12 @@ async function testSteps() {
|
||||||
|
|
||||||
info("Verifying initialization");
|
info("Verifying initialization");
|
||||||
|
|
||||||
|
let request = initStorage();
|
||||||
|
await requestFinished(request);
|
||||||
|
|
||||||
createTestingEnvironment();
|
createTestingEnvironment();
|
||||||
|
|
||||||
let request = initStorageAndChromeOrigin("persistent");
|
request = initPersistentOrigin(getSystemPrincipal());
|
||||||
await requestFinished(request);
|
await requestFinished(request);
|
||||||
|
|
||||||
let testingFiles = getTestingFiles();
|
let testingFiles = getTestingFiles();
|
||||||
|
|
|
@ -252,11 +252,12 @@ function setTimeout(fun, timeout) {
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStorageAndChromeOrigin(persistence) {
|
function initStorage() {
|
||||||
let principal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
|
return Services.qms.init();
|
||||||
Ci.nsIPrincipal
|
}
|
||||||
);
|
|
||||||
return Services.qms.initStorageAndOrigin(principal, persistence, "idb");
|
function initPersistentOrigin(principal) {
|
||||||
|
return Services.qms.initializePersistentOrigin(principal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetOrClearAllDatabases(callback, clear) {
|
function resetOrClearAllDatabases(callback, clear) {
|
||||||
|
@ -537,6 +538,10 @@ function resetPreprocessing() {
|
||||||
SpecialPowers.clearUserPref("dom.indexedDB.preprocessing");
|
SpecialPowers.clearUserPref("dom.indexedDB.preprocessing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSystemPrincipal() {
|
||||||
|
return Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
|
||||||
|
}
|
||||||
|
|
||||||
function getPrincipal(url) {
|
function getPrincipal(url) {
|
||||||
let uri = Services.io.newURI(url);
|
let uri = Services.io.newURI(url);
|
||||||
return Services.scriptSecurityManager.createContentPrincipal(uri, {});
|
return Services.scriptSecurityManager.createContentPrincipal(uri, {});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче