summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/staticNS.js44
-rw-r--r--src/manifest.json2
2 files changed, 19 insertions, 27 deletions
diff --git a/src/content/staticNS.js b/src/content/staticNS.js
index a175220..40e2420 100644
--- a/src/content/staticNS.js
+++ b/src/content/staticNS.js
@@ -3,22 +3,6 @@
let listenersMap = new Map();
let backlog = new Set();
- let stopAndReload = beforeReloading => {
- debug("Should I reload? %o, now: %s", performance.now())
- if (location.href === "about:blank" || performance.now() > 10000 ) {
- debug("Won't reload.");
- return;
- }
- stop();
- setTimeout(() => {
- debug("Reloading...");
- if (typeof beforeReloading === "function") {
- beforeReloading();
- }
- location.reload();
- }, 1000)
- };
-
let ns = {
debug: true, // DEV_ONLY
get embeddingDocument() {
@@ -53,17 +37,25 @@
debug(`Fetching policy from document %s, readyState %s, content %s`,
document.URL, document.readyState, document.documentElement.outerHTML);
let url = document.URL;
- let isFileUrl = url.startsWith("file:");
- if (isFileUrl) {
- addEventListener("beforescriptexecute", e => {
- if (!this.canScript) e.preventDefault();
- }, true);
- }
-
- let policy = browser.runtime.sendSyncMessage(
- {id: "fetchPolicy", url, contextUrl: url});
+ addEventListener("beforescriptexecute", e => {
+ // safety net for syncrhonous load on Firefox
+ if (!this.canScript) e.preventDefault();
+ }, true);
- debug("Fetched %o, readyState %s", policy, document.readyState);
+ let policy = null;
+ for (;;) {
+ try {
+ policy = browser.runtime.sendSyncMessage(
+ {id: "fetchPolicy", url, contextUrl: url});
+ break;
+ } catch (e) {
+ if (e.message !== "Could not esablish connection. Receiving end does not exist.") {
+ break;
+ }
+ error("Background page ready yet, retrying to fetch policy...")
+ }
+ }
+ debug("Fetched %o, readyState %s", policy, document.readyState); // DEV_ONLY
this.setup(policy);
return true;
diff --git a/src/manifest.json b/src/manifest.json
index f3f6675..673a98d 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -92,8 +92,8 @@
"content/DocumentCSP.js",
"content/onScriptDisabled.js",
"content/staticNS.js",
- "content/content.js",
"content/PlaceHolder.js",
+ "content/content.js",
"content/embeddingDocument.js",
"content/webglHook.js",
"content/media.js",