|
1 /* |
|
2 * Mixed Content Block frame navigates for target="_top" - Test for Bug 902350 |
|
3 */ |
|
4 |
|
5 |
|
6 const PREF_ACTIVE = "security.mixed_content.block_active_content"; |
|
7 const gHttpTestRoot = "https://example.com/tests/content/base/test/"; |
|
8 var origBlockActive; |
|
9 var gTestBrowser = null; |
|
10 |
|
11 registerCleanupFunction(function() { |
|
12 // Set preferences back to their original values |
|
13 Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); |
|
14 }); |
|
15 |
|
16 function MixedTestsCompleted() { |
|
17 gBrowser.removeCurrentTab(); |
|
18 window.focus(); |
|
19 finish(); |
|
20 } |
|
21 |
|
22 function test() { |
|
23 waitForExplicitFinish(); |
|
24 |
|
25 origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); |
|
26 |
|
27 Services.prefs.setBoolPref(PREF_ACTIVE, true); |
|
28 |
|
29 var newTab = gBrowser.addTab(); |
|
30 gBrowser.selectedTab = newTab; |
|
31 gTestBrowser = gBrowser.selectedBrowser; |
|
32 newTab.linkedBrowser.stop() |
|
33 |
|
34 gTestBrowser.addEventListener("load", MixedTest1A, true); |
|
35 var url = gHttpTestRoot + "file_bug902350.html"; |
|
36 gTestBrowser.contentWindow.location = url; |
|
37 } |
|
38 |
|
39 // Need to capture 2 loads, one for the main page and one for the iframe |
|
40 function MixedTest1A() { |
|
41 gTestBrowser.removeEventListener("load", MixedTest1A, true); |
|
42 gTestBrowser.addEventListener("load", MixedTest1B, true); |
|
43 } |
|
44 |
|
45 // Find the iframe and click the link in it |
|
46 function MixedTest1B() { |
|
47 gTestBrowser.removeEventListener("load", MixedTest1B, true); |
|
48 gTestBrowser.addEventListener("load", MixedTest1C, true); |
|
49 var frame = content.document.getElementById("testing_frame"); |
|
50 var topTarget = frame.contentWindow.document.getElementById("topTarget"); |
|
51 topTarget.click(); |
|
52 |
|
53 // The link click should have caused a load and should not invoke the Mixed Content Blocker |
|
54 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); |
|
55 ok(!notification, "Mixed Content Doorhanger appears when trying to navigate top"); |
|
56 |
|
57 } |
|
58 |
|
59 function MixedTest1C() { |
|
60 gTestBrowser.removeEventListener("load", MixedTest1C, true); |
|
61 ok(gTestBrowser.contentWindow.location == "http://example.com/", "Navigating to insecure domain through target='_top' failed.") |
|
62 MixedTestsCompleted(); |
|
63 } |
|
64 |
|
65 |