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