feat #303: reset cookies in site manager

This commit is contained in:
Rafee
2024-08-01 13:58:16 -04:00
parent 1537e9f6f2
commit ffbb740445
6 changed files with 50 additions and 6 deletions
+12
View File
@@ -571,6 +571,18 @@ window.assignManager = {
return true;
},
async _resetCookiesForSite(pageUrl, cookieStoreId) {
const url = new URL(pageUrl);
// Remove 'www.' from the domain value
const domain = url.hostname.replace(/^www\./, "");
const cookies = await browser.cookies.getAll({domain: domain, storeId: cookieStoreId});
for (const cookie of cookies) {
const domain = cookie.domain.startsWith(".") ? cookie.domain.slice(1) : cookie.domain;
const cookieUrl = `${cookie.secure ? "https" : "http"}://${domain}${cookie.path}`;
await browser.cookies.remove({ url: cookieUrl, name: cookie.name, storeId: cookie.storeId });
}
},
async _setOrRemoveAssignment(tabId, pageUrl, userContextId, remove) {
let actionName;
// https://github.com/mozilla/testpilot-containers/issues/626