browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* ***** BEGIN LICENSE BLOCK *****
michael@0 3 * Any copyright is dedicated to the Public Domain.
michael@0 4 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 5 *
michael@0 6 * Contributor(s):
michael@0 7 * Tanvi Vyas <tanvi@mozilla.com>
michael@0 8 *
michael@0 9 * ***** END LICENSE BLOCK ***** */
michael@0 10
michael@0 11 // Tests that the Web Console Mixed Content messages are displayed
michael@0 12
michael@0 13 const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html";
michael@0 14
michael@0 15 function test() {
michael@0 16 addTab("data:text/html;charset=utf8,Web Console mixed content test");
michael@0 17 browser.addEventListener("load", onLoad, true);
michael@0 18 }
michael@0 19
michael@0 20 function onLoad(aEvent) {
michael@0 21 browser.removeEventListener("load", onLoad, true);
michael@0 22 Services.prefs.setBoolPref("security.mixed_content.block_display_content", false);
michael@0 23 Services.prefs.setBoolPref("security.mixed_content.block_active_content", false);
michael@0 24 openConsole(null, testMixedContent);
michael@0 25 }
michael@0 26
michael@0 27 function testMixedContent(hud) {
michael@0 28 content.location = TEST_HTTPS_URI;
michael@0 29
michael@0 30 waitForMessages({
michael@0 31 webconsole: hud,
michael@0 32 messages: [{
michael@0 33 text: "example.com",
michael@0 34 category: CATEGORY_NETWORK,
michael@0 35 severity: SEVERITY_WARNING,
michael@0 36 }],
michael@0 37 }).then((results) => {
michael@0 38 let msg = [...results[0].matched][0];
michael@0 39 ok(msg, "page load logged");
michael@0 40 ok(msg.classList.contains("mixed-content"), ".mixed-content element");
michael@0 41
michael@0 42 let link = msg.querySelector(".learn-more-link");
michael@0 43 ok(link, "mixed content link element");
michael@0 44 is(link.textContent, "[Mixed Content]", "link text is accurate");
michael@0 45
michael@0 46 let oldOpenLink = hud.openLink;
michael@0 47 let linkOpened = false;
michael@0 48 hud.openLink = (url) => {
michael@0 49 is(url, "https://developer.mozilla.org/docs/Security/MixedContent",
michael@0 50 "url opened");
michael@0 51 linkOpened = true;
michael@0 52 };
michael@0 53
michael@0 54 EventUtils.synthesizeMouse(link, 2, 2, {}, link.ownerDocument.defaultView);
michael@0 55
michael@0 56 ok(linkOpened, "clicking the Mixed Content link opened a page");
michael@0 57
michael@0 58 hud.openLink = oldOpenLink;
michael@0 59
michael@0 60 ok(!msg.classList.contains("filtered-by-type"), "message is not filtered");
michael@0 61
michael@0 62 hud.setFilterState("netwarn", false);
michael@0 63
michael@0 64 ok(msg.classList.contains("filtered-by-type"), "message is filtered");
michael@0 65
michael@0 66 hud.setFilterState("netwarn", true);
michael@0 67
michael@0 68 Services.prefs.clearUserPref("security.mixed_content.block_display_content");
michael@0 69 Services.prefs.clearUserPref("security.mixed_content.block_active_content");
michael@0 70
michael@0 71 finishTest();
michael@0 72 });
michael@0 73 }

mercurial