Bug 902350 - Mochitest. r=smaug
authorTanvi Vyas <tvyas@mozilla.com>
Sun, 18 Aug 2013 12:32:09 -0700
changeset 143041 75a18dd2b73b
parent 142989 3790c84fc9db
child 143042 8329300901f8
push id25120
push userryanvm@gmail.com
push date2013-08-19 15:52 +0000
treeherdermozilla-central@9b4c4e56f4bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs902350
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 902350 - Mochitest. r=smaug
content/base/test/Makefile.in
content/base/test/browser_bug902350.js
content/base/test/file_bug902350.html
content/base/test/file_bug902350_frame.html
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -610,16 +610,18 @@ MOCHITEST_FILES_C= \
 		bug803225_test_mailto.html \
 		test_mixed_content_blocker_frameNavigation.html \
 		file_mixed_content_frameNavigation.html \
 		file_mixed_content_frameNavigation_innermost.html \
 		file_mixed_content_frameNavigation_grandchild.html \
 		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 \
 		test_bug809003.html \
 		test_bug810494.html \
 		test_bug819051.html \
 		bug819051.sjs \
 		test_textnode_split_in_selection.html \
@@ -700,12 +702,13 @@ MOCHITEST_FILES_PARTS = $(foreach s,A B 
 
 # Disabled for frequent failures (bug 841505, bug 842344, etc)
 #		test_XHR_timeout.html \
 #		test_XHR_timeout.js \
 #		file_XHR_timeout.sjs \
 
 MOCHITEST_BROWSER_FILES = \
 		browser_bug593387.js \
+		browser_bug902350.js \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/content/base/test/browser_bug902350.js
@@ -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();
+}
+
+
new file mode 100644
--- /dev/null
+++ b/content/base/test/file_bug902350.html
@@ -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>
+
+
new file mode 100644
--- /dev/null
+++ b/content/base/test/file_bug902350_frame.html
@@ -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>