browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:eee9bceea962
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 ***** */
10
11 // Tests that the Web Console Mixed Content messages are displayed
12
13 const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html";
14
15 function test() {
16 addTab("data:text/html;charset=utf8,Web Console mixed content test");
17 browser.addEventListener("load", onLoad, true);
18 }
19
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 }
26
27 function testMixedContent(hud) {
28 content.location = TEST_HTTPS_URI;
29
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");
41
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");
45
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 };
53
54 EventUtils.synthesizeMouse(link, 2, 2, {}, link.ownerDocument.defaultView);
55
56 ok(linkOpened, "clicking the Mixed Content link opened a page");
57
58 hud.openLink = oldOpenLink;
59
60 ok(!msg.classList.contains("filtered-by-type"), "message is not filtered");
61
62 hud.setFilterState("netwarn", false);
63
64 ok(msg.classList.contains("filtered-by-type"), "message is filtered");
65
66 hud.setFilterState("netwarn", true);
67
68 Services.prefs.clearUserPref("security.mixed_content.block_display_content");
69 Services.prefs.clearUserPref("security.mixed_content.block_active_content");
70
71 finishTest();
72 });
73 }

mercurial