browser_webconsole_allow_mixedcontent_securityerrors.js (2415B)
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 display content 5 // on it while the "block mixed content" settings are _off_. 6 // It then checks that the loading mixed content warning messages 7 // are logged to the console and have the correct "Learn More" 8 // url appended to them. 9 // Bug 875456 - Log mixed content messages from the Mixed Content 10 // Blocker to the Security Pane in the Web Console 11 12 "use strict"; 13 14 const TEST_URI = 15 "https://example.com/browser/devtools/client/webconsole/" + 16 "test/browser/test-mixedcontent-securityerrors.html"; 17 const LEARN_MORE_URI = 18 "https://developer.mozilla.org/docs/Web/Security/" + 19 "Mixed_content" + 20 DOCS_GA_PARAMS; 21 22 add_task(async function () { 23 await Promise.all([ 24 pushPref("security.mixed_content.block_active_content", false), 25 pushPref("security.mixed_content.block_display_content", false), 26 pushPref("security.mixed_content.upgrade_display_content", false), 27 ]); 28 29 const hud = await openNewTabAndConsole(TEST_URI); 30 31 const activeContentText = 32 "Loading mixed (insecure) active content " + 33 "\u201chttp://example.com/\u201d on a secure page"; 34 const displayContentText = 35 "Loading mixed (insecure) display content " + 36 "\u201chttp://example.com/tests/image/test/mochitest/blue.png\u201d on a secure page"; 37 38 const waitUntilWarningMessage = text => 39 waitFor(() => findWarningMessage(hud, text), undefined, 100); 40 41 const onMixedActiveContent = waitUntilWarningMessage(activeContentText); 42 const onMixedDisplayContent = waitUntilWarningMessage(displayContentText); 43 44 await onMixedDisplayContent; 45 ok(true, "Mixed display content warning message is visible"); 46 47 const mixedActiveContentMessage = await onMixedActiveContent; 48 ok(true, "Mixed active content warning message is visible"); 49 50 const checkLink = ({ link, where, expectedLink, expectedTab }) => { 51 is(link, expectedLink, `Clicking the provided link opens ${link}`); 52 is(where, expectedTab, `Clicking the provided link opens in expected tab`); 53 }; 54 55 info("Clicking on the Learn More link"); 56 const learnMoreLink = 57 mixedActiveContentMessage.querySelector(".learn-more-link"); 58 const linkSimulation = await simulateLinkClick(learnMoreLink); 59 checkLink({ 60 ...linkSimulation, 61 expectedLink: LEARN_MORE_URI, 62 expectedTab: "tab", 63 }); 64 });