commit 274a9fc7ec861f26de90e11786a0c07097e3b42a
parent 2e8cbd62ceb3f409bc311c73c86d80f81d79c115
Author: Maile Lucks <maile.lucks@gmail.com>
Date: Thu, 16 Oct 2025 15:34:18 +0000
Bug 1994309 - Localize felt privacy error pref to browser_mixed_content_cert_override - r=jaws
Differential Revision: https://phabricator.services.mozilla.com/D268763
Diffstat:
3 files changed, 65 insertions(+), 28 deletions(-)
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
@@ -39,10 +39,14 @@ async function checkIdentityPopup(icon) {
);
}
-add_task(async function () {
+async function checkMixedContentCertOverride(feltPrivacyV1) {
await BrowserTestUtils.openNewForegroundTab(gBrowser);
+ Services.prefs.setBoolPref(
+ "security.certerrors.felt-privacy-v1",
+ feltPrivacyV1
+ );
// check that a warning is shown when loading a page with mixed content and an overridden certificate
- await loadBadCertPage(MIXED_CONTENT_URL);
+ await loadBadCertPage(MIXED_CONTENT_URL, feltPrivacyV1);
await checkIdentityPopup("security-warning.svg");
// check that a warning is shown even without mixed content
@@ -58,6 +62,9 @@ add_task(async function () {
"@mozilla.org/security/certoverride;1"
].getService(Ci.nsICertOverrideService);
certOverrideService.clearValidityOverride("self-signed.example.com", -1, {});
-
BrowserTestUtils.removeTab(gBrowser.selectedTab);
-});
+ Services.prefs.clearUserPref("security.certerrors.felt-privacy-v1");
+}
+
+add_task(async () => await checkMixedContentCertOverride(true));
+add_task(async () => await checkMixedContentCertOverride(false));
diff --git a/browser/base/content/test/siteIdentity/head.js b/browser/base/content/test/siteIdentity/head.js
@@ -395,31 +395,58 @@ async function assertMixedContentBlockingState(tabbrowser, states = {}) {
}
}
-async function loadBadCertPage(url) {
+async function loadBadCertPage(url, feltPrivacyV1) {
const loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser);
- BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, url);
+ const loadFlagsSkipCache =
+ Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY |
+ Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
+ BrowserTestUtils.startLoadingURIString(
+ gBrowser.selectedBrowser,
+ url,
+ loadFlagsSkipCache
+ );
await loaded;
- 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 SpecialPowers.spawn(
+ gBrowser.selectedBrowser,
+ [feltPrivacyV1],
+ async prefFeltPrivacyV1 => {
+ if (prefFeltPrivacyV1) {
+ const netErrorCard =
+ content.document.querySelector("net-error-card").wrappedJSObject;
+ await netErrorCard.getUpdateComplete();
+ EventUtils.synthesizeMouseAtCenter(
+ netErrorCard.advancedButton,
+ {},
+ content
+ );
+ await ContentTaskUtils.waitForCondition(() => {
+ return (
+ netErrorCard.exceptionButton &&
+ !netErrorCard.exceptionButton.disabled
+ );
+ }, "Waiting for exception button");
+ netErrorCard.exceptionButton.scrollIntoView(true);
+ EventUtils.synthesizeMouseAtCenter(
+ netErrorCard.exceptionButton,
+ {},
+ content
+ );
+ } else {
+ const advancedButton =
+ content.document.getElementById("advancedButton");
+ advancedButton.scrollIntoView(true);
+ EventUtils.synthesizeMouseAtCenter(advancedButton, {}, content);
+ const exceptionButton = content.document.getElementById(
+ "exceptionDialogButton"
+ );
+ await ContentTaskUtils.waitForCondition(() => {
+ return exceptionButton && !exceptionButton.disabled;
+ }, "Waiting for exception button");
+ exceptionButton.scrollIntoView(true);
+ EventUtils.synthesizeMouseAtCenter(exceptionButton, {}, content);
+ }
+ }
+ );
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
}
diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.sys.mjs b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.sys.mjs
@@ -954,10 +954,13 @@ export var BrowserTestUtils = {
* A xul:browser.
* @param {string} uri
* The URI to load.
+ * @param {number} loadFlags [optional]
+ * Load flags to pass to nsIWebNavigation.loadURI.
*/
- startLoadingURIString(browser, uri) {
+ startLoadingURIString(browser, uri, loadFlags) {
browser.fixupAndLoadURIString(uri, {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+ loadFlags,
});
},