made some suggested changes

This commit is contained in:
Kendall Werts 2020-01-23 10:08:12 -06:00
parent bbcf2b0863
commit 7700873582
10 changed files with 42 additions and 41 deletions

View file

@ -10,7 +10,7 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"addons-linter": "^1.3.2", "addons-linter": "^1.3.2",
"ajv": "^6.6.2", "ajv": "^6.6.3",
"chai": "^4.2.0", "chai": "^4.2.0",
"eslint": "^6.6.0", "eslint": "^6.6.0",
"eslint-plugin-no-unsanitized": "^2.0.0", "eslint-plugin-no-unsanitized": "^2.0.0",

View file

@ -976,7 +976,7 @@ span ~ .panel-header-text {
} }
.no-sync { .no-sync {
line-height: 0;
margin-left: 160px; margin-left: 160px;
line-height: 0px;
text-decoration: underline; text-decoration: underline;
} }

View file

@ -418,7 +418,7 @@ const assignManager = {
const [bookmarkTreeNode] = const [bookmarkTreeNode] =
await browser.bookmarks.get(info.bookmarkId); await browser.bookmarks.get(info.bookmarkId);
if (bookmarkTreeNode.type === "folder") { if (bookmarkTreeNode.type === "folder") {
return await browser.bookmarks.getChildren(bookmarkTreeNode.id); return browser.bookmarks.getChildren(bookmarkTreeNode.id);
} }
return [bookmarkTreeNode]; return [bookmarkTreeNode];
} }
@ -515,7 +515,7 @@ const assignManager = {
// Ensure we have a cookieStore to assign to // Ensure we have a cookieStore to assign to
if (cookieStore if (cookieStore
&& this.isTabPermittedAssign(tab)) { && this.isTabPermittedAssign(tab)) {
return await this.storageArea.get(tab.url); return this.storageArea.get(tab.url);
} }
return false; return false;
}, },

View file

@ -324,7 +324,7 @@ const backgroundLogic = {
containerState.hiddenTabs = []; containerState.hiddenTabs = [];
await Promise.all(promises); await Promise.all(promises);
return await identityState.storageArea.set(options.cookieStoreId, containerState); return identityState.storageArea.set(options.cookieStoreId, containerState);
}, },
cookieStoreId(userContextId) { cookieStoreId(userContextId) {

View file

@ -39,7 +39,7 @@ const identityState = {
async remove(cookieStoreId) { async remove(cookieStoreId) {
const storeKey = this.getContainerStoreKey(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) { async updateUUID(cookieStoreId, uuid) {
if (cookieStoreId && uuid) { if (!cookieStoreId || !uuid) {
const containerState = await this.storageArea.get(cookieStoreId); throw new Error ("cookieStoreId or uuid missing");
containerState.macAddonUUID = uuid; }
await this.storageArea.set(cookieStoreId, containerState); const containerState = await this.storageArea.get(cookieStoreId);
return uuid; containerState.macAddonUUID = uuid;
} await this.storageArea.set(cookieStoreId, containerState);
throw new Error ("cookieStoreId or uuid missing"); return uuid;
}, },
async addUUID(cookieStoreId) { async addUUID(cookieStoreId) {

View file

@ -5,11 +5,11 @@ const sync = {
area: browser.storage.sync, area: browser.storage.sync,
async get(){ async get(){
return await this.area.get(); return this.area.get();
}, },
async set(options) { async set(options) {
return await this.area.set(options); return this.area.set(options);
}, },
async deleteIdentity(deletedIdentityUUID) { async deleteIdentity(deletedIdentityUUID) {
@ -87,7 +87,7 @@ const sync = {
.replace(/\//, ""); .replace(/\//, "");
}, },
async removeInstance(installUUID) { async removeInstance(installUUID) {
console.log("removing", installUUID); if (SYNC_DEBUG) console.log("removing", installUUID);
await this.area.remove(installUUID); await this.area.remove(installUUID);
return; return;
}, },
@ -118,7 +118,7 @@ const sync = {
await this.deleteSite(options.siteStoreKey); await this.deleteSite(options.siteStoreKey);
if (options && options.undeleteSiteStoreKey) if (options && options.undeleteSiteStoreKey)
await removeFromDeletedSitesList(options.undeleteSiteStoreKey); await removeFromDeletedSitesList(options.undeleteSiteStoreKey);
console.log("Backed up!"); if (SYNC_DEBUG) console.log("Backed up!");
await sync.checkForListenersMaybeAdd(); await sync.checkForListenersMaybeAdd();
async function updateSyncIdentities() { async function updateSyncIdentities() {
@ -150,7 +150,7 @@ const sync = {
const date = new Date(); const date = new Date();
const timestamp = date.getTime(); const timestamp = date.getTime();
const installUUID = sync.storageArea.getInstanceKey(); const installUUID = sync.storageArea.getInstanceKey();
console.log("adding", installUUID); if (SYNC_DEBUG) console.log("adding", installUUID);
const identities = []; const identities = [];
const siteAssignments = []; const siteAssignments = [];
for (const identity of identitiesInput) { for (const identity of identitiesInput) {
@ -208,7 +208,7 @@ const sync = {
async errorHandledRunSync () { async errorHandledRunSync () {
await sync.runSync().catch( async (error)=> { await sync.runSync().catch( async (error)=> {
console.error("Error from runSync", error); if (SYNC_DEBUG) console.error("Error from runSync", error);
await sync.checkForListenersMaybeAdd(); await sync.checkForListenersMaybeAdd();
}); });
}, },
@ -257,7 +257,7 @@ const sync = {
console.log("Initial State:", {syncInfo, localInfo, idents}); console.log("Initial State:", {syncInfo, localInfo, idents});
} }
await sync.checkForListenersMaybeRemove(); await sync.checkForListenersMaybeRemove();
console.log("runSync"); if (SYNC_DEBUG) console.log("runSync");
await identityState.storageArea.upgradeData(); await identityState.storageArea.upgradeData();
await assignManager.storageArea.upgradeData(); await assignManager.storageArea.upgradeData();
@ -308,7 +308,7 @@ const sync = {
sync.init(); sync.init();
async function restore() { async function restore() {
console.log("restore"); if (SYNC_DEBUG) console.log("restore");
await reconcileIdentities(); await reconcileIdentities();
await reconcileSiteAssignments(); await reconcileSiteAssignments();
return; return;
@ -320,7 +320,7 @@ async function restore() {
* different. * different.
*/ */
async function reconcileIdentities(){ async function reconcileIdentities(){
console.log("reconcileIdentities"); if (SYNC_DEBUG) console.log("reconcileIdentities");
// first delete any from the deleted list // first delete any from the deleted list
const deletedIdentityList = const deletedIdentityList =
@ -443,7 +443,7 @@ async function ifUUIDMatch(syncIdentity, localCookieStoreID) {
async function ifNoMatch(syncIdentity){ async function ifNoMatch(syncIdentity){
// if no uuid match either, make new identity // 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 = const newIdentity =
await browser.contextualIdentities.create({ await browser.contextualIdentities.create({
name: syncIdentity.name, name: syncIdentity.name,
@ -463,7 +463,7 @@ async function ifNoMatch(syncIdentity){
* If it does not exist, it is created. * If it does not exist, it is created.
*/ */
async function reconcileSiteAssignments() { async function reconcileSiteAssignments() {
console.log("reconcileSiteAssignments"); if (SYNC_DEBUG) console.log("reconcileSiteAssignments");
const assignedSitesLocal = const assignedSitesLocal =
await assignManager.storageArea.getAssignedSites(); await assignManager.storageArea.getAssignedSites();
const assignedSitesFromSync = const assignedSitesFromSync =

View file

@ -187,7 +187,7 @@ const Logic = {
}; };
// Handle old style rejection with null and also Promise.reject new style // Handle old style rejection with null and also Promise.reject new style
try { try {
return await browser.contextualIdentities.get(cookieStoreId) || defaultContainer; return browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
} catch (e) { } catch (e) {
return defaultContainer; return defaultContainer;
} }
@ -357,12 +357,12 @@ const Logic = {
getAssignmentObjectByContainer(userContextId) { getAssignmentObjectByContainer(userContextId) {
if (userContextId) { if (userContextId) {
return browser.runtime.sendMessage({ return {};
method: "getAssignmentObjectByContainer",
message: { userContextId }
});
} }
return {}; return browser.runtime.sendMessage({
method: "getAssignmentObjectByContainer",
message: { userContextId }
});
}, },
setOrRemoveAssignment(tabId, url, userContextId, value) { setOrRemoveAssignment(tabId, url, userContextId, value) {

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Firefox Multi-Account Containers", "name": "Firefox Multi-Account Containers",
"version": "6.1.1", "version": "6.1.3",
"incognito": "not_allowed", "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.", "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": { "icons": {

View file

@ -8,7 +8,6 @@ describe("Sync", () => {
color: "red", color: "red",
icon: "briefcase", icon: "briefcase",
}); });
await background.browser.contextualIdentities.update("firefox-container-2", {color:"purple"}); await background.browser.contextualIdentities.update("firefox-container-2", {color:"purple"});
await background.browser.contextualIdentities.update("firefox-container-4", {icon:"pet"}); 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(); await nextTick();
const sync = await background.browser.storage.sync.get(); const sync = await background.browser.storage.sync.get();
console.log(await background.browser.storage.local.get()); console.log("sync", sync);
// expect(sync.length).to.equal(4);
expect(sync.identities.length).to.equal(5);
}); });
}); });

View file

@ -15,8 +15,9 @@ module.exports = {
beforeParse(window) { beforeParse(window) {
window.browser.storage.local.set({ window.browser.storage.local.set({
"browserActionBadgesClicked": [], "browserActionBadgesClicked": [],
"onboarding-stage": 5, "onboarding-stage": 6,
"achievements": [] "achievements": [],
"syncEnabled": true
}); });
window.browser.storage.local.set.resetHistory(); window.browser.storage.local.set.resetHistory();
window.browser.storage.sync.clear(); window.browser.storage.sync.clear();
@ -37,8 +38,9 @@ module.exports = {
if (!details.localStorage) { if (!details.localStorage) {
details.localStorage = { details.localStorage = {
"browserActionBadgesClicked": [], "browserActionBadgesClicked": [],
"onboarding-stage": 5, "onboarding-stage": 6,
"achievements": [] "achievements": [],
"syncEnabled": true
}; };
} }
if (!details.syncStorage) details.syncStorage = {}; if (!details.syncStorage) details.syncStorage = {};