commit 9b79f00ade001b7da59ef0c8c6f560a62da954bb Author: Arthur Edelstein arthuredelstein@gmail.com Date: Fri Aug 31 15:00:33 2018 -0700
Bug 27401: Start listening for NoScript before it loads --- src/chrome/content/torbutton.js | 2 -- src/components/startup-observer.js | 4 ++++ src/modules/noscript-control.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js index 3f38830b..c3f68510 100644 --- a/src/chrome/content/torbutton.js +++ b/src/chrome/content/torbutton.js @@ -11,7 +11,6 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); let { showDialog, show_torbrowser_manual } = Cu.import("resource://torbutton/modules/utils.js", {}); let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {}); let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {}); -let NoScriptControl = Cu.import("resource://torbutton/modules/noscript-control.js", {}); let { bindPrefAndInit, observe } = Cu.import("resource://torbutton/modules/utils.js", {});
Cu.importGlobalProperties(["XMLHttpRequest"]); @@ -239,7 +238,6 @@ function torbutton_init() { torbutton_log(3, 'called init()');
SecurityPrefs.initialize(); - NoScriptControl.initialize();
if (m_tb_wasinited) { return; diff --git a/src/components/startup-observer.js b/src/components/startup-observer.js index cd9e7d2c..2d20a8ad 100644 --- a/src/components/startup-observer.js +++ b/src/components/startup-observer.js @@ -23,6 +23,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
Cu.import("resource://torbutton/modules/default-prefs.js", {}).ensureDefaultPrefs(); +let NoScriptControl = Cu.import("resource://torbutton/modules/noscript-control.js", {});
// Module specific constants const kMODULE_NAME = "Startup"; @@ -154,6 +155,9 @@ StartupObserver.prototype = { // but only for hackish reasons. this._prefs.setBoolPref("extensions.torbutton.startup", true);
+ // We need to listen for NoScript before it starts. + NoScriptControl.initialize(); + this.setProxySettings(); }
diff --git a/src/modules/noscript-control.js b/src/modules/noscript-control.js index 14f78c49..a03755de 100644 --- a/src/modules/noscript-control.js +++ b/src/modules/noscript-control.js @@ -126,12 +126,14 @@ var initialize = () => { // Wait for the first message from NoScript to arrive, and then // 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])}`); extensionContext.api.browser.runtime.onMessage.removeListener(messageListener); bindPrefAndInit( "extensions.torbutton.security_slider", sliderState => setNoScriptSafetyLevel(securitySliderToSafetyLevel(sliderState))); }; extensionContext.api.browser.runtime.onMessage.addListener(messageListener); + log(3, "Listening for message from NoScript."); } catch (e) { log(5, e.message); }