1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* ***** BEGIN LICENSE BLOCK ***** 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.8 + * 1.9 + * Contributor(s): 1.10 + * Tanvi Vyas <tanvi@mozilla.com> 1.11 + * 1.12 + * ***** END LICENSE BLOCK ***** */ 1.13 + 1.14 +// Tests that the Web Console Mixed Content messages are displayed 1.15 + 1.16 +const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html"; 1.17 + 1.18 +function test() { 1.19 + addTab("data:text/html;charset=utf8,Web Console mixed content test"); 1.20 + browser.addEventListener("load", onLoad, true); 1.21 +} 1.22 + 1.23 +function onLoad(aEvent) { 1.24 + browser.removeEventListener("load", onLoad, true); 1.25 + Services.prefs.setBoolPref("security.mixed_content.block_display_content", false); 1.26 + Services.prefs.setBoolPref("security.mixed_content.block_active_content", false); 1.27 + openConsole(null, testMixedContent); 1.28 +} 1.29 + 1.30 +function testMixedContent(hud) { 1.31 + content.location = TEST_HTTPS_URI; 1.32 + 1.33 + waitForMessages({ 1.34 + webconsole: hud, 1.35 + messages: [{ 1.36 + text: "example.com", 1.37 + category: CATEGORY_NETWORK, 1.38 + severity: SEVERITY_WARNING, 1.39 + }], 1.40 + }).then((results) => { 1.41 + let msg = [...results[0].matched][0]; 1.42 + ok(msg, "page load logged"); 1.43 + ok(msg.classList.contains("mixed-content"), ".mixed-content element"); 1.44 + 1.45 + let link = msg.querySelector(".learn-more-link"); 1.46 + ok(link, "mixed content link element"); 1.47 + is(link.textContent, "[Mixed Content]", "link text is accurate"); 1.48 + 1.49 + let oldOpenLink = hud.openLink; 1.50 + let linkOpened = false; 1.51 + hud.openLink = (url) => { 1.52 + is(url, "https://developer.mozilla.org/docs/Security/MixedContent", 1.53 + "url opened"); 1.54 + linkOpened = true; 1.55 + }; 1.56 + 1.57 + EventUtils.synthesizeMouse(link, 2, 2, {}, link.ownerDocument.defaultView); 1.58 + 1.59 + ok(linkOpened, "clicking the Mixed Content link opened a page"); 1.60 + 1.61 + hud.openLink = oldOpenLink; 1.62 + 1.63 + ok(!msg.classList.contains("filtered-by-type"), "message is not filtered"); 1.64 + 1.65 + hud.setFilterState("netwarn", false); 1.66 + 1.67 + ok(msg.classList.contains("filtered-by-type"), "message is filtered"); 1.68 + 1.69 + hud.setFilterState("netwarn", true); 1.70 + 1.71 + Services.prefs.clearUserPref("security.mixed_content.block_display_content"); 1.72 + Services.prefs.clearUserPref("security.mixed_content.block_active_content"); 1.73 + 1.74 + finishTest(); 1.75 + }); 1.76 +}