Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/quota/test/xpcshell/xpcshell.toml
/**
* Any copyright is dedicated to the Public Domain.
*/
loadScript("dom/quota/test/xpcshell/common/utils.js");
async function verifyOriginEstimation(principal, expectedUsage, expectedLimit) {
info("Estimating origin");
const request = estimateOrigin(principal);
await requestFinished(request);
is(request.result.usage, expectedUsage, "Correct usage");
is(request.result.limit, expectedLimit, "Correct limit");
}
async function testSteps() {
// The group limit is calculated as 20% of the global limit and the minimum
// value of the group limit is 10 MB.
const groupLimitKB = 10 * 1024;
const groupLimitBytes = groupLimitKB * 1024;
const globalLimitKB = groupLimitKB * 5;
const globalLimitBytes = globalLimitKB * 1024;
info("Setting limits");
setGlobalLimit(globalLimitKB);
info("Clearing");
let request = clear();
await requestFinished(request);
info("Filling origins");
info("Verifying origin estimations");
await verifyOriginEstimation(
300,
groupLimitBytes
);
await verifyOriginEstimation(
300,
groupLimitBytes
);
await verifyOriginEstimation(
700,
groupLimitBytes
);
await verifyOriginEstimation(
700,
groupLimitBytes
);
info("Persisting origin");
await requestFinished(request);
info("Verifying origin estimation");
await verifyOriginEstimation(
1000,
globalLimitBytes
);
finishTest();
}