michael@0: /* michael@0: * Mixed Content Block frame navigates for target="_top" - Test for Bug 902350 michael@0: */ michael@0: michael@0: michael@0: const PREF_ACTIVE = "security.mixed_content.block_active_content"; michael@0: const gHttpTestRoot = "https://example.com/tests/content/base/test/"; michael@0: var origBlockActive; michael@0: var gTestBrowser = null; michael@0: michael@0: registerCleanupFunction(function() { michael@0: // Set preferences back to their original values michael@0: Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive); michael@0: }); michael@0: michael@0: function MixedTestsCompleted() { michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: finish(); michael@0: } michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE); michael@0: michael@0: Services.prefs.setBoolPref(PREF_ACTIVE, true); michael@0: michael@0: var newTab = gBrowser.addTab(); michael@0: gBrowser.selectedTab = newTab; michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: newTab.linkedBrowser.stop() michael@0: michael@0: gTestBrowser.addEventListener("load", MixedTest1A, true); michael@0: var url = gHttpTestRoot + "file_bug902350.html"; michael@0: gTestBrowser.contentWindow.location = url; michael@0: } michael@0: michael@0: // Need to capture 2 loads, one for the main page and one for the iframe michael@0: function MixedTest1A() { michael@0: gTestBrowser.removeEventListener("load", MixedTest1A, true); michael@0: gTestBrowser.addEventListener("load", MixedTest1B, true); michael@0: } michael@0: michael@0: // Find the iframe and click the link in it michael@0: function MixedTest1B() { michael@0: gTestBrowser.removeEventListener("load", MixedTest1B, true); michael@0: gTestBrowser.addEventListener("load", MixedTest1C, true); michael@0: var frame = content.document.getElementById("testing_frame"); michael@0: var topTarget = frame.contentWindow.document.getElementById("topTarget"); michael@0: topTarget.click(); michael@0: michael@0: // The link click should have caused a load and should not invoke the Mixed Content Blocker michael@0: var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestBrowser); michael@0: ok(!notification, "Mixed Content Doorhanger appears when trying to navigate top"); michael@0: michael@0: } michael@0: michael@0: function MixedTest1C() { michael@0: gTestBrowser.removeEventListener("load", MixedTest1C, true); michael@0: ok(gTestBrowser.contentWindow.location == "http://example.com/", "Navigating to insecure domain through target='_top' failed.") michael@0: MixedTestsCompleted(); michael@0: } michael@0: michael@0: