зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1628240 - Add a test to ensure the quota storages for the same host but with different host are removed; r=johannh,dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D71715
This commit is contained in:
Родитель
bd96d39a19
Коммит
5043143d22
|
@ -5,6 +5,7 @@
|
|||
|
||||
const EXAMPLE_ORIGIN = "https://www.example.com";
|
||||
const EXAMPLE_ORIGIN_2 = "https://example.org";
|
||||
const EXAMPLE_ORIGIN_3 = "http://localhost:8000";
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { SiteDataManager } = ChromeUtils.import(
|
||||
|
@ -130,11 +131,18 @@ add_task(async function testRemove() {
|
|||
SiteDataTestUtils.addToCookies(EXAMPLE_ORIGIN_2, "foo", "bar");
|
||||
await SiteDataTestUtils.addToIndexedDB(EXAMPLE_ORIGIN_2, 2048);
|
||||
await SiteDataTestUtils.persist(EXAMPLE_ORIGIN_2);
|
||||
await SiteDataTestUtils.addToIndexedDB(EXAMPLE_ORIGIN_3, 2048);
|
||||
|
||||
await SiteDataManager.updateSites();
|
||||
|
||||
let sites = await SiteDataManager.getSites();
|
||||
|
||||
Assert.equal(sites.length, 3, "Has three sites.");
|
||||
|
||||
await SiteDataManager.remove(["localhost"]);
|
||||
|
||||
sites = await SiteDataManager.getSites();
|
||||
|
||||
Assert.equal(sites.length, 2, "Has two sites.");
|
||||
|
||||
await SiteDataManager.remove(["www.example.com"]);
|
||||
|
|
|
@ -122,6 +122,7 @@ const ORG_DOMAIN = "example.com";
|
|||
const ORG_ORIGIN = `https://${ORG_DOMAIN}`;
|
||||
const COM_DOMAIN = "example.org";
|
||||
const COM_ORIGIN = `https://${COM_DOMAIN}`;
|
||||
const LH_DOMAIN = "localhost";
|
||||
|
||||
add_task(async function test_deleteFromHost() {
|
||||
const sites = [
|
||||
|
@ -133,6 +134,10 @@ add_task(async function test_deleteFromHost() {
|
|||
args: [COM_DOMAIN, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA],
|
||||
origin: COM_ORIGIN,
|
||||
},
|
||||
{
|
||||
args: [LH_DOMAIN, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA],
|
||||
origin: `http://${LH_DOMAIN}:8000`,
|
||||
},
|
||||
];
|
||||
|
||||
await runTest(sites, Services.clearData.deleteDataFromHost);
|
||||
|
@ -202,3 +207,26 @@ add_task(async function test_deleteAll() {
|
|||
ok(!hasQuotaStorage(ORG_ORIGIN), `${ORG_ORIGIN} has no quota storage`);
|
||||
ok(!hasQuotaStorage(COM_ORIGIN), `${COM_ORIGIN} has no quota storage`);
|
||||
});
|
||||
|
||||
add_task(async function test_deleteSubdomain() {
|
||||
const ANOTHER_ORIGIN = `https://wwww.${ORG_DOMAIN}`;
|
||||
info(`Adding quota storage`);
|
||||
await addQuotaStorage(getPrincipal(ORG_ORIGIN));
|
||||
await addQuotaStorage(getPrincipal(ANOTHER_ORIGIN));
|
||||
|
||||
info(`Verifying deleteDataFromHost for subdomain`);
|
||||
await new Promise(aResolve => {
|
||||
Services.clearData.deleteDataFromHost(
|
||||
ORG_DOMAIN,
|
||||
true,
|
||||
Ci.nsIClearDataService.CLEAR_DOM_QUOTA,
|
||||
value => {
|
||||
Assert.equal(value, 0);
|
||||
aResolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
ok(!hasQuotaStorage(ORG_ORIGIN), `${ORG_ORIGIN} has no quota storage`);
|
||||
ok(!hasQuotaStorage(COM_ORIGIN), `${ANOTHER_ORIGIN} has no quota storage`);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче