tor-browser

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

commit 10f0c275184c8fdd69a84162b95422f7c9365ce8
parent 4ac13e89818ca3dfd3d088c41cb6acb55e6a7895
Author: Dale Harvey <dale@arandomurl.com>
Date:   Sat, 10 Jan 2026 17:18:41 +0000

Bug 2006026 - Don't overwrite connection attribute during trustpanel navigation. r=daisuke,desktop-theme-reviewers,urlbar-reviewers

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

Diffstat:
Mbrowser/base/content/browser-trustPanel.js | 5+----
Mbrowser/components/controlcenter/content/trustPanel.inc.xhtml | 4++--
Mbrowser/components/urlbar/tests/browser/browser.toml | 1+
Mbrowser/components/urlbar/tests/browser/browser_trust_panel_pages.js | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mbrowser/themes/shared/controlcenter/panel.css | 2+-
5 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/browser/base/content/browser-trustPanel.js b/browser/base/content/browser-trustPanel.js @@ -332,10 +332,7 @@ class TrustPanel { } else { this.#host = ""; } - this.#popup.setAttribute( - "connection", - this.#isSecurePage() ? "secure" : "not-secure" - ); + this.#popup.setAttribute("connection", this.#connectionState()); this.#popup.setAttribute( "tracking-protection", this.#trackingProtectionStatus() diff --git a/browser/components/controlcenter/content/trustPanel.inc.xhtml b/browser/components/controlcenter/content/trustPanel.inc.xhtml @@ -34,13 +34,13 @@ <hbox> <image id="trustpanel-graphic-image"></image> <vbox id="trustpanel-graphic-section-text"> - <label when-connection="secure secure-ev secure-cert-user-overridden chrome" + <label when-connection="secure secure-ev secure-cert-user-overridden chrome file extension" id="trustpanel-header" class="trustpanel-header"></label> <label when-connection="not-secure cert-error-page net-error-page https-only-error-page" class="trustpanel-header" data-l10n-id="trustpanel-header-enabled-insecure"></label> - <label when-connection="secure secure-ev secure-cert-user-overridden chrome" + <label when-connection="secure secure-ev secure-cert-user-overridden chrome file extension" id="trustpanel-description"></label> <label when-connection="not-secure cert-error-page net-error-page https-only-error-page" data-l10n-id="trustpanel-description-enabled-insecure"></label> diff --git a/browser/components/urlbar/tests/browser/browser.toml b/browser/components/urlbar/tests/browser/browser.toml @@ -717,6 +717,7 @@ https_first_disabled = true support-files = ["!/browser/base/content/test/protectionsUI/trackingPage.html"] ["browser_trust_panel_pages.js"] +https_first_disabled = true ["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 @@ -9,48 +9,95 @@ 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", + secure: "chrome://global/skin/icons/security.svg", + broken: "chrome://global/skin/icons/security-broken.svg", }; const TESTS = [ { url: "about:about", icon: ICONS.active, + connectionIcon: ICONS.secure, + descriptionSection: "trustpanel-header-enabled", }, { url: "https://example.com", icon: ICONS.active, + connectionIcon: ICONS.secure, + descriptionSection: "trustpanel-header-enabled", }, { - url: "http://127.0.0.1/", + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + url: "http://example.com", icon: ICONS.insecure, - waitForLoad: false, + connectionIcon: ICONS.broken, + descriptionSection: "trustpanel-header-enabled-insecure", }, ]; -add_setup(async function setup() { +let fetchIconUrl = (doc, id) => { + let icon = doc.defaultView.getComputedStyle( + doc.getElementById(id) + ).listStyleImage; + return icon.match(/url\("([^"]+)"\)/)?.[1] ?? null; +}; + +add_task(async function () { await SpecialPowers.pushPrefEnv({ set: [["browser.urlbar.trustPanel.featureGate", true]], }); -}); -add_task(async function () { + let extension = ExtensionTestUtils.loadExtension({ + manifest: { + web_accessible_resources: ["test_page.html"], + }, + files: { + "test_page.html": `<!doctype html><title>title</title>`, + }, + }); + + await extension.startup(); + + TESTS.push({ + url: `moz-extension://${extension.uuid}/test_page.html`, + icon: ICONS.active, + connectionIcon: ICONS.secure, + descriptionSection: "trustpanel-header-enabled", + }); + 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( + fetchIconUrl(tab.ownerDocument, "trust-icon"), + testData.icon, + "Trustpanel urlbar icon is correct" + ); + + await UrlbarTestUtils.openTrustPanel(window); + Assert.equal( + fetchIconUrl(tab.ownerDocument, "trustpanel-connection-icon"), + testData.connectionIcon, + "Trustpanel connection icon is correct" + ); - Assert.equal(iconUrl, testData.icon, "Trustpanel urlbar icon is correct"); + Assert.ok( + BrowserTestUtils.isVisible( + tab.ownerDocument.querySelector( + `label[data-l10n-id=${testData.descriptionSection}]` + ) + ), + "Expected description section is visible" + ); + await UrlbarTestUtils.closeTrustPanel(window); BrowserTestUtils.removeTab(tab); } + + await extension.unload(); }); diff --git a/browser/themes/shared/controlcenter/panel.css b/browser/themes/shared/controlcenter/panel.css @@ -897,7 +897,7 @@ #trustpanel-siteinfo-icon { list-style-image: url(chrome://global/skin/icons/security-broken.svg); - #trustpanel-popup[connection^="secure"] & { + #trustpanel-popup:is([connection^="secure"], [connection="extension"], [connection="chrome"], [connection="file"]) & { list-style-image: url(chrome://global/skin/icons/security.svg); } }