|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // The test loads a web page with mixed active and display content |
|
5 // on it while the "block mixed content" settings are _off_. |
|
6 // It then checks that the loading mixed content warning messages |
|
7 // are logged to the console and have the correct "Learn More" |
|
8 // url appended to them. |
|
9 // Bug 875456 - Log mixed content messages from the Mixed Content |
|
10 // Blocker to the Security Pane in the Web Console |
|
11 |
|
12 const TEST_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-mixedcontent-securityerrors.html"; |
|
13 const LEARN_MORE_URI = "https://developer.mozilla.org/docs/Security/MixedContent"; |
|
14 |
|
15 function test() |
|
16 { |
|
17 SpecialPowers.pushPrefEnv({"set": |
|
18 [["security.mixed_content.block_active_content", false], |
|
19 ["security.mixed_content.block_display_content", false] |
|
20 ]}, loadingMixedContentTest); |
|
21 } |
|
22 |
|
23 function loadingMixedContentTest() |
|
24 { |
|
25 addTab(TEST_URI); |
|
26 browser.addEventListener("load", function onLoad(aEvent) { |
|
27 browser.removeEventListener(aEvent.type, onLoad, true); |
|
28 openConsole(null, function testSecurityErrorLogged (hud) { |
|
29 waitForMessages({ |
|
30 webconsole: hud, |
|
31 messages: [ |
|
32 { |
|
33 name: "Logged mixed active content", |
|
34 text: "Loading mixed (insecure) active content on a secure page \"http://example.com/\"", |
|
35 category: CATEGORY_SECURITY, |
|
36 severity: SEVERITY_WARNING, |
|
37 objects: true, |
|
38 }, |
|
39 { |
|
40 name: "Logged mixed passive content - image", |
|
41 text: "Loading mixed (insecure) display content on a secure page \"http://example.com/tests/image/test/mochitest/blue.png\"", |
|
42 category: CATEGORY_SECURITY, |
|
43 severity: SEVERITY_WARNING, |
|
44 objects: true, |
|
45 }, |
|
46 ], |
|
47 }).then((results) => testClickOpenNewTab(hud, results)); |
|
48 }); |
|
49 }, true); |
|
50 } |
|
51 |
|
52 function testClickOpenNewTab(hud, results) { |
|
53 let warningNode = results[0].clickableElements[0]; |
|
54 ok(warningNode, "link element"); |
|
55 ok(warningNode.classList.contains("learn-more-link"), "link class name"); |
|
56 |
|
57 // Invoke the click event and check if a new tab would open to the correct page. |
|
58 let linkOpened = false; |
|
59 let oldOpenUILinkIn = window.openUILinkIn; |
|
60 window.openUILinkIn = function(aLink) { |
|
61 if (aLink == LEARN_MORE_URI) { |
|
62 linkOpened = true; |
|
63 } |
|
64 } |
|
65 |
|
66 EventUtils.synthesizeMouse(warningNode, 2, 2, {}, |
|
67 warningNode.ownerDocument.defaultView); |
|
68 ok(linkOpened, "Clicking the Learn More Warning node opens the desired page"); |
|
69 window.openUILinkIn = oldOpenUILinkIn; |
|
70 |
|
71 finishTest(); |
|
72 } |