[tbb-commits] [tor-launcher/master] Added extensions.torlauncher.launch_delay debug pref handling to simulate slow tor launch

gk at torproject.org gk at torproject.org
Wed Jan 19 13:44:39 UTC 2022


commit db7845b74fd1778acd1d2c4c68f724a27ca8ca69
Author: Richard Pospesel <richard at torproject.org>
Date:   Fri Dec 17 16:58:28 2021 +0100

    Added extensions.torlauncher.launch_delay debug pref handling to simulate slow tor launch
---
 src/components/tl-process.js | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index d52dcda..51369a6 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -3,6 +3,8 @@
 //
 // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
 
+const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm")
+
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
@@ -41,6 +43,8 @@ TorProcessService.prototype =
 
   kPrefPromptAtStartup: "extensions.torlauncher.prompt_at_startup",
   kPrefDefaultBridgeType: "extensions.torlauncher.default_bridge_type",
+  // useful for simulating slow tor daemon launch
+  kPrefTorDaemonLaunchDelay: "extensions.torlauncher.launch_delay",
 
   kWizardProgressPageID: "progress",
 
@@ -528,7 +532,17 @@ TorProcessService.prototype =
       for (var i = 0; i < args.length; ++i)
         TorLauncherLogger.log(2, "  " + args[i]);
 
-      p.runwAsync(args, args.length, this, false);
+      const launchDelay = TorLauncherUtil.getIntPref(this.kPrefTorDaemonLaunchDelay, 0);
+      let runwAsync = () => p.runwAsync(args, args.length, this, false);
+
+      if (launchDelay > 0) {
+        setTimeout(() => {
+          runwAsync();
+        }, launchDelay);
+      } else {
+        runwAsync();
+      }
+
       this.mTorProcess = p;
       this.mTorProcessStartTime = Date.now();
     }





More information about the tbb-commits mailing list