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 _on_. |
michael@0 | 6 | // It then checks that the mixed content flags have been set correctly. |
michael@0 | 7 | // The test then overrides the MCB settings and checks that the flags |
michael@0 | 8 | // have been set correctly again. |
michael@0 | 9 | // Bug 838396 - Not setting hasMixedDisplayContentLoaded and |
michael@0 | 10 | // hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp |
michael@0 | 11 | |
michael@0 | 12 | const TEST_URI = "https://example.com/browser/browser/base/content/test/general/test-mixedcontent-securityerrors.html"; |
michael@0 | 13 | let gTestBrowser = null; |
michael@0 | 14 | |
michael@0 | 15 | function test() |
michael@0 | 16 | { |
michael@0 | 17 | waitForExplicitFinish(); |
michael@0 | 18 | SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_active_content", true], |
michael@0 | 19 | ["security.mixed_content.block_display_content", true]]}, blockMixedContentTest); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | function blockMixedContentTest() |
michael@0 | 23 | { |
michael@0 | 24 | gBrowser.selectedTab = gBrowser.addTab(TEST_URI); |
michael@0 | 25 | let tab = gBrowser.selectedTab; |
michael@0 | 26 | gTestBrowser = gBrowser.getBrowserForTab(tab); |
michael@0 | 27 | |
michael@0 | 28 | gTestBrowser.addEventListener("load", function onLoad(aEvent) { |
michael@0 | 29 | gTestBrowser.removeEventListener(aEvent.type, onLoad, true); |
michael@0 | 30 | is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, true, "hasMixedDisplayContentBlocked flag has been set"); |
michael@0 | 31 | is(gTestBrowser.docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set"); |
michael@0 | 32 | is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, false, "hasMixedDisplayContentLoaded flag has been set"); |
michael@0 | 33 | is(gTestBrowser.docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set"); |
michael@0 | 34 | overrideMCB(); |
michael@0 | 35 | }, true); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function overrideMCB() |
michael@0 | 39 | { |
michael@0 | 40 | gTestBrowser.addEventListener("load", mixedContentOverrideTest, true); |
michael@0 | 41 | var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); |
michael@0 | 42 | ok(notification, "Mixed Content Doorhanger didn't appear"); |
michael@0 | 43 | // Click on the doorhanger to allow mixed content. |
michael@0 | 44 | notification.secondaryActions[0].callback(mixedContentOverrideTest); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function mixedContentOverrideTest() |
michael@0 | 48 | { |
michael@0 | 49 | gTestBrowser.removeEventListener("load", mixedContentOverrideTest, true); |
michael@0 | 50 | |
michael@0 | 51 | is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has not been set"); |
michael@0 | 52 | is(gTestBrowser.docShell.hasMixedActiveContentLoaded, true, "hasMixedActiveContentLoaded flag has not been set"); |
michael@0 | 53 | is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set"); |
michael@0 | 54 | is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set"); |
michael@0 | 55 | gBrowser.removeCurrentTab(); |
michael@0 | 56 | finish(); |
michael@0 | 57 | } |