Bug 902350 - Mochitest. r=smaug

This commit is contained in:
Tanvi Vyas 2013-08-18 12:32:09 -07:00
parent ebce935b9a
commit fbb2152434
4 changed files with 101 additions and 0 deletions

View File

@ -615,6 +615,8 @@ MOCHITEST_FILES_C= \
file_mixed_content_frameNavigation_secure.html \
file_mixed_content_frameNavigation_secure_grandchild.html \
file_mixed_content_frameNavigation_blankTarget.html \
file_bug902350.html \
file_bug902350_frame.html \
test_bug789856.html \
file_bug804395.jar \
test_bug804395.html \
@ -705,6 +707,7 @@ MOCHITEST_FILES_PARTS = $(foreach s,A B C,MOCHITEST_FILES_$(s))
MOCHITEST_BROWSER_FILES = \
browser_bug593387.js \
browser_bug902350.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

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

View File

@ -0,0 +1,19 @@
<DOCTYPE HTML>
<html>
<!--
Test for Mixed Content Blocker target="_top" frame navigation
https://bugzilla.mozilla.org/show_bug.cgi?id=902350
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 902350</title>
</head>
<body>
<div id="framediv">
<iframe src="https://example.com/tests/content/base/test/file_bug902350_frame.html" id="testing_frame"></iframe>
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker - Opening link with _top target from an https iframe.
https://bugzilla.mozilla.org/show_bug.cgi?id=902350
-->
<head>
<meta charset="utf-8">
<title>Tests for Mixed Content Frame Navigation</title>
</head>
<body>
<a href="http://example.com/" id="topTarget" target="_top">Go to http site</a>
</body>
</html>