From 89cc8073b2b0d83d1eb7ec193198e27157e9a626 Mon Sep 17 00:00:00 2001 From: Tanvi Vyas Date: Thu, 28 Mar 2013 13:18:53 -0700 Subject: [PATCH] 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 --- ...rowser_webconsole_bug_737873_mixedcontent.js | 17 +++++++++++++++-- .../localstorage/test_localStorageQuota.html | 10 ++++++++++ .../test_localStorageQuotaSessionOnly.html | 9 +++++++++ .../test_localStorageQuotaSessionOnly2.html | 9 +++++++++ .../localstorage/test_localStorageReplace.html | 17 ++++++++++++++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js b/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js index 01fbc5f2d44e..14c9714f30ae 100644 --- a/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js +++ b/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js @@ -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(); +} diff --git a/dom/tests/mochitest/localstorage/test_localStorageQuota.html b/dom/tests/mochitest/localstorage/test_localStorageQuota.html index 91e0130920fe..1e1a68f7fbec 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageQuota.html +++ b/dom/tests/mochitest/localstorage/test_localStorageQuota.html @@ -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(); } diff --git a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html index ab03330a816e..582aff414f22 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html +++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html @@ -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(); } diff --git a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html index 5d4af4ddf6fc..661badf758b9 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html +++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html @@ -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(); } diff --git a/dom/tests/mochitest/localstorage/test_localStorageReplace.html b/dom/tests/mochitest/localstorage/test_localStorageReplace.html index 1852f36c12fe..367400dbdc96 100644 --- a/dom/tests/mochitest/localstorage/test_localStorageReplace.html +++ b/dom/tests/mochitest/localstorage/test_localStorageReplace.html @@ -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();