browser_mixedcontent_securityflags.js (2153B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // The test loads a web page with mixed active and mixed display content and 5 // makes sure that the mixed content flags on the docshell are set correctly. 6 // * Using default about:config prefs (mixed active blocked, mixed display 7 // loaded) we load the page and check the flags. 8 // * We change the about:config prefs (mixed active blocked, mixed display 9 // blocked), reload the page, and check the flags again. 10 11 const TEST_URI = 12 getRootDirectory(gTestPath).replace( 13 "chrome://mochitests/content", 14 "https://example.com" 15 ) + "test-mixedcontent-securityerrors.html"; 16 const PREF_DISPLAY = "security.mixed_content.block_display_content"; 17 const PREF_DISPLAY_UPGRADE = "security.mixed_content.upgrade_display_content"; 18 const PREF_ACTIVE = "security.mixed_content.block_active_content"; 19 var gTestBrowser = null; 20 21 registerCleanupFunction(function () { 22 // Set preferences back to their original values 23 Services.prefs.clearUserPref(PREF_DISPLAY); 24 Services.prefs.clearUserPref(PREF_DISPLAY_UPGRADE); 25 Services.prefs.clearUserPref(PREF_ACTIVE); 26 gBrowser.removeCurrentTab(); 27 }); 28 29 add_task(async function blockMixedActiveContentTest() { 30 // Turn on mixed active blocking and mixed display loading and load the page. 31 Services.prefs.setBoolPref(PREF_DISPLAY, false); 32 Services.prefs.setBoolPref(PREF_DISPLAY_UPGRADE, false); 33 Services.prefs.setBoolPref(PREF_ACTIVE, true); 34 35 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI); 36 gTestBrowser = gBrowser.getBrowserForTab(tab); 37 38 await assertMixedContentBlockingState(gTestBrowser, { 39 activeLoaded: false, 40 activeBlocked: true, 41 passiveLoaded: true, 42 }); 43 44 // Turn on mixed active and mixed display blocking and reload the page. 45 Services.prefs.setBoolPref(PREF_DISPLAY, true); 46 Services.prefs.setBoolPref(PREF_ACTIVE, true); 47 48 gBrowser.reload(); 49 await BrowserTestUtils.browserLoaded(gTestBrowser); 50 51 await assertMixedContentBlockingState(gTestBrowser, { 52 activeLoaded: false, 53 activeBlocked: true, 54 passiveLoaded: false, 55 }); 56 });