Temporary settings survival more resilient and compatible with Fenix.
This commit is contained in:
parent
fa81d3791a
commit
7785661d97
|
@ -75,26 +75,43 @@ var LifeCycle = (() => {
|
||||||
unrestrictedTabs: [...ns.unrestrictedTabs]
|
unrestrictedTabs: [...ns.unrestrictedTabs]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
try {
|
||||||
let l = async (tabId, changeInfo) => {
|
await new Promise((resolve, reject) => {
|
||||||
debug("Survival tab updating", changeInfo);
|
let done = false;
|
||||||
if (changeInfo.status !== "complete") return;
|
let l = async (tabId, changeInfo) => {
|
||||||
try {
|
if (done || tabId !== tab.id) return;
|
||||||
await Messages.send("store", {url, data: toBase64(new Uint8Array(cypherText))}, {tabId, frameId: 0});
|
debug("Survival tab updating", changeInfo);
|
||||||
resolve();
|
if (changeInfo.status !== "complete") return;
|
||||||
debug("Survival tab updated");
|
try {
|
||||||
browser.tabs.onUpdated.removeListener(l);
|
await Messages.send("store", {url, data: toBase64(new Uint8Array(cypherText))}, {tabId, frameId: 0});
|
||||||
} catch (e) {
|
done = true;
|
||||||
if (!Messages.isMissingEndpoint(e)) {
|
resolve();
|
||||||
error(e, "Survival tab failed");
|
debug("Survival tab updated");
|
||||||
reject(e);
|
} catch (e) {
|
||||||
} // otherwise we keep waiting for further updates from the tab until content script is ready to answer
|
if (!Messages.isMissingEndpoint(e)) {
|
||||||
|
error(e, "Survival tab failed");
|
||||||
|
reject(e);
|
||||||
|
} // otherwise we keep waiting for further updates from the tab until content script is ready to answer
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
browser.tabs.onUpdated.addListener(l);
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await Storage.set("local", { "updateInfo": {key, iv: toBase64(iv), tabId}});
|
||||||
|
tabId = -1;
|
||||||
|
debug("Ready to reload...", await Storage.get("local", "updateInfo"));
|
||||||
|
} finally {
|
||||||
|
if (tabId !== -1 && !ns.local.debug) {
|
||||||
|
browser.tabs.remove(tabId); // cleanup on failure unless we want to debug a post-mortem
|
||||||
}
|
}
|
||||||
browser.tabs.onUpdated.addListener(l, {tabId});
|
}
|
||||||
});
|
|
||||||
await Storage.set("local", { "updateInfo": {key, iv: toBase64(iv), tabId}});
|
|
||||||
debug("Ready to reload...", await Storage.get("local", "updateInfo"));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async retrieveAndDestroy() {
|
async retrieveAndDestroy() {
|
||||||
|
|
Loading…
Reference in New Issue