michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* ***** BEGIN LICENSE BLOCK ***** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: * michael@0: * Contributor(s): michael@0: * Tanvi Vyas michael@0: * michael@0: * ***** END LICENSE BLOCK ***** */ michael@0: michael@0: // Tests that the Web Console Mixed Content messages are displayed michael@0: michael@0: const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html"; michael@0: michael@0: function test() { michael@0: addTab("data:text/html;charset=utf8,Web Console mixed content test"); michael@0: browser.addEventListener("load", onLoad, true); michael@0: } michael@0: michael@0: function onLoad(aEvent) { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: Services.prefs.setBoolPref("security.mixed_content.block_display_content", false); michael@0: Services.prefs.setBoolPref("security.mixed_content.block_active_content", false); michael@0: openConsole(null, testMixedContent); michael@0: } michael@0: michael@0: function testMixedContent(hud) { michael@0: content.location = TEST_HTTPS_URI; michael@0: michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [{ michael@0: text: "example.com", michael@0: category: CATEGORY_NETWORK, michael@0: severity: SEVERITY_WARNING, michael@0: }], michael@0: }).then((results) => { michael@0: let msg = [...results[0].matched][0]; michael@0: ok(msg, "page load logged"); michael@0: ok(msg.classList.contains("mixed-content"), ".mixed-content element"); michael@0: michael@0: let link = msg.querySelector(".learn-more-link"); michael@0: ok(link, "mixed content link element"); michael@0: is(link.textContent, "[Mixed Content]", "link text is accurate"); michael@0: michael@0: let oldOpenLink = hud.openLink; michael@0: let linkOpened = false; michael@0: hud.openLink = (url) => { michael@0: is(url, "https://developer.mozilla.org/docs/Security/MixedContent", michael@0: "url opened"); michael@0: linkOpened = true; michael@0: }; michael@0: michael@0: EventUtils.synthesizeMouse(link, 2, 2, {}, link.ownerDocument.defaultView); michael@0: michael@0: ok(linkOpened, "clicking the Mixed Content link opened a page"); michael@0: michael@0: hud.openLink = oldOpenLink; michael@0: michael@0: ok(!msg.classList.contains("filtered-by-type"), "message is not filtered"); michael@0: michael@0: hud.setFilterState("netwarn", false); michael@0: michael@0: ok(msg.classList.contains("filtered-by-type"), "message is filtered"); michael@0: michael@0: hud.setFilterState("netwarn", true); michael@0: michael@0: Services.prefs.clearUserPref("security.mixed_content.block_display_content"); michael@0: Services.prefs.clearUserPref("security.mixed_content.block_active_content"); michael@0: michael@0: finishTest(); michael@0: }); michael@0: }