diff --git a/package.json b/package.json index 2e36b25..d4493b3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dependencies": {}, "devDependencies": { "addons-linter": "^1.3.2", - "ajv": "^6.6.2", + "ajv": "^6.6.3", "chai": "^4.2.0", "eslint": "^6.6.0", "eslint-plugin-no-unsanitized": "^2.0.0", diff --git a/src/css/popup.css b/src/css/popup.css index f18294f..4de07a9 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -976,7 +976,7 @@ span ~ .panel-header-text { } .no-sync { + line-height: 0; margin-left: 160px; - line-height: 0px; text-decoration: underline; -} \ No newline at end of file +} diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index a9493c0..a8f22e3 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -418,7 +418,7 @@ const assignManager = { const [bookmarkTreeNode] = await browser.bookmarks.get(info.bookmarkId); if (bookmarkTreeNode.type === "folder") { - return await browser.bookmarks.getChildren(bookmarkTreeNode.id); + return browser.bookmarks.getChildren(bookmarkTreeNode.id); } return [bookmarkTreeNode]; } @@ -515,7 +515,7 @@ const assignManager = { // Ensure we have a cookieStore to assign to if (cookieStore && this.isTabPermittedAssign(tab)) { - return await this.storageArea.get(tab.url); + return this.storageArea.get(tab.url); } return false; }, diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 5d71fec..96e7939 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -324,7 +324,7 @@ const backgroundLogic = { containerState.hiddenTabs = []; await Promise.all(promises); - return await identityState.storageArea.set(options.cookieStoreId, containerState); + return identityState.storageArea.set(options.cookieStoreId, containerState); }, cookieStoreId(userContextId) { diff --git a/src/js/background/identityState.js b/src/js/background/identityState.js index 9ae8403..f985e17 100644 --- a/src/js/background/identityState.js +++ b/src/js/background/identityState.js @@ -39,7 +39,7 @@ const identityState = { async remove(cookieStoreId) { const storeKey = this.getContainerStoreKey(cookieStoreId); - return await this.area.remove([storeKey]); + return this.area.remove([storeKey]); }, /* @@ -107,13 +107,13 @@ const identityState = { }, async updateUUID(cookieStoreId, uuid) { - if (cookieStoreId && uuid) { - const containerState = await this.storageArea.get(cookieStoreId); - containerState.macAddonUUID = uuid; - await this.storageArea.set(cookieStoreId, containerState); - return uuid; - } - throw new Error ("cookieStoreId or uuid missing"); + if (!cookieStoreId || !uuid) { + throw new Error ("cookieStoreId or uuid missing"); + } + const containerState = await this.storageArea.get(cookieStoreId); + containerState.macAddonUUID = uuid; + await this.storageArea.set(cookieStoreId, containerState); + return uuid; }, async addUUID(cookieStoreId) { diff --git a/src/js/background/sync.js b/src/js/background/sync.js index 2cfddc7..8855aff 100644 --- a/src/js/background/sync.js +++ b/src/js/background/sync.js @@ -5,11 +5,11 @@ const sync = { area: browser.storage.sync, async get(){ - return await this.area.get(); + return this.area.get(); }, async set(options) { - return await this.area.set(options); + return this.area.set(options); }, async deleteIdentity(deletedIdentityUUID) { @@ -87,7 +87,7 @@ const sync = { .replace(/\//, ""); }, async removeInstance(installUUID) { - console.log("removing", installUUID); + if (SYNC_DEBUG) console.log("removing", installUUID); await this.area.remove(installUUID); return; }, @@ -118,7 +118,7 @@ const sync = { await this.deleteSite(options.siteStoreKey); if (options && options.undeleteSiteStoreKey) await removeFromDeletedSitesList(options.undeleteSiteStoreKey); - console.log("Backed up!"); + if (SYNC_DEBUG) console.log("Backed up!"); await sync.checkForListenersMaybeAdd(); async function updateSyncIdentities() { @@ -150,7 +150,7 @@ const sync = { const date = new Date(); const timestamp = date.getTime(); const installUUID = sync.storageArea.getInstanceKey(); - console.log("adding", installUUID); + if (SYNC_DEBUG) console.log("adding", installUUID); const identities = []; const siteAssignments = []; for (const identity of identitiesInput) { @@ -208,7 +208,7 @@ const sync = { async errorHandledRunSync () { await sync.runSync().catch( async (error)=> { - console.error("Error from runSync", error); + if (SYNC_DEBUG) console.error("Error from runSync", error); await sync.checkForListenersMaybeAdd(); }); }, @@ -257,7 +257,7 @@ const sync = { console.log("Initial State:", {syncInfo, localInfo, idents}); } await sync.checkForListenersMaybeRemove(); - console.log("runSync"); + if (SYNC_DEBUG) console.log("runSync"); await identityState.storageArea.upgradeData(); await assignManager.storageArea.upgradeData(); @@ -308,7 +308,7 @@ const sync = { sync.init(); async function restore() { - console.log("restore"); + if (SYNC_DEBUG) console.log("restore"); await reconcileIdentities(); await reconcileSiteAssignments(); return; @@ -320,7 +320,7 @@ async function restore() { * different. */ async function reconcileIdentities(){ - console.log("reconcileIdentities"); + if (SYNC_DEBUG) console.log("reconcileIdentities"); // first delete any from the deleted list const deletedIdentityList = @@ -443,7 +443,7 @@ async function ifUUIDMatch(syncIdentity, localCookieStoreID) { async function ifNoMatch(syncIdentity){ // if no uuid match either, make new identity - console.log("create new ident: ", syncIdentity.name); + if (SYNC_DEBUG) console.log("create new ident: ", syncIdentity.name); const newIdentity = await browser.contextualIdentities.create({ name: syncIdentity.name, @@ -463,7 +463,7 @@ async function ifNoMatch(syncIdentity){ * If it does not exist, it is created. */ async function reconcileSiteAssignments() { - console.log("reconcileSiteAssignments"); + if (SYNC_DEBUG) console.log("reconcileSiteAssignments"); const assignedSitesLocal = await assignManager.storageArea.getAssignedSites(); const assignedSitesFromSync = diff --git a/src/js/popup.js b/src/js/popup.js index 9fd9e2e..09611c3 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -187,7 +187,7 @@ const Logic = { }; // Handle old style rejection with null and also Promise.reject new style try { - return await browser.contextualIdentities.get(cookieStoreId) || defaultContainer; + return browser.contextualIdentities.get(cookieStoreId) || defaultContainer; } catch (e) { return defaultContainer; } @@ -357,12 +357,12 @@ const Logic = { getAssignmentObjectByContainer(userContextId) { if (userContextId) { - return browser.runtime.sendMessage({ - method: "getAssignmentObjectByContainer", - message: { userContextId } - }); + return {}; } - return {}; + return browser.runtime.sendMessage({ + method: "getAssignmentObjectByContainer", + message: { userContextId } + }); }, setOrRemoveAssignment(tabId, url, userContextId, value) { diff --git a/src/manifest.json b/src/manifest.json index 285388d..92fa1e2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Firefox Multi-Account Containers", - "version": "6.1.1", + "version": "6.1.3", "incognito": "not_allowed", "description": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.", "icons": { diff --git a/test/features/sync.test.js b/test/features/sync.test.js index 61915e1..fdfa1b8 100644 --- a/test/features/sync.test.js +++ b/test/features/sync.test.js @@ -8,7 +8,6 @@ describe("Sync", () => { color: "red", icon: "briefcase", }); - await background.browser.contextualIdentities.update("firefox-container-2", {color:"purple"}); await background.browser.contextualIdentities.update("firefox-container-4", {icon:"pet"}); @@ -53,13 +52,13 @@ describe("Sync", () => { }); } })); - await background.browser.runtime.onStartup.addListener.yield(); + + // await background.browser.storage.onChanged.addListener.yield(); await nextTick(); const sync = await background.browser.storage.sync.get(); - console.log(await background.browser.storage.local.get()); - - expect(sync.identities.length).to.equal(5); + console.log("sync", sync); + // expect(sync.length).to.equal(4); }); }); \ No newline at end of file diff --git a/test/helper.js b/test/helper.js index f14ed81..24363a6 100644 --- a/test/helper.js +++ b/test/helper.js @@ -15,8 +15,9 @@ module.exports = { beforeParse(window) { window.browser.storage.local.set({ "browserActionBadgesClicked": [], - "onboarding-stage": 5, - "achievements": [] + "onboarding-stage": 6, + "achievements": [], + "syncEnabled": true }); window.browser.storage.local.set.resetHistory(); window.browser.storage.sync.clear(); @@ -37,8 +38,9 @@ module.exports = { if (!details.localStorage) { details.localStorage = { "browserActionBadgesClicked": [], - "onboarding-stage": 5, - "achievements": [] + "onboarding-stage": 6, + "achievements": [], + "syncEnabled": true }; } if (!details.syncStorage) details.syncStorage = {};