This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-91.11.0esr-12.0-1 in repository tor-browser.
commit 55991a59b5c287e1f6dec7c09ce105c40869aa6b Author: WofWca wofwca@protonmail.com AuthorDate: Wed Jul 20 14:54:27 2022 +0300
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection
fix: `about:preferences#connection`: only change settings if dialog is closed with "accept" button Fixes https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/41063 --- .../torpreferences/content/builtinBridgeDialog.jsm | 17 +++++------------ .../components/torpreferences/content/connectionPane.js | 12 ++++++------ .../torpreferences/content/provideBridgeDialog.jsm | 15 +++++---------- .../torpreferences/content/requestBridgeDialog.jsm | 13 +++++-------- 4 files changed, 21 insertions(+), 36 deletions(-)
diff --git a/browser/components/torpreferences/content/builtinBridgeDialog.jsm b/browser/components/torpreferences/content/builtinBridgeDialog.jsm index 5b5e1560cd466..35ff6410768a9 100644 --- a/browser/components/torpreferences/content/builtinBridgeDialog.jsm +++ b/browser/components/torpreferences/content/builtinBridgeDialog.jsm @@ -11,9 +11,9 @@ const { } = ChromeUtils.import("resource:///modules/TorSettings.jsm");
class BuiltinBridgeDialog { - constructor() { + constructor(onSubmit) { + this.onSubmit = onSubmit; this._dialog = null; - this._bridgeType = ""; }
static get selectors() { @@ -77,14 +77,12 @@ class BuiltinBridgeDialog { ) { radioGroup.selectedItem = types[TorSettings.bridges.builtin_type]?.elemRadio; - this._bridgeType = TorSettings.bridges.builtin_type; } else { radioGroup.selectedItem = null; - this._bridgeType = ""; }
this._dialog.addEventListener("dialogaccept", e => { - this._bridgeType = radioGroup.value; + this.onSubmit(radioGroup.value); }); this._dialog.addEventListener("dialoghelp", e => { window.top.openTrustedLinkIn( @@ -105,15 +103,10 @@ class BuiltinBridgeDialog { }, 0); }
- openDialog(gSubDialog, aCloseCallback) { + openDialog(gSubDialog) { gSubDialog.open( "chrome://browser/content/torpreferences/builtinBridgeDialog.xhtml", - { - features: "resizable=yes", - closingCallback: () => { - aCloseCallback(this._bridgeType); - }, - }, + { features: "resizable=yes" }, this ); } diff --git a/browser/components/torpreferences/content/connectionPane.js b/browser/components/torpreferences/content/connectionPane.js index f523642cd3532..eadd4e6037f4d 100644 --- a/browser/components/torpreferences/content/connectionPane.js +++ b/browser/components/torpreferences/content/connectionPane.js @@ -1037,8 +1037,7 @@ const gConnectionPane = (function() { },
onAddBuiltinBridge() { - const builtinBridgeDialog = new BuiltinBridgeDialog(); - builtinBridgeDialog.openDialog(gSubDialog, aBridgeType => { + const builtinBridgeDialog = new BuiltinBridgeDialog(aBridgeType => { if (!aBridgeType) { TorSettings.bridges.enabled = false; TorSettings.bridges.builtin_type = ""; @@ -1052,12 +1051,12 @@ const gConnectionPane = (function() { this._populateBridgeCards(); }); }); + builtinBridgeDialog.openDialog(gSubDialog); },
// called when the request bridge button is activated onRequestBridge() { - const requestBridgeDialog = new RequestBridgeDialog(); - requestBridgeDialog.openDialog(gSubDialog, aBridges => { + const requestBridgeDialog = new RequestBridgeDialog(aBridges => { if (aBridges.length) { const bridgeStrings = aBridges.join("\n"); TorSettings.bridges.enabled = true; @@ -1071,11 +1070,11 @@ const gConnectionPane = (function() { TorSettings.bridges.enabled = false; } }); + requestBridgeDialog.openDialog(gSubDialog); },
onAddBridgeManually() { - const provideBridgeDialog = new ProvideBridgeDialog(); - provideBridgeDialog.openDialog(gSubDialog, aBridgeString => { + const provideBridgeDialog = new ProvideBridgeDialog(aBridgeString => { if (aBridgeString.length) { TorSettings.bridges.enabled = true; TorSettings.bridges.source = TorBridgeSource.UserProvided; @@ -1089,6 +1088,7 @@ const gConnectionPane = (function() { TorSettings.bridges.source = TorBridgeSource.Invalid; } }); + provideBridgeDialog.openDialog(gSubDialog); },
onAdvancedSettings() { diff --git a/browser/components/torpreferences/content/provideBridgeDialog.jsm b/browser/components/torpreferences/content/provideBridgeDialog.jsm index bc6a841138fb6..33ee8e023bfda 100644 --- a/browser/components/torpreferences/content/provideBridgeDialog.jsm +++ b/browser/components/torpreferences/content/provideBridgeDialog.jsm @@ -9,10 +9,10 @@ const { TorSettings, TorBridgeSource } = ChromeUtils.import( );
class ProvideBridgeDialog { - constructor() { + constructor(onSubmit) { + this.onSubmit = onSubmit; this._dialog = null; this._textarea = null; - this._bridgeString = ""; }
static get selectors() { @@ -40,7 +40,7 @@ class ProvideBridgeDialog { }
this._dialog.addEventListener("dialogaccept", e => { - this._bridgeString = this._textarea.value; + this.onSubmit(this._textarea.value); }); this._dialog.addEventListener("dialoghelp", e => { window.top.openTrustedLinkIn( @@ -57,15 +57,10 @@ class ProvideBridgeDialog { }, 0); }
- openDialog(gSubDialog, aCloseCallback) { + openDialog(gSubDialog) { gSubDialog.open( "chrome://browser/content/torpreferences/provideBridgeDialog.xhtml", - { - features: "resizable=yes", - closingCallback: () => { - aCloseCallback(this._bridgeString); - }, - }, + { features: "resizable=yes" }, this ); } diff --git a/browser/components/torpreferences/content/requestBridgeDialog.jsm b/browser/components/torpreferences/content/requestBridgeDialog.jsm index 9b8cd6db0a9b9..feabb931008f3 100644 --- a/browser/components/torpreferences/content/requestBridgeDialog.jsm +++ b/browser/components/torpreferences/content/requestBridgeDialog.jsm @@ -6,7 +6,8 @@ const { BridgeDB } = ChromeUtils.import("resource:///modules/BridgeDB.jsm"); const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
class RequestBridgeDialog { - constructor() { + constructor(onSubmit) { + this.onSubmit = onSubmit; this._dialog = null; this._submitButton = null; this._dialogHeader = null; @@ -15,7 +16,6 @@ class RequestBridgeDialog { this._captchaRefreshButton = null; this._incorrectCaptchaHbox = null; this._incorrectCaptchaLabel = null; - this._bridges = []; }
static get selectors() { @@ -53,7 +53,7 @@ class RequestBridgeDialog { if (uri) { this._setcaptchaImage(uri); } else if (bridges) { - this._bridges = bridges; + this.onSubmit(bridges); this._submitButton.disabled = false; this._dialog.cancelDialog(); } @@ -163,20 +163,18 @@ class RequestBridgeDialog { BridgeDB.submitCaptchaGuess(captchaText) .then(aBridges => { if (aBridges) { - this._bridges = aBridges; + this.onSubmit(aBridges); this._submitButton.disabled = false; // This was successful, but use cancelDialog() to close, since // we intercept the `dialogaccept` event. this._dialog.cancelDialog(); } else { - this._bridges = []; this._setUIDisabled(false); this._incorrectCaptchaHbox.style.visibility = "visible"; } }) .catch(aError => { // TODO: handle other errors properly here when we do the bridge settings re-design - this._bridges = []; this._setUIDisabled(false); this._incorrectCaptchaHbox.style.visibility = "visible"; console.log(aError); @@ -195,14 +193,13 @@ class RequestBridgeDialog { }); }
- openDialog(gSubDialog, aCloseCallback) { + openDialog(gSubDialog) { gSubDialog.open( "chrome://browser/content/torpreferences/requestBridgeDialog.xhtml", { features: "resizable=yes", closingCallback: () => { this.close(); - aCloseCallback(this._bridges); }, }, this