browser_aboutNetError_invalid_header.js (1541B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const INVALID_HEADER = 7 "https://example.com/browser/browser/base/content/test/about/invalid_header.sjs"; 8 9 // From appstrings.properties 10 const EXPECTED_SHORT_DESC = 11 INVALID_HEADER + 12 " sent back a header with empty characters not allowed by web security standards."; 13 14 add_task(async function test_invalidHeaderValue() { 15 let browser; 16 let pageLoaded; 17 18 await BrowserTestUtils.openNewForegroundTab( 19 gBrowser, 20 () => { 21 gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, INVALID_HEADER); 22 browser = gBrowser.selectedBrowser; 23 pageLoaded = BrowserTestUtils.waitForErrorPage(browser); 24 }, 25 false 26 ); 27 28 await pageLoaded; 29 30 await SpecialPowers.spawn( 31 browser, 32 [EXPECTED_SHORT_DESC], 33 function (expectedShortDesc) { 34 const doc = content.document; 35 ok( 36 doc.documentURI.startsWith("about:neterror"), 37 "Should be showing error page" 38 ); 39 40 const titleEl = doc.querySelector(".title-text"); 41 const actualDataL10nID = titleEl.getAttribute("data-l10n-id"); 42 is( 43 actualDataL10nID, 44 "problem-with-this-site-title", 45 "Correct error link title is set" 46 ); 47 const shortDesc = doc.getElementById("errorShortDesc"); 48 ok( 49 shortDesc.textContent.startsWith(expectedShortDesc), 50 "Correct error page title is set" 51 ); 52 } 53 ); 54 55 BrowserTestUtils.removeTab(gBrowser.selectedTab); 56 });