Bug 1917477 - Add a test for origin clearing requested right after starting client directory opening for LSNG; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D219750
This commit is contained in:
Jan Varga 2024-09-17 21:50:12 +00:00
Родитель 7b7c855af9
Коммит 973adddbb1
4 изменённых файлов: 112 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,26 @@
/*
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
*/
add_task(async function testSteps() {
const principal = getPrincipal("https://example.com");
const data = {
key: "foo",
value: "bar",
};
info("Getting storage");
const storage = getLocalStorage(principal);
info("Adding data");
storage.setItem(data.key, data.value);
info("Resetting origin");
const request = resetOrigin(principal);
await requestFinished(request);
});

Двоичные данные
dom/localstorage/test/unit/somedata_profile.zip Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,79 @@
/**
* 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 { QuotaUtils } = ChromeUtils.importESModule(
"resource://testing-common/dom/quota/test/modules/QuotaUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
add_task(
{
pref_set: [
["dom.quotaManager.storageInitialization.pauseOnIOThreadMs", 2000],
],
},
async function testSteps() {
const principal = PrincipalUtils.createPrincipal("https://example.com");
info(
"Testing origin clearing requested after starting client directory opening"
);
// We need some existing data on disk, otherwise the preloading won't create
// a datastore in memory that holds a directory lock.
info("Clearing");
{
const request = Services.qms.clear();
await QuotaUtils.requestFinished(request);
}
info("Installing package");
installPackage("somedata_profile");
info("Starting database opening");
const openPromise = Services.domStorageManager.preload(principal);
info("Waiting for client directory opening to start");
await TestUtils.topicObserved(
"QuotaManager::ClientDirectoryOpeningStarted"
);
info("Starting origin clearing");
const clearPromise = (async function () {
const request = Services.qms.clearStoragesForPrincipal(principal);
const promise = QuotaUtils.requestFinished(request);
return promise;
})();
info("Waiting for database to finish opening");
try {
await openPromise;
ok(false, "Should have thrown");
} catch (e) {
ok(true, "Should have thrown");
Assert.strictEqual(
e.result,
Cr.NS_ERROR_ABORT,
"Threw right result code"
);
}
info("Waiting for origin to finish clearing");
await clearPromise;
}
);

Просмотреть файл

@ -9,6 +9,7 @@ support-files = [
"migration_profile.zip",
"schema3upgrade_profile.zip",
"schema4upgrade_profile.zip",
"somedata_profile.zip",
"stringLength2_profile.zip",
"stringLength_profile.zip",
"usageAfterMigration_profile.zip",
@ -17,6 +18,9 @@ support-files = [
["make_migration_emptyValue.js"]
skip-if = ["true"] # Only used for recreating migration_emptyValue_profile.zip
["make_somedata.js"]
skip-if = ["true"] # Only used for recreating somedata_profile.zip
["test_archive.js"]
["test_clientValidation.js"]
@ -80,6 +84,9 @@ support-files = ["migration_emptyValue_profile.zip",]
["test_schema4upgrade.js"]
["test_slowStorageInitialization.js"]
skip-if = ["true"]
["test_snapshotting.js"]
skip-if = ["tsan"] # Unreasonably slow, bug 1612707
requesttimeoutfactor = 4