tor-browser

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

commit 2df12e30164a1b46b01e2b89ee9726cf0a81a3d5
parent 7749fdd33aedaf9d72956cc6fa6e892f1edbf418
Author: Maile Lucks <maile.lucks@gmail.com>
Date:   Tue,  7 Oct 2025 14:30:54 +0000

Bug 1990922 - Update mixed content cert error page to work for felt v1 privacy pref - r=niklas

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

Diffstat:
Mbrowser/base/content/test/siteIdentity/browser.toml | 3+++
Mbrowser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js | 8++++----
Mbrowser/base/content/test/siteIdentity/head.js | 25+++++++++++++++++++++----
Mtoolkit/content/net-error-card.mjs | 2+-
4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/browser/base/content/test/siteIdentity/browser.toml b/browser/base/content/test/siteIdentity/browser.toml @@ -112,6 +112,9 @@ support-files = [ ["browser_mixed_content_cert_override.js"] tags = "mcb" +prefs = [ + "security.certerrors.felt-privacy-v1=true" +] support-files = ["test-mixedcontent-securityerrors.html"] ["browser_mixed_content_with_navigation.js"] diff --git a/browser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js b/browser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js @@ -23,7 +23,8 @@ function getIdentityIcon() { .listStyleImage; } -function checkIdentityPopup(icon) { +async function checkIdentityPopup(icon) { + await openIdentityPopup(); gIdentityHandler.refreshIdentityPopup(); is(getIdentityIcon(), `url("chrome://global/skin/icons/${icon}")`); is(getConnectionState(), "secure-cert-user-overridden"); @@ -40,10 +41,9 @@ function checkIdentityPopup(icon) { add_task(async function () { await BrowserTestUtils.openNewForegroundTab(gBrowser); - // check that a warning is shown when loading a page with mixed content and an overridden certificate await loadBadCertPage(MIXED_CONTENT_URL); - checkIdentityPopup("security-warning.svg"); + await checkIdentityPopup("security-warning.svg"); // check that a warning is shown even without mixed content BrowserTestUtils.startLoadingURIString( @@ -51,7 +51,7 @@ add_task(async function () { "https://self-signed.example.com" ); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - checkIdentityPopup("security-warning.svg"); + await checkIdentityPopup("security-warning.svg"); // remove cert exception let certOverrideService = Cc[ diff --git a/browser/base/content/test/siteIdentity/head.js b/browser/base/content/test/siteIdentity/head.js @@ -396,12 +396,29 @@ async function assertMixedContentBlockingState(tabbrowser, states = {}) { } async function loadBadCertPage(url) { - let loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser); + const loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser); BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, url); await loaded; - - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { - content.document.getElementById("exceptionDialogButton").click(); + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => { + const netErrorCard = + content.document.querySelector("net-error-card").wrappedJSObject; + await netErrorCard.getUpdateComplete(); + await EventUtils.synthesizeMouseAtCenter( + netErrorCard.advancedButton, + {}, + content + ); + await ContentTaskUtils.waitForCondition(() => { + return ( + netErrorCard.exceptionButton && !netErrorCard.exceptionButton.disabled + ); + }, "Waiting for exception button"); + netErrorCard.exceptionButton.scrollIntoView(true); + await EventUtils.synthesizeMouseAtCenter( + netErrorCard.exceptionButton, + {}, + content + ); }); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); } diff --git a/toolkit/content/net-error-card.mjs b/toolkit/content/net-error-card.mjs @@ -148,7 +148,7 @@ export class NetErrorCard extends MozLitElement { break; } case "SSL_ERROR_BAD_CERT_DOMAIN": { - if (!this.domainMismatchNames) { + if (this.domainMismatchNames === null) { this.getDomainMismatchNames(); return null; }