michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // The test loads a web page with mixed active and display content michael@0: // on it while the "block mixed content" settings are _off_. michael@0: // It then checks that the loading mixed content warning messages michael@0: // are logged to the console and have the correct "Learn More" michael@0: // url appended to them. michael@0: // Bug 875456 - Log mixed content messages from the Mixed Content michael@0: // Blocker to the Security Pane in the Web Console michael@0: michael@0: const TEST_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-mixedcontent-securityerrors.html"; michael@0: const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/MixedContent"; michael@0: michael@0: function test() michael@0: { michael@0: SpecialPowers.pushPrefEnv({"set": michael@0: [["security.mixed_content.block_active_content", false], michael@0: ["security.mixed_content.block_display_content", false] michael@0: ]}, loadingMixedContentTest); michael@0: } michael@0: michael@0: function loadingMixedContentTest() michael@0: { michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad(aEvent) { michael@0: browser.removeEventListener(aEvent.type, onLoad, true); michael@0: openConsole(null, function testSecurityErrorLogged (hud) { michael@0: waitForMessages({ michael@0: webconsole: hud, michael@0: messages: [ michael@0: { michael@0: name: "Logged mixed active content", michael@0: text: "Loading mixed (insecure) active content on a secure page \"http://example.com/\"", michael@0: category: CATEGORY_SECURITY, michael@0: severity: SEVERITY_WARNING, michael@0: objects: true, michael@0: }, michael@0: { michael@0: name: "Logged mixed passive content - image", michael@0: text: "Loading mixed (insecure) display content on a secure page \"http://example.com/tests/image/test/mochitest/blue.png\"", michael@0: category: CATEGORY_SECURITY, michael@0: severity: SEVERITY_WARNING, michael@0: objects: true, michael@0: }, michael@0: ], michael@0: }).then((results) => testClickOpenNewTab(hud, results)); michael@0: }); michael@0: }, true); michael@0: } michael@0: michael@0: function testClickOpenNewTab(hud, results) { michael@0: let warningNode = results[0].clickableElements[0]; michael@0: ok(warningNode, "link element"); michael@0: ok(warningNode.classList.contains("learn-more-link"), "link class name"); michael@0: michael@0: // Invoke the click event and check if a new tab would open to the correct page. michael@0: let linkOpened = false; michael@0: let oldOpenUILinkIn = window.openUILinkIn; michael@0: window.openUILinkIn = function(aLink) { michael@0: if (aLink == LEARN_MORE_URI) { michael@0: linkOpened = true; michael@0: } michael@0: } michael@0: michael@0: EventUtils.synthesizeMouse(warningNode, 2, 2, {}, michael@0: warningNode.ownerDocument.defaultView); michael@0: ok(linkOpened, "Clicking the Learn More Warning node opens the desired page"); michael@0: window.openUILinkIn = oldOpenUILinkIn; michael@0: michael@0: finishTest(); michael@0: }