summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhackademix2019-10-23 17:20:10 +0200
committerhackademix2019-10-25 23:19:48 +0100
commit810c607e6b4b050147c49a3affe2d28ac4f8fa0f (patch)
tree018367679d7fd20d1ccf4c2709e4838aada187ea /src
parent51e115d3bcd2ad683f264e7d9c97347e0afac14e (diff)
downloadnoscript-810c607e6b4b050147c49a3affe2d28ac4f8fa0f.tar.gz
noscript-810c607e6b4b050147c49a3affe2d28ac4f8fa0f.tar.xz
noscript-810c607e6b4b050147c49a3affe2d28ac4f8fa0f.zip
Consolidated missing endpoint error detection in Messages.
Diffstat (limited to 'src')
-rw-r--r--src/content/content.js2
-rw-r--r--src/content/staticNS.js2
-rw-r--r--src/lib/Messages.js4
3 files changed, 6 insertions, 2 deletions
diff --git a/src/content/content.js b/src/content/content.js
index eabf7c3..74e1d95 100644
--- a/src/content/content.js
+++ b/src/content/content.js
@@ -62,7 +62,7 @@ var notifyPage = async () => {
return true;
} catch (e) {
debug(e);
- if (/Receiving end does not exist/.test(e.message)) {
+ if (Messages.isMissingEndpoint(e)) {
window.setTimeout(notifyPage, 2000);
}
}
diff --git a/src/content/staticNS.js b/src/content/staticNS.js
index 40e2420..828663f 100644
--- a/src/content/staticNS.js
+++ b/src/content/staticNS.js
@@ -49,7 +49,7 @@
{id: "fetchPolicy", url, contextUrl: url});
break;
} catch (e) {
- if (e.message !== "Could not esablish connection. Receiving end does not exist.") {
+ if (!Messages.isMissingEndpoint(e)) {
break;
}
error("Background page ready yet, retrying to fetch policy...")
diff --git a/src/lib/Messages.js b/src/lib/Messages.js
index 0a47c42..f33b621 100644
--- a/src/lib/Messages.js
+++ b/src/lib/Messages.js
@@ -65,6 +65,10 @@
return await browser.tabs.sendMessage(recipientInfo.tabId, args, opts);
}
return await browser.runtime.sendMessage(args);
+ },
+ isMissingEndpoint(error) {
+ return error && error.message ===
+ "Could not esablish connection. Receiving end does not exist.";
}
}
}