tor-browser

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

commit 931328afd49b3abec7eb441f39830a1fb7d4e702
parent 723f5f2a4e41c1724a46b0714918731921d898fb
Author: Dale Harvey <dale@arandomurl.com>
Date:   Tue,  7 Oct 2025 21:08:15 +0000

Bug 1989844 - Show file icon when accessing file urls. r=emz

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

Diffstat:
Mbrowser/base/content/browser-trustPanel.js | 12+++++++-----
Mbrowser/components/controlcenter/content/securityInformation.inc.xhtml | 2--
Mbrowser/components/urlbar/tests/browser/browser.toml | 2++
Abrowser/components/urlbar/tests/browser/browser_trust_panel_pages.js | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbrowser/themes/shared/identity-block/identity-block.css | 4++++
5 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/browser/base/content/browser-trustPanel.js b/browser/base/content/browser-trustPanel.js @@ -248,7 +248,9 @@ class TrustPanel { let secureConnection = this.#isSecurePage(); icon.className = ""; - if (!this.#trackingProtectionEnabled) { + if (this.#isURILoadedFromFile) { + icon.classList.add("file"); + } else if (!this.#trackingProtectionEnabled) { icon.classList.add("inactive"); } else if (secureConnection && this.#trackingProtectionEnabled) { icon.classList.add("secure"); @@ -514,9 +516,9 @@ class TrustPanel { } get #trackingProtectionEnabled() { - return !( - ContentBlockingAllowList.canHandle(window.gBrowser.selectedBrowser) && - ContentBlockingAllowList.includes(window.gBrowser.selectedBrowser) + return ( + !ContentBlockingAllowList.canHandle(window.gBrowser.selectedBrowser) || + !ContentBlockingAllowList.includes(window.gBrowser.selectedBrowser) ); } @@ -836,7 +838,7 @@ class TrustPanel { tooltip = gNavigatorBundle.getString("identity.notSecure.tooltip"); } } - } else { + } else if (!this.#isPotentiallyTrustworthy) { tooltip = gNavigatorBundle.getString("identity.notSecure.tooltip"); } diff --git a/browser/components/controlcenter/content/securityInformation.inc.xhtml b/browser/components/controlcenter/content/securityInformation.inc.xhtml @@ -12,8 +12,6 @@ <!-- These descriptions are shown on a seperate subview when trustpanel is disabled and are only visible here under the trustpanel --> <box class="only-trustpanel"> - <description class="identity-popup-connection-failure security-view" - when-connection="net-error-page" data-l10n-id="identity-connection-failure"></description > <description when-connection="chrome" data-l10n-id="identity-connection-internal"></description> <description when-connection="file" data-l10n-id="identity-connection-file"></description> <description when-connection="associated" data-l10n-id="identity-connection-associated"></description> diff --git a/browser/components/urlbar/tests/browser/browser.toml b/browser/components/urlbar/tests/browser/browser.toml @@ -713,6 +713,8 @@ https_first_disabled = true ["browser_trust_panel.js"] +["browser_trust_panel_pages.js"] + ["browser_trust_panel_security_view.js"] https_first_disabled = true diff --git a/browser/components/urlbar/tests/browser/browser_trust_panel_pages.js b/browser/components/urlbar/tests/browser/browser_trust_panel_pages.js @@ -0,0 +1,59 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* This test checks pages of different URL variants (mostly differing in scheme) + * and verifies that the shield is only shown when content blocking can deal + * with the specific variant. */ + +const ICONS = { + active: "chrome://browser/skin/trust-icon-active.svg", + insecure: "chrome://browser/skin/trust-icon-insecure.svg", + file: "chrome://global/skin/icons/page-portrait.svg", +}; + +const TESTS = [ + { + url: "about:about", + icon: ICONS.insecure, + }, + { + url: "https://example.com", + icon: ICONS.active, + }, + { + url: "http://127.0.0.1/", + icon: ICONS.insecure, + }, + { + url: "file:////", + icon: ICONS.file, + }, +]; + +add_setup(async function setup() { + await SpecialPowers.pushPrefEnv({ + set: [["browser.urlbar.trustPanel.featureGate", true]], + }); +}); + +add_task(async function () { + for (let testData of TESTS) { + info(`Testing state of for ${testData.url}`); + + const tab = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + opening: testData.url, + waitForLoad: testData.url != "http://127.0.0.1/", + }); + + let doc = tab.ownerDocument; + let icon = doc.defaultView.getComputedStyle( + doc.getElementById("trust-icon") + ).listStyleImage; + let iconUrl = icon.match(/url\("([^"]+)"\)/)?.[1] ?? null; + + Assert.equal(iconUrl, testData.icon, "Trustpanel urlbar icon is correct"); + + BrowserTestUtils.removeTab(tab); + } +}); diff --git a/browser/themes/shared/identity-block/identity-block.css b/browser/themes/shared/identity-block/identity-block.css @@ -319,6 +319,10 @@ list-style-image: url(chrome://browser/skin/trust-icon-warning.svg); } + &.file { + list-style-image: url(chrome://global/skin/icons/page-portrait.svg); + } + .urlbar-input-container[pageproxystate="valid"] > &:not(.chickletShown) { display: flex; }