[tbb-commits] [tor-browser/tor-browser-91.2.0esr-11.0-1] fixup! Bug 27477: Implement about:torconnect captive portal within Tor Browser

sysrqb at torproject.org sysrqb at torproject.org
Wed Oct 6 13:32:12 UTC 2021


commit 67e4e06d45d415c815f6b7c45d6a22b92379c384
Author: Matthew Finkel <sysrqb at torproject.org>
Date:   Fri Sep 3 03:52:25 2021 +0000

    fixup! Bug 27477: Implement about:torconnect captive portal within Tor Browser
    
    This reverts commit ff3b679987ee9d5515508d94d78ed28166706249.
---
 .../components/torpreferences/content/torPane.js   |  9 +++++----
 browser/modules/TorConnect.jsm                     | 23 +++++++++++-----------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/browser/components/torpreferences/content/torPane.js b/browser/components/torpreferences/content/torPane.js
index cde424a3f32a..afdb27351831 100644
--- a/browser/components/torpreferences/content/torPane.js
+++ b/browser/components/torpreferences/content/torPane.js
@@ -159,10 +159,11 @@ const gTorPane = (function() {
       this._messageBoxButton = prefpane.querySelector(selectors.messageBox.button);
       // wire up connect button
       this._messageBoxButton.addEventListener("click", () => {
-        TorConnect.beginBootstrap();
-        let win = Services.wm.getMostRecentWindow("navigator:browser");
-        // switch to existing about:torconnect tab or create a new one
-        win.switchToTabHavingURI("about:torconnect", true);
+        TorConnect.beginBootstrap().then((result) => {
+          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 = () => {
diff --git a/browser/modules/TorConnect.jsm b/browser/modules/TorConnect.jsm
index 17a786dc31f0..6444ab39e928 100644
--- a/browser/modules/TorConnect.jsm
+++ b/browser/modules/TorConnect.jsm
@@ -167,19 +167,19 @@ const TorConnect = (() => {
             /* Initial is never transitioned to */
             [TorConnectState.Initial, null],
             /* Configuring */
-            [TorConnectState.Configuring, (self, prevState) => {
+            [TorConnectState.Configuring, async (self, prevState) => {
                 // TODO move this to the transition function
                 if (prevState === TorConnectState.Bootstrapping) {
-                    TorProtocolService.torStopBootstrap();
+                    await TorProtocolService.torStopBootstrap();
                 }
             }],
             /* AutoConfiguring */
-            [TorConnectState.AutoConfiguring, (self, prevState) => {
+            [TorConnectState.AutoConfiguring, async (self, prevState) => {
 
             }],
             /* Bootstrapping */
-            [TorConnectState.Bootstrapping, (self, prevState) => {
-                let error = TorProtocolService.connect();
+            [TorConnectState.Bootstrapping, async (self, prevState) => {
+                let error = await TorProtocolService.connect();
                 if (error) {
                     self.onError(error.message, error.details);
                 } else {
@@ -187,12 +187,12 @@ const TorConnect = (() => {
                 }
             }],
             /* Bootstrapped */
-            [TorConnectState.Bootstrapped, (self,prevState) => {
+            [TorConnectState.Bootstrapped, async (self,prevState) => {
                 // notify observers of bootstrap completion
                 Services.obs.notifyObservers(null, TorConnectTopics.BootstrapComplete);
             }],
             /* Error */
-            [TorConnectState.Error, (self, prevState, errorMessage, errorDetails, fatal) => {
+            [TorConnectState.Error, async (self, prevState, errorMessage, errorDetails, fatal) => {
                 self._errorMessage = errorMessage;
                 self._errorDetails = errorDetails;
 
@@ -204,7 +204,7 @@ const TorConnect = (() => {
                 }
             }],
             /* FatalError */
-            [TorConnectState.FatalError, (self, prevState) => {
+            [TorConnectState.FatalError, async (self, prevState) => {
                 Services.obs.notifyObservers(null, TorConnectTopics.FatalError);
             }],
             /* Disabled */
@@ -213,7 +213,7 @@ const TorConnect = (() => {
             }],
         ])),
 
-        _changeState: function(newState, ...args) {
+        _changeState: async function(newState, ...args) {
             const prevState = this._state;
 
             // ensure this is a valid state transition
@@ -228,7 +228,7 @@ const TorConnect = (() => {
             this._state = newState;
 
             // call our transition function and forward any args
-            this._transitionCallbacks.get(newState)(this, prevState, ...args);
+            await this._transitionCallbacks.get(newState)(this, prevState, ...args);
 
             Services.obs.notifyObservers({state: newState}, TorConnectTopics.StateChange);
         },
@@ -306,8 +306,7 @@ const TorConnect = (() => {
             /* Handle bootstrap error*/
             case TorTopics.BootstrapError: {
                 const obj = subject?.wrappedJSObject;
-                TorProtocolService.torStopBootstrap();
-                this.onError(obj.message, obj.details);
+                TorProtocolService.torStopBootstrap().then(() => this.onError(obj.message, obj.details));
                 break;
             }
             case TorTopics.LogHasWarnOrErr: {





More information about the tbb-commits mailing list