michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // The test loads a web page with mixed active and display content michael@0: // on it while the "block mixed content" settings are _on_. michael@0: // It then checks that the mixed content flags have been set correctly. michael@0: // The test then overrides the MCB settings and checks that the flags michael@0: // have been set correctly again. michael@0: // Bug 838396 - Not setting hasMixedDisplayContentLoaded and michael@0: // hasMixedDisplayContentBlocked flag in nsMixedContentBlocker.cpp michael@0: michael@0: const TEST_URI = "https://example.com/browser/browser/base/content/test/general/test-mixedcontent-securityerrors.html"; michael@0: let gTestBrowser = null; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_active_content", true], michael@0: ["security.mixed_content.block_display_content", true]]}, blockMixedContentTest); michael@0: } michael@0: michael@0: function blockMixedContentTest() michael@0: { michael@0: gBrowser.selectedTab = gBrowser.addTab(TEST_URI); michael@0: let tab = gBrowser.selectedTab; michael@0: gTestBrowser = gBrowser.getBrowserForTab(tab); michael@0: michael@0: gTestBrowser.addEventListener("load", function onLoad(aEvent) { michael@0: gTestBrowser.removeEventListener(aEvent.type, onLoad, true); michael@0: is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, true, "hasMixedDisplayContentBlocked flag has been set"); michael@0: is(gTestBrowser.docShell.hasMixedActiveContentBlocked, true, "hasMixedActiveContentBlocked flag has been set"); michael@0: is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, false, "hasMixedDisplayContentLoaded flag has been set"); michael@0: is(gTestBrowser.docShell.hasMixedActiveContentLoaded, false, "hasMixedActiveContentLoaded flag has been set"); michael@0: overrideMCB(); michael@0: }, true); michael@0: } michael@0: michael@0: function overrideMCB() michael@0: { michael@0: gTestBrowser.addEventListener("load", mixedContentOverrideTest, true); michael@0: var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); michael@0: ok(notification, "Mixed Content Doorhanger didn't appear"); michael@0: // Click on the doorhanger to allow mixed content. michael@0: notification.secondaryActions[0].callback(mixedContentOverrideTest); michael@0: } michael@0: michael@0: function mixedContentOverrideTest() michael@0: { michael@0: gTestBrowser.removeEventListener("load", mixedContentOverrideTest, true); michael@0: michael@0: is(gTestBrowser.docShell.hasMixedDisplayContentLoaded, true, "hasMixedDisplayContentLoaded flag has not been set"); michael@0: is(gTestBrowser.docShell.hasMixedActiveContentLoaded, true, "hasMixedActiveContentLoaded flag has not been set"); michael@0: is(gTestBrowser.docShell.hasMixedDisplayContentBlocked, false, "second hasMixedDisplayContentBlocked flag has been set"); michael@0: is(gTestBrowser.docShell.hasMixedActiveContentBlocked, false, "second hasMixedActiveContentBlocked flag has been set"); michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }