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
2 changed files:
- browser/components/torconnect/content/torConnectTitlebarStatus.js
- browser/components/torconnect/content/torConnectUrlbarButton.js
Changes:
... | ... | @@ -72,7 +72,6 @@ var gTorConnectTitlebarStatus = { |
72 | 72 | this.node.hidden = true;
|
73 | 73 | return;
|
74 | 74 | case TorConnectState.Bootstrapped:
|
75 | - this._startHiding();
|
|
76 | 75 | textId = "titlebarStatusConnected";
|
77 | 76 | connected = true;
|
78 | 77 | break;
|
... | ... | @@ -114,6 +113,14 @@ var gTorConnectTitlebarStatus = { |
114 | 113 | );
|
115 | 114 | this.node.classList.toggle("tor-connect-status-connected", connected);
|
116 | 115 | this.connected = connected;
|
116 | + if (connected) {
|
|
117 | + this._startHiding();
|
|
118 | + } else {
|
|
119 | + // We can leave the connected state when we are no longer Bootstrapped
|
|
120 | + // because the underlying tor process exited early and needs a
|
|
121 | + // restart. In this case we want to re-show the status.
|
|
122 | + this._stopHiding();
|
|
123 | + }
|
|
117 | 124 | }
|
118 | 125 | this.node.classList.toggle(
|
119 | 126 | "tor-connect-status-potentially-blocked",
|
... | ... | @@ -125,8 +132,23 @@ var gTorConnectTitlebarStatus = { |
125 | 132 | * Mark the component to be hidden after some delay.
|
126 | 133 | */
|
127 | 134 | _startHiding() {
|
128 | - setTimeout(() => {
|
|
135 | + if (this._hidingTimeout) {
|
|
136 | + // Already hiding.
|
|
137 | + return;
|
|
138 | + }
|
|
139 | + this._hidingTimeout = setTimeout(() => {
|
|
129 | 140 | this.node.hidden = true;
|
130 | 141 | }, 5000);
|
131 | 142 | },
|
143 | + |
|
144 | + /**
|
|
145 | + * Re-show the component immediately.
|
|
146 | + */
|
|
147 | + _stopHiding() {
|
|
148 | + if (this._hidingTimeout) {
|
|
149 | + clearTimeout(this._hidingTimeout);
|
|
150 | + this._hidingTimeout = 0;
|
|
151 | + }
|
|
152 | + this.node.hidden = false;
|
|
153 | + },
|
|
132 | 154 | }; |
... | ... | @@ -112,10 +112,10 @@ var gTorConnectUrlbarButton = { |
112 | 112 | * Callback for when the TorConnect state changes.
|
113 | 113 | */
|
114 | 114 | _torConnectStateChanged() {
|
115 | - if (
|
|
116 | - TorConnect.state === TorConnectState.Bootstrapped ||
|
|
117 | - TorConnect.state === TorConnectState.Disabled
|
|
118 | - ) {
|
|
115 | + if (TorConnect.state === TorConnectState.Disabled) {
|
|
116 | + // NOTE: We do not uninit early when we reach the
|
|
117 | + // TorConnectState.Bootstrapped state because we can still leave the
|
|
118 | + // Bootstrapped state if the tor process exists early and needs a restart.
|
|
119 | 119 | this.uninit();
|
120 | 120 | return;
|
121 | 121 | }
|