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