Bug 834836 - /dom/tests - Fix tests that break when security.mixed_content.block_active_content is set to true and if/when security.mixed_content.block_display_content is set to true. r=smaug,msucan

This commit is contained in:
Tanvi Vyas 2013-03-28 13:18:53 -07:00
parent 185a697986
commit 89cc8073b2
5 changed files with 59 additions and 3 deletions

View File

@ -12,6 +12,9 @@
const TEST_HTTPS_URI = "https://example.com/browser/browser/devtools/webconsole/test/test-bug-737873-mixedcontent.html";
var origBlockDisplay;
var origBlockActive;
function test() {
addTab("data:text/html;charset=utf8,Web Console mixed content test");
browser.addEventListener("load", onLoad, true);
@ -19,6 +22,10 @@ function test() {
function onLoad(aEvent) {
browser.removeEventListener("load", onLoad, true);
origBlockDisplay = Services.prefs.getBoolPref("security.mixed_content.block_display_content");
origBlockActive = Services.prefs.getBoolPref("security.mixed_content.block_active_content")
Services.prefs.setBoolPref("security.mixed_content.block_display_content", false);
Services.prefs.setBoolPref("security.mixed_content.block_active_content", false);
openConsole(null, testMixedContent);
}
@ -45,10 +52,10 @@ function testMixedContent(hud) {
is(warningNode.value, "[Mixed Content]", "Message text is accurate." );
testClickOpenNewTab(warningNode);
finishTest();
endTest();
},
failureFn: finishTest,
failureFn: endTest,
}
);
@ -81,3 +88,9 @@ function testClickOpenNewTab(warningNode) {
window.openUILinkIn = oldOpenUILinkIn;
}
function endTest() {
Services.prefs.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay);
Services.prefs.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
finishTest();
}

View File

@ -14,6 +14,8 @@ var currentTest = 1;
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var quota;
var origBlockDisplay;
var origBlockActive;
function doNextTest()
{
@ -33,6 +35,12 @@ function doNextTest()
}
prefs.setIntPref("dom.storage.default_quota", 1);
origBlockDisplay = prefs.getBoolPref("security.mixed_content.block_display_content");
origBlockActive = prefs.getBoolPref("security.mixed_content.block_active_content");
prefs.setBoolPref("security.mixed_content.block_display_content", false);
prefs.setBoolPref("security.mixed_content.block_active_content", false);
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuota.html?add&A&success";
break;
@ -100,6 +108,8 @@ function doNextTest()
default: // end
prefs.setIntPref("dom.storage.default_quota", quota);
prefs.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay);
prefs.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
SimpleTest.finish();
}

View File

@ -22,6 +22,8 @@ var cp = Components.classes["@mozilla.org/cookie/permission;1"]
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_SESSION);
var quota;
var origBlockDisplay;
var origBlockActive;
function doNextTest()
{
@ -41,6 +43,11 @@ function doNextTest()
}
prefs.setIntPref("dom.storage.default_quota", 1);
origBlockDisplay = prefs.getBoolPref("security.mixed_content.block_display_content");
origBlockActive = prefs.getBoolPref("security.mixed_content.block_active_content");
prefs.setBoolPref("security.mixed_content.block_display_content", false);
prefs.setBoolPref("security.mixed_content.block_active_content", false);
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success";
@ -109,6 +116,8 @@ function doNextTest()
default:
prefs.setIntPref("dom.storage.default_quota", quota);
prefs.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay);
prefs.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_DEFAULT);
SimpleTest.finish();
}

View File

@ -20,6 +20,8 @@ var cp = Cc["@mozilla.org/cookie/permission;1"]
.getService(SpecialPowers.Ci.nsICookiePermission);
var quota;
var origBlockDisplay;
var origBlockActive;
function doNextTest()
{
@ -37,6 +39,11 @@ function doNextTest()
}
prefs.setIntPref("dom.storage.default_quota", 1);
origBlockDisplay = prefs.getBoolPref("security.mixed_content.block_display_content");
origBlockActive = prefs.getBoolPref("security.mixed_content.block_active_content");
prefs.setBoolPref("security.mixed_content.block_display_content", false);
prefs.setBoolPref("security.mixed_content.block_active_content", false)
slaveOrigin = "http://example.com";
slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success";
@ -93,6 +100,8 @@ function doNextTest()
default:
prefs.setIntPref("dom.storage.default_quota", quota);
prefs.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay);
prefs.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
cp.setAccess(uri, SpecialPowers.Ci.nsICookiePermission.ACCESS_DEFAULT);
SimpleTest.finish();
}

View File

@ -17,6 +17,9 @@
var shell;
var shellType;
var failureRegExp = new RegExp("^FAILURE");
var origBlockDisplay;
var origBlockActive;
window.addEventListener("message", onMessageReceived, false);
@ -47,7 +50,7 @@ function onMessageReceived(event)
case "window":
shell.close();
window.setTimeout(function() {SimpleTest.finish();}, 0);
window.setTimeout(function() {endTest();}, 0);
break;
}
break;
@ -60,11 +63,23 @@ function onMessageReceived(event)
function startTest()
{
origBlockDisplay = SpecialPowers.getBoolPref("security.mixed_content.block_display_content");
origBlockActive = SpecialPowers.getBoolPref("security.mixed_content.block_active_content");
SpecialPowers.setBoolPref("security.mixed_content.block_display_content", false);
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", false);
shellType = "frame";
shell = frame;
shell.location = "http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType;
}
function endTest()
{
SpecialPowers.setBoolPref("security.mixed_content.block_display_content", origBlockDisplay);
SpecialPowers.setBoolPref("security.mixed_content.block_active_content", origBlockActive);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
</script>