Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/**
* Any copyright is dedicated to the Public Domain.
*/
const { PrincipalUtils } = ChromeUtils.importESModule(
);
const { QuotaUtils } = ChromeUtils.importESModule(
);
async function testSteps() {
const origins = [
];
function verifyResult(result, expectedOrigins) {
ok(Array.isArray(result), "Got an array object");
Assert.equal(
result.length,
expectedOrigins.length,
"Correct number of elements"
);
info("Sorting elements");
result.sort(function (a, b) {
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
});
info("Verifying elements");
for (let i = 0; i < result.length; i++) {
Assert.equal(
result[i],
expectedOrigins[i],
"Result matches expected origin"
);
}
}
info("Clearing");
{
const request = Services.qms.clear();
await QuotaUtils.requestFinished(request);
}
info("Listing origins");
const originsBeforeInit = await (async function () {
const request = Services.qms.listOrigins();
const result = await QuotaUtils.requestFinished(request);
return result;
})();
info("Verifying result");
verifyResult(originsBeforeInit, []);
info("Clearing");
{
const request = Services.qms.clear();
await QuotaUtils.requestFinished(request);
}
info("Initializing");
{
const request = Services.qms.init();
await QuotaUtils.requestFinished(request);
}
info("Initializing temporary storage");
{
const request = Services.qms.initTemporaryStorage();
await QuotaUtils.requestFinished(request);
}
info("Initializing origins");
for (const origin of origins) {
const request = Services.qms.initializeTemporaryOrigin(
"default",
PrincipalUtils.createPrincipal(origin)
);
await QuotaUtils.requestFinished(request);
}
info("Listing origins");
const originsAfterInit = await (async function () {
const request = Services.qms.listOrigins();
const result = await QuotaUtils.requestFinished(request);
return result;
})();
info("Verifying result");
verifyResult(originsAfterInit, origins);
}