"use strict"; const kTestPath = getRootDirectory(gTestPath).replace( "chrome://mochitests/content", "https://example.com" ); const kTestXFrameOptionsURI = kTestPath + "file_framing_error_pages_xfo.html"; const kTestXFrameOptionsURIFrame = kTestPath + "file_framing_error_pages.sjs?xfo"; const kTestFrameAncestorsURI = kTestPath + "file_framing_error_pages_csp.html"; const kTestFrameAncestorsURIFrame = kTestPath + "file_framing_error_pages.sjs?csp"; add_task(async function open_test_xfo_error_page() { await BrowserTestUtils.withNewTab("about:blank", async function (browser) { let loaded = BrowserTestUtils.browserLoaded( browser, true, kTestXFrameOptionsURIFrame, true ); BrowserTestUtils.startLoadingURIString(browser, kTestXFrameOptionsURI); await loaded; await SpecialPowers.spawn(browser, [], async function () { const iframe = content.document.getElementById("testframe"); const getErrorPage = () => { const netErrorCard = iframe.contentDocument?.querySelector("net-error-card"); if (netErrorCard?.shadowRoot) { return netErrorCard.shadowRoot.innerHTML; } return iframe.contentDocument?.body?.innerHTML; }; await ContentTaskUtils.waitForCondition( () => getErrorPage()?.includes("csp-xfo-error-title"), "Waiting for csp-xfo-error-title to appear" ); const errorPage = getErrorPage(); ok(errorPage.includes("csp-xfo-error-title"), "xfo error page correct"); }); }); }); add_task(async function open_test_csp_frame_ancestor_error_page() { await BrowserTestUtils.withNewTab("about:blank", async function (browser) { let loaded = BrowserTestUtils.browserLoaded( browser, true, kTestFrameAncestorsURIFrame, true ); BrowserTestUtils.startLoadingURIString(browser, kTestFrameAncestorsURI); await loaded; await SpecialPowers.spawn(browser, [], async function () { const iframe = content.document.getElementById("testframe"); const getErrorPage = () => { const netErrorCard = iframe.contentDocument?.querySelector("net-error-card"); if (netErrorCard?.shadowRoot) { return netErrorCard.shadowRoot.innerHTML; } return iframe.contentDocument?.body?.innerHTML; }; await ContentTaskUtils.waitForCondition( () => getErrorPage()?.includes("csp-xfo-error-title"), "Waiting for csp-xfo-error-title to appear" ); const errorPage = getErrorPage(); ok(errorPage.includes("csp-xfo-error-title"), "csp error page correct"); }); }); });