tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit b8cbddc6aef7e15f2879eac238a6813a94409fa2
parent cb2cd703778be16cfb583c081d5a00c2377db0b2
Author: Eemeli Aro <eemeli@mozilla.com>
Date:   Thu, 30 Oct 2025 10:57:45 +0000

Bug 1760013 - Use Services.locale.ellipsis. r=glandium,extension-reviewers,credential-management-reviewers,places-reviewers,dimi

Differential Revision: https://phabricator.services.mozilla.com/D266754

Diffstat:
Mbrowser/base/content/nsContextMenu.sys.mjs | 10++--------
Mbrowser/base/content/test/static/browser_all_files_referenced.js | 12------------
Mbrowser/components/extensions/parent/ext-menus.js | 10++--------
Mbrowser/components/places/PlacesUIUtils.sys.mjs | 9+--------
Mdom/base/nsContentUtils.cpp | 3++-
Mmodules/libpref/init/all.js | 1-
Mtoolkit/components/aboutconfig/test/browser/browser_basic.js | 1-
Mtoolkit/components/alerts/alert.js | 11++---------
Mtoolkit/components/passwordmgr/LoginManagerAuthPrompter.sys.mjs | 17+----------------
Mtoolkit/components/prompts/src/Prompter.sys.mjs | 15++-------------
Dtoolkit/locales/en-US/chrome/global-platform/mac/intl.properties | 7-------
Dtoolkit/locales/en-US/chrome/global-platform/unix/intl.properties | 7-------
Dtoolkit/locales/en-US/chrome/global-platform/win/intl.properties | 7-------
Mtoolkit/locales/jar.mn | 3---
14 files changed, 12 insertions(+), 101 deletions(-)

diff --git a/browser/base/content/nsContextMenu.sys.mjs b/browser/base/content/nsContextMenu.sys.mjs @@ -176,13 +176,6 @@ export class nsContextMenu { this.viewFrameSourceElement = this.document.getElementById( "context-viewframesource" ); - this.ellipsis = "\u2026"; - try { - this.ellipsis = Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; - } catch (e) {} // Reset after "on-build-contextmenu" notification in case selection was // changed during the notification. @@ -2786,7 +2779,8 @@ export class nsContextMenu { if (truncChar >= 0xdc00 && truncChar <= 0xdfff) { truncLength++; } - selectedText = selectedText.substr(0, truncLength) + this.ellipsis; + selectedText = + selectedText.substr(0, truncLength) + Services.locale.ellipsis; } const { gNavigatorBundle } = this.window; diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js @@ -214,10 +214,6 @@ var allowlist = [ platforms: ["linux", "win"], }, { - file: "resource://gre/chrome/en-US/locale/en-US/global-platform/mac/intl.properties", - platforms: ["linux", "win"], - }, - { file: "resource://gre/chrome/en-US/locale/en-US/global-platform/mac/platformKeys.properties", platforms: ["linux", "win"], }, @@ -226,10 +222,6 @@ var allowlist = [ platforms: ["macosx", "win"], }, { - file: "resource://gre/chrome/en-US/locale/en-US/global-platform/unix/intl.properties", - platforms: ["macosx", "win"], - }, - { file: "resource://gre/chrome/en-US/locale/en-US/global-platform/unix/platformKeys.properties", platforms: ["macosx", "win"], }, @@ -238,10 +230,6 @@ var allowlist = [ platforms: ["linux", "macosx"], }, { - file: "resource://gre/chrome/en-US/locale/en-US/global-platform/win/intl.properties", - platforms: ["linux", "macosx"], - }, - { file: "resource://gre/chrome/en-US/locale/en-US/global-platform/win/platformKeys.properties", platforms: ["linux", "macosx"], }, diff --git a/browser/components/extensions/parent/ext-menus.js b/browser/components/extensions/parent/ext-menus.js @@ -350,16 +350,10 @@ var gMenuBuilder = { } if (codePointsToRemove) { - let ellipsis = "\u2026"; - try { - ellipsis = Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; - } catch (e) {} codePointsToRemove += 1; selection = - selectionArray.slice(0, -codePointsToRemove).join("") + ellipsis; + selectionArray.slice(0, -codePointsToRemove).join("") + + Services.locale.ellipsis; } label = label.replace(/%s/g, selection); diff --git a/browser/components/places/PlacesUIUtils.sys.mjs b/browser/components/places/PlacesUIUtils.sys.mjs @@ -984,7 +984,7 @@ export var PlacesUIUtils = { title = host + (fileName - ? (host ? "/" + this.ellipsis + "/" : "") + fileName + ? (host ? "/" + Services.locale.ellipsis + "/" : "") + fileName : uri.pathQueryRef); } } catch (e) { @@ -1777,13 +1777,6 @@ ChromeUtils.defineLazyGetter(PlacesUIUtils, "SUPPORTED_FLAVORS", () => { return [...PlacesUIUtils.PLACES_FLAVORS, ...PlacesUIUtils.URI_FLAVORS]; }); -ChromeUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function () { - return Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; -}); - ChromeUtils.defineLazyGetter(PlacesUIUtils, "promptLocalization", () => { return new Localization( ["browser/placesPrompts.ftl", "branding/brand.ftl"], diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp @@ -224,6 +224,7 @@ #include "mozilla/gfx/Rect.h" #include "mozilla/gfx/Types.h" #include "mozilla/glean/GleanPings.h" +#include "mozilla/intl/LocaleService.h" #include "mozilla/ipc/ProtocolUtils.h" #include "mozilla/net/UrlClassifierCommon.h" #include "mozilla/widget/IMEData.h" @@ -6822,7 +6823,7 @@ const nsDependentString nsContentUtils::GetLocalizedEllipsis() { if (!nsContentUtils::ShouldResistFingerprinting("No context", RFPTarget::JSLocale)) { nsAutoString tmp; - Preferences::GetLocalizedString("intl.ellipsis", tmp); + intl::LocaleService::GetInstance()->GetEllipsis(tmp); uint32_t len = std::min(uint32_t(tmp.Length()), uint32_t(std::size(sBuf) - 1)); CopyUnicodeTo(tmp, 0, sBuf, len); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js @@ -1488,7 +1488,6 @@ pref("converter.html2txt.header_strategy", 1); // 0 = no indention; 1 = indenti pref("intl.accept_languages", "chrome://global/locale/intl.properties"); pref("intl.menuitems.alwaysappendaccesskeys","chrome://global/locale/intl.properties"); pref("intl.menuitems.insertseparatorbeforeaccesskeys","chrome://global/locale/intl.properties"); -pref("intl.ellipsis", "chrome://global-platform/locale/intl.properties"); // this pref allows user to request that all internationalization formatters // like date/time formatting, unit formatting, calendars etc. should use // OS locale set instead of the app locale set. diff --git a/toolkit/components/aboutconfig/test/browser/browser_basic.js b/toolkit/components/aboutconfig/test/browser/browser_basic.js @@ -36,7 +36,6 @@ add_task(async function test_load_settings() { // any of these are removed or their value changes, just update the value // here or point to a different preference in the same file. Assert.equal(this.getRow("font.language.group").value, "x-western"); - Assert.equal(this.getRow("intl.ellipsis").value, "\u2026"); // Test to see if user created value is not empty string when it matches // /^chrome:\/\/.+\/locale\/.+\.properties/. diff --git a/toolkit/components/alerts/alert.js b/toolkit/components/alerts/alert.js @@ -137,14 +137,6 @@ function prefillAlertInfo() { if (bodyText.length > BODY_TEXT_LIMIT) { bodyTextLabel.setAttribute("tooltiptext", bodyText); - let ellipsis = "\u2026"; - try { - ellipsis = Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; - } catch (e) {} - // Copied from nsContextMenu.js' formatSearchContextItem(). // If the JS character after our truncation point is a trail surrogate, // include it in the truncated string to avoid splitting a surrogate pair. @@ -154,7 +146,8 @@ function prefillAlertInfo() { truncLength++; } - bodyText = bodyText.substring(0, truncLength) + ellipsis; + bodyText = + bodyText.substring(0, truncLength) + Services.locale.ellipsis; } bodyTextLabel.textContent = bodyText; } diff --git a/toolkit/components/passwordmgr/LoginManagerAuthPrompter.sys.mjs b/toolkit/components/passwordmgr/LoginManagerAuthPrompter.sys.mjs @@ -314,20 +314,6 @@ LoginManagerAuthPrompter.prototype = { return this.__strBundle; }, - __ellipsis: null, - get _ellipsis() { - if (!this.__ellipsis) { - this.__ellipsis = "\u2026"; - try { - this.__ellipsis = Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; - } catch (e) {} - } - return this.__ellipsis; - }, - // Whether we are in private browsing mode get _inPrivateBrowsing() { if (this._chromeWindow) { @@ -953,8 +939,7 @@ LoginManagerAuthPrompter.prototype = { */ _sanitizeUsername(username) { if (username.length > 30) { - username = username.substring(0, 30); - username += this._ellipsis; + username = username.substring(0, 30) + Services.locale.ellipsis; } return username.replace(/['"]/g, ""); }, diff --git a/toolkit/components/prompts/src/Prompter.sys.mjs b/toolkit/components/prompts/src/Prompter.sys.mjs @@ -866,7 +866,7 @@ var InternalPromptUtils = { if (realm.length > 150) { realm = realm.substring(0, 150); // Append "..." (or localized equivalent). - realm += this.ellipsis; + realm += Services.locale.ellipsis; } return this.getLocalizedString("EnterLoginForProxy3", [ @@ -905,7 +905,7 @@ var InternalPromptUtils = { if (realm.length > 150) { realm = realm.substring(0, 150); // Append "..." (or localized equivalent). - realm += this.ellipsis; + realm += Services.locale.ellipsis; } let text; @@ -960,17 +960,6 @@ ChromeUtils.defineLazyGetter(InternalPromptUtils, "brandBundle", function () { return bundle; }); -ChromeUtils.defineLazyGetter(InternalPromptUtils, "ellipsis", function () { - let ellipsis = "\u2026"; - try { - ellipsis = Services.prefs.getComplexValue( - "intl.ellipsis", - Ci.nsIPrefLocalizedString - ).data; - } catch (e) {} - return ellipsis; -}); - class ModalPrompter { constructor({ browsingContext = null, diff --git a/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties b/toolkit/locales/en-US/chrome/global-platform/mac/intl.properties @@ -1,7 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, -# or use "..." if \u2026 doesn't suit traditions in your locale. -intl.ellipsis=… diff --git a/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties b/toolkit/locales/en-US/chrome/global-platform/unix/intl.properties @@ -1,7 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, -# or use "..." if \u2026 doesn't suit traditions in your locale. -intl.ellipsis=… diff --git a/toolkit/locales/en-US/chrome/global-platform/win/intl.properties b/toolkit/locales/en-US/chrome/global-platform/win/intl.properties @@ -1,7 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# LOCALIZATION NOTE (intl.ellipsis): Use the unicode ellipsis char, \u2026, -# or use "..." if \u2026 doesn't suit traditions in your locale. -intl.ellipsis=… diff --git a/toolkit/locales/jar.mn b/toolkit/locales/jar.mn @@ -44,9 +44,6 @@ locale/@AB_CD@/global-platform/mac/platformKeys.properties (%chrome/global-platform/mac/platformKeys.properties) locale/@AB_CD@/global-platform/unix/platformKeys.properties (%chrome/global-platform/unix/platformKeys.properties) locale/@AB_CD@/global-platform/win/platformKeys.properties (%chrome/global-platform/win/platformKeys.properties) - locale/@AB_CD@/global-platform/mac/intl.properties (%chrome/global-platform/mac/intl.properties) - locale/@AB_CD@/global-platform/unix/intl.properties (%chrome/global-platform/unix/intl.properties) - locale/@AB_CD@/global-platform/win/intl.properties (%chrome/global-platform/win/intl.properties) % locale mozapps @AB_CD@ %locale/@AB_CD@/mozapps/ locale/@AB_CD@/mozapps/downloads/unknownContentType.properties (%chrome/mozapps/downloads/unknownContentType.properties) locale/@AB_CD@/mozapps/downloads/downloads.properties (%chrome/mozapps/downloads/downloads.properties)