diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js | 69 |
1 files changed, 69 insertions, 0 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 new file mode 100644 index 0000000000..99f4efce9c --- /dev/null +++ b/browser/base/content/test/siteIdentity/browser_mixed_content_cert_override.js @@ -0,0 +1,69 @@ +/* + * Bug 1253771 - check mixed content blocking in combination with overriden certificates + */ + +"use strict"; + +const MIXED_CONTENT_URL = + getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://self-signed.example.com" + ) + "test-mixedcontent-securityerrors.html"; + +function getConnectionState() { + return document.getElementById("identity-popup").getAttribute("connection"); +} + +function getPopupContentVerifier() { + return document.getElementById("identity-popup-content-verifier"); +} + +function getIdentityIcon() { + return window.getComputedStyle(document.getElementById("identity-icon")) + .listStyleImage; +} + +function checkIdentityPopup(icon) { + gIdentityHandler.refreshIdentityPopup(); + is(getIdentityIcon(), `url("chrome://global/skin/icons/${icon}")`); + is(getConnectionState(), "secure-cert-user-overridden"); + isnot( + getPopupContentVerifier().style.display, + "none", + "Overridden certificate warning is shown" + ); + ok( + getPopupContentVerifier().textContent.includes("security exception"), + "Text shows overridden certificate warning." + ); +} + +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"); + + // check that the crossed out icon is shown when disabling mixed content protection + gIdentityHandler.disableMixedContentProtection(); + await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + + checkIdentityPopup("security-broken.svg"); + + // check that a warning is shown even without mixed content + BrowserTestUtils.startLoadingURIString( + gBrowser.selectedBrowser, + "https://self-signed.example.com" + ); + await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); + checkIdentityPopup("security-warning.svg"); + + // remove cert exception + let certOverrideService = Cc[ + "@mozilla.org/security/certoverride;1" + ].getService(Ci.nsICertOverrideService); + certOverrideService.clearValidityOverride("self-signed.example.com", -1, {}); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); +}); |