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": {},
"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",

View file

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

View file

@ -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;
},

View file

@ -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) {

View file

@ -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) {

View file

@ -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 =

View file

@ -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) {

View file

@ -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": {

View file

@ -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);
});
});

View file

@ -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 = {};