Remove loop around XHR.

This commit is contained in:
hackademix 2019-11-03 13:29:34 +01:00
parent 0ac6b4de85
commit 049485e495
1 changed files with 7 additions and 11 deletions

View File

@ -188,15 +188,13 @@
// on Firefox we first need to send an async message telling the // on Firefox we first need to send an async message telling the
// background script about the tab ID, which does not get sent // background script about the tab ID, which does not get sent
// with "privileged" XHR // with "privileged" XHR
let result, done = false; let result;
browser.runtime.sendMessage( browser.runtime.sendMessage(
{__syncMessage__: {id: msgId, payload: msg}} {__syncMessage__: {id: msgId, payload: msg}}
).then(r => { ).then(r => {
done = true;
result = r; result = r;
if (callback) callback(r); if (callback) callback(r);
}).catch(e => { }).catch(e => {
done = true;
throw e; throw e;
}); });
@ -209,7 +207,6 @@
let suspend = () => { let suspend = () => {
if (suspended) return; if (suspended) return;
suspended = true; suspended = true;
while(!done) {
try { try {
let r = new XMLHttpRequest(); let r = new XMLHttpRequest();
r.open("GET", suspendURL, false); r.open("GET", suspendURL, false);
@ -217,7 +214,6 @@
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
}
suspended = false; suspended = false;
}; };
let domSuspender = new MutationObserver(records => { let domSuspender = new MutationObserver(records => {