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
authorTanvi Vyas <tvyas@mozilla.com>
Thu, 28 Mar 2013 13:18:53 -0700
changeset 126622 ae4bb9b986cf50e038870b8a75abfdd99ba00f23
parent 126621 d2eefc0da377f856fc31a0c363c4f75aeacb7601
child 126623 0e4a2753c2a281af70b35bbf40c4017284d80b67
push id24492
push userryanvm@gmail.com
push dateSat, 30 Mar 2013 23:31:27 +0000
treeherdermozilla-central@1932c6f78248 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, msucan
bugs834836
milestone22.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 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
browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
dom/tests/mochitest/localstorage/test_localStorageQuota.html
dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html
dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html
dom/tests/mochitest/localstorage/test_localStorageReplace.html
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_737873_mixedcontent.js
@@ -7,23 +7,30 @@
  *  Tanvi Vyas <tanvi@mozilla.com>
  *
  * ***** END LICENSE BLOCK ***** */
 
 // Tests that the Web Console Mixed Content messages are displayed
 
 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);
 }
 
 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);
 }
 
 function testMixedContent(hud) {
   content.location = TEST_HTTPS_URI;
   var aOutputNode = hud.outputNode;
 
   waitForSuccess(
@@ -40,20 +47,20 @@ function testMixedContent(hud) {
         let node = aOutputNode.querySelector(".webconsole-mixed-content");
         ok(testSeverity(node), "Severity type is SEVERITY_WARNING.");
 
         //tests on the warningNode
         let warningNode = aOutputNode.querySelector(".webconsole-mixed-content-link");
         is(warningNode.value, "[Mixed Content]", "Message text is accurate." );
         testClickOpenNewTab(warningNode);
 
-        finishTest();
+        endTest();
       },
 
-      failureFn: finishTest,
+      failureFn: endTest,
     }
   );
 
 }
 
 function testSeverity(node) {
   let linkNode = node.parentNode;
   let msgNode = linkNode.parentNode;
@@ -76,8 +83,14 @@ function testClickOpenNewTab(warningNode
 
   EventUtils.synthesizeMouse(warningNode, 2, 2, {},
                              warningNode.ownerDocument.defaultView);
 
   ok(linkOpened, "Clicking the Mixed Content Warning node opens the desired page");
 
   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();
+}
--- a/dom/tests/mochitest/localstorage/test_localStorageQuota.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageQuota.html
@@ -9,16 +9,18 @@
 <script type="text/javascript">
 
 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
 var currentTest = 1;
 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
             .getService(Components.interfaces.nsIPrefBranch);
 var quota;
+var origBlockDisplay;
+var origBlockActive;
 
 function doNextTest()
 {
   slave = frame;
 
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   switch (currentTest)
@@ -28,16 +30,22 @@ function doNextTest()
     case 1:
       try {
         quota = prefs.getIntPref("dom.storage.default_quota");
       } catch (ex) {
         quota = 5*1024;
       }
       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;
 
     // In subdomain now set another key with length 500 bytes, i.e.
     // allocate 501 bytes
     case 2:
       slaveOrigin = "http://test1.example.com";
@@ -95,16 +103,18 @@ function doNextTest()
     case 10:
       // Do a clean up...
       slaveOrigin = "https://test2.example.com";
       slave.location = slaveOrigin + slavePath + "frameQuota.html?clear";
       break;
 
     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();
   }
 
   ++currentTest;
 }
 
 function doStep()
 {
--- a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly.html
@@ -17,16 +17,18 @@ var io = Components.classes["@mozilla.or
   .getService(Components.interfaces.nsIIOService);
 var uri = io.newURI(window.location, "", null);
 var cp = Components.classes["@mozilla.org/cookie/permission;1"]
   .getService(Components.interfaces.nsICookiePermission);
 
 cp.setAccess(uri, Components.interfaces.nsICookiePermission.ACCESS_SESSION);
 
 var quota;
+var origBlockDisplay;
+var origBlockActive;
 
 function doNextTest()
 {
   slave = frame;
 
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   switch (currentTest)
@@ -36,16 +38,21 @@ function doNextTest()
     case 1:
       try {
         quota = prefs.getIntPref("dom.storage.default_quota");
       } catch (ex) {
         quota = 5*1024;
       }
       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";
       break;
 
     // In subdomain now set another key with length 500 bytes, i.e.
     // allocate 501 bytes
     case 2:
@@ -104,16 +111,18 @@ function doNextTest()
     case 10:
       // Do a clean up...
       slaveOrigin = "https://test2.example.com";
       slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
       break;
 
     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();
   }
 
   ++currentTest;
 }
 
 function doStep()
--- a/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html
@@ -15,16 +15,18 @@ var prefs = Cc["@mozilla.org/preferences
             .getService(SpecialPowers.Ci.nsIPrefBranch);
 var io = Cc["@mozilla.org/network/io-service;1"]
   .getService(SpecialPowers.Ci.nsIIOService);
 var uri = io.newURI(window.location, "", null);
 var cp = Cc["@mozilla.org/cookie/permission;1"]
   .getService(SpecialPowers.Ci.nsICookiePermission);
 
 var quota;
+var origBlockDisplay;
+var origBlockActive;
 
 function doNextTest()
 {
   slave = frame;
 
   switch (currentTest)
   {
     // Initialy setup the quota to testing value of 1024B and
@@ -32,16 +34,21 @@ function doNextTest()
     case 1:
       try {
         quota = prefs.getIntPref("dom.storage.default_quota");
       } catch (ex) {
         quota = 5*1024;
       }
       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";
       break;
 
     // In subdomain now set another key with length 500 bytes, i.e.
     // allocate 501 bytes
     case 2:
@@ -88,16 +95,18 @@ function doNextTest()
       // Do a clean up...
       slaveOrigin = "http://example.com";
       slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
       cp.setAccess(uri, SpecialPowers.Ci.nsICookiePermission.ACCESS_DEFAULT);
       break;
 
     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();
   }
 
   ++currentTest;
 }
 
 function doStep()
--- a/dom/tests/mochitest/localstorage/test_localStorageReplace.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageReplace.html
@@ -12,16 +12,19 @@
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
 
 var shell;
 var shellType;
 var failureRegExp = new RegExp("^FAILURE");
+var origBlockDisplay;
+var origBlockActive;
+
 
 window.addEventListener("message", onMessageReceived, false);
 
 function onMessageReceived(event)
 {
   switch (event.data)
   {
     case "init_done":
@@ -42,34 +45,46 @@ function onMessageReceived(event)
           // We finished testing in a frame
           // proceed with test in a separate window
           shellType = "window";
           shell = window.open("http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType);
           break;
 
         case "window":
           shell.close();
-          window.setTimeout(function() {SimpleTest.finish();}, 0);
+          window.setTimeout(function() {endTest();}, 0);
           break;
       }
       break;
 
     default:
       SimpleTest.ok(!event.data.match(failureRegExp), event.data);
       break;
   }
 }
 
 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>
 
 </head>
 
 <body onload="startTest();">
   <iframe src="" name="frame"></iframe>