1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/browser_bug902350.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* 1.5 + * Mixed Content Block frame navigates for target="_top" - Test for Bug 902350 1.6 + */ 1.7 + 1.8 + 1.9 +const PREF_ACTIVE = "security.mixed_content.block_active_content"; 1.10 +const gHttpTestRoot = "https://example.com/tests/content/base/test/"; 1.11 +var origBlockActive; 1.12 +var gTestBrowser = null; 1.13 + 1.14 +registerCleanupFunction(function() { 1.15 + // Set preferences back to their original values 1.16 + Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); 1.17 +}); 1.18 + 1.19 +function MixedTestsCompleted() { 1.20 + gBrowser.removeCurrentTab(); 1.21 + window.focus(); 1.22 + finish(); 1.23 +} 1.24 + 1.25 +function test() { 1.26 + waitForExplicitFinish(); 1.27 + 1.28 + origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); 1.29 + 1.30 + Services.prefs.setBoolPref(PREF_ACTIVE, true); 1.31 + 1.32 + var newTab = gBrowser.addTab(); 1.33 + gBrowser.selectedTab = newTab; 1.34 + gTestBrowser = gBrowser.selectedBrowser; 1.35 + newTab.linkedBrowser.stop() 1.36 + 1.37 + gTestBrowser.addEventListener("load", MixedTest1A, true); 1.38 + var url = gHttpTestRoot + "file_bug902350.html"; 1.39 + gTestBrowser.contentWindow.location = url; 1.40 +} 1.41 + 1.42 +// Need to capture 2 loads, one for the main page and one for the iframe 1.43 +function MixedTest1A() { 1.44 + gTestBrowser.removeEventListener("load", MixedTest1A, true); 1.45 + gTestBrowser.addEventListener("load", MixedTest1B, true); 1.46 +} 1.47 + 1.48 +// Find the iframe and click the link in it 1.49 +function MixedTest1B() { 1.50 + gTestBrowser.removeEventListener("load", MixedTest1B, true); 1.51 + gTestBrowser.addEventListener("load", MixedTest1C, true); 1.52 + var frame = content.document.getElementById("testing_frame"); 1.53 + var topTarget = frame.contentWindow.document.getElementById("topTarget"); 1.54 + topTarget.click(); 1.55 + 1.56 + // The link click should have caused a load and should not invoke the Mixed Content Blocker 1.57 + var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); 1.58 + ok(!notification, "Mixed Content Doorhanger appears when trying to navigate top"); 1.59 + 1.60 +} 1.61 + 1.62 +function MixedTest1C() { 1.63 + gTestBrowser.removeEventListener("load", MixedTest1C, true); 1.64 + ok(gTestBrowser.contentWindow.location == "http://example.com/", "Navigating to insecure domain through target='_top' failed.") 1.65 + MixedTestsCompleted(); 1.66 +} 1.67 + 1.68 +