Back out 196fbc36c878 (bug 840388) for asserting

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-03-26 20:18:34 -07:00
parent 21e212bf80
commit ab08c180ef
7 changed files with 4 additions and 439 deletions

View File

@ -594,16 +594,10 @@ MOCHITEST_FILES_C= \
test_mixed_content_blocker.html \ test_mixed_content_blocker.html \
file_mixed_content_main.html \ file_mixed_content_main.html \
file_mixed_content_server.sjs \ file_mixed_content_server.sjs \
test_mixed_content_blocker_bug803225.html \ test_mixed_content_blocker_bug803225.html \
file_mixed_content_main_bug803225.html \ file_mixed_content_main_bug803225.html \
file_mixed_content_main_bug803225_websocket_wsh.py \ file_mixed_content_main_bug803225_websocket_wsh.py \
bug803225_test_mailto.html \ 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 \
test_bug789856.html \ test_bug789856.html \
file_bug804395.jar \ file_bug804395.jar \
test_bug804395.html \ test_bug804395.html \

View File

@ -1,74 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker related to navigating children, grandchildren, etc
https://bugzilla.mozilla.org/show_bug.cgi?id=840388
-->
<head>
<meta charset="utf-8">
<title>Tests for Mixed Content Frame Navigation</title>
</head>
<body>
<div id="testContent"></div>
<script>
var baseUrlHttps = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html";
// For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
var MAX_COUNT = 50;
var TIMEOUT_INTERVAL = 100;
var testContent = document.getElementById("testContent");
// Test 1: Navigate secure iframe to insecure iframe on an insecure page
var iframe_test1 = document.createElement("iframe");
var counter_test1 = 0;
iframe_test1.src = baseUrlHttps + "?insecurePage_navigate_child";
iframe_test1.setAttribute("id", "test1");
iframe_test1.onerror = function() {
parent.postMessage({"test": "insecurePage_navigate_child", "msg": "got an onerror alert when loading or navigating testing iframe"}, "http://mochi.test:8888");
};
testContent.appendChild(iframe_test1);
function navigationStatus(iframe_test1)
{
// When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
// Catch that specific exception and return
try {
var loc = document.getElementById("test1").contentDocument.location;
} catch(e) {
if (e.name === "SecurityError") {
// We received an exception we didn't expect.
throw e;
}
counter_test1++;
return;
}
if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_child_response") {
return;
}
else {
if(counter_test1 < MAX_COUNT) {
counter_test1++;
setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
}
else {
// After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
parent.postMessage({"test": "insecurePage_navigate_child", "msg": "navigating to insecure iframe blocked on insecure page"}, "http://mochi.test:8888");
}
}
}
setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
// Test 2: Navigate secure grandchild iframe to insecure grandchild iframe on a page that has no secure parents
var iframe_test2 = document.createElement("iframe");
iframe_test2.src = "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_grandchild.html"
iframe_test2.onerror = function() {
parent.postMessage({"test": "insecurePage_navigate_grandchild", "msg": "got an on error alert when loading or navigating testing iframe"}, "http://mochi.test:8888");
};
testContent.appendChild(iframe_test2);
</script>
</body>
</html>

View File

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker - Navigating Grandchild frames when a secure parent doesn't exist
https://bugzilla.mozilla.org/show_bug.cgi?id=840388
-->
<head>
<meta charset="utf-8">
<title>Tests for Mixed Content Frame Navigation</title>
</head>
<body>
<iframe src="https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_grandchild" id="child"></iframe>
<script>
// For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
var MAX_COUNT = 50;
var TIMEOUT_INTERVAL = 100;
var counter = 0;
var child = document.getElementById("child");
function navigationStatus(child)
{
// When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
// Catch that specific exception and return
try {
var loc = child.contentDocument.location;
} catch(e) {
if (e.message && e.message.indexOf("Permission denied to access property") == -1) {
// We received an exception we didn't expect.
throw e;
}
counter++;
return;
}
if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_grandchild_response") {
return;
}
else {
if(counter < MAX_COUNT) {
counter++;
setTimeout(navigationStatus, TIMEOUT_INTERVAL, child);
}
else {
// After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
parent.parent.postMessage({"test": "insecurePage_navigate_grandchild", "msg": "navigating to insecure grandchild iframe blocked on insecure page"}, "http://mochi.test:8888");
}
}
}
setTimeout(navigationStatus, TIMEOUT_INTERVAL, child);
</script>
</body>
</html>

View File

@ -1,61 +0,0 @@
<!DOCTYPE HTML>
<html>
<body>
<div id="content"></div>
<script>
// get the case from the query string
var type = location.search.substring(1);
switch (type) {
case "insecurePage_navigate_child":
document.getElementById("content").innerHTML =
'<a href="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_child_response" id="link">Testing\<\/a>';
document.getElementById("link").click();
break;
case "insecurePage_navigate_child_response":
parent.parent.postMessage({"test": "insecurePage_navigate_child", "msg": "navigated to insecure iframe on insecure page"}, "http://mochi.test:8888");
document.getElementById("content").innerHTML = "Navigated from secure to insecure frame on an insecure page";
break;
case "insecurePage_navigate_grandchild":
document.getElementById("content").innerHTML =
'<a href="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_grandchild_response" id="link">Testing\<\/a>';
document.getElementById("link").click();
break;
case "insecurePage_navigate_grandchild_response":
parent.parent.parent.postMessage({"test": "insecurePage_navigate_grandchild", "msg": "navigated to insecure grandchild iframe on insecure page"}, "http://mochi.test:8888");
document.getElementById("content").innerHTML = "Navigated from secure to insecure grandchild frame on an insecure page";
break;
case "securePage_navigate_child":
document.getElementById("content").innerHTML =
'<a href="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?securePage_navigate_child_response" id="link">Testing\<\/a>';
document.getElementById("link").click();
break;
case "securePage_navigate_child_response":
document.getElementById("content").innerHTML = "<p>Navigated from secure to insecure frame on a secure page</p>";
parent.parent.postMessage({"test": "securePage_navigate_child", "msg": "navigated to insecure iframe on secure page"}, "http://mochi.test:8888");
break;
case "securePage_navigate_grandchild":
document.getElementById("content").innerHTML=
'<a href="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?securePage_navigate_grandchild_response" id="link">Testing\<\/a>';
document.getElementById("link").click();
break;
case "securePage_navigate_grandchild_response":
parent.parent.parent.postMessage({"test": "securePage_navigate_grandchild", "msg": "navigated to insecure grandchild iframe on secure page"}, "http://mochi.test:8888");
document.getElementById("content").innerHTML = "<p>Navigated from secure to insecure grandchild frame on a secure page</p>";
break;
default:
document.getElementById("content").innerHTML = "Hello";
break;
}
</script>
</body>
</html>

View File

@ -1,75 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker related to navigating children, grandchildren, etc
https://bugzilla.mozilla.org/show_bug.cgi?id=840388
-->
<head>
<meta charset="utf-8">
<title>Tests for Mixed Content Frame Navigation</title>
</head>
<body>
<div id="testContent"></div>
<script>
var baseUrl = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html";
// For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
var MAX_COUNT = 50;
var TIMEOUT_INTERVAL = 100;
var testContent = document.getElementById("testContent");
// Test 1: Navigate secure iframe to insecure iframe on a secure page
var iframe_test1 = document.createElement("iframe");
var counter_test1 = 0;
iframe_test1.setAttribute("id", "test1");
iframe_test1.src = baseUrl + "?securePage_navigate_child";
iframe_test1.onerror = function() {
parent.postMessage({"test": "securePage_navigate_child", "msg": "got an onerror event when loading or navigating testing iframe"}, "http://mochi.test:8888");
};
testContent.appendChild(iframe_test1);
function navigationStatus(iframe_test1)
{
// When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
// Catch that specific exception and return
try {
var loc = document.getElementById("test1").contentDocument.location;
} catch(e) {
if (e.name === "SecurityError") {
// We received an exception we didn't expect.
throw e;
}
counter_test1++;
return;
}
if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?insecurePage_navigate_child_response") {
return;
} else {
if(counter_test1 < MAX_COUNT) {
counter_test1++;
setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
}
else {
// After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
parent.postMessage({"test": "securePage_navigate_child", "msg": "navigating to insecure iframe blocked on secure page"}, "http://mochi.test:8888");
}
}
}
setTimeout(navigationStatus, TIMEOUT_INTERVAL, iframe_test1);
// Test 2: Navigate secure grandchild iframe to insecure grandchild iframe on a page that has at least one secure parent (in this example, both the parent and grandparent are https)
var iframe_test2 = document.createElement("iframe");
iframe_test2.src = "https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_secure_grandchild.html";
iframe_test2.onerror = function() {
parent.postMessage({"test": "securePage_navigate_grandchild", "msg": "got an onerror event when loading or navigating testing iframe"}, "http://mochi.test:8888");
};
testContent.appendChild(iframe_test2);
</script>
</body>
</html>

View File

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker - Navigating Grandchild Frames when a secure parent exists
https://bugzilla.mozilla.org/show_bug.cgi?id=840388
-->
<head>
<meta charset="utf-8">
<title>Tests for Mixed Content Frame Navigation</title>
</head>
<body>
<iframe src="https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?securePage_navigate_grandchild" id="child"></iframe>
<script>
// For tests that require setTimeout, set the maximum polling time to 50 x 100ms = 5 seconds.
var MAX_COUNT = 50;
var TIMEOUT_INTERVAL = 100;
var counter = 0;
var child = document.getElementById("child");
function navigationStatus(child)
{
// When the page is navigating, it goes through about:blank and we will get a permission denied for loc.
// Catch that specific exception and return
try {
var loc = child.contentDocument.location;
} catch(e) {
if (e.message && e.message.indexOf("Permission denied to access property") == -1) {
// We received an exception we didn't expect.
throw e;
}
counter++;
return;
}
if (loc == "http://example.com/tests/content/base/test/file_mixed_content_frameNavigation_innermost.html?securePage_navigate_grandchild_response") {
return;
}
else {
if(counter < MAX_COUNT) {
counter++;
setTimeout(navigationStatus, TIMEOUT_INTERVAL, child);
}
else {
// After we have called setTimeout the maximum number of times, assume navigating the iframe is blocked
parent.parent.postMessage({"test": "securePage_navigate_grandchild", "msg": "navigating to insecure grandchild iframe blocked on secure page"}, "http://mochi.test:8888");
}
}
}
setTimeout(navigationStatus, TIMEOUT_INTERVAL, child);
</script>
</body>
</html>

View File

@ -1,111 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Tests for Mixed Content Blocker
https://bugzilla.mozilla.org/show_bug.cgi?id=840388
-->
<head>
<meta charset="utf-8">
<title>Tests for Bug 840388</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script>
var counter = 0;
var origBlockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", true);
var blockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
var testsToRun = {
insecurePage_navigate_child: false,
insecurePage_navigate_grandchild: false,
securePage_navigate_child: false,
securePage_navigate_grandchild: false,
};
function log(msg) {
document.getElementById("log").textContent += "\n" + msg;
}
function checkTestsCompleted() {
for (var prop in testsToRun) {
// some test hasn't run yet so we're not done
if (!testsToRun[prop])
return;
}
//if the testsToRun are all completed, change the block mixed active content pref and run the tests again.
if(counter < 1) {
for (var prop in testsToRun) {
testsToRun[prop] = false;
}
//call to change the preferences
counter++;
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", false);
blockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
log("blockActive set to "+blockActive+".");
document.getElementById('framediv').innerHTML = '<iframe src="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation.html"></iframe>';
document.getElementById('secure_framediv').innerHTML = '<iframe src="https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_secure.html"></iframe>';
}
else {
//set the prefs back to what they were set to originally
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
SimpleTest.finish();
}
}
var firstTest = true;
// listen for a messages from the mixed content test harness
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if(firstTest) {
log("blockActive set to "+blockActive);
firstTest = false;
}
log("test: "+event.data.test+", msg: "+event.data.msg + ".");
// test that the load type matches the pref for this type of content
// (i.e. active vs. display)
switch(event.data.test) {
case "insecurePage_navigate_child":
ok((event.data.msg == "navigated to insecure iframe on insecure page"), "navigating to insecure iframe blocked on insecure page");
testsToRun["insecurePage_navigate_child"] = true;
break;
case "insecurePage_navigate_grandchild":
ok((event.data.msg == "navigated to insecure grandchild iframe on insecure page"), "navigating to insecure grandchild iframe blocked on insecure page");
testsToRun["insecurePage_navigate_grandchild"] = true;
break;
case "securePage_navigate_child":
ok(blockActive == (event.data.msg == "navigating to insecure iframe blocked on secure page"), "navigated to insecure iframe on secure page");
testsToRun["securePage_navigate_child"] = true;
break;
case "securePage_navigate_grandchild":
ok(blockActive == (event.data.msg == "navigating to insecure grandchild iframe blocked on secure page"), "navigated to insecure granchild iframe on secure page");
testsToRun["securePage_navigate_grandchild"] = true;
break;
}
checkTestsCompleted();
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body>
<div id="framediv">
<iframe src="http://example.com/tests/content/base/test/file_mixed_content_frameNavigation.html"></iframe>
</div>
<div id="secure_framediv">
<iframe src="https://example.com/tests/content/base/test/file_mixed_content_frameNavigation_secure.html"></iframe>
</div>
<pre id="log"></pre>
</body>
</html>