morgan pushed to branch tor-browser-149.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: c80e93f9 by Henry Wilkes at 2026-03-30T15:23:45+00:00 fixup! TB 27476: Implement about:torconnect captive portal within Tor Browser TB 44781: Use a static title for `about:torconnect`. We now use Fluent to set the page `<title>`, this causes some delay between the page being loaded and the title being set. Which cause the `about:torconnect` URL to flash in the browser tab selector. Moreover, even the prior non-Fluent approach would have "New Tab" flash in the title just before "Connect to Tor" was set. As such, we adjust `tabbrowser.js` and `tabs.js` to: 1. Set the `about:torconnect`'s tab label to the expected page title before the page has loaded and set it's title. 2. Set the very first tab's label to the `about:torconnect` page title at startup, rather than "New Tab". - - - - - 5da6decb by Henry Wilkes at 2026-03-30T15:23:45+00:00 fixup! Tor Browser strings TB 44781: Add the Fluent tor connect title. - - - - - 5 changed files: - browser/components/tabbrowser/content/tabbrowser.js - browser/components/tabbrowser/content/tabs.js - browser/components/torconnect/content/aboutTorConnect.html - browser/components/torconnect/content/aboutTorConnect.js - toolkit/locales/en-US/toolkit/global/tor-browser.ftl Changes: ===================================== browser/components/tabbrowser/content/tabbrowser.js ===================================== @@ -133,6 +133,11 @@ true ); }); + // Add a synchronous localisation to get the about:torconnect title. + // See tor-browser#44781. + ChromeUtils.defineLazyGetter(this, "torconnectLocalization", () => { + return new Localization(["toolkit/global/tor-browser.ftl"], true); + }); XPCOMUtils.defineLazyPreferenceGetter( this, "_shouldExposeContentTitle", @@ -2113,6 +2118,39 @@ return false; } + // We want to set the title for an about:torconnect tab prior to the page + // being loaded. In particular, we need to wait for: + // + // 1. The first `<browser>` element to switch `currentURI` from + // `about:blank` to `about:torconnect`. + // 2. The page's `<title>` to be set, which is delayed by the page load + // and the async FluentDOM. + // + // This avoids flashes of "New Tab" and the URL appearing in the tab + // label. See tor-browser#44781. + if (aTab._isFirstTabLoading) { + if (!isURL && !isContentTitle) { + // Wait until we have a proper title or URL. + // NOTES: + // 1. This is only expected for the first call to `onLocationChange` + // for the very first tab opened in a new window. In this scenario, + // we expect the page's `currentURI` to be `about:blank` (and not + // the actual `chrome:` path to `blanktab.html`). We use the + // `_isFirstTabLoading` condition as an extra protection. + // 2. We have already set the title for this tab in + // `MozTabbrowserTabs.init`, depending on whether we expect this to + // turn into `about:torconnect` or a "New Tab" (`about:tor` or + // `blanktab.html`). So we don't need to make any changes here. + return false; + } + delete aTab._isFirstTabLoading; + } + if (isURL && aLabel.startsWith("about:torconnect")) { + aLabel = this.tabContainer.torconnectTitle; + isContentTitle = true; + isURL = false; + } + // If it's a long data: URI that uses base64 encoding, truncate to a // reasonable length rather than trying to display the entire thing, // which can hang or crash the browser. ===================================== browser/components/tabbrowser/content/tabs.js ===================================== @@ -132,7 +132,16 @@ this._hiddenSoundPlayingTabs = new Set(); this.previewPanel = null; - this.allTabs[0].label = this.emptyTabTitle; + // When a new application window is spawned, this will set the initial + // tab's displayed title. If `shouldShowTorConnect` is true, we expect + // this first page to be `about:torconnect`, so we show the corresponding + // title that will be used once the page is shown. See tor-browser#44781. + this.allTabs[0].label = TorConnect.shouldShowTorConnect + ? this.torconnectTitle + : this.emptyTabTitle; + // Mark this as the first tab that is still loading. This can be cleared + // once we have a definite title or URI. + this.allTabs[0]._isFirstTabLoading = true; // Hide the secondary text for locales where it is unsupported due to size constraints. const language = Services.locale.appLocaleAsBCP47; @@ -807,6 +816,18 @@ return gBrowser.tabLocalization.formatValueSync(l10nId); } + /** + * The about:torconnect page <title>, to be fetched when about:torconnect + * has not yet been loaded. + * + * @type {string} + */ + get torconnectTitle() { + return gBrowser.torconnectLocalization.formatValueSync( + "tor-connect-page-title" + ); + } + get tabbox() { return document.getElementById("tabbrowser-tabbox"); } ===================================== browser/components/torconnect/content/aboutTorConnect.html ===================================== @@ -6,6 +6,8 @@ http-equiv="Content-Security-Policy" content="default-src chrome:; object-src 'none'" /> + <title data-l10n-id="tor-connect-page-title"></title> + <link rel="stylesheet" href="chrome://global/skin/tor-common.css" /> <link rel="stylesheet" @@ -14,6 +16,8 @@ media="all" /> + <link rel="localization" href="toolkit/global/tor-browser.ftl" /> + <script type="module" src="chrome://global/content/elements/moz-toggle.mjs" ===================================== browser/components/torconnect/content/aboutTorConnect.js ===================================== @@ -229,7 +229,6 @@ class AboutTorConnect { if (className) { this.elements.title.classList.add(className); } - document.title = title; } setLongText(...args) { ===================================== toolkit/locales/en-US/toolkit/global/tor-browser.ftl ===================================== @@ -9,6 +9,12 @@ appmenu-open-tor-manual = .label = Tor Browser manual .accesskey = m +## Tor connect page. + +# The tab name for the page. +# Here "Tor" refers to the Tor network. +tor-connect-page-title = Connect to Tor + ## Tor Browser home page. tor-browser-home-heading-stable = Explore. Privately. View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/388ab39... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/388ab39... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
morgan (@morgan)