browser_no_mcb_on_http_site.js (3897B)
1 /* 2 * Description of the Tests for 3 * - Bug 909920 - Mixed content warning should not show on a HTTP site 4 * 5 * Description of the tests: 6 * Test 1: 7 * 1) Load an http page 8 * 2) The page includes a css file using https 9 * 3) The css file loads an |IMAGE| << over http 10 * 11 * Test 2: 12 * 1) Load an http page 13 * 2) The page includes a css file using https 14 * 3) The css file loads a |FONT| over http 15 * 16 * Test 3: 17 * 1) Load an http page 18 * 2) The page includes a css file using https 19 * 3) The css file imports (@import) another css file using http 20 * 3) The imported css file loads a |FONT| over http 21 * 22 * Since the top-domain is >> NOT << served using https, the MCB 23 * should >> NOT << trigger a warning. 24 */ 25 26 const PREF_ACTIVE = "security.mixed_content.block_active_content"; 27 const PREF_DISPLAY = "security.mixed_content.block_display_content"; 28 29 const HTTP_TEST_ROOT = getRootDirectory(gTestPath).replace( 30 "chrome://mochitests/content", 31 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 32 "http://example.com" 33 ); 34 35 var gTestBrowser = null; 36 37 function cleanUpAfterTests() { 38 gBrowser.removeCurrentTab(); 39 window.focus(); 40 } 41 42 add_setup(async function () { 43 await SpecialPowers.pushPrefEnv({ 44 set: [ 45 [PREF_ACTIVE, true], 46 [PREF_DISPLAY, true], 47 ], 48 }); 49 let url = HTTP_TEST_ROOT + "test_no_mcb_on_http_site_img.html"; 50 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); 51 gTestBrowser = tab.linkedBrowser; 52 }); 53 54 // ------------- TEST 1 ----------------------------------------- 55 56 add_task(async function test1() { 57 let expected = 58 "Verifying MCB does not trigger warning/error for an http page "; 59 expected += "with https css that includes http image"; 60 61 await SpecialPowers.spawn( 62 gTestBrowser, 63 [expected], 64 async function (condition) { 65 await ContentTaskUtils.waitForCondition( 66 () => content.document.getElementById("testDiv").innerHTML == condition, 67 "Waited too long for status in Test 1!" 68 ); 69 } 70 ); 71 72 // Explicit OKs needed because the harness requires at least one call to ok. 73 ok(true, "test 1 passed"); 74 75 // set up test 2 76 let url = HTTP_TEST_ROOT + "test_no_mcb_on_http_site_font.html"; 77 BrowserTestUtils.startLoadingURIString(gTestBrowser, url); 78 await BrowserTestUtils.browserLoaded(gTestBrowser); 79 }); 80 81 // ------------- TEST 2 ----------------------------------------- 82 83 add_task(async function test2() { 84 let expected = 85 "Verifying MCB does not trigger warning/error for an http page "; 86 expected += "with https css that includes http font"; 87 88 await SpecialPowers.spawn( 89 gTestBrowser, 90 [expected], 91 async function (condition) { 92 await ContentTaskUtils.waitForCondition( 93 () => content.document.getElementById("testDiv").innerHTML == condition, 94 "Waited too long for status in Test 2!" 95 ); 96 } 97 ); 98 99 ok(true, "test 2 passed"); 100 101 // set up test 3 102 let url = HTTP_TEST_ROOT + "test_no_mcb_on_http_site_font2.html"; 103 BrowserTestUtils.startLoadingURIString(gTestBrowser, url); 104 await BrowserTestUtils.browserLoaded(gTestBrowser); 105 }); 106 107 // ------------- TEST 3 ----------------------------------------- 108 109 add_task(async function test3() { 110 let expected = 111 "Verifying MCB does not trigger warning/error for an http page "; 112 expected += 113 "with https css that imports another http css which includes http font"; 114 115 await SpecialPowers.spawn( 116 gTestBrowser, 117 [expected], 118 async function (condition) { 119 await ContentTaskUtils.waitForCondition( 120 () => content.document.getElementById("testDiv").innerHTML == condition, 121 "Waited too long for status in Test 3!" 122 ); 123 } 124 ); 125 126 ok(true, "test3 passed"); 127 }); 128 129 // ------------------------------------------------------ 130 131 add_task(async function cleanup() { 132 BrowserTestUtils.removeTab(gBrowser.selectedTab); 133 });