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