[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-115.2.1esr-13.0-1] fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser

richard (@richard) git at gitlab.torproject.org
Fri Sep 15 18:52:17 UTC 2023



richard pushed to branch tor-browser-115.2.1esr-13.0-1 at The Tor Project / Applications / Tor Browser


Commits:
3d4edb72 by Henry Wilkes at 2023-09-15T18:51:48+00:00
fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser

Bug 42079: Support moving out of the TorConnectState.Bootsrapped state
for gTorConnectTitlebarStatus and gTorConnectUrlbarButton.

- - - - -


2 changed files:

- browser/components/torconnect/content/torConnectTitlebarStatus.js
- browser/components/torconnect/content/torConnectUrlbarButton.js


Changes:

=====================================
browser/components/torconnect/content/torConnectTitlebarStatus.js
=====================================
@@ -72,7 +72,6 @@ var gTorConnectTitlebarStatus = {
         this.node.hidden = true;
         return;
       case TorConnectState.Bootstrapped:
-        this._startHiding();
         textId = "titlebarStatusConnected";
         connected = true;
         break;
@@ -114,6 +113,14 @@ var gTorConnectTitlebarStatus = {
       );
       this.node.classList.toggle("tor-connect-status-connected", connected);
       this.connected = connected;
+      if (connected) {
+        this._startHiding();
+      } else {
+        // We can leave the connected state when we are no longer Bootstrapped
+        // because the underlying tor process exited early and needs a
+        // restart. In this case we want to re-show the status.
+        this._stopHiding();
+      }
     }
     this.node.classList.toggle(
       "tor-connect-status-potentially-blocked",
@@ -125,8 +132,23 @@ var gTorConnectTitlebarStatus = {
    * Mark the component to be hidden after some delay.
    */
   _startHiding() {
-    setTimeout(() => {
+    if (this._hidingTimeout) {
+      // Already hiding.
+      return;
+    }
+    this._hidingTimeout = setTimeout(() => {
       this.node.hidden = true;
     }, 5000);
   },
+
+  /**
+   * Re-show the component immediately.
+   */
+  _stopHiding() {
+    if (this._hidingTimeout) {
+      clearTimeout(this._hidingTimeout);
+      this._hidingTimeout = 0;
+    }
+    this.node.hidden = false;
+  },
 };


=====================================
browser/components/torconnect/content/torConnectUrlbarButton.js
=====================================
@@ -112,10 +112,10 @@ var gTorConnectUrlbarButton = {
    * Callback for when the TorConnect state changes.
    */
   _torConnectStateChanged() {
-    if (
-      TorConnect.state === TorConnectState.Bootstrapped ||
-      TorConnect.state === TorConnectState.Disabled
-    ) {
+    if (TorConnect.state === TorConnectState.Disabled) {
+      // NOTE: We do not uninit early when we reach the
+      // TorConnectState.Bootstrapped state because we can still leave the
+      // Bootstrapped state if the tor process exists early and needs a restart.
       this.uninit();
       return;
     }



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/3d4edb729f52c892d17a1c5db8fd6f45de32eebb

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/3d4edb729f52c892d17a1c5db8fd6f45de32eebb
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20230915/e1264ba7/attachment-0001.htm>


More information about the tor-commits mailing list