/* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; const AUTH_ROUTE = "https://example.com/browser/browser/base/content/test/about/sandbox_corp_iframe.sjs"; add_task(async function test_coepError_legacy() { let browser; let pageLoaded; await setSecurityCertErrorsFeltPrivacyToFalse(); const uri = `${AUTH_ROUTE}?error=coep`; await BrowserTestUtils.openNewForegroundTab( gBrowser, () => { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri); browser = gBrowser.selectedBrowser; pageLoaded = BrowserTestUtils.waitForErrorPage(browser); }, false ); await pageLoaded; await SpecialPowers.spawn(browser, [], function () { // The error is displayed in the iframe for COEP const doc = content.document.querySelector("iframe").contentDocument; ok( doc.documentURI.startsWith("about:neterror"), "Should be showing error page" ); const titleEl = doc.querySelector(".title-text"); const actualDataL10nID = titleEl.getAttribute("data-l10n-id"); is( actualDataL10nID, "general-body-title", "Correct error link title (CORP) is set" ); const anchor = doc.querySelector("a"); const actualAnchorl10nID = anchor.getAttribute("data-l10n-id"); is( actualAnchorl10nID, "certerror-coep-learn-more", "Correct error link is set" ); }); BrowserTestUtils.removeTab(gBrowser.selectedTab); }); add_task(async function test_coepError() { let browser; let pageLoaded; const uri = `${AUTH_ROUTE}?error=coep`; await setSecurityCertErrorsFeltPrivacyToTrue(); await BrowserTestUtils.openNewForegroundTab( gBrowser, () => { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri); browser = gBrowser.selectedBrowser; pageLoaded = BrowserTestUtils.waitForErrorPage(browser); }, false ); await pageLoaded; await SpecialPowers.spawn(browser, [], async function () { // The error is displayed in the iframe for COEP const doc = content.document.querySelector("iframe").contentDocument; Assert.ok( doc.documentURI.startsWith("about:neterror"), "Should be showing error page" ); const netErrorCard = doc.querySelector("net-error-card").wrappedJSObject; await netErrorCard.getUpdateComplete(); Assert.strictEqual( netErrorCard.errorTitle.dataset.l10nId, "fp-certerror-body-title", "Correct error link title (CORP) is set" ); await ContentTaskUtils.waitForCondition(() => { return ( netErrorCard.learnMoreLink && netErrorCard.learnMoreLink.textContent != "" && netErrorCard.learnMoreLink.tagName.toLowerCase() === "a" ); }, "learn more link is visible and is a link"); Assert.strictEqual( netErrorCard.learnMoreLink.dataset.l10nId, "certerror-coep-learn-more", "Learn more element is a link and has COEP text" ); }); BrowserTestUtils.removeTab(gBrowser.selectedTab); await SpecialPowers.popPrefEnv(); });