browser_aboutNetError_httpAuthDisabled.js (2598B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const BAD_CERT = "https://expired.example.com/"; 7 8 // The revoked certificate page should not offer a proceed button. 9 add_task(async function checkHttpAuthDisabledCopy() { 10 await setSecurityCertErrorsFeltPrivacyToTrue(); 11 const tab = await openErrorPage(BAD_CERT); 12 const browser = tab.linkedBrowser; 13 14 await SpecialPowers.spawn(browser, [], async function () { 15 const mockErrorInfo = { 16 errorCodeString: "NS_ERROR_BASIC_HTTP_AUTH_DISABLED", 17 channelStatus: 0, 18 errorMessage: "Unauthorized", 19 responseStatusText: "Unauthorized", 20 responseStatus: 401, 21 }; 22 23 content.document.getFailedCertSecurityInfo = () => mockErrorInfo; 24 25 const netErrorCard = 26 content.document.querySelector("net-error-card").wrappedJSObject; 27 const info = Cu.cloneInto(mockErrorInfo, netErrorCard); 28 netErrorCard.errorInfo = info; 29 netErrorCard.hideExceptionButton = netErrorCard.shouldHideExceptionButton( 30 info.errorCodeString 31 ); 32 netErrorCard.requestUpdate(); 33 await netErrorCard.getUpdateComplete(); 34 35 const advancedButton = netErrorCard.advancedButton; 36 advancedButton.scrollIntoView(true); 37 EventUtils.synthesizeMouseAtCenter(advancedButton, {}, content); 38 39 await ContentTaskUtils.waitForCondition( 40 () => netErrorCard.advancedContainer, 41 "Advanced section should be rendered for disabled HTTP auth." 42 ); 43 await ContentTaskUtils.waitForCondition( 44 () => netErrorCard.whyDangerous && netErrorCard.whatCanYouDo, 45 "Disabled HTTP auth copy should be rendered" 46 ); 47 48 Assert.ok( 49 netErrorCard.advancedShowing, 50 "Advanced details are shown disabled HTTP auth." 51 ); 52 Assert.ok( 53 !netErrorCard.exceptionButton, 54 "Proceed button should not be shown for disabled HTTP auth." 55 ); 56 Assert.equal( 57 netErrorCard.whyDangerous.dataset.l10nId, 58 "fp-neterror-http-auth-disabled-why-dangerous-body", 59 "Using the 'http auth disabled' variant of the 'Why Dangerous' copy." 60 ); 61 Assert.equal( 62 netErrorCard.whatCanYouDo.dataset.l10nId, 63 "fp-neterror-http-auth-disabled-what-can-you-do-body", 64 "Using the 'http auth disabled' variant of the 'What can you do' copy." 65 ); 66 Assert.equal( 67 netErrorCard.learnMoreLink.dataset.l10nId, 68 "fp-learn-more-about-https-connections", 69 "'Learn more' link points to the HTTPS Connections page." 70 ); 71 }); 72 73 BrowserTestUtils.removeTab(tab); 74 await SpecialPowers.popPrefEnv(); 75 });