refactored runSync and following functions

This commit is contained in:
Kendall Werts 2020-01-02 17:42:09 -06:00
parent 19dce3ba45
commit 0252f9d1c3
3 changed files with 183 additions and 114 deletions

View file

@ -1,4 +1,3 @@
/* jshint esversion: 8*/
const assignManager = { const assignManager = {
MENU_ASSIGN_ID: "open-in-this-container", MENU_ASSIGN_ID: "open-in-this-container",
MENU_REMOVE_ID: "remove-open-in-this-container", MENU_REMOVE_ID: "remove-open-in-this-container",
@ -53,14 +52,18 @@ const assignManager = {
get(pageUrl) { get(pageUrl) {
const siteStoreKey = this.getSiteStoreKey(pageUrl); const siteStoreKey = this.getSiteStoreKey(pageUrl);
return this.getByUrlKey(siteStoreKey);
},
getByUrlKey(siteStoreKey) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.area.get([siteStoreKey]).then((storageResponse) => { this.area.get([siteStoreKey]).then((storageResponse) => {
if (storageResponse && siteStoreKey in storageResponse) { if (storageResponse && siteStoreKey in storageResponse) {
resolve(storageResponse[siteStoreKey]); resolve(storageResponse[siteStoreKey]);
} }
resolve(null); resolve(()=> { throw new Error (siteStoreKey, " does not exist"); });
}).catch((e) => { }).catch((e) => {
reject(e); throw e; // reject(e);
}); });
}); });
}, },
@ -108,7 +111,7 @@ const assignManager = {
site.hostname = urlKey.replace(/^siteContainerMap@@_/, ""); site.hostname = urlKey.replace(/^siteContainerMap@@_/, "");
sites[urlKey] = site; sites[urlKey] = site;
} }
}; }
return sites; return sites;
}, },
}, },

View file

@ -1,4 +1,3 @@
/* jshint esversion: 8*/
const identityState = { const identityState = {
storageArea: { storageArea: {
area: browser.storage.local, area: browser.storage.local,
@ -14,10 +13,15 @@ const identityState = {
if (storageResponse && storeKey in storageResponse) { if (storageResponse && storeKey in storageResponse) {
return storageResponse[storeKey]; return storageResponse[storeKey];
} }
const identities = await browser.contextualIdentities.query({});
const match = identities.find(
(identity) => identity.cookieStoreId === cookieStoreId);
if (match) {
const defaultContainerState = identityState._createIdentityState(); const defaultContainerState = identityState._createIdentityState();
await this.set(cookieStoreId, defaultContainerState); await this.set(cookieStoreId, defaultContainerState);
return defaultContainerState; return defaultContainerState;
}
throw new Error (`${cookieStoreId} not found`);
}, },
set(cookieStoreId, data) { set(cookieStoreId, data) {
@ -97,10 +101,10 @@ const identityState = {
}, },
async lookupMACaddonUUID(cookieStoreId) { async lookupMACaddonUUID(cookieStoreId) {
console.log(cookieStoreId) console.log(cookieStoreId);
const macConfigs = await this.storageArea.area.get(); const macConfigs = await this.storageArea.area.get();
for(const configKey of Object.keys(macConfigs)) { for(const configKey of Object.keys(macConfigs)) {
if (configKey == "identitiesState@@_" + cookieStoreId) { if (configKey === "identitiesState@@_" + cookieStoreId) {
return macConfigs[configKey].macAddonUUID; return macConfigs[configKey].macAddonUUID;
} }
} }

View file

@ -1,5 +1,4 @@
/* jshint esversion: 8*/ const SYNC_DEBUG = true;
SYNC_DEBUG = true;
const sync = { const sync = {
storageArea: { storageArea: {
@ -24,8 +23,7 @@ const sync = {
}, },
async getStoredItem(objectKey) { async getStoredItem(objectKey) {
const outputObject = await this.area.get(objectKey); const outputObject = await this.get(objectKey);
console.log(outputObject)
if (outputObject && outputObject[objectKey]) if (outputObject && outputObject[objectKey])
return outputObject[objectKey]; return outputObject[objectKey];
if (SYNC_DEBUG) if (SYNC_DEBUG)
@ -34,14 +32,14 @@ const sync = {
}, },
async hasSyncStorage(){ async hasSyncStorage(){
const inSync = await this.storageArea.get(); const inSync = await this.get();
return !(Object.entries(inSync).length === 0); return !(Object.entries(inSync).length === 0);
}, },
async backup(options) { async backup(options) {
console.log("backup"); console.log("backup");
// remove listeners to avoid an infinite loop! // remove listeners to avoid an infinite loop!
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
removeContextualIdentityListeners(syncCIListenerList); removeContextualIdentityListeners(syncCIListenerList);
await updateSyncIdentities(); await updateSyncIdentities();
@ -61,7 +59,7 @@ const sync = {
console.log("inLocal:", localStorage); console.log("inLocal:", localStorage);
} }
await browser.storage.onChanged.addListener(syncOnChangedListener); await browser.storage.onChanged.addListener(sync.storageArea.onChangedListener);
await addContextualIdentityListeners(syncCIListenerList); await addContextualIdentityListeners(syncCIListenerList);
async function updateSyncIdentities() { async function updateSyncIdentities() {
@ -76,7 +74,8 @@ const sync = {
} }
async function updateSyncSiteAssignments() { async function updateSyncSiteAssignments() {
const assignedSites = await assignManager.storageArea.getAssignedSites(); const assignedSites =
await assignManager.storageArea.getAssignedSites();
await sync.storageArea.set({ assignedSites }); await sync.storageArea.set({ assignedSites });
} }
@ -92,7 +91,8 @@ const sync = {
} }
async function addToDeletedSitesList(siteStoreKey) { async function addToDeletedSitesList(siteStoreKey) {
let { deletedSiteList } = await sync.storageArea.get("deletedSiteList"); let { deletedSiteList } =
await sync.storageArea.get("deletedSiteList");
if (!deletedSiteList) deletedSiteList = []; if (!deletedSiteList) deletedSiteList = [];
if (deletedSiteList.find(element => element === siteStoreKey)) return; if (deletedSiteList.find(element => element === siteStoreKey)) return;
deletedSiteList.push(siteStoreKey); deletedSiteList.push(siteStoreKey);
@ -100,27 +100,49 @@ const sync = {
} }
async function removeFromDeletedSitesList(siteStoreKey) { async function removeFromDeletedSitesList(siteStoreKey) {
let { deletedSiteList } = await sync.storageArea.get("deletedSiteList"); let { deletedSiteList } =
await sync.storageArea.get("deletedSiteList");
if (!deletedSiteList) return; if (!deletedSiteList) return;
deletedSiteList = deletedSiteList.filter(element => element !== siteStoreKey); deletedSiteList = deletedSiteList
.filter(element => element !== siteStoreKey);
await sync.storageArea.set({ deletedSiteList }); await sync.storageArea.set({ deletedSiteList });
} }
}, },
async cleanup() { async cleanup() {
console.log("cleanupSync") console.log("cleanupSync");
const identitiesList = await sync.storageArea.getStoredObject("identities"); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
const cookieStoreIDmap = await sync.storageArea.getStoredObject("cookieStoreIDmap"); const identitiesList =
await sync.storageArea.getStoredObject("identities");
const cookieStoreIDmap =
await sync.storageArea.getStoredObject("cookieStoreIDmap");
for(const cookieStoreId of Object.keys(cookieStoreIDmap)) { for(const cookieStoreId of Object.keys(cookieStoreIDmap)) {
const match = identitiesList const match = identitiesList
.find(syncIdentity => syncIdentity.cookieStoreId === cookieStoreId); .find(syncIdentity =>
syncIdentity.cookieStoreId === cookieStoreId
);
if (!match) { if (!match) {
delete cookieStoreIDmap[cookieStoreId]; delete cookieStoreIDmap[cookieStoreId];
await sync.storageArea.set({ cookieStoreIDmap }); await sync.storageArea.set({ cookieStoreIDmap });
console.log("removed ", cookieStoreId, " from sync list"); console.log("removed ", cookieStoreId, " from sync list");
} }
} }
await browser.storage.onChanged.addListener(sync.storageArea.onChangedListener);
}, },
onChangedListener(changes, areaName) {
if (areaName === "sync") runSync();
},
async addToDeletedList(changeInfo) {
const identity = changeInfo.contextualIdentity;
console.log("addToDeletedList", identity.cookieStoreId);
const deletedUUID =
await identityState.lookupMACaddonUUID(identity.cookieStoreId);
await identityState.storageArea.remove(identity.cookieStoreId);
console.log(deletedUUID);
sync.storageArea.backup({uuid: deletedUUID});
}
}, },
init() { init() {
@ -183,28 +205,51 @@ async function restoreFirstRun() {
async function reconcileIdentitiesByName(){ async function reconcileIdentitiesByName(){
console.log("reconcileIdentitiesByName"); console.log("reconcileIdentitiesByName");
const localIdentities = await browser.contextualIdentities.query({}); const localIdentities = await browser.contextualIdentities.query({});
const syncIdentities = sync.storageArea.getStoredObject("identities"); const syncIdentities = await sync.storageArea.getStoredObject("identities");
const cookieStoreIDmap = sync.storageArea.getStoredObject("cookieStoreIDmap"); const cookieStoreIDmap =
await sync.storageArea.getStoredObject("cookieStoreIDmap");
for (const syncIdentity of syncIdentities) { for (const syncIdentity of syncIdentities) {
syncIdentity.macAddonUUID = cookieStoreIDmap[syncIdentity.cookieStoreId]; syncIdentity.macAddonUUID = cookieStoreIDmap[syncIdentity.cookieStoreId];
const match = localIdentities.find(localIdentity => localIdentity.name === syncIdentity.name); const match = localIdentities.find(
localIdentity => localIdentity.name === syncIdentity.name
);
if (!match) { if (!match) {
console.log("create new ident: ", syncIdentity.name) console.log("create new ident: ", syncIdentity.name);
newIdentity = await browser.contextualIdentities.create({name: syncIdentity.name, color: syncIdentity.color, icon: syncIdentity.icon}); const newIdentity =
await identityState.updateUUID(newIdentity.cookieStoreId, syncIdentity.macAddonUUID); await browser.contextualIdentities.create({
name: syncIdentity.name,
color: syncIdentity.color,
icon: syncIdentity.icon
});
await identityState.updateUUID(
newIdentity.cookieStoreId,
syncIdentity.macAddonUUID
);
continue; continue;
} }
if (syncIdentity.color === match.color && syncIdentity.icon === match.icon) { if (syncIdentity.color !== match.color
identityState.updateUUID(match.cookieStoreId, syncIdentity.macAddonUUID); || syncIdentity.icon !== match.icon) {
await browser.contextualIdentities.update(
match.cookieStoreId, {
name: syncIdentity.name,
color: syncIdentity.color,
icon: syncIdentity.icon
});
continue; continue;
} }
if (SYNC_DEBUG) { if (SYNC_DEBUG) {
if (match.color !== syncIdentity.color) {console.log(match.name, "Change color: ", syncIdentity.color)} if (match.color !== syncIdentity.color) {
if (match.icon !== syncIdentity.icon) {console.log(match.name, "Change icon: ", syncIdentity.icon)} console.log(match.name, "Change color: ", syncIdentity.color);
}
if (match.icon !== syncIdentity.icon) {
console.log(match.name, "Change icon: ", syncIdentity.icon);
}
} }
// end testing // end testing
await browser.contextualIdentities.update(match.cookieStoreId, {name: syncIdentity.name, color: syncIdentity.color, icon: syncIdentity.icon}); await identityState.updateUUID(
await identityState.updateUUID(match.cookieStoreId, syncIdentity.macAddonUUID); match.cookieStoreId,
cookieStoreIDmap[syncIdentity.cookieStoreId]
);
} }
} }
@ -214,11 +259,14 @@ async function reconcileIdentitiesByName(){
* a different assignment, the user is prompted (not yet implemented). * a different assignment, the user is prompted (not yet implemented).
* If it does not exist, it is created. * If it does not exist, it is created.
*/ */
async function reconcileSiteAssignments(inSync) { async function reconcileSiteAssignments() {
console.log("reconcileSiteAssignments"); console.log("reconcileSiteAssignments");
const assignedSitesLocal = await assignManager.storageArea.getAssignedSites(); const assignedSitesLocal =
const assignedSitesFromSync = await sync.storageArea.getStoredObject("assignedSites"); await assignManager.storageArea.getAssignedSites();
const deletedSiteList = await sync.storageArea.getStoredArray("deletedSiteList"); const assignedSitesFromSync =
await sync.storageArea.getStoredObject("assignedSites");
const deletedSiteList =
await sync.storageArea.getStoredArray("deletedSiteList");
for(const siteStoreKey of deletedSiteList) { for(const siteStoreKey of deletedSiteList) {
if (assignedSitesLocal.hasOwnProperty(siteStoreKey)) { if (assignedSitesLocal.hasOwnProperty(siteStoreKey)) {
assignManager assignManager
@ -230,13 +278,15 @@ async function reconcileSiteAssignments(inSync) {
await sync.storageArea.getStoredObject("cookieStoreIDmap"); await sync.storageArea.getStoredObject("cookieStoreIDmap");
for(const urlKey of Object.keys(assignedSitesFromSync)) { for(const urlKey of Object.keys(assignedSitesFromSync)) {
const assignedSite = assignedSitesFromSync[urlKey] const assignedSite = assignedSitesFromSync[urlKey];
if (assignedSitesLocal.hasOwnProperty(urlKey)) { if (assignedSitesLocal.hasOwnProperty(urlKey)) {
const syncUUID = const syncUUID =
lookupSyncSiteAssigmentIdentityUUID(assignedSite, cookieStoreIDmap); await lookupSyncSiteAssigmentIdentityUUID(
assignedSite, cookieStoreIDmap, urlKey
);
const localIdentityUUID = const localIdentityUUID =
lookupLocalSiteAssignmentIdentityUUID(urlKey); await lookupLocalSiteAssignmentIdentityUUID(urlKey);
if (syncUUID === localIdentityUUID) { if (syncUUID === localIdentityUUID) {
continue; continue;
@ -245,25 +295,32 @@ async function reconcileSiteAssignments(inSync) {
await setAssignmentWithUUID(syncUUID, assignedSite, urlKey); await setAssignmentWithUUID(syncUUID, assignedSite, urlKey);
continue; continue;
} }
console.log("new assignment ", assignedSite, ": ", assignedSite.userContextId) console.log("new assignment ", assignedSite, ": ",
const newUUID = await inSync.cookieStoreIDmap[ assignedSite.userContextId);
const newUUID = cookieStoreIDmap[
"firefox-container-" + assignedSite.userContextId "firefox-container-" + assignedSite.userContextId
]; ];
await setAssignmentWithUUID(newUUID, assignedSite, urlKey); await setAssignmentWithUUID(newUUID, assignedSite, urlKey);
} }
async function lookupLocalSiteAssignmentIdentityUUID(urlKey){ async function lookupLocalSiteAssignmentIdentityUUID(urlKey){
const localAssignedSite = await assignManager.storageArea.getByUrlKey(urlKey); const localAssignedSite =
if (!localAssignedSite.userContextId) await assignManager.storageArea.getByUrlKey(urlKey);
if (!localAssignedSite || !localAssignedSite.userContextId)
throw new Error (urlKey, "userContextId does not exist"); throw new Error (urlKey, "userContextId does not exist");
const localCookieStoreId = "firefox-container-" + const localCookieStoreId = "firefox-container-" +
localAssignedSite.userContextId; localAssignedSite.userContextId;
return await identityState.storageArea.get(localCookieStoreId).macAddonUUID; return await identityState.storageArea
.get(localCookieStoreId).macAddonUUID;
} }
async function lookupSyncSiteAssigmentIdentityUUID(assignedSite, cookieStoreIDmap){ async function lookupSyncSiteAssigmentIdentityUUID(
assignedSite,
cookieStoreIDmap,
urlKey
){
if (!assignedSite.userContextId) if (!assignedSite.userContextId)
throw new Error (urlKey, "userContextId does not exist"); throw new Error (`${urlKey} userContextId does not exist`);
const syncCookieStoreId = "firefox-container-" + assignedSite.userContextId; const syncCookieStoreId = "firefox-container-" + assignedSite.userContextId;
if (!cookieStoreIDmap[syncCookieStoreId]) if (!cookieStoreIDmap[syncCookieStoreId])
throw new Error (syncCookieStoreId, " does not have a uuid"); throw new Error (syncCookieStoreId, " does not have a uuid");
@ -282,77 +339,87 @@ async function setAssignmentWithUUID (newUUID, assignedSite, urlKey) {
); );
return; return;
} }
throw new Error ("No cookieStoreId found for: ", throw new Error (`No cookieStoreId found for: ${newUUID}, ${urlKey}`);
newUUID, assignedSite, urlKey);
} }
async function runSync() { async function runSync() {
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
removeContextualIdentityListeners(syncCIListenerList); removeContextualIdentityListeners(syncCIListenerList);
console.log("runSync"); console.log("runSync");
await identityState.storageArea.cleanup(); await identityState.storageArea.cleanup();
const inSync = await sync.storageArea.get();
await sync.storageArea.cleanup(); await sync.storageArea.cleanup();
if (Object.entries(inSync).length === 0){ if (await sync.storageArea.hasSyncStorage()){
console.log("storage found, attempting to restore ...");
await restore();
return;
}
console.log("no sync storage, backing up..."); console.log("no sync storage, backing up...");
await sync.storageArea.backup(); await sync.storageArea.backup();
return; return;
} }
console.log("storage found, attempting to restore ...");
await restore(inSync);
}
async function restore(inSync) { async function restore() {
console.log("restore"); console.log("restore");
await reconcileIdentitiesByUUID(inSync); await reconcileIdentitiesByUUID();
await reconcileSiteAssignments(inSync); await reconcileSiteAssignments();
await sync.storageArea.backup(); await sync.storageArea.backup();
} }
function syncOnChangedListener(changes, areaName) {
if (areaName == "sync") runSync();
}
/* /*
* Matches uuids in sync to uuids locally, and updates containers accordingly. * Matches uuids in sync to uuids locally, and updates containers accordingly.
* If there is no match, it creates the new container. * If there is no match, it creates the new container.
*/ */
async function reconcileIdentitiesByUUID(inSync) { async function reconcileIdentitiesByUUID() {
console.log("reconcileIdentitiesByUUID"); console.log("reconcileIdentitiesByUUID");
const syncIdentities = inSync.identities; const syncIdentities = await sync.storageArea.getStoredObject("identities");
const syncCookieStoreIDmap = inSync.cookieStoreIDmap; const cookieStoreIDmap =
if (inSync.deletedIdentityList) { await sync.storageArea.getStoredObject("cookieStoreIDmap");
for (const deletedUUID of inSync.deletedIdentityList) { const deletedIdentityList =
await sync.storageArea.getStoredArray("deletedIdentityList");
// first remove any deleted identities
for (const deletedUUID of deletedIdentityList) {
const deletedCookieStoreId = const deletedCookieStoreId =
await identityState.lookupCookieStoreId(deletedUUID); await identityState.lookupCookieStoreId(deletedUUID);
if (deletedCookieStoreId){ if (deletedCookieStoreId){
await browser.contextualIdentities.remove(deletedCookieStoreId); await browser.contextualIdentities.remove(deletedCookieStoreId);
} }
} }
}
for (const syncCookieStoreID of Object.keys(syncCookieStoreIDmap)) { // Lookup all identities in teh cookieStoreIDmap and make sure they
const syncUUID = syncCookieStoreIDmap[syncCookieStoreID]; // exist locally
for (const syncCookieStoreID of Object.keys(cookieStoreIDmap)) {
const syncUUID = cookieStoreIDmap[syncCookieStoreID];
//find localCookiesStoreID by looking up the syncUUID //find localCookiesStoreID by looking up the syncUUID
const localCookieStoreID = await identityState.lookupCookieStoreId(syncUUID); const localCookieStoreID =
await identityState.lookupCookieStoreId(syncUUID);
// get correct indentity info from sync // get correct indentity info from sync
identityInfo = findIdentityFromSync(syncCookieStoreID, syncIdentities); const identityInfo =
findIdentityFromSync(syncCookieStoreID, syncIdentities);
if (localCookieStoreID) { if (localCookieStoreID) {
if (SYNC_DEBUG) { if (SYNC_DEBUG) {
const getIdent = await browser.contextualIdentities.get(localCookieStoreID); const getIdent =
if (getIdent.name !== identityInfo.name) {console.log(getIdent.name, "Change name: ", identityInfo.name)} await browser.contextualIdentities.get(localCookieStoreID);
if (getIdent.color !== identityInfo.color) {console.log(getIdent.name, "Change color: ", identityInfo.color)} if (getIdent.name !== identityInfo.name) {
if (getIdent.icon !== identityInfo.icon) {console.log(getIdent.name, "Change icon: ", identityInfo.icon)} console.log(getIdent.name, "Change name: ", identityInfo.name);
}
if (getIdent.color !== identityInfo.color) {
console.log(getIdent.name, "Change color: ", identityInfo.color);
}
if (getIdent.icon !== identityInfo.icon) {
console.log(getIdent.name, "Change icon: ", identityInfo.icon);
}
} }
// update the local container with the sync data // update the local container with the sync data
await browser.contextualIdentities.update(localCookieStoreID, identityInfo); await browser.contextualIdentities
.update(localCookieStoreID, identityInfo);
continue; continue;
} }
//not found, create new with same UUID //not found, create new with same UUID
console.log("new Identity: ", identityInfo.name) console.log("new Identity: ", identityInfo.name);
const newIdentity = await browser.contextualIdentities.create(identityInfo); const newIdentity =
console.log(newIdentity.cookieStoreId) await browser.contextualIdentities.create(identityInfo);
await identityState.updateUUID(newIdentity.cookieStoreId, syncUUID); await identityState.updateUUID(newIdentity.cookieStoreId, syncUUID);
} }
return; return;
@ -367,7 +434,7 @@ function findIdentityFromSync(cookieStoreId, identitiesList){
const syncCIListenerList = [ const syncCIListenerList = [
sync.storageArea.backup, sync.storageArea.backup,
addToDeletedList, sync.storageArea.addToDeletedList,
sync.storageArea.backup sync.storageArea.backup
]; ];
@ -383,21 +450,16 @@ function removeContextualIdentityListeners(listenerList) {
browser.contextualIdentities.onUpdated.removeListener(listenerList[2]); browser.contextualIdentities.onUpdated.removeListener(listenerList[2]);
} }
async function addToDeletedList(changeInfo) {
const identity = changeInfo.contextualIdentity;
console.log("addToDeletedList", identity.cookieStoreId);
const deletedUUID =
await identityState.lookupMACaddonUUID(identity.cookieStoreId);
await identityState.storageArea.remove(identity.cookieStoreId);
console.log(deletedUUID);
backup({uuid: deletedUUID});
}
if(SYNC_DEBUG) { if(SYNC_DEBUG) {
browser.resetMAC1 = async function () { browser.resetMAC1 = async function () {
// for debugging and testing: remove all containers except the // for debugging and testing: remove all containers except the
// default 4 and the first one created // default 4 and the first one created
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
// sync state on install: no sync data // sync state on install: no sync data
await browser.storage.sync.clear(); await browser.storage.sync.clear();
@ -410,7 +472,7 @@ if(SYNC_DEBUG) {
browser.resetMAC2 = async function () { browser.resetMAC2 = async function () {
// for debugging and testing: remove all containers except the default 4 and the first one created // for debugging and testing: remove all containers except the default 4 and the first one created
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
// sync state after FF1 (default + 1) // sync state after FF1 (default + 1)
await browser.storage.sync.clear(); await browser.storage.sync.clear();
@ -429,7 +491,7 @@ if(SYNC_DEBUG) {
browser.resetMAC3 = async function () { browser.resetMAC3 = async function () {
// for debugging and testing: remove all containers except the default 4 and the first one created // for debugging and testing: remove all containers except the default 4 and the first one created
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
// sync state after FF2 synced // sync state after FF2 synced
await browser.storage.sync.clear(); await browser.storage.sync.clear();
@ -448,7 +510,7 @@ if(SYNC_DEBUG) {
browser.resetMAC4 = async function () { browser.resetMAC4 = async function () {
// for debugging and testing: remove all containers except the default 4 and the first one created // for debugging and testing: remove all containers except the default 4 and the first one created
browser.storage.onChanged.removeListener(syncOnChangedListener); browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
// sync state after FF2 synced // sync state after FF2 synced
await browser.storage.sync.clear(); await browser.storage.sync.clear();