This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-91.9.0esr-11.5-2 in repository tor-browser.
commit 6bb230b225baf1a79439324a20fb8506d6d899b3 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Fri Apr 8 11:20:37 2022 +0200
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection
Changes introduced by !275 --- .../torpreferences/content/connectionPane.js | 402 ++++++--------------- .../torpreferences/content/connectionPane.xhtml | 17 + .../torpreferences/content/torPreferences.css | 130 ++++++- 3 files changed, 251 insertions(+), 298 deletions(-)
diff --git a/browser/components/torpreferences/content/connectionPane.js b/browser/components/torpreferences/content/connectionPane.js index 309d6498a0c80..46fbbfecf832f 100644 --- a/browser/components/torpreferences/content/connectionPane.js +++ b/browser/components/torpreferences/content/connectionPane.js @@ -110,6 +110,7 @@ const gConnectionPane = (function() { chooseForMe: "#torPreferences-bridges-buttonChooseBridgeForMe", currentHeader: "#torPreferences-currentBridges-header", currentHeaderText: "#torPreferences-currentBridges-headerText", + currentDescriptionText: "#torPreferences-currentBridges-description", switch: "#torPreferences-currentBridges-switch", cards: "#torPreferences-currentBridges-cards", cardTemplate: "#torPreferences-bridgeCard-template", @@ -135,6 +136,13 @@ const gConnectionPane = (function() { requestButton: "#torPreferences-addBridge-buttonRequestBridge", enterLabel: "#torPreferences-addBridge-labelEnterBridge", enterButton: "#torPreferences-addBridge-buttonEnterBridge", + removeOverlay: "#bridge-remove-overlay", + removeModal: "#bridge-remove-modal", + removeDismiss: "#bridge-remove-dismiss", + removeQuestion: "#bridge-remove-question", + removeWarning: "#bridge-remove-warning", + removeConfirm: "#bridge-remove-confirm", + removeCancel: "#bridge-remove-cancel", }, advanced: { header: "h1#torPreferences-advanced-header", @@ -280,9 +288,7 @@ const gConnectionPane = (function() { if (TorConnect.state === TorConnectState.Bootstrapped) { torIcon.className = "connected"; torStatus.textContent = TorStrings.settings.statusTorConnected; - } else if ( - TorConnect.detectedCensorshipLevel > TorCensorshipLevel.None - ) { + } else if (TorConnect.hasBootstrapEverFailed) { torIcon.className = "blocked"; torStatus.textContent = TorStrings.settings.statusTorBlocked; } else { @@ -346,36 +352,46 @@ const gConnectionPane = (function() { TorConnect.beginAutoBootstrap(location.value); }); this._populateLocations = () => { - let value = location.value; + const currentValue = location.value; locationEntries.textContent = ""; - - { - const item = document.createXULElement("menuitem"); - item.setAttribute("value", ""); - item.setAttribute( - "label", - TorStrings.settings.bridgeLocationAutomatic - ); - locationEntries.appendChild(item); - } - - const codes = TorConnect.countryCodes; - const items = codes.map(code => { + const createItem = (value, label, disabled) => { const item = document.createXULElement("menuitem"); - item.setAttribute("value", code); - item.setAttribute( - "label", - TorConnect.countryNames[code] - ? TorConnect.countryNames[code] - : code - ); + item.setAttribute("value", value); + item.setAttribute("label", label); + if (disabled) { + item.setAttribute("disabled", "true"); + } return item; - }); - items.sort((left, right) => - left.textContent.localeCompare(right.textContent) + }; + const addLocations = codes => { + const items = []; + for (const code of codes) { + items.push( + createItem( + code, + TorConnect.countryNames[code] + ? TorConnect.countryNames[code] + : code + ) + ); + } + items.sort((left, right) => left.label.localeCompare(right.label)); + locationEntries.append(...items); + }; + locationEntries.append( + createItem("", TorStrings.settings.bridgeLocationAutomatic) ); - locationEntries.append(...items); - location.value = value; + if (TorConnect.countryCodes.length) { + locationEntries.append( + createItem("", TorStrings.settings.bridgeLocationFrequent, true) + ); + addLocations(TorConnect.countryCodes); + locationEntries.append( + createItem("", TorStrings.settings.bridgeLocationOther, true) + ); + } + addLocations(Object.keys(TorConnect.countryNames)); + location.value = currentValue; }; this._showAutoconfiguration = () => { if ( @@ -413,6 +429,9 @@ const gConnectionPane = (function() { this._populateBridgeCards(); }); }); + prefpane.querySelector( + selectors.bridges.currentDescriptionText + ).textContent = TorStrings.settings.bridgeCurrentDescription; const bridgeTemplate = prefpane.querySelector( selectors.bridges.cardTemplate ); @@ -439,6 +458,12 @@ const gConnectionPane = (function() { card.removeAttribute("id"); const grid = card.querySelector(selectors.bridges.cardQrGrid); card.addEventListener("click", e => { + if ( + card.classList.contains("currently-connected") || + bridgeCards.classList.contains("single-card") + ) { + return; + } let target = e.target; let apply = true; while (target !== null && target !== card && apply) { @@ -598,7 +623,7 @@ const gConnectionPane = (function() { const removeAll = prefpane.querySelector(selectors.bridges.removeAll); removeAll.setAttribute("label", TorStrings.settings.bridgeRemoveAll); removeAll.addEventListener("command", () => { - this.onRemoveAllBridges(); + this._confirmBridgeRemoval(); }); this._populateBridgeCards = async () => { const collapseThreshold = 4; @@ -617,6 +642,7 @@ const gConnectionPane = (function() { bridgeCards.removeAttribute("hidden"); bridgeSwitch.checked = TorSettings.bridges.enabled; bridgeCards.classList.toggle("disabled", !TorSettings.bridges.enabled); + bridgeCards.classList.toggle("single-card", numBridges === 1);
let shownCards = 0; const toShow = this._currentBridgesExpanded @@ -787,7 +813,37 @@ const gConnectionPane = (function() { }); }
- Services.obs.addObserver(this, TorConnectTopics.StateChange); + { + const overlay = prefpane.querySelector(selectors.bridges.removeOverlay); + this._confirmBridgeRemoval = () => { + overlay.classList.remove("hidden"); + }; + const closeDialog = () => { + overlay.classList.add("hidden"); + }; + overlay.addEventListener("click", closeDialog); + const modal = prefpane.querySelector(selectors.bridges.removeModal); + modal.addEventListener("click", e => { + e.stopPropagation(); + }); + const dismiss = prefpane.querySelector(selectors.bridges.removeDismiss); + dismiss.addEventListener("click", closeDialog); + const question = prefpane.querySelector( + selectors.bridges.removeQuestion + ); + question.textContent = TorStrings.settings.removeBridgesQuestion; + const warning = prefpane.querySelector(selectors.bridges.removeWarning); + warning.textContent = TorStrings.settings.removeBridgesWarning; + const confirm = prefpane.querySelector(selectors.bridges.removeConfirm); + confirm.setAttribute("label", TorStrings.settings.remove); + confirm.addEventListener("command", () => { + this.onRemoveAllBridges(); + closeDialog(); + }); + const cancel = prefpane.querySelector(selectors.bridges.removeCancel); + cancel.setAttribute("label", TorStrings.settings.cancel); + cancel.addEventListener("command", closeDialog); + }
// Advanced setup prefpane.querySelector(selectors.advanced.header).innerText = @@ -816,6 +872,8 @@ const gConnectionPane = (function() { torLogsButton.addEventListener("command", () => { this.onViewTorLogs(); }); + + Services.obs.addObserver(this, TorConnectTopics.StateChange); },
init() { @@ -915,6 +973,9 @@ const gConnectionPane = (function() { onRemoveAllBridges() { TorSettings.bridges.enabled = false; TorSettings.bridges.bridge_strings = ""; + if (TorSettings.bridges.source == TorBridgeSource.BuiltIn) { + TorSettings.bridges.builtin_type = ""; + } TorSettings.saveToPrefs(); TorSettings.applySettings().then(result => { this._populateBridgeCards(); @@ -1018,272 +1079,33 @@ function makeBridgeId(bridgeString) { // JS uses UTF-16. While most of these emojis are surrogate pairs, a few // ones fit one UTF-16 character. So we could not use neither indices, // nor substr, nor some function to split the string. - const emojis = [ - "๐๏ธ", - "๐๏ธ", - "๐", - "๐ญ๏ธ", - "๐๏ธ", - "๐๏ธ", - "๐คฉ๏ธ", - "๐", - "๐๏ธ", - "๐๏ธ", - "๐ท", - "๐คข", - "๐ค", - "๐คง", - "๐ฅต", - "๐ฅถ", - "๐ฅด", - "๐ต๏ธ", - "๐คฎ๏ธ", - "๐ค", - "๐ค", - "๐ซข", - "๐ค", - "๐ฎโ๐จ", - "๐", - "๐คค", - "๐ด", - "๐คฏ", - "๐ค ", - "๐ฅณ", - "๐ฅธ", - "๐ค", - "๐ง", - "๐จ", - "๐ณ", - "๐ฅบ", - "๐คฌ", - "๐", - "๐ฟ", - "๐", - "๐ฉ", - "๐คก", - "๐บ", - "๐ป", - "๐ฝ", - "๐ฆด", - "๐ค", - "๐ธ", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐ฏ", - "๐ข", - "๐ง", - "๐จ", - "๐ญ", - "๐ค", - "๐", - "๐", - "โ", - "๐", - "๐", - "๐ค", - "๐", - "๐ช", - "๐", - "โ", - "๐ง ", - "๐", - "๐", - "๐ ", - "๐ฆท", - "๐พ", - "๐ถ", - "๐ฆ", - "๐ฆ", - "๐", - "๐ฆ", - "๐ฏ", - "๐ด", - "๐ฆ", - "๐ฆ", - "๐ฎ", - "๐ท", - "๐", - "๐ช", - "๐", - "๐ญ", - "๐ฐ", - "๐ฆ", - "๐ฆ", - "๐ป", - "๐จ", - "๐ผ", - "๐", - "๐ฆจ", - "๐ฆ", - "๐ฆ", - "๐ง", - "๐ฆฉ", - "๐ฆ", - "๐ฆ", - "๐ชถ", - "๐ธ", - "๐", - "๐ข", - "๐ฆ", - "๐", - "๐ฆ", - "๐ฆ", - "๐ฌ", - "๐", - "๐", - "๐", - "๐", - "๐ธ", - "๐ฒ", - "๐ต", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐ฅฅ", - "๐", - "๐", - "๐", - "๐ซ", - "๐ฅ", - "๐ฅ", - "๐ฅ", - "๐ง ", - "๐ฐ", - "๐", - "๐", - "๐ฅ", - "๐ง", - "๐", - "๐", - "๐", - "๐", - "๐ฅ", - "๐ฟ", - "๐ง", - "๐", - "๐ฆ", - "๐ฉ", - "๐ช", - "๐", - "๐ฌ", - "๐ญ", - "๐ฅ", - "โ", - "๐ซ", - "๐พ", - "๐ท", - "๐น", - "๐บ", - "๐ด", - "๐ฅ", - "๐ซ", - "๐งญ", - "๐", - "๐ชต", - "๐ก", - "๐ข", - "๐ฐ", - "โฒ", - "โบ", - "๐ก", - "๐", - "๐", - "๐", - "๐ฒ", - "๐", - "๐จ", - "โฝ", - "๐ฅ", - "๐ง", - "โ", - "โต", - "๐", - "๐ช", - "๐", - "โ", - "โฐ", - "๐", - "๐", - "๐", - "๐", - "โ ", - "โก", - "๐ฅ", - "๐", - "๐", - "๐", - "๐", - "โจ", - "๐", - "๐", - "๐", - "๐ ", - "๐ฎ", - "๐ช", - "๐พ", - "๐ณ", - "๐ฒ", - "๐ญ", - "๐จ", - "๐งต", - "๐ฉ", - "๐ข", - "๐", - "๐ต", - "๐ค", - "๐ง", - "๐ท", - "๐ธ", - "๐ฅ", - "๐", - "๐", - "๐ป", - "๐พ", - "๐ฟ", - "๐ฌ", - "๐บ", - "๐ท", - "๐ฎ", - "๐งฉ", - "๐", - "๐ก", - "๐", - "๐ฐ", - "๐ผ", - "๐", - "๐", - "๐", - "๐", - "๐", - "๐ง", - "๐ช", - "๐ฉ", - "๐งฒ", - "๐ฌ", - "๐ญ", - "๐ก", - "๐ช", - "๐ช", - "โ", - "๐ฉ", +const emojis = [ + "๐ฝ","๐ค","๐ง","๐ง","๐","๐ต","๐ฆ","๐ถ","๐บ","๐ฆ","๐","๐ฆ","๐ฏ","๐ด","๐ฆ","๐ฆ", + "๐ฆ","๐ฎ","๐ท","๐","๐","๐ฆ","๐ฆ","๐","๐ญ","๐น","๐","๐ฟ","๐ฆ","๐จ","๐ผ","๐ฆฅ", + "๐ฆจ","๐ฆ","๐","๐ฅ","๐ฆ","๐ง","๐","๐ฆ","๐ฆข","๐ฆ","๐ฆค","๐ฆฉ","๐ฆ","๐ฆ","๐","๐ข", + "๐ฆ","๐","๐","๐ฆ","๐ฆ","๐","๐ฌ","๐","๐ ","๐ก","๐ฆ","๐","๐","๐","๐ฆ","๐", + "๐","๐","๐","๐ธ","๐น","๐บ","๐ป","๐ผ","๐ท","๐ฑ","๐ฒ","๐ณ","๐ด","๐ต","๐ฟ","๐", + "๐","๐","๐","๐","๐","๐","๐ฅญ","๐","๐","๐","๐","๐","๐ฅ","๐ ","๐ฅฅ","๐ฅ", + "๐","๐ฅ","๐ฝ","๐ถ","๐ฅฌ","๐ฅฆ","๐ง ","๐","๐ฅ","๐ฅ","๐ฅ","๐ฅจ","๐ฅ","๐ง","๐","๐", + "๐ญ","๐ฎ","๐ฏ","๐ฅ","๐ฟ","๐","๐ฅ","๐ฆ","๐ฆ","๐ฆ","๐ฆ","๐ฉ","๐ง","๐ฌ","๐ญ","๐ง", + "๐ง","๐งญ","โฐ","๐","๐","๐ก","โฒ","โบ","๐ ","๐ก","๐","๐","๐","๐","๐","๐", + "๐","๐ต","๐บ","๐ฒ","๐ด","๐น","โ๏ธ","โต","๐ถ","๐ค","๐ข","โ๏ธ","๐ช","๐","๐ ","๐ฐ", + "๐","๐ธ","โณ","๐","๐ก","โ๏ธ","๐ช","โญ","โ๏ธ","๐ง","๐ฉ","๐","๐","โ๏ธ","โ๏ธ","โ๏ธ", + "๐ฅ","๐ง","๐","๐","โจ","๐","๐","๐","๐","๐","๐","โฝ","๐","๐","๐พ","๐ฅ", + "๐","โธ","๐ช","๐ช","๐ฑ","๐ฎ","๐ช","๐น","๐ฒ","๐งฉ","๐งธ","๐จ","๐งต","๐งถ","๐ถ","๐งฆ", + "๐","๐","๐ ","๐","๐","๐งข","๐","๐","๐ข","๐ต","๐","๐ค","๐ง","๐ป","๐ท","๐ช", + "๐ธ","๐บ","๐ป","๐ช","๐ฅ","โ๏ธ","๐ฟ","๐ฅ","๐ฌ","๐บ","๐ท","๐","๐ก","๐ฆ","๐","๐", + "๐ท","โ๏ธ","๐","๐","๐","๐","๐","๐ช","๐น","โ๏ธ","๐งฒ","๐งช","๐งฌ","๐ญ","๐ก","๐ฟ", ];
+ // FNV-1a implementation that is compatible with other languages const prime = 0x01000193; const offset = 0x811c9dc5; let hash = offset; const encoder = new TextEncoder(); - for (const charCode of encoder.encode(bridgeString)) { - hash = Math.imul(hash ^ charCode, prime); + for (const byte of encoder.encode(bridgeString)) { + hash = Math.imul(hash ^ byte, prime); }
const hashBytes = [ diff --git a/browser/components/torpreferences/content/connectionPane.xhtml b/browser/components/torpreferences/content/connectionPane.xhtml index 67f98685d8038..39a9c184502f0 100644 --- a/browser/components/torpreferences/content/connectionPane.xhtml +++ b/browser/components/torpreferences/content/connectionPane.xhtml @@ -93,6 +93,9 @@ <html:span id="torPreferences-currentBridges-headerText"/> <html:input type="checkbox" id="torPreferences-currentBridges-switch" class="toggle-button"/> </html:h2> + <description flex="1"> + <html:span id="torPreferences-currentBridges-description"/> + </description> <menupopup id="torPreferences-bridgeCard-menu"/> <vbox id="torPreferences-bridgeCard-template" class="torPreferences-bridgeCard"> <hbox class="torPreferences-bridgeCard-heading"> @@ -174,4 +177,18 @@ </hbox> </box> </groupbox> + +<html:div id="bridge-remove-overlay" class="hidden"> + <html:div id="bridge-remove-modal"> + <html:img id="bridge-remove-dismiss" src="chrome://global/skin/icons/close.svg"/> + <html:div id="bridge-remove-icon"/> + <html:p id="bridge-remove-question"/> + <html:p id="bridge-remove-warning"/> + <html:div id="bridge-remove-buttonbar"> + <button id="bridge-remove-cancel"/> + <button id="bridge-remove-confirm"/> + </html:div> + </html:div> +</html:div> + </html:template> diff --git a/browser/components/torpreferences/content/torPreferences.css b/browser/components/torpreferences/content/torPreferences.css index 31b6e29d679f3..2ab29bcd60faa 100644 --- a/browser/components/torpreferences/content/torPreferences.css +++ b/browser/components/torpreferences/content/torPreferences.css @@ -176,6 +176,11 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { width: 280px; }
+#torPreferences-bridges-location menuitem[disabled="true"] { + color: var(--in-content-button-text-color, inherit); + font-weight: 700; +} + /* Bridge cards */ :root { --bridgeCard-animation-time: 0.25s; @@ -188,7 +193,7 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { }
#torPreferences-currentBridges-cards.list-collapsed { - mask-image: linear-gradient(rgb(0, 0, 0), rgba(0, 0, 0, 0.1)); + mask-image: linear-gradient(rgb(0, 0, 0) 0% 75%, rgba(0, 0, 0, 0.1)); }
#torPreferences-currentBridges-cards.disabled { @@ -200,9 +205,12 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { /* define border-radius here because of the transition */ border-radius: 4px; transition: margin var(--bridgeCard-animation-time), box-shadow 150ms; + cursor: pointer; }
-.torPreferences-bridgeCard.expanded { +.torPreferences-bridgeCard.expanded, +.torPreferences-bridgeCard.currently-connected, +.single-card .torPreferences-bridgeCard { margin: 12px 0; background: var(--in-content-box-background); box-shadow: var(--card-shadow); @@ -211,7 +219,11 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { .torPreferences-bridgeCard:hover { background: var(--in-content-box-background); box-shadow: var(--card-shadow-hover); - cursor: pointer; +} + +.single-card .torPreferences-bridgeCard, +.torPreferences-bridgeCard.currently-connected { + cursor: default; }
.torPreferences-bridgeCard-heading { @@ -228,7 +240,7 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { padding: 4px; font-size: 20px; border-radius: 4px; - background: var(--in-content-button-background-hover); + background: var(--in-content-box-background-odd); }
.torPreferences-bridgeCard-headingAddr { @@ -237,12 +249,15 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { width: 20px; flex: 1; margin: 0 8px; - white-space: nowrap; overflow: hidden; + color: var(--in-content-deemphasized-text); + white-space: nowrap; text-overflow: ellipsis; }
-.expanded .torPreferences-bridgeCard-headingAddr { +.expanded .torPreferences-bridgeCard-headingAddr, +.currently-connected .torPreferences-bridgeCard-headingAddr, +.single-card .torPreferences-bridgeCard-headingAddr { display: none; }
@@ -354,10 +369,17 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { visibility: hidden; }
-.expanded .torPreferences-bridgeCard-grid { +.expanded .torPreferences-bridgeCard-grid, +.currently-connected .torPreferences-bridgeCard-grid, +.single-card .torPreferences-bridgeCard-grid { visibility: visible; }
+.currently-connected .torPreferences-bridgeCard-grid, +.single-card .torPreferences-bridgeCard-grid { + height: auto; +} + .torPreferences-bridgeCard-grid.to-animate { transition: height var(--bridgeCard-animation-time) ease-out, visibility var(--bridgeCard-animation-time); overflow: hidden; @@ -375,8 +397,9 @@ html:dir(rtl) input[type="checkbox"].toggle-button::before { margin: 8px 0; }
-.torPreferences-bridgeCard-addr { +input.torPreferences-bridgeCard-addr { width: 100%; + color: var(--in-content-deemphasized-text); }
.torPreferences-bridgeCard-leranMoreBox { @@ -539,3 +562,94 @@ textarea#torPreferences-torDialog-textarea { /* 10 lines */ min-height: 20em; } + +/* Bridge remove overlay */ +#bridge-remove-overlay { + position: fixed; + display: flex; + align-items: center; + justify-content: center; + top: 0; + inset: 0; + width: 100%; + height: 100%; + z-index: 1; + background-color: rgba(0, 0, 0, 0.5); +} + +#bridge-remove-overlay.hidden { + display: none; +} + +#bridge-remove-modal { + position: relative; + min-width: 250px; + max-width: 500px; + min-height: 200px; + z-index: 2; + text-align: center; + background: var(--in-content-page-background); + box-shadow: var(--shadow-30); +} + +#bridge-remove-dismiss { + position: absolute; + top: 16px; + inset-inline-end: 16px; + width: 16px; + height: 16px; + fill: currentColor; + -moz-context-properties: fill; +} + +#bridge-remove-dismiss:hover { + background-color: var(--in-content-button-background-hover); + color: var(--in-content-button-text-color-hover); + border: 1px solid var(--in-content-button-border-color-hover); + border-radius: 4px; +} + +#bridge-remove-dismiss:hover:active { + background-color: var(--in-content-button-background-active); +} + +#bridge-remove-icon { + width: 40px; + height: 40px; + background-image: url("chrome://global/skin/icons/warning.svg"); + background-size: 40px; + margin: 16px auto; + fill: currentColor; + -moz-context-properties: fill; +} + +#bridge-remove-question { + font-size: 150%; +} + +#bridge-remove-warning { + color: var(--in-content-deemphasized-text); +} + +#bridge-remove-buttonbar { + padding: 16px 32px; +} + +#bridge-remove-buttonbar button { + min-width: 140px; +} + +#bridge-remove-confirm { + background: var(--in-content-danger-button-background); + color: var(--in-content-primary-button-text-color); +} + +#bridge-remove-confirm:hover { + background: var(--in-content-danger-button-background-hover); + color: var(--in-content-primary-button-text-color-hover); + border-color: var(--in-content-primary-button-border-hover); +} + +#bridge-remove-confirm:hover:active { + background: var(--in-content-danger-button-background-active); +}