browser_identityPopup_custom_roots.js (2767B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /* Test that the UI for imported root certificates shows up correctly in the identity popup. 5 */ 6 7 const TEST_PATH = getRootDirectory(gTestPath).replace( 8 "chrome://mochitests/content", 9 "https://example.com" 10 ); 11 12 // This test is incredibly simple, because our test framework already 13 // imports root certificates by default, so we just visit example.com 14 // and verify that the custom root certificates UI is visible. 15 add_task(async function test_https() { 16 await BrowserTestUtils.withNewTab("https://example.com", async function () { 17 let promisePanelOpen = BrowserTestUtils.waitForEvent( 18 window, 19 "popupshown", 20 true, 21 event => event.target == gIdentityHandler._identityPopup 22 ); 23 24 gIdentityHandler._identityIconBox.click(); 25 await promisePanelOpen; 26 let customRootWarning = document.getElementById( 27 "identity-popup-security-decription-custom-root" 28 ); 29 ok( 30 BrowserTestUtils.isVisible(customRootWarning), 31 "custom root warning is visible" 32 ); 33 34 let securityView = document.getElementById("identity-popup-securityView"); 35 let shown = BrowserTestUtils.waitForEvent(securityView, "ViewShown"); 36 document.getElementById("identity-popup-security-button").click(); 37 await shown; 38 39 let subPanelInfo = document.getElementById( 40 "identity-popup-content-verifier-unknown" 41 ); 42 ok( 43 BrowserTestUtils.isVisible(subPanelInfo), 44 "custom root warning in sub panel is visible" 45 ); 46 }); 47 }); 48 49 // Also check that there are conditions where this isn't shown. 50 add_task(async function test_http() { 51 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 52 await BrowserTestUtils.withNewTab("http://example.com", async function () { 53 let promisePanelOpen = BrowserTestUtils.waitForEvent( 54 window, 55 "popupshown", 56 true, 57 event => event.target == gIdentityHandler._identityPopup 58 ); 59 gIdentityHandler._identityIconBox.click(); 60 await promisePanelOpen; 61 let customRootWarning = document.getElementById( 62 "identity-popup-security-decription-custom-root" 63 ); 64 ok( 65 BrowserTestUtils.isHidden(customRootWarning), 66 "custom root warning is hidden" 67 ); 68 69 let securityView = document.getElementById("identity-popup-securityView"); 70 let shown = BrowserTestUtils.waitForEvent(securityView, "ViewShown"); 71 document.getElementById("identity-popup-security-button").click(); 72 await shown; 73 74 let subPanelInfo = document.getElementById( 75 "identity-popup-content-verifier-unknown" 76 ); 77 ok( 78 BrowserTestUtils.isHidden(subPanelInfo), 79 "custom root warning in sub panel is hidden" 80 ); 81 }); 82 });