From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser_identityPopup_custom_roots.js | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 browser/base/content/test/siteIdentity/browser_identityPopup_custom_roots.js (limited to 'browser/base/content/test/siteIdentity/browser_identityPopup_custom_roots.js') diff --git a/browser/base/content/test/siteIdentity/browser_identityPopup_custom_roots.js b/browser/base/content/test/siteIdentity/browser_identityPopup_custom_roots.js new file mode 100644 index 0000000000..2b9ef53bb0 --- /dev/null +++ b/browser/base/content/test/siteIdentity/browser_identityPopup_custom_roots.js @@ -0,0 +1,82 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* Test that the UI for imported root certificates shows up correctly in the identity popup. + */ + +const TEST_PATH = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" +); + +// This test is incredibly simple, because our test framework already +// imports root certificates by default, so we just visit example.com +// and verify that the custom root certificates UI is visible. +add_task(async function test_https() { + await BrowserTestUtils.withNewTab("https://example.com", async function () { + let promisePanelOpen = BrowserTestUtils.waitForEvent( + window, + "popupshown", + true, + event => event.target == gIdentityHandler._identityPopup + ); + + gIdentityHandler._identityIconBox.click(); + await promisePanelOpen; + let customRootWarning = document.getElementById( + "identity-popup-security-decription-custom-root" + ); + ok( + BrowserTestUtils.is_visible(customRootWarning), + "custom root warning is visible" + ); + + let securityView = document.getElementById("identity-popup-securityView"); + let shown = BrowserTestUtils.waitForEvent(securityView, "ViewShown"); + document.getElementById("identity-popup-security-button").click(); + await shown; + + let subPanelInfo = document.getElementById( + "identity-popup-content-verifier-unknown" + ); + ok( + BrowserTestUtils.is_visible(subPanelInfo), + "custom root warning in sub panel is visible" + ); + }); +}); + +// Also check that there are conditions where this isn't shown. +add_task(async function test_http() { + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + await BrowserTestUtils.withNewTab("http://example.com", async function () { + let promisePanelOpen = BrowserTestUtils.waitForEvent( + window, + "popupshown", + true, + event => event.target == gIdentityHandler._identityPopup + ); + gIdentityHandler._identityIconBox.click(); + await promisePanelOpen; + let customRootWarning = document.getElementById( + "identity-popup-security-decription-custom-root" + ); + ok( + BrowserTestUtils.is_hidden(customRootWarning), + "custom root warning is hidden" + ); + + let securityView = document.getElementById("identity-popup-securityView"); + let shown = BrowserTestUtils.waitForEvent(securityView, "ViewShown"); + document.getElementById("identity-popup-security-button").click(); + await shown; + + let subPanelInfo = document.getElementById( + "identity-popup-content-verifier-unknown" + ); + ok( + BrowserTestUtils.is_hidden(subPanelInfo), + "custom root warning in sub panel is hidden" + ); + }); +}); -- cgit v1.2.3