[tbb-commits] [tor-browser] 02/02: fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
gitolite role
git at cupani.torproject.org
Tue May 17 20:17:01 UTC 2022
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1
in repository tor-browser.
commit d559a9e30f1d5efe17bed733baa49cb54278461d
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Tue May 17 16:39:47 2022 +0200
fixup! Bug 27476: Implement about:torconnect captive portal within Tor Browser
Bug 40923: Redirect to location confirmation rather than location
detection failed when Moat reports a country code but the bootstrap
fails anyway.
---
browser/components/torconnect/TorConnectParent.jsm | 2 ++
.../torconnect/content/aboutTorConnect.js | 34 ++++++++++++++--------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm
index 3c2a56934c145..a39f7a07a0ade 100644
--- a/browser/components/torconnect/TorConnectParent.jsm
+++ b/browser/components/torconnect/TorConnectParent.jsm
@@ -36,6 +36,7 @@ class TorConnectParent extends JSWindowActorParent {
BootstrapProgress: TorConnect.bootstrapProgress,
BootstrapStatus: TorConnect.bootstrapStatus,
InternetStatus: TorConnect.internetStatus,
+ DetectedLocation: TorConnect.detectedLocation,
ShowViewLog: TorConnect.logHasWarningOrError,
QuickStartEnabled: TorSettings.quickstart.enabled,
UIState: TorConnect.uiState,
@@ -81,6 +82,7 @@ class TorConnectParent extends JSWindowActorParent {
self.state.ErrorMessage = obj.message;
self.state.ErrorDetails = obj.details;
self.state.InternetStatus = TorConnect.internetStatus;
+ self.state.DetectedLocation = TorConnect.detectedLocation;
self.state.ShowViewLog = true;
break;
}
diff --git a/browser/components/torconnect/content/aboutTorConnect.js b/browser/components/torconnect/content/aboutTorConnect.js
index 28356045525a3..bafbe7c7eeb43 100644
--- a/browser/components/torconnect/content/aboutTorConnect.js
+++ b/browser/components/torconnect/content/aboutTorConnect.js
@@ -404,12 +404,17 @@ class AboutTorConnect {
this.transitionUIState(UIStates.ConnectionAssist, state);
} else if (state.PreviousState === TorConnectState.AutoBootstrapping) {
if (this.uiState.bootstrapCause === UIStates.ConnectionAssist) {
- this.transitionUIState(
- this.getLocation() === "automatic"
- ? UIStates.CouldNotLocate
- : UIStates.LocationConfirm,
- state
- );
+ if (this.getLocation() === "automatic") {
+ this.uiState.allowAutomaticLocation = false;
+ if (!state.DetectedLocation) {
+ this.transitionUIState(UIStates.CouldNotLocate, state);
+ return;
+ }
+ // Change the location only here, to avoid overriding any user change/
+ // insisting with the detected location
+ this.setLocation(state.DetectedLocation);
+ }
+ this.transitionUIState(UIStates.LocationConfirm, state);
} else {
this.transitionUIState(UIStates.FinalError, state);
}
@@ -629,7 +634,7 @@ class AboutTorConnect {
RPMSendQuery("torconnect:get-country-codes").then(codes => {
if (codes && codes.length) {
this.populateFrequentLocations(codes);
- this.setLocationFromState();
+ this.setLocation();
}
});
let firstOpt = this.elements.locationDropdownSelect.options[0];
@@ -640,7 +645,7 @@ class AboutTorConnect {
firstOpt.value = "";
firstOpt.textContent = TorStrings.torConnect.selectCountryRegion;
}
- this.setLocationFromState();
+ this.setLocation();
this.validateLocation();
this.show(this.elements.locationDropdownLabel);
this.show(this.elements.locationDropdown);
@@ -657,8 +662,13 @@ class AboutTorConnect {
return this.elements.locationDropdownSelect.options[selectedIndex].value;
}
- setLocationFromState() {
- if (this.getLocation() === this.uiState.selectedLocation) {
+ setLocation(code) {
+ if (!code) {
+ code = this.uiState.selectedLocation;
+ } else {
+ this.uiState.selectedLocation = code;
+ }
+ if (this.getLocation() === code) {
return;
}
const options = this.elements.locationDropdownSelect.options;
@@ -666,7 +676,7 @@ class AboutTorConnect {
// the .value way to select (which would however require the label,
// rather than the code)...
for (let i = 0; i < options.length; i++) {
- if (options[i].value === this.uiState.selectedLocation) {
+ if (options[i].value === code) {
this.elements.locationDropdownSelect.selectedIndex = i;
break;
}
@@ -777,7 +787,7 @@ class AboutTorConnect {
RPMAddMessageListener("torconnect:user-action", ({ data }) => {
if (data.location) {
this.uiState.selectedLocation = data.location;
- this.setLocationFromState();
+ this.setLocation();
}
if (data.uiState !== undefined) {
this.transitionUIState(data.uiState, data.connState);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list