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
-
5da6decb
by Henry Wilkes at 2026-03-30T15:23:45+00:00
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:
| ... | ... | @@ -133,6 +133,11 @@ |
| 133 | 133 | true
|
| 134 | 134 | );
|
| 135 | 135 | });
|
| 136 | + // Add a synchronous localisation to get the about:torconnect title.
|
|
| 137 | + // See tor-browser#44781.
|
|
| 138 | + ChromeUtils.defineLazyGetter(this, "torconnectLocalization", () => {
|
|
| 139 | + return new Localization(["toolkit/global/tor-browser.ftl"], true);
|
|
| 140 | + });
|
|
| 136 | 141 | XPCOMUtils.defineLazyPreferenceGetter(
|
| 137 | 142 | this,
|
| 138 | 143 | "_shouldExposeContentTitle",
|
| ... | ... | @@ -2113,6 +2118,39 @@ |
| 2113 | 2118 | return false;
|
| 2114 | 2119 | }
|
| 2115 | 2120 | |
| 2121 | + // We want to set the title for an about:torconnect tab prior to the page
|
|
| 2122 | + // being loaded. In particular, we need to wait for:
|
|
| 2123 | + //
|
|
| 2124 | + // 1. The first `<browser>` element to switch `currentURI` from
|
|
| 2125 | + // `about:blank` to `about:torconnect`.
|
|
| 2126 | + // 2. The page's `<title>` to be set, which is delayed by the page load
|
|
| 2127 | + // and the async FluentDOM.
|
|
| 2128 | + //
|
|
| 2129 | + // This avoids flashes of "New Tab" and the URL appearing in the tab
|
|
| 2130 | + // label. See tor-browser#44781.
|
|
| 2131 | + if (aTab._isFirstTabLoading) {
|
|
| 2132 | + if (!isURL && !isContentTitle) {
|
|
| 2133 | + // Wait until we have a proper title or URL.
|
|
| 2134 | + // NOTES:
|
|
| 2135 | + // 1. This is only expected for the first call to `onLocationChange`
|
|
| 2136 | + // for the very first tab opened in a new window. In this scenario,
|
|
| 2137 | + // we expect the page's `currentURI` to be `about:blank` (and not
|
|
| 2138 | + // the actual `chrome:` path to `blanktab.html`). We use the
|
|
| 2139 | + // `_isFirstTabLoading` condition as an extra protection.
|
|
| 2140 | + // 2. We have already set the title for this tab in
|
|
| 2141 | + // `MozTabbrowserTabs.init`, depending on whether we expect this to
|
|
| 2142 | + // turn into `about:torconnect` or a "New Tab" (`about:tor` or
|
|
| 2143 | + // `blanktab.html`). So we don't need to make any changes here.
|
|
| 2144 | + return false;
|
|
| 2145 | + }
|
|
| 2146 | + delete aTab._isFirstTabLoading;
|
|
| 2147 | + }
|
|
| 2148 | + if (isURL && aLabel.startsWith("about:torconnect")) {
|
|
| 2149 | + aLabel = this.tabContainer.torconnectTitle;
|
|
| 2150 | + isContentTitle = true;
|
|
| 2151 | + isURL = false;
|
|
| 2152 | + }
|
|
| 2153 | + |
|
| 2116 | 2154 | // If it's a long data: URI that uses base64 encoding, truncate to a
|
| 2117 | 2155 | // reasonable length rather than trying to display the entire thing,
|
| 2118 | 2156 | // which can hang or crash the browser.
|
| ... | ... | @@ -132,7 +132,16 @@ |
| 132 | 132 | this._hiddenSoundPlayingTabs = new Set();
|
| 133 | 133 | this.previewPanel = null;
|
| 134 | 134 | |
| 135 | - this.allTabs[0].label = this.emptyTabTitle;
|
|
| 135 | + // When a new application window is spawned, this will set the initial
|
|
| 136 | + // tab's displayed title. If `shouldShowTorConnect` is true, we expect
|
|
| 137 | + // this first page to be `about:torconnect`, so we show the corresponding
|
|
| 138 | + // title that will be used once the page is shown. See tor-browser#44781.
|
|
| 139 | + this.allTabs[0].label = TorConnect.shouldShowTorConnect
|
|
| 140 | + ? this.torconnectTitle
|
|
| 141 | + : this.emptyTabTitle;
|
|
| 142 | + // Mark this as the first tab that is still loading. This can be cleared
|
|
| 143 | + // once we have a definite title or URI.
|
|
| 144 | + this.allTabs[0]._isFirstTabLoading = true;
|
|
| 136 | 145 | |
| 137 | 146 | // Hide the secondary text for locales where it is unsupported due to size constraints.
|
| 138 | 147 | const language = Services.locale.appLocaleAsBCP47;
|
| ... | ... | @@ -807,6 +816,18 @@ |
| 807 | 816 | return gBrowser.tabLocalization.formatValueSync(l10nId);
|
| 808 | 817 | }
|
| 809 | 818 | |
| 819 | + /**
|
|
| 820 | + * The about:torconnect page <title>, to be fetched when about:torconnect
|
|
| 821 | + * has not yet been loaded.
|
|
| 822 | + *
|
|
| 823 | + * @type {string}
|
|
| 824 | + */
|
|
| 825 | + get torconnectTitle() {
|
|
| 826 | + return gBrowser.torconnectLocalization.formatValueSync(
|
|
| 827 | + "tor-connect-page-title"
|
|
| 828 | + );
|
|
| 829 | + }
|
|
| 830 | + |
|
| 810 | 831 | get tabbox() {
|
| 811 | 832 | return document.getElementById("tabbrowser-tabbox");
|
| 812 | 833 | }
|
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | http-equiv="Content-Security-Policy"
|
| 7 | 7 | content="default-src chrome:; object-src 'none'"
|
| 8 | 8 | />
|
| 9 | + <title data-l10n-id="tor-connect-page-title"></title>
|
|
| 10 | + |
|
| 9 | 11 | <link rel="stylesheet" href="">"chrome://global/skin/tor-common.css" />
|
| 10 | 12 | <link
|
| 11 | 13 | rel="stylesheet"
|
| ... | ... | @@ -14,6 +16,8 @@ |
| 14 | 16 | media="all"
|
| 15 | 17 | />
|
| 16 | 18 | |
| 19 | + <link rel="localization" href="">"toolkit/global/tor-browser.ftl" />
|
|
| 20 | + |
|
| 17 | 21 | <script
|
| 18 | 22 | type="module"
|
| 19 | 23 | src="">"chrome://global/content/elements/moz-toggle.mjs"
|
| ... | ... | @@ -229,7 +229,6 @@ class AboutTorConnect { |
| 229 | 229 | if (className) {
|
| 230 | 230 | this.elements.title.classList.add(className);
|
| 231 | 231 | }
|
| 232 | - document.title = title;
|
|
| 233 | 232 | }
|
| 234 | 233 | |
| 235 | 234 | setLongText(...args) {
|
| ... | ... | @@ -9,6 +9,12 @@ appmenu-open-tor-manual = |
| 9 | 9 | .label = Tor Browser manual
|
| 10 | 10 | .accesskey = m
|
| 11 | 11 | |
| 12 | +## Tor connect page.
|
|
| 13 | + |
|
| 14 | +# The tab name for the page.
|
|
| 15 | +# Here "Tor" refers to the Tor network.
|
|
| 16 | +tor-connect-page-title = Connect to Tor
|
|
| 17 | + |
|
| 12 | 18 | ## Tor Browser home page.
|
| 13 | 19 | |
| 14 | 20 | tor-browser-home-heading-stable = Explore. Privately.
|