mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
Bug 1917453 - Use a common helper for observing notifications in tests; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D219515
This commit is contained in:
parent
a7b9d641d9
commit
1f464aab35
@ -3,6 +3,10 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const { TestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
/* exported testSteps */
|
||||
async function testSteps() {
|
||||
info("Sending fake 'idle-daily' notification to QuotaManager");
|
||||
@ -13,10 +17,5 @@ async function testSteps() {
|
||||
|
||||
info("Waiting for maintenance to start");
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
Services.obs.addObserver(function observer(subject, topic) {
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
resolve();
|
||||
}, "QuotaManager::MaintenanceStarted");
|
||||
});
|
||||
await TestUtils.topicObserved("QuotaManager::MaintenanceStarted");
|
||||
}
|
||||
|
@ -10,27 +10,18 @@
|
||||
* below the global usage.
|
||||
*/
|
||||
|
||||
const { TestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
loadScript("dom/quota/test/common/file.js");
|
||||
|
||||
function awaitStoragePressure() {
|
||||
let promise_resolve;
|
||||
|
||||
let promise = new Promise(function (resolve) {
|
||||
promise_resolve = resolve;
|
||||
});
|
||||
|
||||
function observer(subject, topic) {
|
||||
ok(true, "Got the storage pressure event");
|
||||
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
|
||||
let usage = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
promise_resolve(usage);
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, "QuotaManager::StoragePressure");
|
||||
|
||||
return promise;
|
||||
async function awaitStoragePressure() {
|
||||
const [subject] = await TestUtils.topicObserved(
|
||||
"QuotaManager::StoragePressure"
|
||||
);
|
||||
const usage = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
|
||||
return usage;
|
||||
}
|
||||
|
||||
async function testSteps() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user