Pier Angelo Vendrame pushed to branch tor-browser-128.0esr-14.0-2 at The Tor Project / Applications / Tor Browser
Commits: 646ee32d by Henry Wilkes at 2024-07-31T14:16:49+01:00 fixup! Bug 40597: Implement TorSettings module
Bug 42622: Send TorConnect "Error" signal before "StateChange".
- - - - -
1 changed file:
- toolkit/modules/TorConnect.sys.mjs
Changes:
===================================== toolkit/modules/TorConnect.sys.mjs ===================================== @@ -687,16 +687,7 @@ class ErrorState extends StateCallback { ErrorState.#hasEverHappened = true; }
- run(error) { - if (!(error instanceof TorConnectError)) { - error = new TorConnectError(TorConnectError.ExternalError, error); - } - TorConnect._errorCode = error.code; - TorConnect._errorDetails = error; - lazy.logger.error(`Entering error state (${error.code})`, error); - - Services.obs.notifyObservers(error, TorConnectTopics.Error); - + run(_error) { this.changeState(TorConnectState.Configuring); }
@@ -904,6 +895,23 @@ export const TorConnect = { // Set our new state first so that state transitions can themselves // trigger a state transition. this._stateHandler = this._makeState(newState); + + // Error signal needs to be sent out before we enter the Error state. + // Expected on android `onBootstrapError` to set lastKnownError. + // Expected in about:torconnect to set the error codes and internet status + // *before* the StateChange signal. + if (newState === TorConnectState.Error) { + let error = args[0]; + if (!(error instanceof TorConnectError)) { + error = new TorConnectError(TorConnectError.ExternalError, error); + } + TorConnect._errorCode = error.code; + TorConnect._errorDetails = error; + lazy.logger.error(`Entering error state (${error.code})`, error); + + Services.obs.notifyObservers(error, TorConnectTopics.Error); + } + Services.obs.notifyObservers( { state: newState }, TorConnectTopics.StateChange
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/646ee32d...
tbb-commits@lists.torproject.org