Fixed problem where creating a new container did not correctly associate the proxy entered with it
This commit is contained in:
parent
0a864f0cf3
commit
34bde83067
3 changed files with 41 additions and 8 deletions
|
@ -46,6 +46,11 @@ const backgroundLogic = {
|
|||
window.proxifiedContainers.set(this.cookieStoreId(options.userContextId), options.proxy);
|
||||
} else {
|
||||
donePromise = browser.contextualIdentities.create(options.params);
|
||||
|
||||
//We cannot yet access the new cookieStoreId via this.cookieStoreId(...), so we take this from the resolved promise
|
||||
donePromise.then((identity) => {
|
||||
window.proxifiedContainers.set(identity.cookieStoreId, options.proxy);
|
||||
});
|
||||
}
|
||||
await donePromise;
|
||||
browser.runtime.sendMessage({
|
||||
|
|
|
@ -1069,6 +1069,9 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
iconInput.checked = iconInput.value === identity.icon;
|
||||
});
|
||||
|
||||
//Clear the proxy field before doing the retrieval requests below
|
||||
document.querySelector("#edit-container-panel-proxy").value = "";
|
||||
|
||||
const edit_proxy_dom = function(result) {
|
||||
if(result.type === "http")
|
||||
document.querySelector("#edit-container-panel-proxy").value = result.host.toString() + ":" + result.port.toString();
|
||||
|
@ -1083,18 +1086,18 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
}, (error) => {
|
||||
if(error.error === "uninitialized" || error.error === "doesnotexist") {
|
||||
window.proxifiedContainers.set(identity.cookieStoreId, DEFAULT_PROXY, error.error === "uninitialized").then((result) => {
|
||||
edit_proxy_dom(result.proxy);
|
||||
edit_proxy_dom(result);
|
||||
}, (error) => {
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: occurence 1");
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: error 1");
|
||||
}).catch((error) => {
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: occurence 2");
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: error 2");
|
||||
});
|
||||
}
|
||||
else {
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: occurence 3");
|
||||
window.proxifiedContainers.report_proxy_error(error, "popup.js: error 3");
|
||||
}
|
||||
}).catch((err) => {
|
||||
window.proxifiedContainers.report_proxy_error(err, "popup.js: occurence 4");
|
||||
window.proxifiedContainers.report_proxy_error(err, "popup.js: error 4");
|
||||
});
|
||||
|
||||
return Promise.resolve(null);
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
//Below lets us print errors, huge thanks to Jonothan @ https://stackoverflow.com/questions/18391212/is-it-not-possible-to-stringify-an-error-using-json-stringify
|
||||
if (!('toJSON' in Error.prototype))
|
||||
Object.defineProperty(Error.prototype, 'toJSON', {
|
||||
value: function () {
|
||||
var alt = {};
|
||||
|
||||
Object.getOwnPropertyNames(this).forEach(function (key) {
|
||||
alt[key] = this[key];
|
||||
}, this);
|
||||
|
||||
return alt;
|
||||
},
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
|
||||
|
||||
//This object allows other scripts to access the list mapping containers to their proxies
|
||||
window.proxifiedContainers = {
|
||||
|
||||
|
@ -60,7 +77,7 @@ window.proxifiedContainers = {
|
|||
message: error
|
||||
});
|
||||
}).catch((error) => {
|
||||
window.proxifiedContainers.report_proxy_error(error, "5");
|
||||
window.proxifiedContainers.report_proxy_error(error, "proxified-containers.js: error 1");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -68,15 +85,22 @@ window.proxifiedContainers = {
|
|||
return new Promise((resolve, reject) => {
|
||||
if (initialize === true) {
|
||||
const proxifiedContainersStore = [];
|
||||
proxifiedContainersStore.push({
|
||||
cookieStoreId: cookieStoreId,
|
||||
proxy: proxy
|
||||
});
|
||||
|
||||
browser.storage.local.set({
|
||||
proxifiedContainersKey: proxifiedContainersStore
|
||||
});
|
||||
|
||||
resolve(proxy);
|
||||
}
|
||||
|
||||
//Assumes proxy is a properly formatted object
|
||||
window.proxifiedContainers.retrieve().then((proxifiedContainersStore) => {
|
||||
|
||||
let index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId);
|
||||
|
||||
if (index === -1) {
|
||||
proxifiedContainersStore.push({
|
||||
cookieStoreId: cookieStoreId,
|
||||
|
@ -93,6 +117,7 @@ window.proxifiedContainers = {
|
|||
browser.storage.local.set({
|
||||
proxifiedContainersKey: proxifiedContainersStore
|
||||
});
|
||||
|
||||
resolve(proxifiedContainersStore[index]);
|
||||
}, (errorObj) => {
|
||||
reject(errorObj);
|
||||
|
|
Loading…
Add table
Reference in a new issue