[tbb-commits] [tor-browser/tor-browser-78.12.0esr-10.5-1] Bug 27476: Implement about:torconnect captive portal within Tor Browser

sysrqb at torproject.org sysrqb at torproject.org
Fri Jul 9 02:28:13 UTC 2021


commit 21b5e347ba1e18c6c1485ebbb442f567134f5094
Author: Richard Pospesel <richard at torproject.org>
Date:   Wed Apr 28 23:09:34 2021 -0500

    Bug 27476: Implement about:torconnect captive portal within Tor Browser
    
    - implements new about:torconnect page as tor-launcher replacement
    - adds tor connection status to url bar and tweaks UX when not online
    - adds new torconnect component to browser
    - tor process management functionality remains implemented in tor-launcher through the TorProtocolService module
    - the onion pattern from about:tor migrated to an .inc.xhtml file now used by both about:tor and about:torconnect
    - various design tweaks and resusability fixes to onion pattern
    - adds warning/error box to about:preferences#tor when not connected to tor
    - explicitly allows about:torconnect URIs to ignore Resist Fingerprinting (RFP)
    - various tweaks to info-pages.inc.css for about:torconnect (also affects other firefox info pages)
---
 browser/actors/NetErrorParent.jsm                  |   8 +
 browser/base/content/aboutNetError.js              |  10 +-
 browser/base/content/browser-siteIdentity.js       |   2 +-
 browser/base/content/browser.js                    |  10 +
 browser/base/content/browser.xhtml                 |   2 +
 browser/components/BrowserGlue.jsm                 |  42 ++-
 browser/components/about/AboutRedirector.cpp       |   4 +
 browser/components/about/components.conf           |   1 +
 browser/components/moz.build                       |   1 +
 .../onionservices/HttpsEverywhereControl.jsm       |  17 +-
 browser/components/sessionstore/SessionStore.jsm   |  16 +
 browser/components/torconnect/TorConnectChild.jsm  |   9 +
 browser/components/torconnect/TorConnectParent.jsm | 122 ++++++++
 .../torconnect/content/aboutTorConnect.css         | 151 +++++++++
 .../torconnect/content/aboutTorConnect.js          | 339 +++++++++++++++++++++
 .../torconnect/content/aboutTorConnect.xhtml       |  54 ++++
 .../components/torconnect/content/onion-slash.svg  |   7 +
 browser/components/torconnect/content/onion.svg    |   3 +
 .../torconnect/content/torBootstrapUrlbar.js       | 136 +++++++++
 .../torconnect/content/torconnect-urlbar.css       |  65 ++++
 .../torconnect/content/torconnect-urlbar.inc.xhtml |  11 +
 browser/components/torconnect/jar.mn               |   7 +
 browser/components/torconnect/moz.build            |   6 +
 .../components/torpreferences/content/torPane.js   |  86 ++++++
 .../torpreferences/content/torPane.xhtml           |  34 +++
 .../torpreferences/content/torPreferences.css      | 121 ++++++++
 browser/components/urlbar/UrlbarInput.jsm          |  31 ++
 browser/modules/TorConnect.jsm                     |  62 ++++
 browser/modules/TorProcessService.jsm              |  12 +
 browser/modules/TorProtocolService.jsm             | 124 +++++++-
 browser/modules/TorStrings.jsm                     |  75 +++++
 browser/modules/moz.build                          |   2 +
 browser/themes/shared/jar.inc.mn                   |   1 +
 browser/themes/shared/onionPattern.css             | 124 ++++++++
 browser/themes/shared/onionPattern.inc.xhtml       | 210 +++++++++++++
 browser/themes/shared/urlbar-searchbar.inc.css     |   2 +
 dom/base/Document.cpp                              |  51 +++-
 dom/base/nsGlobalWindowOuter.cpp                   |   2 +
 toolkit/modules/AsyncPrefs.jsm                     |   2 +
 toolkit/modules/RemotePageAccessManager.jsm        |  26 ++
 toolkit/mozapps/update/UpdateService.jsm           |  68 ++++-
 .../themes/shared/in-content/info-pages.inc.css    |  15 +-
 .../lib/environments/browser-window.js             |   4 +
 43 files changed, 2059 insertions(+), 16 deletions(-)

diff --git a/browser/actors/NetErrorParent.jsm b/browser/actors/NetErrorParent.jsm
index 035195391554..fa3cbf23fcb7 100644
--- a/browser/actors/NetErrorParent.jsm
+++ b/browser/actors/NetErrorParent.jsm
@@ -17,6 +17,10 @@ const { SessionStore } = ChromeUtils.import(
 );
 const { HomePage } = ChromeUtils.import("resource:///modules/HomePage.jsm");
 
+const { TorProtocolService } = ChromeUtils.import(
+  "resource:///modules/TorProtocolService.jsm"
+);
+
 const PREF_SSL_IMPACT_ROOTS = [
   "security.tls.version.",
   "security.ssl3.",
@@ -318,6 +322,10 @@ class NetErrorParent extends JSWindowActorParent {
             break;
           }
         }
+        break;
+      case "ShouldShowTorConnect":
+        return TorProtocolService.shouldShowTorConnect();
     }
+    return undefined;
   }
 }
diff --git a/browser/base/content/aboutNetError.js b/browser/base/content/aboutNetError.js
index 60db17f46eb9..6844154e16e3 100644
--- a/browser/base/content/aboutNetError.js
+++ b/browser/base/content/aboutNetError.js
@@ -194,8 +194,16 @@ async function setErrorPageStrings(err) {
   document.l10n.setAttributes(titleElement, title);
 }
 
-function initPage() {
+async function initPage() {
   var err = getErrorCode();
+
+  // proxyConnectFailure because no-tor running daemon would return this error
+  if (
+    (err === "proxyConnectFailure") &&
+    (await RPMSendQuery("ShouldShowTorConnect"))
+  ) {
+    document.location.replace("about:torconnect");
+  }
   // List of error pages with an illustration.
   let illustratedErrors = [
     "malformedURI",
diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js
index 539d6d4056a3..2a3431172886 100644
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -57,7 +57,7 @@ var gIdentityHandler = {
    * RegExp used to decide if an about url should be shown as being part of
    * the browser UI.
    */
-  _secureInternalUIWhitelist: (AppConstants.TOR_BROWSER_UPDATE ? /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|tbupdate)(?:[?#]|$)/i : /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor)(?:[?#]|$)/i),
+  _secureInternalUIWhitelist: (AppConstants.TOR_BROWSER_UPDATE ? /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect|tbupdate)(?:[?#]|$)/i : /^(?:accounts|addons|cache|certificate|config|crashes|downloads|license|logins|preferences|protections|rights|sessionrestore|support|welcomeback|tor|torconnect)(?:[?#]|$)/i),
 
   /**
    * Whether the established HTTPS connection is considered "broken".
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 04f8752b93f4..916cd69320cb 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -77,6 +77,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
   TabModalPrompt: "chrome://global/content/tabprompts.jsm",
   TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
   TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
+  TorProtocolService: "resource:///modules/TorProtocolService.jsm",
   Translation: "resource:///modules/translation/TranslationParent.jsm",
   OnionAliasStore: "resource:///modules/OnionAliasStore.jsm",
   UITour: "resource:///modules/UITour.jsm",
@@ -633,6 +634,7 @@ var gPageIcons = {
 
 var gInitialPages = [
   "about:tor",
+  "about:torconnect",
   "about:blank",
   "about:newtab",
   "about:home",
@@ -1959,6 +1961,8 @@ var gBrowserInit = {
     }
 
     this._loadHandled = true;
+
+    TorBootstrapUrlbar.init();
   },
 
   _cancelDelayedStartup() {
@@ -2490,6 +2494,10 @@ var gBrowserInit = {
       let uri = window.arguments[0];
       let defaultArgs = BrowserHandler.defaultArgs;
 
+      if (TorProtocolService.shouldShowTorConnect()) {
+        return "about:torconnect";
+      }
+
       // If the given URI is different from the homepage, we want to load it.
       if (uri != defaultArgs) {
         AboutNewTab.noteNonDefaultStartup();
@@ -2582,6 +2590,8 @@ var gBrowserInit = {
 
     OnionAuthPrompt.uninit();
 
+    TorBootstrapUrlbar.uninit();
+
     gAccessibilityServiceIndicator.uninit();
 
     AccessibilityRefreshBlocker.uninit();
diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml
index c2caecc1a416..032db1967c69 100644
--- a/browser/base/content/browser.xhtml
+++ b/browser/base/content/browser.xhtml
@@ -112,6 +112,7 @@
   Services.scriptloader.loadSubScript("chrome://browser/content/search/searchbar.js", this);
   Services.scriptloader.loadSubScript("chrome://torbutton/content/tor-circuit-display.js", this);
   Services.scriptloader.loadSubScript("chrome://torbutton/content/torbutton.js", this);
+  Services.scriptloader.loadSubScript("chrome://browser/content/torconnect/torBootstrapUrlbar.js", this);
 
   window.onload = gBrowserInit.onLoad.bind(gBrowserInit);
   window.onunload = gBrowserInit.onUnload.bind(gBrowserInit);
@@ -1055,6 +1056,7 @@
                      data-l10n-id="urlbar-go-button"/>
               <hbox id="page-action-buttons" context="pageActionContextMenu">
                 <toolbartabstop/>
+#include ../../components/torconnect/content/torconnect-urlbar.inc.xhtml
                 <hbox id="contextual-feature-recommendation" role="button" hidden="true">
                   <hbox id="cfr-label-container">
                     <label id="cfr-label"/>
diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm
index 5f708fca3d5c..914b782afdb1 100644
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -17,6 +17,14 @@ const { AppConstants } = ChromeUtils.import(
   "resource://gre/modules/AppConstants.jsm"
 );
 
+const { TorProtocolService } = ChromeUtils.import(
+  "resource:///modules/TorProtocolService.jsm"
+);
+
+const { TorConnect } = ChromeUtils.import(
+  "resource:///modules/TorConnect.jsm"
+);
+
 ChromeUtils.defineModuleGetter(
   this,
   "ActorManagerParent",
@@ -503,6 +511,20 @@ let JSWINDOWACTORS = {
     allFrames: true,
   },
 
+  TorConnect: {
+    parent: {
+      moduleURI: "resource:///modules/TorConnectParent.jsm",
+    },
+    child: {
+      moduleURI: "resource:///modules/TorConnectChild.jsm",
+      events: {
+        DOMWindowCreated: {},
+      },
+    },
+
+    matches: ["about:torconnect"],
+  },
+
   Translation: {
     parent: {
       moduleURI: "resource:///modules/translation/TranslationParent.jsm",
@@ -2492,7 +2514,25 @@ BrowserGlue.prototype = {
 
       {
         task: () => {
-          OnionAliasStore.init();
+          if (TorProtocolService.isBootstrapDone() || !TorProtocolService.ownsTorDaemon) {
+            // we will take this path when the user is using the legacy tor launcher or
+            // when Tor Browser didn't launch its own tor.
+            OnionAliasStore.init();
+          } else {
+            // this path is taken when using about:torconnect, we wait to init
+            // after we are bootstrapped and connected to tor
+            const topic = "torconnect:bootstrap-complete";
+            let bootstrapObserver = {
+              observe(aSubject, aTopic, aData) {
+                if (aTopic === topic) {
+                  OnionAliasStore.init();
+                  // we only need to init once, so remove ourselves as an obvserver
+                  Services.obs.removeObserver(this, topic);
+                }
+              }
+            };
+            Services.obs.addObserver(bootstrapObserver, topic);
+          }
         },
       },
 
diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp
index e7c377d655e7..db5f3ead4bb8 100644
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -120,6 +120,10 @@ static const RedirEntry kRedirMap[] = {
          nsIAboutModule::URI_MUST_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
          nsIAboutModule::HIDE_FROM_ABOUTABOUT},
 #endif
+    {"torconnect", "chrome://browser/content/torconnect/aboutTorConnect.xhtml",
+     nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
+         nsIAboutModule::URI_CAN_LOAD_IN_CHILD | nsIAboutModule::ALLOW_SCRIPT |
+         nsIAboutModule::HIDE_FROM_ABOUTABOUT},
 };
 
 static nsAutoCString GetAboutModuleName(nsIURI* aURI) {
diff --git a/browser/components/about/components.conf b/browser/components/about/components.conf
index 8e04467c05da..01c99ad4ed0c 100644
--- a/browser/components/about/components.conf
+++ b/browser/components/about/components.conf
@@ -26,6 +26,7 @@ pages = [
     'robots',
     'sessionrestore',
     'tabcrashed',
+    'torconnect',
     'welcome',
     'welcomeback',
 ]
diff --git a/browser/components/moz.build b/browser/components/moz.build
index b660be047b14..fb90c499c616 100644
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -59,6 +59,7 @@ DIRS += [
     'syncedtabs',
     'uitour',
     'urlbar',
+    'torconnect',
     'torpreferences',
     'translation',
 ]
diff --git a/browser/components/onionservices/HttpsEverywhereControl.jsm b/browser/components/onionservices/HttpsEverywhereControl.jsm
index 525ed5233be7..d673de4cd6e5 100644
--- a/browser/components/onionservices/HttpsEverywhereControl.jsm
+++ b/browser/components/onionservices/HttpsEverywhereControl.jsm
@@ -41,6 +41,7 @@ const SECUREDROP_TOR_ONION_CHANNEL = {
 class HttpsEverywhereControl {
   constructor() {
     this._extensionMessaging = null;
+    this._init();
   }
 
   async _sendMessage(type, object) {
@@ -61,7 +62,6 @@ class HttpsEverywhereControl {
    * Installs the .tor.onion update channel in https-everywhere
    */
   async installTorOnionUpdateChannel(retries = 5) {
-    this._init();
 
     // TODO: https-everywhere store is initialized asynchronously, so sending a message
     // immediately results in a `store.get is undefined` error.
@@ -143,5 +143,20 @@ class HttpsEverywhereControl {
     if (!this._extensionMessaging) {
       this._extensionMessaging = new ExtensionMessaging();
     }
+
+    // update all of the existing https-everywhere channels
+    setTimeout(async () => {
+      let pinnedChannels = await this._sendMessage("get_pinned_update_channels");
+      for(let channel of pinnedChannels.update_channels) {
+        this._sendMessage("update_update_channel", channel);
+      }
+
+      let storedChannels = await this._sendMessage("get_stored_update_channels");
+      for(let channel of storedChannels.update_channels) {
+        this._sendMessage("update_update_channel", channel);
+      }
+    }, 0);
+
+
   }
 }
diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm
index 6ab86fd5913e..2d66422abf58 100644
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -213,6 +213,10 @@ ChromeUtils.defineModuleGetter(
   "resource://gre/modules/sessionstore/SessionHistory.jsm"
 );
 
+const { TorProtocolService } = ChromeUtils.import(
+    "resource:///modules/TorProtocolService.jsm"
+);
+
 XPCOMUtils.defineLazyServiceGetters(this, {
   gScreenManager: ["@mozilla.org/gfx/screenmanager;1", "nsIScreenManager"],
   Telemetry: ["@mozilla.org/base/telemetry;1", "nsITelemetry"],
@@ -1888,11 +1892,23 @@ var SessionStoreInternal = {
         }, "browser-delayed-startup-finished");
       });
 
+      let bootstrapPromise = new Promise(resolve => {
+        if (TorProtocolService.isBootstrapDone() || !TorProtocolService.ownsTorDaemon) {
+          resolve();
+        } else {
+          Services.obs.addObserver(function obs(subject, topic) {
+            Services.obs.removeObserver(obs, topic);
+            resolve();
+          }, "torconnect:bootstrap-complete");
+        }
+      });
+
       // We are ready for initialization as soon as the session file has been
       // read from disk and the initial window's delayed startup has finished.
       this._promiseReadyForInitialization = Promise.all([
         promise,
         SessionStartup.onceInitialized,
+        bootstrapPromise,
       ]);
     }
 
diff --git a/browser/components/torconnect/TorConnectChild.jsm b/browser/components/torconnect/TorConnectChild.jsm
new file mode 100644
index 000000000000..bd6dd549f156
--- /dev/null
+++ b/browser/components/torconnect/TorConnectChild.jsm
@@ -0,0 +1,9 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
+var EXPORTED_SYMBOLS = ["TorConnectChild"];
+
+const { RemotePageChild } = ChromeUtils.import(
+  "resource://gre/actors/RemotePageChild.jsm"
+);
+
+class TorConnectChild extends RemotePageChild {}
diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm
new file mode 100644
index 000000000000..54548891fbab
--- /dev/null
+++ b/browser/components/torconnect/TorConnectParent.jsm
@@ -0,0 +1,122 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
+var EXPORTED_SYMBOLS = ["TorConnectParent"];
+
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { TorProtocolService } = ChromeUtils.import(
+  "resource:///modules/TorProtocolService.jsm"
+);
+const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
+const { TorLauncherUtil } = ChromeUtils.import(
+  "resource://torlauncher/modules/tl-util.jsm"
+);
+
+const kTorProcessReadyTopic = "TorProcessIsReady";
+const kTorProcessExitedTopic = "TorProcessExited";
+const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
+const kTorShowProgressPanelTopic = "TorShowProgressPanel";
+const kTorBootstrapStatusTopic = "TorBootstrapStatus";
+const kTorBootstrapErrorTopic = "TorBootstrapError";
+const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
+
+const gActiveTopics = [
+  kTorProcessReadyTopic,
+  kTorProcessExitedTopic,
+  kTorProcessDidNotStartTopic,
+  kTorShowProgressPanelTopic,
+  kTorBootstrapStatusTopic,
+  kTorBootstrapErrorTopic,
+  kTorLogHasWarnOrErrTopic,
+  "torconnect:bootstrap-complete",
+];
+
+const gTorLauncherPrefs = {
+  quickstart: "extensions.torlauncher.quickstart",
+}
+
+class TorConnectParent extends JSWindowActorParent {
+  constructor(...args) {
+    super(...args);
+
+    const self = this;
+    this.gObserver = {
+      observe(aSubject, aTopic, aData) {
+        const obj = aSubject?.wrappedJSObject;
+        if (obj) {
+          obj.handled = true;
+        }
+        self.sendAsyncMessage(aTopic, obj);
+      },
+    };
+
+    for (const topic of gActiveTopics) {
+      Services.obs.addObserver(this.gObserver, topic);
+    }
+
+    this.quickstartObserver = {
+      observe(aSubject, aTopic, aData) {
+        if (aTopic === "nsPref:changed" &&
+            aData == gTorLauncherPrefs.quickstart) {
+          self.sendAsyncMessage("TorQuickstartPrefChanged", Services.prefs.getBoolPref(gTorLauncherPrefs.quickstart));
+        }
+      },
+    }
+    Services.prefs.addObserver(gTorLauncherPrefs.quickstart, this.quickstartObserver);
+  }
+
+  willDestroy() {
+    for (const topic of gActiveTopics) {
+      Services.obs.removeObserver(this.gObserver, topic);
+    }
+  }
+
+
+  _OpenTorAdvancedPreferences() {
+    const win = this.browsingContext.top.embedderElement.ownerGlobal;
+    win.openTrustedLinkIn("about:preferences#tor", "tab");
+  }
+
+  _TorCopyLog() {
+    // Copy tor log messages to the system clipboard.
+    const chSvc = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(
+      Ci.nsIClipboardHelper
+    );
+    const countObj = { value: 0 };
+    chSvc.copyString(TorProtocolService.getLog(countObj));
+    const count = countObj.value;
+    return TorLauncherUtil.getFormattedLocalizedString(
+      "copiedNLogMessagesShort",
+      [count],
+      1
+    );
+  }
+
+  receiveMessage(message) {
+    switch (message.name) {
+      case "TorBootstrapErrorOccurred":
+        return TorProtocolService.torBootstrapErrorOccurred();
+      case "TorRetrieveBootstrapStatus":
+        return TorProtocolService.retrieveBootstrapStatus();
+      case "OpenTorAdvancedPreferences":
+        return this._OpenTorAdvancedPreferences();
+      case "GetLocalizedBootstrapStatus":
+        const { status, keyword } = message.data;
+        return TorLauncherUtil.getLocalizedBootstrapStatus(status, keyword);
+      case "TorCopyLog":
+        return this._TorCopyLog();
+      case "TorIsNetworkDisabled":
+        return TorProtocolService.isNetworkDisabled();
+      case "TorStopBootstrap":
+        return TorProtocolService.torStopBootstrap();
+      case "TorConnect":
+        return TorProtocolService.connect();
+      case "GetDirection":
+        return Services.locale.isAppLocaleRTL ? "rtl" : "ltr";
+      case "GetTorStrings":
+        return TorStrings;
+      case "TorLogHasWarnOrErr":
+        return TorProtocolService.torLogHasWarnOrErr();
+    }
+    return undefined;
+  }
+}
diff --git a/browser/components/torconnect/content/aboutTorConnect.css b/browser/components/torconnect/content/aboutTorConnect.css
new file mode 100644
index 000000000000..a70904ca0b28
--- /dev/null
+++ b/browser/components/torconnect/content/aboutTorConnect.css
@@ -0,0 +1,151 @@
+
+/* Copyright (c) 2021, The Tor Project, Inc. */
+
+
+ at import url("chrome://browser/skin/error-pages.css");
+
+:root {
+  --onion-opacity: 1;
+  --onion-color: var(--card-outline-color);
+  --onion-radius: 50px;
+}
+
+/* override firefox's default blue focus coloring */
+:focus {
+  outline:  none!important;
+  box-shadow: 0 0 0 3px #CD8CED !important;
+  border:  1px #59316B solid !important;
+}
+
+ at media (prefers-color-scheme: dark)
+{
+  :focus {
+    box-shadow: 0 0 0 3px #8C689E !important;
+  }
+}
+
+/* override firefox's default blue border on hover */
+input[type="checkbox"]:not(:disabled):hover {
+  border-color: #59316B;
+}
+
+/* fix checkbox visibility when dark mode enabled */
+input[type="checkbox"]:checked {
+  fill: var(--in-content-page-color);
+}
+
+#connectButton {
+  background-color: #7D4698;
+}
+
+#connectButton:hover {
+  background-color: #59316B;
+}
+
+#progressBackground {
+  position:fixed;
+  padding:0;
+  margin:0;
+  top:0;
+  left:0;
+  width: 0%;
+  height: 7px;
+  background-image: linear-gradient(90deg, rgb(20, 218, 221) 0%, rgb(128, 109, 236) 100%);
+  border-radius: 0;
+}
+
+#connectPageContainer {
+  margin-top: 10vh;
+  width: 50%;
+}
+
+#quickstartCheckbox, #quickstartCheckboxLabel {
+  vertical-align: middle;
+}
+
+#copyLogButton {
+  position: relative;
+}
+
+/* mirrors p element spacing */
+#copyLogContainer {
+  margin:  1em 0;
+  height:  1.2em;
+  min-height:  1.2em;
+}
+
+#copyLogLink {
+  position:  relative;
+  display:  inline-block;
+  color:  var(--in-content-link-color);
+}
+
+/* hidden apparently only works if no display is set; who knew? */
+#copyLogLink[hidden="true"] {
+  display:  none;
+}
+
+#copyLogLink:hover {
+  cursor:pointer;
+}
+
+/* This div:
+   - is centered over its parent
+   - centers its child
+   - has z-index above parent
+   - ignores mouse events from parent
+*/
+#copyLogTooltip {
+  pointer-events: none;
+  visibility: hidden;
+  display:  flex;
+  justify-content: center;
+  white-space: nowrap;
+  width: 0;
+  position:  absolute;
+
+  z-index:  1;
+  left: 50%;
+  bottom:  calc(100% + 0.25em);
+}
+
+/* tooltip content (any content could go here) */
+#copyLogTooltipText {
+  background-color: #30E60B;
+  color: #003706;
+  border-radius: 2px;
+  padding: 4px;
+  line-height: 13px;
+  font: 11px sans-serif;
+  font-weight: 400;
+}
+
+/* our speech bubble tail */
+#copyLogTooltipText::after {
+  content: "";
+  position: absolute;
+  top: 100%;
+  left: 50%;
+  margin-left: -4px;
+  border-width: 4px;
+  border-style: solid;
+  border-color: #30E60B transparent transparent transparent;
+}
+
+body {
+  padding: 0px !important;
+  justify-content: space-between;
+  background-color: var(--in-content-page-background);
+}
+
+.title {
+  background-image: url("chrome://browser/content/torconnect/onion.svg");
+  -moz-context-properties: fill, fill-opacity;
+  fill-opacity: 1;
+  fill: var(--onion-color);
+}
+
+.title.error {
+  background-image: url("chrome://browser/content/torconnect/onion-slash.svg");
+}
+
diff --git a/browser/components/torconnect/content/aboutTorConnect.js b/browser/components/torconnect/content/aboutTorConnect.js
new file mode 100644
index 000000000000..19fd335ccd13
--- /dev/null
+++ b/browser/components/torconnect/content/aboutTorConnect.js
@@ -0,0 +1,339 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
+/* eslint-env mozilla/frame-script */
+
+const kTorProcessReadyTopic = "TorProcessIsReady";
+const kTorProcessExitedTopic = "TorProcessExited";
+const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
+const kTorBootstrapStatusTopic = "TorBootstrapStatus";
+const kTorBootstrapErrorTopic = "TorBootstrapError";
+const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
+const kTorQuickstartPrefChanged = "TorQuickstartPrefChanged";
+
+const TorLauncherPrefs = {
+  quickstart: "extensions.torlauncher.quickstart",
+  prompt_at_startup: "extensions.torlauncher.prompt_at_startup",
+}
+
+class AboutTorConnect {
+  log(...args) {
+    console.log(...args);
+  }
+
+  logError(...args) {
+    console.error(...args);
+  }
+
+  logDebug(...args) {
+    console.debug(...args);
+  }
+
+  getElem(id) {
+    return document.getElementById(id);
+  }
+  get elemProgressContent() {
+    return this.getElem("progressContent");
+  }
+  get elemProgressDesc() {
+    return this.getElem("connectShortDescText");
+  }
+  get elemProgressMeter() {
+    return this.getElem("progressBackground");
+  }
+  get elemCopyLogLink() {
+    return this.getElem("copyLogLink");
+  }
+  get elemCopyLogTooltip() {
+    return this.getElem("copyLogTooltip");
+  }
+  get elemCopyLogTooltipText() {
+    return this.getElem("copyLogTooltipText");
+  }
+  get elemQuickstartCheckbox() {
+    return this.getElem("quickstartCheckbox");
+  }
+  get elemQuickstartLabel() {
+    return this.getElem("quickstartCheckboxLabel");
+  }
+  get elemConnectButton() {
+    return this.getElem("connectButton");
+  }
+  get elemAdvancedButton() {
+    return this.getElem("advancedButton");
+  }
+  get elemCancelButton() {
+    return this.getElem("cancelButton");
+  }
+  get elemTextContainer() {
+    return this.getElem("text-container");
+  }
+  get elemTitle() {
+    return this.elemTextContainer.getElementsByClassName("title")[0];
+  }
+
+  static get STATE_INITIAL() {
+    return "STATE_INITIAL";
+  }
+
+  static get STATE_BOOTSTRAPPING() {
+    return "STATE_BOOTSTRAPPING";
+  }
+
+  static get STATE_BOOTSTRAPPED() {
+    return "STATE_BOOTSTRAPPED";
+  }
+
+  static get STATE_BOOTSTRAP_ERROR() {
+    return "STATE_BOOTSTRAP_ERROR";
+  }
+
+  get state() {
+    return this._state;
+  }
+
+  setInitialUI() {
+    this.setTitle(this.torStrings.torConnect.torConnect);
+    this.elemProgressDesc.textContent =
+      this.torStrings.settings.torPreferencesDescription;
+    this.showElem(this.elemConnectButton);
+    this.elemConnectButton.focus();
+    this.showElem(this.elemAdvancedButton);
+    this.hideElem(this.elemCopyLogLink);
+    this.hideElem(this.elemCancelButton);
+    this.hideElem(this.elemProgressContent);
+    this.hideElem(this.elemProgressMeter);
+    this.elemTitle.classList.remove("error");
+  }
+
+  setBootstrappingUI() {
+    this.setTitle(this.torStrings.torConnect.torConnecting);
+    this.hideElem(this.elemConnectButton);
+    this.hideElem(this.elemAdvancedButton);
+    this.hideElem(this.elemCopyLogLink);
+    this.showElem(this.elemCancelButton);
+    this.elemCancelButton.focus();
+    this.showElem(this.elemProgressContent);
+    this.showElem(this.elemProgressMeter);
+    this.elemTitle.classList.remove("error");
+  }
+
+  setBootstrapErrorUI() {
+    this.setTitle(this.torStrings.torConnect.torBootstrapFailed);
+    this.elemConnectButton.textContent = this.torStrings.torConnect.tryAgain;
+    this.showElem(this.elemConnectButton);
+    this.hideElem(this.elemCancelButton);
+    this.showElem(this.elemAdvancedButton);
+    this.elemAdvancedButton.focus();
+    this.showElem(this.elemProgressContent);
+    this.hideElem(this.elemProgressMeter);
+    this.elemTitle.classList.add("error");
+  }
+
+  set state(state) {
+    const oldState = this.state;
+    if (oldState === state) {
+      return;
+    }
+    this._state = state;
+    switch (this.state) {
+      case AboutTorConnect.STATE_INITIAL:
+        this.setInitialUI();
+        break;
+      case AboutTorConnect.STATE_BOOTSTRAPPING:
+        this.setBootstrappingUI();
+        break;
+      case AboutTorConnect.STATE_BOOTSTRAP_ERROR:
+        this.setBootstrapErrorUI();
+        break;
+      case AboutTorConnect.STATE_BOOTSTRAPPED:
+        window.close();
+        break;
+    }
+  }
+
+  async showErrorMessage(aErrorObj) {
+    if (aErrorObj && aErrorObj.message) {
+      this.setTitle(aErrorObj.message);
+      if (aErrorObj.details) {
+        this.elemProgressDesc.textContent = aErrorObj.details;
+      }
+    }
+
+    this.showCopyLog();
+    this.showElem(this.elemConnectButton);
+  }
+
+  showElem(elem) {
+    elem.removeAttribute("hidden");
+  }
+
+  hideElem(elem) {
+    elem.setAttribute("hidden", "true");
+  }
+
+  async connect() {
+    // reset the text to original description
+    // in case we are trying again after an error (clears out error text)
+    this.elemProgressDesc.textContent =
+      this.torStrings.settings.torPreferencesDescription;
+
+    this.state = AboutTorConnect.STATE_BOOTSTRAPPING;
+    const error = await RPMSendQuery("TorConnect");
+    if (error) {
+      if (error.details) {
+        this.showErrorMessage({ message: error.details }, true);
+        this.showSaveSettingsError(error.details);
+      }
+    }
+  }
+
+  showCopyLog() {
+    this.elemCopyLogLink.removeAttribute("hidden");
+  }
+
+  async updateBootstrapProgress(status) {
+    let labelText = await RPMSendQuery("GetLocalizedBootstrapStatus", {
+      status,
+      keyword: "TAG",
+    });
+    let percentComplete = status.PROGRESS ? status.PROGRESS : 0;
+    this.elemProgressMeter.style.width = `${percentComplete}%`;
+
+    if (await RPMSendQuery("TorBootstrapErrorOccurred")) {
+      this.state = AboutTorConnect.STATE_BOOTSTRAP_ERROR;
+      return;
+    } else if (await RPMSendQuery("TorIsNetworkDisabled")) {
+      // If tor network is not connected, let's go to the initial state, even
+      // if bootstrap state is greater than 0.
+      this.state = AboutTorConnect.STATE_INITIAL;
+      return;
+    } else if (percentComplete > 0) {
+      this.state = AboutTorConnect.STATE_BOOTSTRAPPING;
+    }
+
+    // Due to async, status might have changed. Do not override desc if so.
+    if (this.state === AboutTorConnect.STATE_BOOTSTRAPPING) {
+      this.hideElem(this.elemConnectButton);
+    }
+  }
+
+  stopTorBootstrap() {
+    RPMSendAsyncMessage("TorStopBootstrap");
+  }
+
+  setTitle(title) {
+    const titleElement = document.querySelector(".title-text");
+    titleElement.textContent = title;
+    document.title = title;
+  }
+
+  async initElements() {
+    this.elemAdvancedButton.textContent = this.torStrings.torConnect.torConfigure;
+    this.elemAdvancedButton.addEventListener("click", () => {
+      RPMSendAsyncMessage("OpenTorAdvancedPreferences");
+    });
+
+    // sets the text content while keping the child elements intact
+    this.elemCopyLogLink.childNodes[0].nodeValue =
+      this.torStrings.torConnect.copyLog;
+    this.elemCopyLogLink.addEventListener("click", async (event) => {
+      const copiedMessage = await RPMSendQuery("TorCopyLog");
+      aboutTorConnect.elemCopyLogTooltipText.textContent = copiedMessage;
+      aboutTorConnect.elemCopyLogTooltip.style.visibility = "visible";
+
+      // clear previous timeout if one already exists
+      if (aboutTorConnect.copyLogTimeoutId) {
+        clearTimeout(aboutTorConnect.copyLogTimeoutId);
+      }
+
+      // hide tooltip after X ms
+      const TOOLTIP_TIMEOUT = 2000;
+      aboutTorConnect.copyLogTimeoutId = setTimeout(function() {
+        aboutTorConnect.elemCopyLogTooltip.style.visibility = "hidden";
+        aboutTorConnect.copyLogTimeoutId = 0;
+      }, TOOLTIP_TIMEOUT);
+    });
+
+
+    this.elemQuickstartLabel.textContent = this.torStrings.settings.quickstartCheckbox;
+    this.elemQuickstartCheckbox.addEventListener("change", () => {
+      const quickstart = this.elemQuickstartCheckbox.checked;
+      RPMSetBoolPref(TorLauncherPrefs.quickstart, quickstart);
+    });
+    this.elemQuickstartCheckbox.checked = await RPMGetBoolPref(TorLauncherPrefs.quickstart);
+
+    this.elemConnectButton.textContent =
+      this.torStrings.torConnect.torConnectButton;
+    this.elemConnectButton.addEventListener("click", () => {
+      this.connect();
+    });
+
+    this.elemCancelButton.textContent = this.torStrings.torConnect.cancel;
+    this.elemCancelButton.addEventListener("click", () => {
+      this.stopTorBootstrap();
+    });
+  }
+
+  initObservers() {
+    RPMAddMessageListener(kTorBootstrapErrorTopic, ({ data }) => {
+      this.showCopyLog();
+      this.stopTorBootstrap();
+      this.showErrorMessage(data);
+    });
+    RPMAddMessageListener(kTorLogHasWarnOrErrTopic, () => {
+      this.showCopyLog();
+    });
+    RPMAddMessageListener(kTorProcessDidNotStartTopic, ({ data }) => {
+      this.showErrorMessage(data);
+    });
+    RPMAddMessageListener(kTorBootstrapStatusTopic, ({ data }) => {
+      this.updateBootstrapProgress(data);
+    });
+    RPMAddMessageListener(kTorQuickstartPrefChanged, ({ data }) => {
+      // update checkbox with latest quickstart pref value
+      this.elemQuickstartCheckbox.checked = data;
+    });
+    RPMAddMessageListener("torconnect:bootstrap-complete", () => {
+      this.state = AboutTorConnect.STATE_BOOTSTRAPPED;
+    });
+  }
+
+  initKeyboardShortcuts() {
+    document.onkeydown = (evt) => {
+      // unfortunately it looks like we still haven't standardized keycodes to
+      // integers, so we must resort to a string compare here :(
+      // see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code for relevant documentation
+      if (evt.code === "Escape") {
+        this.stopTorBootstrap();
+      }
+    };
+  }
+
+  async init() {
+    this.torStrings = await RPMSendQuery("GetTorStrings");
+    document.documentElement.setAttribute(
+      "dir",
+      await RPMSendQuery("GetDirection")
+    );
+    this.initElements();
+    this.initObservers();
+    this.initKeyboardShortcuts();
+    this.state = AboutTorConnect.STATE_INITIAL;
+
+    // Request the most recent bootstrap status info so that a
+    // TorBootstrapStatus notification is generated as soon as possible.
+    RPMSendAsyncMessage("TorRetrieveBootstrapStatus");
+
+    // quickstart is the user set pref for starting tor automatically
+    // prompt_at_startup will be set to false after successful bootstrap, and true on error
+    // by tor-launcher, so we want to keep the connect screen up when prompt_at_startup is true
+    ///  even if quickstart is enabled so user can potentially resolve errors on next launch
+    if (await RPMGetBoolPref(TorLauncherPrefs.quickstart) &&
+       !await RPMGetBoolPref(TorLauncherPrefs.prompt_at_startup)) {
+      this.connect();
+    }
+  }
+}
+
+const aboutTorConnect = new AboutTorConnect();
+aboutTorConnect.init();
diff --git a/browser/components/torconnect/content/aboutTorConnect.xhtml b/browser/components/torconnect/content/aboutTorConnect.xhtml
new file mode 100644
index 000000000000..0a0721afb7db
--- /dev/null
+++ b/browser/components/torconnect/content/aboutTorConnect.xhtml
@@ -0,0 +1,54 @@
+<!-- Copyright (c) 2021, The Tor Project, Inc. -->
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'" />
+    <link rel="stylesheet" href="chrome://browser/skin/onionPattern.css" type="text/css" media="all" />
+    <link rel="stylesheet" href="chrome://browser/content/torconnect/aboutTorConnect.css" type="text/css" media="all" />
+  </head>
+  <body>
+    <div id="progressBackground"></div>
+    <div id="connectPageContainer" class="container">
+      <div id="text-container">
+        <div class="title">
+          <h1 class="title-text"/>
+        </div>
+        <div id="connectLongContent">
+          <div id="connectShortDesc">
+            <p id="connectShortDescText" />
+          </div>
+        </div>
+
+        <div id="progressContent" hidden="true">
+          <div class="tbb-header" pack="center">
+            <image class="tbb-logo"/>
+          </div>
+          <div flex="1">
+            <div id="progressDesc"/>
+          </div>
+        </div>
+
+        <div id="copyLogContainer">
+          <span id="copyLogLink" hidden="true">
+            <div id="copyLogTooltip">
+              <span id="copyLogTooltipText"/>
+            </div>
+          </span>
+        </div>
+
+        <div id="quickstartContainer">
+          <input id="quickstartCheckbox" type="checkbox" />
+          <label id="quickstartCheckboxLabel" for="quickstartCheckbox"/>
+        </div>
+
+        <div id="connectButtonContainer" class="button-container">
+          <button id="advancedButton" hidden="true"></button>
+          <button id="cancelButton" hidden="true"></button>
+          <button id="connectButton" class="primary try-again" hidden="true"></button>
+        </div>
+      </div>
+    </div>
+#include ../../../themes/shared/onionPattern.inc.xhtml
+  </body>
+  <script src="chrome://browser/content/torconnect/aboutTorConnect.js"/>
+</html>
diff --git a/browser/components/torconnect/content/onion-slash.svg b/browser/components/torconnect/content/onion-slash.svg
new file mode 100644
index 000000000000..efb09700ec0b
--- /dev/null
+++ b/browser/components/torconnect/content/onion-slash.svg
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+  <g fill-opacity="context-fill-opacity" fill="context-fill">
+  	<path d="M3.409559 13.112147C3.409559 13.112147 8.200807 8.103115 8.200807 8.103115C8.200807 8.103115 8.200807 6.516403 8.200807 6.516403C8.620819 6.516403 9.009719 6.703075 9.274171 6.998639C9.274171 6.998639 10.160863 6.080835 10.160863 6.080835C9.663071 5.567487 8.978607 5.256367 8.200807 5.256367C8.200807 5.256367 8.200807 4.400787 8.200807 4.400787C9.196391 4.400787 10.098639 4.805243 10.736435 5.458595C10.736435 5.458595 11.623127 4.540791 11.623127 4.540791C10.751991 3.669655 9.538623 3.125195 8.200807 3.125195C8.200807 3.125195 8.200807 2.269615 8.200807 2.269615C9.756407 2.269615 11.172003 2.907411 12.214255 3.918551C12.214255 3.918551 13.100947 3.000747 13.100947 3.000747C11.825355 1.756267 10.098639 0.994023 8.185251 0.994023C4.311807 0.994023 1.185051 4.120779 1.185051 7.994223C1.185051 10.016503 2.040631 11.836555 3.409559 13.112147C3.409559 13.112147 3.409559 13.112147 3.409559 13.112147"/>
+  	<path d="M14.205423 4.416343C14.205423 4.416343 13.287619 5.380815 13.287619 5.380815C13.692075 6.158615 13.909859 7.045307 13.909859 7.994223C13.909859 11.152091 11.358675 13.718831 8.200807 13.718831C8.200807 13.718831 8.200807 12.863251 8.200807 12.863251C10.891995 12.863251 13.069835 10.669855 13.069835 7.978667C13.069835 7.278647 12.929831 6.625295 12.665379 6.018611C12.665379 6.018611 11.685351 7.045307 11.685351 7.045307C11.763131 7.340871 11.809799 7.651991 11.809799 7.963111C11.809799 9.954279 10.207531 11.556547 8.216363 11.572103C8.216363 11.572103 8.216363 10.716523 8.216363 10.716523C9.725295 10.700967 10.954219 9.472043 10.954219 7.963111C10.954219 7.916443 10.954219 7.854219 10.954219 7.807551C10.954219 7.807551 4.887379 14.169955 4.887379 14.169955C5.867407 14.698859 6.987439 14.994423 8.185251 14.994423C12.058695 14.994423 15.185451 11.867667 15.185451 7.994223C15.185451 6.687519 14.827663 5.474151 14.205423 4.416343C14.205423 4.416343 14.205423 4.416343 14.20542
 3 4.416343"/>
+  	<path d="M1.791735 15.461103C1.402835 15.461103 1.045047 15.212207 0.889487 14.838863C0.733927 14.465519 0.827267 14.014395 1.107271 13.734387C1.107271 13.734387 13.458735 0.822907 13.458735 0.822907C13.847635 0.434007 14.454319 0.449563 14.827663 0.838467C15.201007 1.227367 15.216563 1.865163 14.843223 2.269619C14.843223 2.269619 2.491759 15.181099 2.491759 15.181099C2.289531 15.352215 2.040635 15.461107 1.791739 15.461107C1.791739 15.461107 1.791735 15.461103 1.791735 15.461103"/>
+  </g>
+</svg>
diff --git a/browser/components/torconnect/content/onion.svg b/browser/components/torconnect/content/onion.svg
new file mode 100644
index 000000000000..30cd52ba5c51
--- /dev/null
+++ b/browser/components/torconnect/content/onion.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
+  <path fill="context-fill" fill-opacity="context-fill-opacity" d="M12.0246161,21.8174863 L12.0246161,20.3628098 C16.6324777,20.3495038 20.3634751,16.6108555 20.3634751,11.9996673 C20.3634751,7.38881189 16.6324777,3.65016355 12.0246161,3.63685757 L12.0246161,2.18218107 C17.4358264,2.1958197 21.8178189,6.58546322 21.8178189,11.9996673 C21.8178189,17.4142042 17.4358264,21.8041803 12.0246161,21.8174863 L12.0246161,21.8174863 Z M12.0246161,16.7259522 C14.623607,16.7123136 16.7272828,14.6023175 16.7272828,11.9996673 C16.7272828,9.39734991 14.623607,7.28735377 12.0246161,7.27371516 L12.0246161,5.81937131 C15.4272884,5.8326773 18.1819593,8.59400123 18.1819593,11.9996673 C18.1819593,15.4056661 15.4272884,18.1669901 12.0246161,18.1802961 L12.0246161,16.7259522 Z M12.0246161,9.45556355 C13.4187503,9.46886953 14.5454344,10.6022066 14.5454344,11.9996673 C14.5454344,13.3974608 13.4187503,14.5307978 12.0246161,14.5441038 L12.0246161,9.45556355 Z M0,11.9996673 C0,18.6273771 5.37229031,24 12,24 C18
 .6273771,24 24,18.6273771 24,11.9996673 C24,5.37229031 18.6273771,0 12,0 C5.37229031,0 0,5.37229031 0,11.9996673 Z"/>
+</svg>
\ No newline at end of file
diff --git a/browser/components/torconnect/content/torBootstrapUrlbar.js b/browser/components/torconnect/content/torBootstrapUrlbar.js
new file mode 100644
index 000000000000..55a595b2dbab
--- /dev/null
+++ b/browser/components/torconnect/content/torBootstrapUrlbar.js
@@ -0,0 +1,136 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
+"use strict";
+
+ const TorConnectionStatus = {
+   invalid: -1,
+   offline: 0,
+   connecting: 1,
+   connected: 2,
+   failure: 3,
+ };
+var TorBootstrapUrlbar;
+
+{
+  const { TorProtocolService } = ChromeUtils.import(
+    "resource:///modules/TorProtocolService.jsm"
+  );
+  const { TorLauncherUtil } = ChromeUtils.import(
+    "resource://torlauncher/modules/tl-util.jsm"
+  );
+  const { TorStrings } = ChromeUtils.import(
+    "resource:///modules/TorStrings.jsm"
+  );
+
+  const kTorProcessReadyTopic = "TorProcessIsReady";
+  const kTorProcessExitedTopic = "TorProcessExited";
+  const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
+  const kTorBootstrapStatusTopic = "TorBootstrapStatus";
+  const kTorBootstrapErrorTopic = "TorBootstrapError";
+
+  const gActiveTopics = [
+    kTorProcessReadyTopic,
+    kTorProcessExitedTopic,
+    kTorProcessDidNotStartTopic,
+    kTorBootstrapStatusTopic,
+    kTorBootstrapErrorTopic,
+  ];
+
+  TorBootstrapUrlbar = {
+    _connectionStatus: TorConnectionStatus.invalid,
+    get ConnectionStatus() {
+      return this._connectionStatus;
+    },
+
+    _torConnectBox : null,
+    get TorConnectBox() {
+      if (!this._torConnectBox) {
+        this._torConnectBox =
+          browser.ownerGlobal.document.getElementById("torconnect-box");
+      }
+      return this._torConnectBox;
+    },
+
+    _torConnectLabel : null,
+    get TorConnectLabel() {
+      if (!this._torConnectLabel) {
+        this._torConnectLabel =
+          browser.ownerGlobal.document.getElementById("torconnect-label");
+      }
+      return this._torConnectLabel;
+    },
+
+    _updateConnectionStatus(percentComplete = 0) {
+      if (TorProtocolService.ownsTorDaemon &&
+          !TorLauncherUtil.useLegacyLauncher) {
+        if (TorProtocolService.isNetworkDisabled()) {
+            if (TorProtocolService.torBootstrapErrorOccurred()) {
+              this._connectionStatus = TorConnectionStatus.failure;
+            } else {
+              this._connectionStatus = TorConnectionStatus.offline;
+            }
+        } else if (percentComplete < 100) {
+          this._connectionStatus = TorConnectionStatus.connecting;
+        } else if (percentComplete === 100) {
+          this._connectionStatus = TorConnectionStatus.connected;
+        }
+      }
+      else
+      {
+        this._connectionStatus = TorConnectionStatus.invalid;
+      }
+
+      switch(this._connectionStatus)
+      {
+        case TorConnectionStatus.failure:
+        case TorConnectionStatus.offline:
+          this.TorConnectBox.removeAttribute("hidden");
+          this.TorConnectLabel.textContent = TorStrings.torConnect.offline;
+          gURLBar._inputContainer.setAttribute("torconnect", "offline");
+          break;
+        case TorConnectionStatus.connecting:
+          this.TorConnectLabel.textContent =
+            TorStrings.torConnect.torConnectingConcise;
+          gURLBar._inputContainer.setAttribute("torconnect", "connecting");
+          break;
+        case TorConnectionStatus.connected:
+          this.TorConnectLabel.textContent =
+            TorStrings.torConnect.torConnectedConcise;
+          gURLBar._inputContainer.setAttribute("torconnect", "connected");
+          // hide torconnect box after 5 seconds
+          let self = this;
+          setTimeout(function() {
+            self.TorConnectBox.setAttribute("hidden", "true");
+          }, 5000);
+          break;
+      }
+    },
+
+    observe(aSubject, aTopic, aData) {
+      const obj = aSubject?.wrappedJSObject;
+
+      switch (aTopic) {
+        case kTorProcessReadyTopic:
+        case kTorProcessExitedTopic:
+        case kTorProcessDidNotStartTopic:
+        case kTorBootstrapErrorTopic:
+          this._updateConnectionStatus();
+          break;
+        case kTorBootstrapStatusTopic:
+          let percentComplete = obj.PROGRESS ? obj.PROGRESS : 0;
+          this._updateConnectionStatus(percentComplete);
+          break;
+      }
+    },
+    init() {
+      for (const topic of gActiveTopics) {
+        Services.obs.addObserver(this, topic);
+      }
+    },
+    uninit() {
+      for (const topic of gActiveTopics) {
+        Services.obs.removeObserver(this, topic);
+      }
+    },
+  };
+}
diff --git a/browser/components/torconnect/content/torconnect-urlbar.css b/browser/components/torconnect/content/torconnect-urlbar.css
new file mode 100644
index 000000000000..db2f1069b22b
--- /dev/null
+++ b/browser/components/torconnect/content/torconnect-urlbar.css
@@ -0,0 +1,65 @@
+/*
+    ensure our torconnect button is always visible (same rule as for the bookmark button)
+*/
+hbox.urlbar-page-action#torconnect-box {
+    display: -moz-inline-box!important;
+    margin: 0 6px;
+    height: 28px;
+}
+/* disable the button-like default css */
+hbox.urlbar-page-action#torconnect-box:hover,
+hbox.urlbar-page-action#torconnect-box:active {
+    background-color: inherit!important;
+}
+
+label#torconnect-label {
+    line-height: 28px;
+    margin: 0;
+    opacity: 0.6;
+}
+
+/* set appropriate sizes for the non-standard ui densities */
+:root[uidensity=compact] {
+    hbox.urlbar-page-action#torconnect-box {
+        margin: 0 4px;
+        height: 24px;
+    }
+    label#torconnect-label {
+        line-height: 24px;
+    }
+}
+:root[uidensity=touch] {
+    hbox.urlbar-page-action#torconnect-box {
+        margin: 0 7px;
+        height: 30px;
+    }
+    label#torconnect-label {
+        line-height: 30px;
+    }
+}
+
+/* hide when hidden attribute is set */
+hbox.urlbar-page-action#torconnect-box[hidden="true"],
+/* hide when user is typing in URL bar */
+#urlbar[usertyping] > #urlbar-input-container > #page-action-buttons > #torconnect-box {
+    display: none!important;
+}
+
+/* hide urlbar's placeholder text when not connectd to tor */
+hbox#urlbar-input-container[torconnect="offline"] input#urlbar-input::placeholder,
+hbox#urlbar-input-container[torconnect="connecting"] input#urlbar-input::placeholder {
+    opacity: 0;
+}
+
+/* hide search suggestions when not connected to tor */
+hbox#urlbar-input-container[torconnect="offline"] + vbox.urlbarView,
+hbox#urlbar-input-container[torconnect="connecting"] + vbox.urlbarView {
+    display: none!important;
+}
+
+/* hide search icon when we are not connected to tor */
+hbox#urlbar-input-container[torconnect="offline"] > #identity-box[pageproxystate="invalid"] > #identity-icon,
+hbox#urlbar-input-container[torconnect="connecting"] > #identity-box[pageproxystate="invalid"] > #identity-icon
+{
+    display: none!important;
+}
diff --git a/browser/components/torconnect/content/torconnect-urlbar.inc.xhtml b/browser/components/torconnect/content/torconnect-urlbar.inc.xhtml
new file mode 100644
index 000000000000..bdf9d8f0df00
--- /dev/null
+++ b/browser/components/torconnect/content/torconnect-urlbar.inc.xhtml
@@ -0,0 +1,11 @@
+# Copyright (c) 2021, The Tor Project, Inc.
+
+<hbox id="torconnect-box"
+      class="urlbar-icon-wrapper urlbar-page-action"
+      role="status"
+      hidden="true">
+    <image id="torconnect-button" role="presentation"/>
+    <hbox id="torconnect-container">
+        <label id="torconnect-label"/>
+    </hbox>
+</hbox>
\ No newline at end of file
diff --git a/browser/components/torconnect/jar.mn b/browser/components/torconnect/jar.mn
new file mode 100644
index 000000000000..ed8a4de299b2
--- /dev/null
+++ b/browser/components/torconnect/jar.mn
@@ -0,0 +1,7 @@
+browser.jar:
+    content/browser/torconnect/torBootstrapUrlbar.js               (content/torBootstrapUrlbar.js)
+    content/browser/torconnect/aboutTorConnect.css                 (content/aboutTorConnect.css)
+*   content/browser/torconnect/aboutTorConnect.xhtml               (content/aboutTorConnect.xhtml)
+    content/browser/torconnect/aboutTorConnect.js                  (content/aboutTorConnect.js)
+    content/browser/torconnect/onion.svg                           (content/onion.svg)
+    content/browser/torconnect/onion-slash.svg                     (content/onion-slash.svg)
diff --git a/browser/components/torconnect/moz.build b/browser/components/torconnect/moz.build
new file mode 100644
index 000000000000..eb29c31a4243
--- /dev/null
+++ b/browser/components/torconnect/moz.build
@@ -0,0 +1,6 @@
+JAR_MANIFESTS += ['jar.mn']
+
+EXTRA_JS_MODULES += [
+    'TorConnectChild.jsm',
+    'TorConnectParent.jsm',
+]
diff --git a/browser/components/torpreferences/content/torPane.js b/browser/components/torpreferences/content/torPane.js
index 49054b5dac6a..01609ddda090 100644
--- a/browser/components/torpreferences/content/torPane.js
+++ b/browser/components/torpreferences/content/torPane.js
@@ -1,5 +1,7 @@
 "use strict";
 
+/* global Services */
+
 const { TorProtocolService } = ChromeUtils.import(
   "resource:///modules/TorProtocolService.jsm"
 );
@@ -51,6 +53,10 @@ const { parsePort, parseBridgeStrings, parsePortList } = ChromeUtils.import(
   "chrome://browser/content/torpreferences/parseFunctions.jsm"
 );
 
+const TorLauncherPrefs = {
+  quickstart: "extensions.torlauncher.quickstart",
+}
+
 /*
   Tor Pane
 
@@ -62,11 +68,21 @@ const gTorPane = (function() {
     category: {
       title: "label#torPreferences-labelCategory",
     },
+    messageBox: {
+      box: "div#torPreferences-connectMessageBox",
+      message: "td#torPreferences-connectMessageBox-message",
+      button: "button#torPreferences-connectMessageBox-button",
+    },
     torPreferences: {
       header: "h1#torPreferences-header",
       description: "span#torPreferences-description",
       learnMore: "label#torPreferences-learnMore",
     },
+    quickstart: {
+      header: "h2#torPreferences-quickstart-header",
+      description: "span#torPreferences-quickstart-description",
+      enableQuickstartCheckbox: "checkbox#torPreferences-quickstart-toggle",
+    },
     bridges: {
       header: "h2#torPreferences-bridges-header",
       description: "span#torPreferences-bridges-description",
@@ -112,6 +128,10 @@ const gTorPane = (function() {
 
   let retval = {
     // cached frequently accessed DOM elements
+    _messageBox: null,
+    _messageBoxMessage: null,
+    _messageBoxButton: null,
+    _enableQuickstartCheckbox: null,
     _useBridgeCheckbox: null,
     _bridgeSelectionRadiogroup: null,
     _builtinBridgeOption: null,
@@ -161,6 +181,43 @@ const gTorPane = (function() {
 
       let prefpane = document.getElementById("mainPrefPane");
 
+      // 'Connect to Tor' Message Bar
+
+      this._messageBox = prefpane.querySelector(selectors.messageBox.box);
+      this._messageBoxMessage = prefpane.querySelector(selectors.messageBox.message);
+      this._messageBoxButton = prefpane.querySelector(selectors.messageBox.button);
+      // wire up connect button
+      this._messageBoxButton.addEventListener("click", () => {
+        TorProtocolService.connect();
+        let win = Services.wm.getMostRecentWindow("navigator:browser");
+        // switch to existing about:torconnect tab or create a new one
+        win.switchToTabHavingURI("about:torconnect", true);
+      });
+
+      let populateMessagebox = () => {
+        if (TorProtocolService.shouldShowTorConnect()) {
+          // set messagebox style and text
+          if (TorProtocolService.torBootstrapErrorOccurred()) {
+            this._messageBox.className = "error";
+            this._messageBoxMessage.innerText = TorStrings.torConnect.tryAgainMessage;
+            this._messageBoxButton.innerText = TorStrings.torConnect.tryAgain;
+          } else {
+            this._messageBox.className = "warning";
+            this._messageBoxMessage.innerText = TorStrings.torConnect.connectMessage;
+            this._messageBoxButton.innerText = TorStrings.torConnect.torConnectButton;
+          }
+        } else {
+          this._messageBox.className = "hidden";
+          this._messageBoxMessage.innerText = "";
+          this._messageBoxButton.innerText = "";
+        }
+      }
+      populateMessagebox();
+      // update the messagebox whenever we come back to the page
+      window.addEventListener("focus", val => {
+        populateMessagebox();
+      });
+
       // Heading
       prefpane.querySelector(selectors.torPreferences.header).innerText =
         TorStrings.settings.torPreferencesHeading;
@@ -177,6 +234,26 @@ const gTorPane = (function() {
         );
       }
 
+      // Quickstart
+      prefpane.querySelector(selectors.quickstart.header).innerText =
+        TorStrings.settings.quickstartHeading;
+      prefpane.querySelector(selectors.quickstart.description).textContent =
+        TorStrings.settings.quickstartDescription;
+
+      this._enableQuickstartCheckbox = prefpane.querySelector(
+        selectors.quickstart.enableQuickstartCheckbox
+      );
+      this._enableQuickstartCheckbox.setAttribute(
+        "label",
+        TorStrings.settings.quickstartCheckbox
+      );
+      this._enableQuickstartCheckbox.addEventListener("command", e => {
+        const checked = this._enableQuickstartCheckbox.checked;
+        Services.prefs.setBoolPref(TorLauncherPrefs.quickstart, checked);
+      });
+      this._enableQuickstartCheckbox.checked = Services.prefs.getBoolPref(TorLauncherPrefs.quickstart);
+      Services.prefs.addObserver(TorLauncherPrefs.quickstart, this);
+
       // Bridge setup
       prefpane.querySelector(selectors.bridges.header).innerText =
         TorStrings.settings.bridgesHeading;
@@ -537,6 +614,15 @@ const gTorPane = (function() {
     // Callbacks
     //
 
+    // callback for when the quickstart pref changes
+    observe(subject, topic, data) {
+      if (topic != "nsPref:changed") return;
+      if (data === TorLauncherPrefs.quickstart) {
+        this._enableQuickstartCheckbox.checked =
+          Services.prefs.getBoolPref(TorLauncherPrefs.quickstart);
+      }
+    },
+
     // callback when using bridges toggled
     onToggleBridge(enabled) {
       this._useBridgeCheckbox.checked = enabled;
diff --git a/browser/components/torpreferences/content/torPane.xhtml b/browser/components/torpreferences/content/torPane.xhtml
index 3c966b2b3726..7c8071f2cf10 100644
--- a/browser/components/torpreferences/content/torPane.xhtml
+++ b/browser/components/torpreferences/content/torPane.xhtml
@@ -3,6 +3,29 @@
 <script type="application/javascript"
         src="chrome://browser/content/torpreferences/torPane.js"/>
 <html:template id="template-paneTor">
+
+<!-- Tor Connect Message Box -->
+<groupbox data-category="paneTor" hidden="true">
+  <html:div id="torPreferences-connectMessageBox"
+            class="subcategory"
+            data-category="paneTor"
+            hidden="true">
+    <html:table >
+      <html:tr>
+        <html:td>
+          <html:div id="torPreferences-connectMessageBox-icon"/>
+        </html:td>
+        <html:td id="torPreferences-connectMessageBox-message">
+        </html:td>
+        <html:td>
+          <html:button id="torPreferences-connectMessageBox-button">
+          </html:button>
+        </html:td>
+      </html:tr>
+    </html:table>
+  </html:div>
+</groupbox>
+
 <hbox id="torPreferencesCategory"
       class="subcategory"
       data-category="paneTor"
@@ -18,6 +41,17 @@
   </description>
 </groupbox>
 
+<!-- Quickstart -->
+<groupbox id="torPreferences-quickstart-group"
+          data-category="paneTor"
+          hidden="true">
+  <html:h2 id="torPreferences-quickstart-header"/>
+  <description flex="1">
+    <html:span id="torPreferences-quickstart-description"/>
+  </description>
+  <checkbox id="torPreferences-quickstart-toggle"/>
+</groupbox>
+
 <!-- Bridges -->
 <groupbox id="torPreferences-bridges-group"
           data-category="paneTor"
diff --git a/browser/components/torpreferences/content/torPreferences.css b/browser/components/torpreferences/content/torPreferences.css
index 4dac2c457823..f125936dac74 100644
--- a/browser/components/torpreferences/content/torPreferences.css
+++ b/browser/components/torpreferences/content/torPreferences.css
@@ -2,6 +2,127 @@
   list-style-image: url("chrome://browser/content/torpreferences/torPreferencesIcon.svg");
 }
 
+/* Connect Message Box */
+
+#torPreferences-connectMessageBox {
+  display: block;
+  position: relative;
+
+  width: auto;
+  min-height: 32px;
+  border-radius: 4px;
+  padding: 4px;
+}
+
+#torPreferences-connectMessageBox.hidden {
+  display: none;
+}
+
+#torPreferences-connectMessageBox.error {
+  background-color: var(--red-60);
+  color: white;
+}
+
+#torPreferences-connectMessageBox.warning {
+  background-color: var(--yellow-50);
+  color: var(--yellow-90);
+}
+
+#torPreferences-connectMessageBox table {
+  border-collapse: collapse;
+  width: 100%;
+}
+
+#torPreferences-connectMessageBox td {
+  vertical-align: top;
+  padding: 0px;
+}
+
+#torPreferences-connectMessageBox td:first-child {
+  width: 24px;
+}
+
+#torPreferences-connectMessageBox-icon {
+  display: block;
+  width: 16px;
+  height: 16px;
+  padding: 4px;
+
+  mask-repeat: no-repeat !important;
+  mask-size: 16px !important;
+  mask-position: 4px 4px !important;
+}
+
+#torPreferences-connectMessageBox.error #torPreferences-connectMessageBox-icon
+{
+  mask: url("chrome://browser/skin/onion-slash.svg");
+  background-color: white;
+}
+
+#torPreferences-connectMessageBox.warning #torPreferences-connectMessageBox-icon
+{
+  mask: url("chrome://global/skin/icons/warning.svg");
+  background-color: black;
+}
+
+#torPreferences-connectMessageBox-message {
+  display: block;
+  line-height: 16px;
+  font-size: 13px;
+  margin-right: 8px;
+  padding-left: 4px!important;
+  padding-top: 4px!important;
+}
+
+#torPreferences-connectMessageBox-button {
+  display: block;
+  width: auto;
+  height: 24px;
+  line-height: 24px;
+  min-height: 24px;
+  max-height: 24px;
+  margin: 0px;
+
+  border-radius: 2px;
+  border: 0;
+  padding-left: 8px;
+  padding-right: 8px;
+  margin-left: auto;
+  margin-right: 0px;
+
+  font-size: 11px;
+  font-weight: 400;
+  white-space: nowrap;
+}
+
+#torPreferences-connectMessageBox.error #torPreferences-connectMessageBox-button {
+  background-color: var(--red-70);
+}
+
+#torPreferences-connectMessageBox.error #torPreferences-connectMessageBox-button:hover {
+  background-color: var(--red-80);
+}
+
+#torPreferences-connectMessageBox.error #torPreferences-connectMessageBox-button:active {
+  background-color: var(--red-90);
+}
+
+#torPreferences-connectMessageBox.warning #torPreferences-connectMessageBox-button {
+  background-color: var(--yellow-60);
+}
+
+#torPreferences-connectMessageBox.warning #torPreferences-connectMessageBox-button:hover {
+  background-color: var(--yellow-70);
+  color: white!important;
+}
+
+#torPreferences-connectMessageBox.warning #torPreferences-connectMessageBox-button:active {
+  background-color: var(--yellow-80);
+  color: white!important;
+}
+
+/* Advanced Settings */
+
 #torPreferences-advanced-grid {
   display: grid;
   grid-template-columns: auto 1fr;
diff --git a/browser/components/urlbar/UrlbarInput.jsm b/browser/components/urlbar/UrlbarInput.jsm
index 13b1279105f2..f727c386701c 100644
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -10,6 +10,33 @@ const { XPCOMUtils } = ChromeUtils.import(
   "resource://gre/modules/XPCOMUtils.jsm"
 );
 
+const { TorProtocolService } = ChromeUtils.import(
+  "resource:///modules/TorProtocolService.jsm"
+);
+
+// in certain scenarios we want user input uris to open in a new tab if they do so from the
+// about:torconnect tab 
+function maybeUpdateOpenLocationForTorConnect(openUILinkWhere, currentURI, destinationURI) {
+  try {
+    // only open in new tab if:
+    if (// user is navigating away from about:torconnect
+        currentURI === "about:torconnect" &&
+        // we are trying to open in same tab
+        openUILinkWhere === "current" &&
+        // only if user still has not bootstrapped
+        TorProtocolService.shouldShowTorConnect() &&
+        // and user is not just navigating to about:torconnect
+        destinationURI !== "about:torconnect") {
+      return "tab";
+    }
+  } catch (e) {
+    // swallow exception and fall through returning original so we don't accidentally break
+    // anything if an exception is thrown
+  }
+
+  return openUILinkWhere;
+};
+
 XPCOMUtils.defineLazyModuleGetters(this, {
   AppConstants: "resource://gre/modules/AppConstants.jsm",
   BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
@@ -1832,6 +1859,10 @@ class UrlbarInput {
     // area when the current tab is re-selected.
     browser.focus();
 
+    openUILinkWhere = maybeUpdateOpenLocationForTorConnect(
+                        openUILinkWhere,
+                        this.window.gBrowser.currentURI.asciiSpec,
+                        url);
     if (openUILinkWhere != "current") {
       this.handleRevert();
     }
diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm
new file mode 100644
index 000000000000..3125c84558db
--- /dev/null
+++ b/browser/modules/TorConnect.jsm
@@ -0,0 +1,62 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["TorConnect"];
+
+const { Services } = ChromeUtils.import(
+    "resource://gre/modules/Services.jsm"
+);
+
+const { BrowserWindowTracker } = ChromeUtils.import(
+    "resource:///modules/BrowserWindowTracker.jsm"
+);
+
+const { TorProtocolService } = ChromeUtils.import(
+    "resource:///modules/TorProtocolService.jsm"
+);
+
+// TODO: move the bootstrap state management out of each of the individual
+// about:torconnect pages and stick it here
+var TorConnect = (() => {
+    let retval = {
+        init : function() {
+            let topics = [
+                "TorBootstrapStatus",
+            ];
+
+            for(const topic of topics) {
+                Services.obs.addObserver(this, topic);
+            }
+        },
+
+        observe: function(subject, topic, data) {
+            switch(topic) {
+            case "TorBootstrapStatus":
+                const obj = subject?.wrappedJSObject;
+                if (obj?.PROGRESS === 100) {
+                    // open home page(s) in new tabs
+                    const win = BrowserWindowTracker.getTopWindow()
+                    const urls = Services.prefs.getStringPref("browser.startup.homepage").split('|');
+
+                    let location="tab";
+                    for(const url of urls) {
+                        win.openTrustedLinkIn(url, location);
+                        // open subsequent tabs behind first tab
+                        location = "tabshifted";
+                    }
+
+                    Services.obs.notifyObservers(null, "torconnect:bootstrap-complete");
+                }
+                break;
+            default:
+                // ignore
+                break;
+            }
+        },
+
+        shouldShowTorConnect : function() {
+            return TorProtocolService.shouldShowTorConnect();
+        },
+    };
+    retval.init();
+    return retval;
+})(); /* TorConnect */
\ No newline at end of file
diff --git a/browser/modules/TorProcessService.jsm b/browser/modules/TorProcessService.jsm
new file mode 100644
index 000000000000..201e331b2806
--- /dev/null
+++ b/browser/modules/TorProcessService.jsm
@@ -0,0 +1,12 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["TorProcessService"];
+
+var TorProcessService = {
+  get isBootstrapDone() {
+    const svc = Cc["@torproject.org/torlauncher-process-service;1"].getService(
+      Ci.nsISupports
+    ).wrappedJSObject;
+    return svc.mIsBootstrapDone;
+  },
+};
diff --git a/browser/modules/TorProtocolService.jsm b/browser/modules/TorProtocolService.jsm
index b4e6ed9a3253..fc7f2c884aa2 100644
--- a/browser/modules/TorProtocolService.jsm
+++ b/browser/modules/TorProtocolService.jsm
@@ -1,3 +1,5 @@
+// Copyright (c) 2021, The Tor Project, Inc.
+
 "use strict";
 
 var EXPORTED_SYMBOLS = ["TorProtocolService"];
@@ -11,6 +13,10 @@ var TorProtocolService = {
     Ci.nsISupports
   ).wrappedJSObject,
 
+  _tlproc: Cc["@torproject.org/torlauncher-process-service;1"].getService(
+    Ci.nsISupports
+  ).wrappedJSObject,
+
   // maintain a map of tor settings set by Tor Browser so that we don't
   // repeatedly set the same key/values over and over
   // this map contains string keys to primitive or array values
@@ -196,11 +202,11 @@ var TorProtocolService = {
 
   // writes current tor settings to disk
   flushSettings() {
-    this._tlps.TorSendCommand("SAVECONF");
+    this.sendCommand("SAVECONF");
   },
 
-  getLog() {
-    let countObj = { value: 0 };
+  getLog(countObj) {
+    countObj = countObj || { value: 0 };
     let torLog = this._tlps.TorGetLog(countObj);
     return torLog;
   },
@@ -209,4 +215,116 @@ var TorProtocolService = {
   get ownsTorDaemon() {
     return TorLauncherUtil.shouldStartAndOwnTor;
   },
+
+  // Assumes `ownsTorDaemon` is true
+  isNetworkDisabled() {
+    const reply = TorProtocolService._tlps.TorGetConfBool(
+      "DisableNetwork",
+      true
+    );
+    if (TorProtocolService._tlps.TorCommandSucceeded(reply)) {
+      return reply.retVal;
+    }
+    return true;
+  },
+
+  enableNetwork() {
+    let settings = {};
+    settings.DisableNetwork = false;
+    let errorObject = {};
+    if (!this._tlps.TorSetConfWithReply(settings, errorObject)) {
+      throw new Error(errorObject.details);
+    }
+  },
+
+  sendCommand(cmd) {
+    return this._tlps.TorSendCommand(cmd);
+  },
+
+  retrieveBootstrapStatus() {
+    return this._tlps.TorRetrieveBootstrapStatus();
+  },
+
+  _GetSaveSettingsErrorMessage(aDetails) {
+    try {
+      return TorLauncherUtil.getSaveSettingsErrorMessage(aDetails);
+    } catch (e) {
+      console.log("GetSaveSettingsErrorMessage error", e);
+      return "Unexpected Error";
+    }
+  },
+
+  setConfWithReply(settings) {
+    let result = false;
+    const error = {};
+    try {
+      result = this._tlps.TorSetConfWithReply(settings, error);
+    } catch (e) {
+      console.log("TorSetConfWithReply error", e);
+      error.details = this._GetSaveSettingsErrorMessage(e.message);
+    }
+    return { result, error };
+  },
+
+  isBootstrapDone() {
+    return this._tlproc.mIsBootstrapDone;
+  },
+
+  clearBootstrapError() {
+    return this._tlproc.TorClearBootstrapError();
+  },
+
+  shouldShowTorConnect() {
+    return (
+      this.ownsTorDaemon &&
+      !TorLauncherUtil.useLegacyLauncher &&
+      (this.isNetworkDisabled() || !this.isBootstrapDone())
+    );
+  },
+
+  torBootstrapErrorOccurred() {
+    return this._tlproc.TorBootstrapErrorOccurred;
+  },
+
+  // Resolves to null if ok, or an error otherwise
+  connect() {
+    const kTorConfKeyDisableNetwork = "DisableNetwork";
+    const settings = {};
+    settings[kTorConfKeyDisableNetwork] = false;
+    const { result, error } = this.setConfWithReply(settings);
+    if (!result) {
+      return error;
+    }
+    try {
+      this.sendCommand("SAVECONF");
+      this.clearBootstrapError();
+      this.retrieveBootstrapStatus();
+    } catch (e) {
+      return error;
+    }
+    return null;
+  },
+
+  torLogHasWarnOrErr() {
+    return this._tlps.TorLogHasWarnOrErr;
+  },
+
+  torStopBootstrap() {
+    // Tell tor to disable use of the network; this should stop the bootstrap
+    // process.
+    const kErrorPrefix = "Setting DisableNetwork=1 failed: ";
+    try {
+      let settings = {};
+      settings.DisableNetwork = true;
+      const { result, error } = this.setConfWithReply(settings);
+      if (!result) {
+        console.log(
+          `Error stopping bootstrap ${kErrorPrefix} ${error.details}`
+        );
+      }
+    } catch (e) {
+      console.log(`Error stopping bootstrap ${kErrorPrefix} ${e}`);
+    }
+    this.retrieveBootstrapStatus();
+  },
 };
diff --git a/browser/modules/TorStrings.jsm b/browser/modules/TorStrings.jsm
index 1e08b168e4af..c086d0fe3117 100644
--- a/browser/modules/TorStrings.jsm
+++ b/browser/modules/TorStrings.jsm
@@ -257,6 +257,9 @@ var TorStrings = {
         "Tor Browser routes your traffic over the Tor Network, run by thousands of volunteers around the world."
       ),
       learnMore: getString("torPreferences.learnMore", "Learn More"),
+      quickstartHeading: getString("torPreferences.quickstart", "Quickstart"),
+      quickstartDescription: getString("torPreferences.quickstartDescription", "Quickstart allows Tor Browser to connect automatically."),
+      quickstartCheckbox : getString("torPreferences.quickstartCheckbox", "Always connect automatically"),
       bridgesHeading: getString("torPreferences.bridges", "Bridges"),
       bridgesDescription: getString(
         "torPreferences.bridgesDescription",
@@ -364,6 +367,78 @@ var TorStrings = {
     return retval;
   })() /* Tor Network Settings Strings */,
 
+  torConnect: (() => {
+    const tsbNetwork = new TorDTDStringBundle(
+      ["chrome://torlauncher/locale/network-settings.dtd"],
+      ""
+    );
+    const tsbLauncher = new TorPropertyStringBundle(
+      "chrome://torlauncher/locale/torlauncher.properties",
+      "torlauncher."
+    );
+    const tsbCommon = new TorPropertyStringBundle(
+      "chrome://global/locale/commonDialogs.properties",
+      ""
+    );
+
+    const getStringNet = tsbNetwork.getString.bind(tsbNetwork);
+    const getStringLauncher = tsbLauncher.getString.bind(tsbLauncher);
+    const getStringCommon = tsbCommon.getString.bind(tsbCommon);
+
+    return {
+      torConnect: getStringNet(
+        "torsettings.wizard.title.default",
+        "Connect to Tor"
+      ),
+
+      torConnecting: getStringNet(
+        "torsettings.wizard.title.connecting",
+        "Establishing a Connection"
+      ),
+
+      torConnectingConcise: getStringNet(
+        "torConnect.connectingConcise",
+        "Connecting…"
+      ),
+
+      torBootstrapFailed: getStringLauncher(
+        "tor_bootstrap_failed",
+        "Tor failed to establish a Tor network connection."
+      ),
+
+      torConfigure: getStringNet(
+        "torsettings.wizard.title.configure",
+        "Tor Network Settings"
+      ),
+
+      copyLog: getStringNet(
+        "torConnect.copyLog",
+        "Copy Tor Logs"
+      ),
+
+      torConnectButton: getStringNet("torSettings.connect", "Connect"),
+
+      cancel: getStringCommon("Cancel", "Cancel"),
+
+      torConnected: getStringLauncher(
+        "torlauncher.bootstrapStatus.done",
+        "Connected to the Tor network"
+      ),
+
+      torConnectedConcise: getStringLauncher(
+        "torConnect.connectedConcise",
+        "Connected"
+      ),
+
+      tryAgain: getStringNet("torConnect.tryAgain", "Try connecting again"),
+      offline: getStringNet("torConnect.offline", "Offline"),
+
+      // tor connect strings for message box in about:preferences#tor
+      connectMessage: getStringNet("torConnect.connectMessage", "Changes to Tor Settings will not take effect until you connect to the Tor Network"),
+      tryAgainMessage: getStringNet("torConnect.tryAgainMessage", "Tor Browser has failed to establish a connection to the Tor Network"),
+    };
+  })(),
+
   /*
     Tor Onion Services Strings, e.g., for the authentication prompt.
   */
diff --git a/browser/modules/moz.build b/browser/modules/moz.build
index 5fb78d1c07a8..7f091e0e7711 100644
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -155,6 +155,8 @@ EXTRA_JS_MODULES += [
     'TabUnloader.jsm',
     'ThemeVariableMap.jsm',
     'TopSiteAttribution.jsm',
+    'TorConnect.jsm',
+    'TorProcessService.jsm',
     'TorProtocolService.jsm',
     'TorStrings.jsm',
     'TransientPrefs.jsm',
diff --git a/browser/themes/shared/jar.inc.mn b/browser/themes/shared/jar.inc.mn
index e4a3c8d2d41c..d38e1001282b 100644
--- a/browser/themes/shared/jar.inc.mn
+++ b/browser/themes/shared/jar.inc.mn
@@ -8,6 +8,7 @@
 # to the location of the actual manifest.
 
   skin/classic/browser/aboutNetError.css                       (../shared/aboutNetError.css)
+  skin/classic/browser/onionPattern.css                        (../shared/onionPattern.css)
   skin/classic/browser/blockedSite.css                         (../shared/blockedSite.css)
   skin/classic/browser/error-pages.css                         (../shared/error-pages.css)
   skin/classic/browser/aboutRestartRequired.css                (../shared/aboutRestartRequired.css)
diff --git a/browser/themes/shared/onionPattern.css b/browser/themes/shared/onionPattern.css
new file mode 100644
index 000000000000..c605a4b4f59e
--- /dev/null
+++ b/browser/themes/shared/onionPattern.css
@@ -0,0 +1,124 @@
+/* Onion pattern */
+
+:root {
+  --sqrt3: 1.73205080757;
+}
+
+.onion-pattern-container {
+  opacity: var(--onion-opacity, 1);
+  flex: auto;           /* grow to consume remaining space on the page */
+  display: flex;
+  margin: 0 auto;
+  width: 100%;
+  height: calc((2 + var(--sqrt3)) * var(--onion-radius, 50px));    /* room for 2 rows of circles */
+  max-height: calc((2 + var(--sqrt3)) * var(--onion-radius, 50px));
+  direction: ltr;
+}
+
+.onion-pattern-crop {
+  display: flex;
+  justify-content: center;
+  overflow-x: hidden;
+  pointer-events: none; /* for some reason, elements with overflow-x: hidden set become focusable */
+
+  margin: 0 auto;
+}
+
+/* Centers horizontally within the root container*/
+.onion-pattern-column {
+  width: calc(40 * var(--onion-radius, 50px)); /* room for 20 circles in a row */
+  height: calc((2 + var(--sqrt3)) * var(--onion-radius, 50px)); /* room for 2 rows of circles */
+  flex-shrink: 0;
+  overflow-x: hidden;   /* clip extra circles on the sides */
+  pointer-events: none; /* for some reason, elements with overflow-x: hidden set become focusable */
+}
+
+.onion-pattern-row {
+  width: calc(40 * var(--onion-radius, 50px)); /* room for 20 circles in a row */
+  display: flex;
+  flex-direction: row;
+  position: relative;
+}
+
+.onion-pattern-offset-row {
+  left: calc(-1 * var(--onion-radius, 50px));
+  margin-top: calc((var(--sqrt3) - 2.0) * var(--onion-radius, 50px));
+}
+
+/* With borders, circles are 100x100 pixels*/
+.circle {
+  position: relative;
+  min-width: calc(2 * var(--onion-radius, 50px));
+  min-height: calc(2 * var(--onion-radius, 50px));
+  border-radius: 50%;
+  box-sizing: border-box;
+}
+
+.inner {
+  position: absolute;
+  box-sizing: border-box;
+  border-radius: 50%;
+}
+
+.inner:nth-child(1){
+  width: 100%;
+  height: 100%;
+}
+
+.inner:nth-child(2){
+  transform: translate(20%, 20%);
+  width: calc(100% * 5/7);
+  height: calc(100% * 5/7);
+}
+
+.inner:nth-child(3){
+  transform: translate(calc(100% * 2/3), calc(100% * 2/3));
+  width: calc(100% * 3/7);
+  height: calc(100% * 3/7);
+}
+
+.inner:nth-child(4){
+  transform: translate(300%, 300%);
+  width: calc(100% * 1/7);
+  height: calc(100% * 1/7);
+}
+
+.solid {
+  background-color: var(--onion-color, #000);
+}
+
+.border {
+  border: 4px solid var(--onion-color, #000);
+}
+
+.dashed {
+  border: 4px dashed var(--onion-color, #000);
+}
+
+.dotted {
+  border: 4px dotted var(--onion-color, #000);
+}
+
+.bold {
+  border: 8px solid var(--onion-color, #000);
+}
+
+.top-half {
+  width: calc(2 * var(--onion-radius, 50px));
+  height: var(--onion-radius, 50px);
+  border-radius: var(--onion-radius, 50px) var(--onion-radius, 50px) 0 0;
+  box-sizing: border-box;
+}
+
+.bottom-half {
+  width: calc(2 * var(--onion-radius, 50px));
+  height: var(--onion-radius, 50px);
+  border-radius: 0 0 var(--onion-radius, 50px) var(--onion-radius, 50px);
+  box-sizing: border-box;
+}
+
+.scaler {
+  position: absolute;
+  left:0;
+  bottom:0;
+}
\ No newline at end of file
diff --git a/browser/themes/shared/onionPattern.inc.xhtml b/browser/themes/shared/onionPattern.inc.xhtml
new file mode 100644
index 000000000000..6bbde93684a2
--- /dev/null
+++ b/browser/themes/shared/onionPattern.inc.xhtml
@@ -0,0 +1,210 @@
+<!--
+ - The abstract onion pattern begins here. There are two
+ - "onion-pattern-row" elements, each containing 14 circles. The width
+ - of "onion-pattern-row" is fixed at a value that is wide enough so the
+ - circles are not distorted by the flex-based layout. The parent
+ - "onion-pattern-container" element has overflow-x: hidden and is designed
+ - to expand to the width of the page, until it reaches a maximum width
+ - that can accommodate all 14 circles. Since the rows are wider than
+ - most browser windows, typically the two rows of onions will fill the
+ - bottom of the page. On really wide pages, the onions are centered at
+ - the bottom of the page.
+-->
+
+<div class="onion-pattern-container">
+  <!-- for some reason, these two elements are focusable, seems related to
+   - flex css somehow; disable their tabindex to fix
+  -->
+  <div class="onion-pattern-crop" tabindex="-1">
+    <div class="onion-pattern-column" tabindex="-1">
+      <div class="onion-pattern-row">
+        <div class="circle solid"></div>
+
+        <div class="circle dashed"></div>
+
+        <div class="circle">
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+        </div>
+
+        <div class="circle">
+          <div class="bottom-half solid"></div>
+          <div class="bottom-half dotted"></div>
+        </div>
+
+        <div class="circle border"></div>
+
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle solid"></div>
+
+        <div class="circle">
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+        </div>
+
+        <div class="circle bold"></div>
+
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+        </div>
+
+        <div class="circle bold"></div>
+
+        <div class="circle">
+          <div class="bottom-half solid"></div>
+          <div class="bottom-half solid"></div>
+        </div>
+
+       <div class="circle">
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+        </div>
+
+        <div class="circle dotted"></div>
+
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle solid"></div>
+
+        <div class="circle">
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+        </div>
+
+        <div class="circle bold"></div>
+
+        <div class="circle dashed"></div>
+      </div>
+
+      <div class="onion-pattern-row onion-pattern-offset-row">
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+        </div>
+
+        <div class="circle bold"></div>
+
+        <div class="circle solid"></div>
+
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle">
+          <div class="top-half solid"></div>
+          <div class="top-half solid"></div>
+        </div>
+
+        <div class="circle border"></div>
+
+        <div class="circle dotted"></div>
+
+        <div class="circle">
+          <div class="top-half border"></div>
+          <div class="top-half dashed"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+        </div>
+
+        <div class="circle">
+          <div class="top-half dotted"></div>
+          <div class="top-half solid"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+          <div class="inner dashed"></div>
+        </div>
+
+        <div class="circle dotted"></div>
+
+        <div class="circle bold"></div>
+
+        <div class="circle solid"></div>
+
+        <div class="circle">
+          <div class="top-half solid"></div>
+          <div class="top-half dotted"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+          <div class="inner dotted"></div>
+        </div>
+
+        <div class="circle">
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+          <div class="inner border"></div>
+        </div>
+
+        <div class="circle dotted"></div>
+
+        <div class="circle">
+          <div class="top-half solid"></div>
+          <div class="top-half solid"></div>
+        </div>
+
+        <div class="circle dotted"></div>
+      </div>
+    </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/browser/themes/shared/urlbar-searchbar.inc.css b/browser/themes/shared/urlbar-searchbar.inc.css
index d3cc6bf7f024..297dbcdf444d 100644
--- a/browser/themes/shared/urlbar-searchbar.inc.css
+++ b/browser/themes/shared/urlbar-searchbar.inc.css
@@ -826,3 +826,5 @@
 }
 
 %include ../../components/onionservices/content/onionlocation-urlbar.css
+%include ../../components/torconnect/content/torconnect-urlbar.css
+
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
index afc872569519..e74851a6672c 100644
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -16387,9 +16387,56 @@ void Document::RemoveToplevelLoadingDocument(Document* aDoc) {
 
 StylePrefersColorScheme Document::PrefersColorScheme(
     IgnoreRFP aIgnoreRFP) const {
+
+  // tor-browser#27476
+  // should this document ignore resist finger-printing settings with regards to
+  // setting the color scheme
+  // currently only enabled for about:torconnect but we could expand to other non-
+  // SystemPrincipal pages if we wish
+  const auto documentUsesPreferredColorScheme = [](auto const* constDocument) -> bool {
+    if (auto* document = const_cast<Document*>(constDocument); document != nullptr) {
+      auto uri = document->GetDocBaseURI();
+
+      // try and extract out our prepath and filepath portions of the uri to C-strings
+      nsAutoCString prePathStr, filePathStr;
+      if(NS_FAILED(uri->GetPrePath(prePathStr)) ||
+         NS_FAILED(uri->GetFilePath(filePathStr))) {
+        return false;
+      }
+
+      // stick them in string view for easy comparisons
+      std::string_view prePath(prePathStr.get(), prePathStr.Length()),
+                       filePath(filePathStr.get(), filePathStr.Length());
+
+      // these about URIs will have the user's preferred color scheme exposed to them
+      // we can place other URIs here in the future if we wish
+      // see nsIURI.idl for URI part definitions
+      constexpr struct {
+        std::string_view prePath;
+        std::string_view filePath;
+      } allowedURIs[] = {
+        { "about:", "torconnect" },
+      };
+
+      // check each uri in the allow list against this document's uri
+      // verify the prepath and the file path match
+      for(auto const& uri : allowedURIs) {
+        if (prePath == uri.prePath &&
+            filePath == uri.filePath) {
+          // positive match means we can apply dark-mode to the page
+          return true;
+        }
+      }
+    }
+
+    // do not allow if no match or other error
+    return false;
+  };
+
   if (aIgnoreRFP == IgnoreRFP::No &&
-      nsContentUtils::ShouldResistFingerprinting(this)) {
-    return StylePrefersColorScheme::Light;
+      nsContentUtils::ShouldResistFingerprinting(this) &&
+      !documentUsesPreferredColorScheme(this)) {
+      return StylePrefersColorScheme::Light;
   }
 
   if (nsPresContext* pc = GetPresContext()) {
diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp
index abe1e56d9714..759060f131ff 100644
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -6082,6 +6082,8 @@ void nsGlobalWindowOuter::CloseOuter(bool aTrustedCaller) {
     NS_ENSURE_SUCCESS_VOID(rv);
 
     if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
+        // we want about:torconnect pages to be able to close themselves after bootstrap
+        !StringBeginsWith(url, NS_LITERAL_STRING("about:torconnect")) &&
         !HadOriginalOpener() && !aTrustedCaller) {
       bool allowClose =
           mAllowScriptsToClose ||
diff --git a/toolkit/modules/AsyncPrefs.jsm b/toolkit/modules/AsyncPrefs.jsm
index aca86556cd5e..b81ff5e22b9b 100644
--- a/toolkit/modules/AsyncPrefs.jsm
+++ b/toolkit/modules/AsyncPrefs.jsm
@@ -18,6 +18,8 @@ const kAllowedPrefs = new Set([
   "testing.allowed-prefs.some-char-pref",
   "testing.allowed-prefs.some-int-pref",
 
+  "extensions.torlauncher.quickstart",
+
   "narrate.rate",
   "narrate.voice",
 
diff --git a/toolkit/modules/RemotePageAccessManager.jsm b/toolkit/modules/RemotePageAccessManager.jsm
index eceaa7c857de..0927391c2ba7 100644
--- a/toolkit/modules/RemotePageAccessManager.jsm
+++ b/toolkit/modules/RemotePageAccessManager.jsm
@@ -96,6 +96,7 @@ let RemotePageAccessManager = {
       RPMPrefIsLocked: ["security.tls.version.min"],
       RPMAddToHistogram: ["*"],
       RPMGetTorStrings: ["*"],
+      RPMSendQuery: ["ShouldShowTorConnect"],
     },
     "about:newinstall": {
       RPMGetUpdateChannel: ["*"],
@@ -179,6 +180,31 @@ let RemotePageAccessManager = {
       RPMAddMessageListener: ["*"],
       RPMRemoveMessageListener: ["*"],
     },
+    "about:torconnect": {
+      RPMAddMessageListener: ["*"],
+      RPMSendAsyncMessage: [
+        "OpenTorAdvancedPreferences",
+        "TorRetrieveBootstrapStatus",
+        "TorStopBootstrap",
+      ],
+      RPMSendQuery: [
+        "GetDirection",
+        "GetLocalizedBootstrapStatus",
+        "GetTorStrings",
+        "TorBootstrapErrorOccurred",
+        "TorConnect",
+        "TorCopyLog",
+        "TorIsNetworkDisabled",
+        "TorLogHasWarnOrErr",
+      ],
+      RPMGetBoolPref: [
+        "extensions.torlauncher.quickstart",
+        "extensions.torlauncher.prompt_at_startup",
+      ],
+      RPMSetBoolPref: [
+        "extensions.torlauncher.quickstart",
+      ],
+    },
   },
 
   /**
diff --git a/toolkit/mozapps/update/UpdateService.jsm b/toolkit/mozapps/update/UpdateService.jsm
index 1fb397373151..79881cba42d6 100644
--- a/toolkit/mozapps/update/UpdateService.jsm
+++ b/toolkit/mozapps/update/UpdateService.jsm
@@ -12,6 +12,17 @@ const { AppConstants } = ChromeUtils.import(
 const { AUSTLMY } = ChromeUtils.import(
   "resource://gre/modules/UpdateTelemetry.jsm"
 );
+
+const { TorProtocolService } = ChromeUtils.import(
+  "resource:///modules/TorProtocolService.jsm"
+);
+
+function _shouldRegisterBootstrapObserver(errorCode) {
+  return errorCode == PROXY_SERVER_CONNECTION_REFUSED &&
+         !TorProtocolService.isBootstrapDone() &&
+         TorProtocolService.ownsTorDaemon;
+};
+
 const {
   Bits,
   BitsRequest,
@@ -201,6 +212,7 @@ const INVALID_UPDATER_STATUS_CODE = 99;
 // Custom update error codes
 const BACKGROUNDCHECK_MULTIPLE_FAILURES = 110;
 const NETWORK_ERROR_OFFLINE = 111;
+const PROXY_SERVER_CONNECTION_REFUSED = 2152398920;
 
 // Error codes should be < 1000. Errors above 1000 represent http status codes
 const HTTP_ERROR_OFFSET = 1000;
@@ -2220,6 +2232,9 @@ UpdateService.prototype = {
       case "network:offline-status-changed":
         this._offlineStatusChanged(data);
         break;
+      case "torconnect:bootstrap-complete":
+        this._bootstrapComplete();
+        break;
       case "nsPref:changed":
         if (data == PREF_APP_UPDATE_LOG || data == PREF_APP_UPDATE_LOG_FILE) {
           gLogEnabled; // Assigning this before it is lazy-loaded is an error.
@@ -2640,6 +2655,35 @@ UpdateService.prototype = {
     this._attemptResume();
   },
 
+  _registerBootstrapObserver: function AUS__registerBootstrapObserver() {
+    if (this._registeredBootstrapObserver) {
+      LOG(
+        "UpdateService:_registerBootstrapObserver - observer already registered"
+      );
+      return;
+    }
+
+    LOG(
+      "UpdateService:_registerBootstrapObserver - waiting for tor bootstrap to " +
+        "be complete, then forcing another check"
+    );
+
+    Services.obs.addObserver(this, "torconnect:bootstrap-complete");
+    this._registeredBootstrapObserver = true;
+  },
+
+  _bootstrapComplete: function AUS__bootstrapComplete() {
+    Services.obs.removeObserver(this, "torconnect:bootstrap-complete");
+    this._registeredBootstrapObserver = false;
+
+    LOG(
+      "UpdateService:_bootstrapComplete - bootstrapping complete, forcing " +
+        "another background check"
+    );
+
+    this._attemptResume();
+  },
+
   onCheckComplete: function AUS_onCheckComplete(request, updates) {
     this._selectAndInstallUpdate(updates);
   },
@@ -2659,6 +2703,11 @@ UpdateService.prototype = {
         AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_OFFLINE);
       }
       return;
+    } else if (_shouldRegisterBootstrapObserver(update.errorCode)) {
+      // Register boostrap observer to try again, but only when we own the
+      // tor process.
+      this._registerBootstrapObserver();
+      return;
     }
 
     // Send the error code to telemetry
@@ -5189,6 +5238,7 @@ Downloader.prototype = {
     var state = this._patch.state;
     var shouldShowPrompt = false;
     var shouldRegisterOnlineObserver = false;
+    var shouldRegisterBootstrapObserver = false;
     var shouldRetrySoon = false;
     var deleteActiveUpdate = false;
     var retryTimeout = Services.prefs.getIntPref(
@@ -5266,7 +5316,18 @@ Downloader.prototype = {
       );
       shouldRegisterOnlineObserver = true;
       deleteActiveUpdate = false;
-
+    } else if(_shouldRegisterBootstrapObserver(status)) {
+      // Register a bootstrap observer to try again.
+      // The bootstrap observer will continue the incremental download by
+      // calling downloadUpdate on the active update which continues
+      // downloading the file from where it was.
+      LOG("Downloader:onStopRequest - not bootstrapped, register bootstrap observer: true");
+      AUSTLMY.pingDownloadCode(
+        this.isCompleteUpdate,
+        AUSTLMY.DWNLD_RETRY_OFFLINE
+      );
+      shouldRegisterBootstrapObserver = true;
+      deleteActiveUpdate = false;
       // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED,
       // NS_ERROR_NET_RESET and NS_ERROR_DOCUMENT_NOT_CACHED can be returned
       // when disconnecting the internet while a download of a MAR is in
@@ -5384,7 +5445,7 @@ Downloader.prototype = {
 
     // Only notify listeners about the stopped state if we
     // aren't handling an internal retry.
-    if (!shouldRetrySoon && !shouldRegisterOnlineObserver) {
+    if (!shouldRetrySoon && !shouldRegisterOnlineObserver && !shouldRegisterBootstrapObserver) {
       // Make shallow copy in case listeners remove themselves when called.
       var listeners = this._listeners.concat();
       var listenerCount = listeners.length;
@@ -5532,6 +5593,9 @@ Downloader.prototype = {
     if (shouldRegisterOnlineObserver) {
       LOG("Downloader:onStopRequest - Registering online observer");
       this.updateService._registerOnlineObserver();
+    } else if (shouldRegisterBootstrapObserver) {
+      LOG("Downloader:onStopRequest - Registering bootstrap observer");
+      this.updateService._registerBootstrapObserver();
     } else if (shouldRetrySoon) {
       LOG("Downloader:onStopRequest - Retrying soon");
       this.updateService._consecutiveSocketErrors++;
diff --git a/toolkit/themes/shared/in-content/info-pages.inc.css b/toolkit/themes/shared/in-content/info-pages.inc.css
index 6943a3340e35..5b3c911a5aab 100644
--- a/toolkit/themes/shared/in-content/info-pages.inc.css
+++ b/toolkit/themes/shared/in-content/info-pages.inc.css
@@ -41,10 +41,11 @@ body.wide-container {
   background-image: url("chrome://global/skin/icons/info.svg");
   background-position: left 0;
   background-repeat: no-repeat;
-  background-size: 1.6em;
-  margin-inline-start: -2.3em;
-  padding-inline-start: 2.3em;
-  font-size: 2.2em;
+  background-size: 3.0em;
+  margin-inline-start: -4.5em;
+  padding-inline-start: 4.5em;
+  margin-bottom: -2.0em;
+  font-size: 1.5em;
   -moz-context-properties: fill;
   fill: currentColor;
 }
@@ -56,7 +57,10 @@ body.wide-container {
 
 .title-text {
   font-size: inherit;
-  padding-bottom: 0.4em;
+  padding-bottom: 2.0em !important;
+  line-height: 1.0em;
+  font-weight: bold;
+  vertical-align: top;
 }
 
 @media (max-width: 970px) {
@@ -68,6 +72,7 @@ body.wide-container {
 
   .title-text {
     padding-top: 0;
+    vertical-align: middle !important;
   }
 }
 
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
index 2ff107b553b2..f8fa83574df7 100644
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
@@ -70,6 +70,10 @@ function getGlobalScriptIncludes(scriptPath) {
     let match = line.match(globalScriptsRegExp);
     if (match) {
       let sourceFile = match[1]
+        .replace(
+          "chrome://browser/content/torconnect/",
+          "browser/components/torconnect/content/"
+        )
         .replace(
           "chrome://browser/content/search/",
           "browser/components/search/content/"





More information about the tbb-commits mailing list