Bug 1919788 - LSNG: Add a new testing only notification for request finalization; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D222458
This commit is contained in:
Jan Varga 2024-10-04 11:23:49 +00:00
parent d4657c7ef2
commit 3c753be15b
5 changed files with 42 additions and 0 deletions

View File

@ -6372,6 +6372,8 @@ nsresult LSRequestBase::SendReadyMessageInternal() {
return NS_ERROR_FAILURE;
}
localstorage::NotifyRequestFinalizationStarted();
mState = State::WaitingForFinish;
mWaitingForFinish = true;

View File

@ -19,4 +19,13 @@ void NotifyDatabaseWorkStarted() {
quota::NotifyObserversOnMainThread("LocalStorage::DatabaseWorkStarted");
}
void NotifyRequestFinalizationStarted() {
if (!StaticPrefs::dom_storage_testing()) {
return;
}
quota::NotifyObserversOnMainThread(
"LocalStorage::RequestFinalizationStarted");
}
} // namespace mozilla::dom::localstorage

View File

@ -11,6 +11,8 @@ namespace mozilla::dom::localstorage {
void NotifyDatabaseWorkStarted();
void NotifyRequestFinalizationStarted();
} // namespace mozilla::dom::localstorage
#endif // DOM_LOCALSTORAGE_NOTIFYUTILS_H_

View File

@ -0,0 +1,27 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const { PrincipalUtils } = ChromeUtils.importESModule(
"resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
add_task(async function testSteps() {
const principal = PrincipalUtils.createPrincipal("https://example.com");
info("Starting database opening");
const openPromise = Services.domStorageManager.preload(principal);
info("Waiting for request finalization to start");
await TestUtils.topicObserved("LocalStorage::RequestFinalizationStarted");
info("Waiting for database to finish opening");
await openPromise;
});

View File

@ -83,6 +83,8 @@ support-files = ["migration_emptyValue_profile.zip",]
["test_preloading.js"]
["test_requestFinalizationStarted.js"]
["test_schema3upgrade.js"]
["test_schema4upgrade.js"]