browser_mock_https_rr.js (1138B)
1 // This test verifies that Firefox correctly upgrades an HTTP request to HTTPS 2 // when the request's domain name matches network.dns.mock_HTTPS_RR_domain. 3 4 "use strict"; 5 6 const testPathUpgradeable = getRootDirectory(gTestPath).replace( 7 "chrome://mochitests/content", 8 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 9 "http://example.org" 10 ); 11 12 const kTestURI = testPathUpgradeable + "dummy.html"; 13 14 add_task(async function () { 15 // Set the mock_HTTPS_RR_domain and tell necko to use HTTPS RR. 16 await SpecialPowers.pushPrefEnv({ 17 set: [ 18 ["network.dns.mock_HTTPS_RR_domain", "example.org"], 19 ["network.dns.force_use_https_rr", true], 20 ], 21 }); 22 23 await BrowserTestUtils.withNewTab("about:blank", async function (browser) { 24 const loaded = BrowserTestUtils.browserLoaded(browser, false, null, true); 25 // The page should be upgraded to HTTPS. 26 BrowserTestUtils.startLoadingURIString(browser, kTestURI); 27 await loaded; 28 await ContentTask.spawn(browser, {}, async () => { 29 ok( 30 content.document.location.href.startsWith("https://"), 31 "Should be https" 32 ); 33 }); 34 }); 35 });