commit 7939b8f6b78bd1e58bc0aa5d528ffda4d4c804bb
parent 29a2d51c2e09d9f8e6ee24f217c6a70c6d5589ae
Author: Dale Harvey <dale@arandomurl.com>
Date: Wed, 8 Oct 2025 12:25:00 +0000
Bug 1989844 - Show file icon when accessing file urls. r=emz
Differential Revision: https://phabricator.services.mozilla.com/D266731
Diffstat:
5 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/browser/base/content/browser-trustPanel.js b/browser/base/content/browser-trustPanel.js
@@ -249,7 +249,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");
@@ -515,9 +517,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)
);
}
@@ -837,7 +839,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,56 @@
+/* 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,
+ waitForLoad: false,
+ },
+];
+
+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.waitForLoad ?? true,
+ });
+
+ 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;
}