Bug 1628240 - Do not clear all origins that match the pattern for QuotaCleaner.deleteByHost; r=dom-workers-and-storage-reviewers,janv

We do clearStoragsForPrincipal based on the result from listOrigin, so it's fine
to not clear all stroages that match the prefix here. Also, since the passing
principals can contain origin attributes which is not allowed to be used with
aClearAll.

Differential Revision: https://phabricator.services.mozilla.com/D73417
This commit is contained in:
Tom Tung 2020-05-13 13:57:28 +00:00
Родитель 81b5f914d9
Коммит 6dfa60337a
2 изменённых файлов: 7 добавлений и 4 удалений

Просмотреть файл

@ -511,10 +511,7 @@ const QuotaCleaner = {
promises.push(
new Promise((aResolve, aReject) => {
let clearRequest = Services.qms.clearStoragesForPrincipal(
principal,
null,
null,
true
principal
);
clearRequest.callback = () => {
if (clearRequest.resultCode == Cr.NS_OK) {

Просмотреть файл

@ -123,6 +123,7 @@ const ORG_ORIGIN = `https://${ORG_DOMAIN}`;
const COM_DOMAIN = "example.org";
const COM_ORIGIN = `https://${COM_DOMAIN}`;
const LH_DOMAIN = "localhost";
const FOO_DOMAIN = "foo.com";
add_task(async function test_deleteFromHost() {
const sites = [
@ -138,6 +139,11 @@ add_task(async function test_deleteFromHost() {
args: [LH_DOMAIN, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA],
origin: `http://${LH_DOMAIN}:8000`,
},
{
args: [FOO_DOMAIN, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA],
origin: `http://${FOO_DOMAIN}`,
originAttributes: { userContextId: 1 },
},
];
await runTest(sites, Services.clearData.deleteDataFromHost);