summaryrefslogtreecommitdiff
path: root/src/bg/popupHandler.js
diff options
context:
space:
mode:
authorhackademix2019-03-28 12:35:52 +0100
committerhackademix2019-03-28 13:04:36 +0100
commit661a2a436bfac1bb1d4f3b235d1bf26b00135d00 (patch)
tree0a6f794d25a9120a1649a6ae56795fe90700bfeb /src/bg/popupHandler.js
parentc806c6bbff7e551fd24cf7c456c812b7c54007b5 (diff)
downloadnoscript-661a2a436bfac1bb1d4f3b235d1bf26b00135d00.tar.gz
noscript-661a2a436bfac1bb1d4f3b235d1bf26b00135d00.tar.xz
noscript-661a2a436bfac1bb1d4f3b235d1bf26b00135d00.zip
Chromium-compatible popup closure handling.
Diffstat (limited to 'src/bg/popupHandler.js')
-rw-r--r--src/bg/popupHandler.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bg/popupHandler.js b/src/bg/popupHandler.js
new file mode 100644
index 0000000..b893174
--- /dev/null
+++ b/src/bg/popupHandler.js
@@ -0,0 +1,17 @@
+browser.runtime.onConnect.addListener(port => {
+ if (port.name === "noscript.popup") {
+ let pendingReload = false;
+ let tabId = -1;
+ port.onMessage.addListener(m => {
+ if ("pendingReload" in m) {
+ tabId = m.tabId;
+ pendingReload = m.pendingReload;
+ }
+ });
+ port.onDisconnect.addListener(() => {
+ if (pendingReload) {
+ browser.tabs.reload(tabId);
+ }
+ });
+ }
+});