From 4302246ac01d7dc56650ffa227ad87fe98ccfc03 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 22 Jul 2018 19:14:54 +0200 Subject: More reliable handling of edge startup cases. --- src/bg/main.js | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) (limited to 'src/bg/main.js') diff --git a/src/bg/main.js b/src/bg/main.js index d89ef63..47ee89e 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -194,38 +194,27 @@ return this.policy.enforced && (tabId === -1 || !this.unrestrictedTabs.has(tabId)); }, - async start() { + start() { if (this.running) return; this.running = true; - let initializing = init(); - let wr = browser.webRequest; - let waitForPolicy = async r => { - try { - await initializing; - } catch (e) { - error(e); - } - } - wr.onBeforeRequest.addListener(waitForPolicy, { - urls: [""] - }, ["blocking"]); - await initializing; - wr.onBeforeRequest.removeListener(waitForPolicy); + deferWebTraffic(init(), + async () => { - await include("/bg/Settings.js"); - MessageHandler.listen(); + await include("/bg/Settings.js"); + MessageHandler.listen(); - log("STARTED"); + log("STARTED"); - this.devMode = (await browser.management.getSelf()).installType === "development"; - if (this.local.debug) { - if (this.devMode) { - include("/test/run.js"); - } - } else { - debug = () => {}; // suppress verbosity - } + this.devMode = (await browser.management.getSelf()).installType === "development"; + if (this.local.debug) { + if (this.devMode) { + include("/test/run.js"); + } + } else { + debug = () => {}; // suppress verbosity + } + }); }, stop() { -- cgit v1.2.3