From 6016a170f0266cf926b7ff305796ba83cc353536 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Fri, 14 Sep 2018 13:05:08 +0000 Subject: [PATCH] Bug 27760: Fix NoScript IPC for about:blank by whitelisting messages If about:blank is the homepage (or has been passed as a command line parameter), NoScript will send a message named "fetchChildPolicy" _before_ "started". Torbutton would then send its "updateSettings" too soon, resulting in the dreaded error "Could not establish connection. Receiving end does not exist" (see bug 26520). Fix this by whitelisting the relevant messages from NoScript: "started" and also "pageshow" for a slightly more graceful failure mode in case Torbutton somehow misses NoScript startup. --- src/modules/noscript-control.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/noscript-control.js b/src/modules/noscript-control.js index 934a4ef0..621f2b7f 100644 --- a/src/modules/noscript-control.js +++ b/src/modules/noscript-control.js @@ -129,6 +129,9 @@ var initialize = () => { // bind the security_slider pref to the NoScript settings. let messageListener = (a,b,c) => { log(3, `Message received from NoScript: ${JSON.stringify([a,b,c])}`); + if (!["started", "pageshow"].includes(a.__meta.name)) { + return; + } extensionContext.api.browser.runtime.onMessage.removeListener(messageListener); bindPrefAndInit( "extensions.torbutton.security_slider", -- 2.11.4.GIT