diff --git a/index.js b/index.js index da80968..28fbb22 100644 --- a/index.js +++ b/index.js @@ -103,6 +103,8 @@ const ContainerService = { sendReply(this[message.method](message)); } }); + }).catch(() => { + throw new Error("WebExtension startup failed. Unable to continue."); }); }, @@ -194,8 +196,7 @@ const ContainerService = { showTabs(args) { if (!("userContextId" in args)) { - Promise.reject("showTabs must be called with userContextId argument."); - return; + return Promise.reject("showTabs must be called with userContextId argument."); } const promises = []; @@ -279,6 +280,8 @@ const ContainerService = { Promise.all(promises).then(() => { resolve(list); + }).catch((e) => { + reject(e); }); }); }, @@ -386,8 +389,7 @@ const ContainerService = { getIdentity(args) { if (!("userContextId" in args)) { - Promise.reject("getIdentity must be called with userContextId argument."); - return; + return Promise.reject("getIdentity must be called with userContextId argument."); } const identity = ContextualIdentityService.getIdentityFromId(args.userContextId); @@ -397,8 +399,7 @@ const ContainerService = { createIdentity(args) { for (let arg of [ "name", "color", "icon"]) { // eslint-disable-line prefer-const if (!(arg in args)) { - Promise.reject("createIdentity must be called with " + arg + " argument."); - return; + return Promise.reject("createIdentity must be called with " + arg + " argument."); } } @@ -415,8 +416,7 @@ const ContainerService = { updateIdentity(args) { if (!("userContextId" in args)) { - Promise.reject("updateIdentity must be called with userContextId argument."); - return; + return Promise.reject("updateIdentity must be called with userContextId argument."); } const identity = ContextualIdentityService.getIdentityFromId(args.userContextId); @@ -436,8 +436,7 @@ const ContainerService = { removeIdentity(args) { if (!("userContextId" in args)) { - Promise.reject("removeIdentity must be called with userContextId argument."); - return; + return Promise.reject("removeIdentity must be called with userContextId argument."); } return Promise.resolve(ContextualIdentityService.remove(args.userContextId)); }, diff --git a/package.json b/package.json index c8dcdf6..89bfcc3 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "title": "Containers Experiment", "description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.", "version": "0.0.1", - "author": "Luke Crouch & Jonathan Kingston", + "author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston", "bugs": { "url": "https://github.com/mozilla/testpilot-containers/issues" }, diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 1241cc4..b2ef64e 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -44,6 +44,10 @@ const Logic = { } else { this.showPanel(P_ONBOARDING_1); } + }) + + .catch(() => { + throw new Error("Failed to retrieve the identities. We cannot continue."); }); }, @@ -73,6 +77,9 @@ const Logic = { panelElement.classList.add("hide"); } document.querySelector(this._panels[panel].panelSelector).classList.remove("hide"); + }) + .catch(() => { + throw new Error("Failed to show panel " + panel); }); }, @@ -186,6 +193,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, { method: "sortTabs" }).then(() => { window.close(); + }).catch(() => { + window.close(); }); }); }, @@ -221,6 +230,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, { }); }).then(() => { window.close(); + }).catch(() => { + window.close(); }); } else if (e.target.matches(".info")) { Logic.showPanel(P_CONTAINER_INFO, identity); @@ -256,6 +267,8 @@ Logic.registerPanel(P_CONTAINER_INFO, { userContextId: identity.userContextId }).then(() => { window.close(); + }).catch(() => { + window.close(); }); }); @@ -318,6 +331,8 @@ Logic.registerPanel(P_CONTAINER_INFO, { tabId: tab.id, }).then(() => { window.close(); + }).catch(() => { + window.close(); }); }); } @@ -418,6 +433,8 @@ Logic.registerPanel(P_CONTAINER_EDIT, { return Logic.refreshIdentities(); }).then(() => { Logic.showPreviousPanel(); + }).catch(() => { + Logic.showPanel(P_CONTAINERS_LIST); }); }); }, @@ -453,6 +470,8 @@ Logic.registerPanel(P_CONTAINER_DELETE, { return Logic.refreshIdentities(); }).then(() => { Logic.showPreviousPanel(); + }).catch(() => { + Logic.showPanel(P_CONTAINERS_LIST); }); }); },