diff options
author | hackademix | 2019-11-03 13:29:34 +0100 |
---|---|---|
committer | hackademix | 2019-11-03 13:29:34 +0100 |
commit | 049485e495e0d1ce0d54694d92500ecdeadb1ef0 (patch) | |
tree | bf5941f2e17a129f417a4c3f8b29b5ba26947e46 /src | |
parent | 0ac6b4de85ac145f95b7f328e43ffaa2f466359f (diff) | |
download | noscript-049485e495e0d1ce0d54694d92500ecdeadb1ef0.tar.gz noscript-049485e495e0d1ce0d54694d92500ecdeadb1ef0.tar.xz noscript-049485e495e0d1ce0d54694d92500ecdeadb1ef0.zip |
Remove loop around XHR.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/SyncMessage.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index 217cb24..5880cdb 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -188,15 +188,13 @@ // on Firefox we first need to send an async message telling the // background script about the tab ID, which does not get sent // with "privileged" XHR - let result, done = false; + let result; browser.runtime.sendMessage( {__syncMessage__: {id: msgId, payload: msg}} ).then(r => { - done = true; result = r; if (callback) callback(r); }).catch(e => { - done = true; throw e; }); @@ -209,14 +207,12 @@ let suspend = () => { if (suspended) return; suspended = true; - while(!done) { - try { - let r = new XMLHttpRequest(); - r.open("GET", suspendURL, false); - r.send(null); - } catch (e) { - console.error(e); - } + try { + let r = new XMLHttpRequest(); + r.open("GET", suspendURL, false); + r.send(null); + } catch (e) { + console.error(e); } suspended = false; }; |