зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917479 - Add a test for origin clearing requested right after starting client directory opening for FS; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D219863
This commit is contained in:
Родитель
347f22b7f3
Коммит
dfa7f0ec23
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This test doesn't use the shared module system (running the same test in
|
||||||
|
// multiple test suites) on purpose because it needs to create an unprivileged
|
||||||
|
// sandbox which is not possible if the test is already running in a sandbox.
|
||||||
|
|
||||||
|
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"
|
||||||
|
);
|
||||||
|
|
||||||
|
info("Starting database opening");
|
||||||
|
|
||||||
|
const openPromise = new Promise(function (resolve, reject) {
|
||||||
|
const sandbox = new Cu.Sandbox(principal, {
|
||||||
|
wantGlobalProperties: ["storage"],
|
||||||
|
forceSecureContext: true,
|
||||||
|
});
|
||||||
|
sandbox.resolve = resolve;
|
||||||
|
sandbox.reject = reject;
|
||||||
|
Cu.evalInSandbox(
|
||||||
|
`storage.getDirectory().then(resolve, reject);`,
|
||||||
|
sandbox
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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.name, "AbortError", "Threw right result code");
|
||||||
|
}
|
||||||
|
|
||||||
|
info("Waiting for origin to finish clearing");
|
||||||
|
|
||||||
|
await clearPromise;
|
||||||
|
}
|
||||||
|
);
|
|
@ -11,6 +11,9 @@ head = "head.js"
|
||||||
|
|
||||||
["test_getDirectoryFailure.js"]
|
["test_getDirectoryFailure.js"]
|
||||||
|
|
||||||
|
["test_slowStorageInitialization.js"]
|
||||||
|
skip-if = ["true"]
|
||||||
|
|
||||||
["test_syncAccessHandle_worker.js"]
|
["test_syncAccessHandle_worker.js"]
|
||||||
|
|
||||||
["test_writableFileStream.js"]
|
["test_writableFileStream.js"]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче