1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_mixedcontent_securityflags.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// The test loads a web page with mixed active and display content 1.8 +// on it while the "block mixed content" settings are _on_. 1.9 +// It then checks that the mixed content flags have been set correctly. 1.10 +// The test then overrides the MCB settings and checks that the flags 1.11 +// have been set correctly again. 1.12 +// Bug 838396 - Not setting hasMixedDisplayContentLoaded and 1.13 +// hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp 1.14 + 1.15 +const TEST_URI = "https://example.com/browser/browser/base/content/test/general/test-mixedcontent-securityerrors.html"; 1.16 +let gTestBrowser = null; 1.17 + 1.18 +function test() 1.19 +{ 1.20 + waitForExplicitFinish(); 1.21 + SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_active_content", true], 1.22 + ["security.mixed_content.block_display_content", true]]}, blockMixedContentTest); 1.23 +} 1.24 + 1.25 +function blockMixedContentTest() 1.26 +{ 1.27 + gBrowser.selectedTab = gBrowser.addTab(TEST_URI); 1.28 + let tab = gBrowser.selectedTab; 1.29 + gTestBrowser = gBrowser.getBrowserForTab(tab); 1.30 + 1.31 + gTestBrowser.addEventListener("load", function onLoad(aEvent) { 1.32 + gTestBrowser.removeEventListener(aEvent.type, onLoad, true); 1.33 + is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, true, "hasMixedDisplayContentBlocked flag has been set"); 1.34 + is(gTestBrowser.docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set"); 1.35 + is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, false, "hasMixedDisplayContentLoaded flag has been set"); 1.36 + is(gTestBrowser.docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set"); 1.37 + overrideMCB(); 1.38 + }, true); 1.39 +} 1.40 + 1.41 +function overrideMCB() 1.42 +{ 1.43 + gTestBrowser.addEventListener("load", mixedContentOverrideTest, true); 1.44 + var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); 1.45 + ok(notification, "Mixed Content Doorhanger didn't appear"); 1.46 + // Click on the doorhanger to allow mixed content. 1.47 + notification.secondaryActions[0].callback(mixedContentOverrideTest); 1.48 +} 1.49 + 1.50 +function mixedContentOverrideTest() 1.51 +{ 1.52 + gTestBrowser.removeEventListener("load", mixedContentOverrideTest, true); 1.53 + 1.54 + is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has not been set"); 1.55 + is(gTestBrowser.docShell.hasMixedActiveContentLoaded, true, "hasMixedActiveContentLoaded flag has not been set"); 1.56 + is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set"); 1.57 + is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set"); 1.58 + gBrowser.removeCurrentTab(); 1.59 + finish(); 1.60 +}