Bug 674321 - port docshell_helpers.js to SpecialPowers, r=jgriffin, a=test-only
authorJoel Maher <jmaher@mozilla.com>
Thu, 28 Jul 2011 12:03:59 -0400
changeset 73506 de3002d94566bc6a6e064781119d65b99fc922f7
parent 73475 f7c8248747d6aa876546628d2b8bac5896ac2d39
child 73507 aa9db005872678b9b7bb72e1927195e0b1f8aa69
push idunknown
push userunknown
push dateunknown
reviewersjgriffin, test-only
bugs674321
milestone8.0a1
Bug 674321 - port docshell_helpers.js to SpecialPowers, r=jgriffin, a=test-only
docshell/test/chrome/docshell_helpers.js
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -312,20 +312,17 @@ function pageEventListener(event) {
 function finish() {
   // Work around bug 467960.
   var history = TestWindow.getBrowser().webNavigation.sessionHistory;
   history.PurgeHistory(history.count);
   
   // If the test changed the value of max_total_viewers via a call to
   // enableBFCache(), then restore it now.
   if (typeof(gOrigMaxTotalViewers) != "undefined") {
-    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                .getService(Components.interfaces.nsIPrefBranch);
-    prefs.setIntPref("browser.sessionhistory.max_total_viewers",
+    SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers",
       gOrigMaxTotalViewers);
   }
 
   // Close the test window and signal the framework that the test is done.
   let opener = window.opener;
   window.close();
   opener.wrappedJSObject.SimpleTest.finish();
 }
@@ -382,36 +379,31 @@ function waitForTrue(fn, onWaitComplete,
  * Enable or disable the bfcache.
  *
  * Parameters:
  *
  *   enable: if true, set max_total_viewers to -1 (the default); if false, set 
  *           to 0 (disabled), if a number, set it to that specific number
  */
 function enableBFCache(enable) {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-              .getService(Components.interfaces.nsIPrefBranch);
-  
   // If this is the first time the test called enableBFCache(),
   // store the original value of max_total_viewers, so it can
   // be restored at the end of the test.
   if (typeof(gOrigMaxTotalViewers) == "undefined") {
-    gOrigMaxTotalViewers =
-      prefs.getIntPref("browser.sessionhistory.max_total_viewers");
+    gOrigMaxTotalViewers = SpecialPowers.getIntPref("browser.sessionhistory.max_total_viewers");
   }
   
   if (typeof(enable) == "boolean") {
     if (enable)
-      prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1);
+      SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers", -1);
     else
-      prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0);    
+      SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers", 0);    
   }
   else if (typeof(enable) == "number") {
-    prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable);    
+    SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers", enable);    
   }
 }
 
 /*
  * get http root for local tests.  Use a single extractJarToTmp instead of 
  * extracting for each test.  
  * Returns a file://path if we have a .jar file
  */