Bug 707786 - Use Services.prefs instead of preferences-services /gPrefService in SeaMonkey. r=Neil
authorEdmund Wong <ewong@pw-wspx.org>
Fri, 09 Mar 2012 11:29:27 +0800
changeset 11038 714c2c71f32367b79f6190a15179a18291325750
parent 11037 4c3e576941e834028da42718e6b69193fb553716
child 11039 817576bcae20addaa6634a0709e0cad91e6e219d
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs707786
Bug 707786 - Use Services.prefs instead of preferences-services /gPrefService in SeaMonkey. r=Neil
suite/common/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
suite/common/places/tests/unit/test_421483.js
suite/common/places/tests/unit/test_457441-import-export-corrupt-bookmarks-html.js
suite/common/places/tests/unit/test_bookmarks_html.js
suite/common/places/tests/unit/test_browserGlue_distribution.js
suite/common/places/tests/unit/test_browserGlue_smartBookmarks.js
suite/common/tests/browser/browser_346337.js
suite/common/tests/browser/browser_350525.js
suite/common/tests/chrome/test_idcheck.xul
suite/modules/test/browser_sanitizer.js
--- a/suite/common/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
+++ b/suite/common/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
@@ -59,19 +59,17 @@ function test()
 {
   var dm = Components.classes["@mozilla.org/download-manager;1"]
                      .getService(Components.interfaces.nsIDownloadManager);
 
   // Empty any old downloads
   dm.DBConnection.executeSimpleSQL("DELETE FROM moz_downloads");
 
   var setClose = function(aVal)
-    Components.classes["@mozilla.org/preferences-service;1"]
-              .getService(Components.interfaces.nsIPrefBranch)
-              .setBoolPref("browser.download.manager.closeWhenDone", aVal);
+    Services.prefs.setBoolPref("browser.download.manager.closeWhenDone", aVal);
 
   // Close the UI if necessary
   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                      .getService(Components.interfaces.nsIWindowMediator);
   var win = wm.getMostRecentWindow("Download:Manager");
   if (win) win.close();
 
   var os = Components.classes["@mozilla.org/observer-service;1"]
--- a/suite/common/places/tests/unit/test_421483.js
+++ b/suite/common/places/tests/unit/test_421483.js
@@ -55,68 +55,60 @@ try {
 // Get browser glue
 try {
   var gluesvc = Cc["@mozilla.org/suite/suiteglue;1"].
                 getService(Ci.nsISuiteGlue);
 } catch(ex) {
   do_throw("Could not get SuiteGlue service\n");
 }
 
-// Get pref service
-try {
-  var pref =  Cc["@mozilla.org/preferences-service;1"].
-              getService(Ci.nsIPrefBranch);
-} catch(ex) {
-  do_throw("Could not get Preferences service\n");
-}
-
 const SMART_BOOKMARKS_ANNO = "Places/SmartBookmark";
 const SMART_BOOKMARKS_PREF = "browser.places.smartBookmarksVersion";
 
 // main
 function run_test() {
   // TEST 1: smart bookmarks disabled
-  pref.setIntPref("browser.places.smartBookmarksVersion", -1);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1);
   gluesvc.ensurePlacesDefaultQueriesInitialized();
   var smartBookmarkItemIds = annosvc.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO);
   do_check_eq(smartBookmarkItemIds.length, 0);
   // check that pref has not been bumped up
-  do_check_eq(pref.getIntPref("browser.places.smartBookmarksVersion"), -1);
+  do_check_eq(Services.prefs.getIntPref("browser.places.smartBookmarksVersion"), -1);
 
   // TEST 2: create smart bookmarks
-  pref.setIntPref("browser.places.smartBookmarksVersion", 0);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
   gluesvc.ensurePlacesDefaultQueriesInitialized();
   smartBookmarkItemIds = annosvc.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO);
   do_check_neq(smartBookmarkItemIds.length, 0);
   // check that pref has been bumped up
-  do_check_true(pref.getIntPref("browser.places.smartBookmarksVersion") > 0);
+  do_check_true(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0);
 
   var smartBookmarksCount = smartBookmarkItemIds.length;
 
   // TEST 3: smart bookmarks restore
   // remove one smart bookmark and restore
   bmsvc.removeItem(smartBookmarkItemIds[0]);
-  pref.setIntPref("browser.places.smartBookmarksVersion", 0);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
   gluesvc.ensurePlacesDefaultQueriesInitialized();
   smartBookmarkItemIds = annosvc.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO);
   do_check_eq(smartBookmarkItemIds.length, smartBookmarksCount);
   // check that pref has been bumped up
-  do_check_true(pref.getIntPref("browser.places.smartBookmarksVersion") > 0);
+  do_check_true(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0);
 
   // TEST 4: move a smart bookmark, change its title, then restore
   // smart bookmark should be restored in place
   var parent = bmsvc.getFolderIdForItem(smartBookmarkItemIds[0]);
   var oldTitle = bmsvc.getItemTitle(smartBookmarkItemIds[0]);
   // create a subfolder and move inside it
   var newParent = bmsvc.createFolder(parent, "test", bmsvc.DEFAULT_INDEX);
   bmsvc.moveItem(smartBookmarkItemIds[0], newParent, bmsvc.DEFAULT_INDEX);
   // change title
   bmsvc.setItemTitle(smartBookmarkItemIds[0], "new title");
   // restore
-  pref.setIntPref("browser.places.smartBookmarksVersion", 0);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
   gluesvc.ensurePlacesDefaultQueriesInitialized();
   smartBookmarkItemIds = annosvc.getItemsWithAnnotation(SMART_BOOKMARKS_ANNO);
   do_check_eq(smartBookmarkItemIds.length, smartBookmarksCount);
   do_check_eq(bmsvc.getFolderIdForItem(smartBookmarkItemIds[0]), newParent);
   do_check_eq(bmsvc.getItemTitle(smartBookmarkItemIds[0]), oldTitle);
   // check that pref has been bumped up
-  do_check_true(pref.getIntPref("browser.places.smartBookmarksVersion") > 0);
+  do_check_true(Services.prefs.getIntPref("browser.places.smartBookmarksVersion") > 0);
 }
--- a/suite/common/places/tests/unit/test_457441-import-export-corrupt-bookmarks-html.js
+++ b/suite/common/places/tests/unit/test_457441-import-export-corrupt-bookmarks-html.js
@@ -46,33 +46,31 @@ var hs = Cc["@mozilla.org/browser/nav-hi
          getService(Ci.nsINavHistoryService);
 var dbConn = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 var as = Cc["@mozilla.org/browser/annotation-service;1"].
          getService(Ci.nsIAnnotationService);
 var icos = Cc["@mozilla.org/browser/favicon-service;1"].
            getService(Ci.nsIFaviconService);
-var ps = Cc["@mozilla.org/preferences-service;1"].
-         getService(Ci.nsIPrefBranch);
 var ies = Cc["@mozilla.org/browser/places/import-export-service;1"].
           getService(Ci.nsIPlacesImportExportService);
 
 const DESCRIPTION_ANNO = "bookmarkProperties/description";
 const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
 const POST_DATA_ANNO = "bookmarkProperties/POSTData";
 
 const TEST_FAVICON_PAGE_URL = "http://www.seamonkey-project.org/";
 const TEST_FAVICON_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QwCEiUG/+wAegAAAu5JREFUOMtlk01oXFUUx3/3vfte3kydmeeQJgUTMsEaKX40tREbDHYE6UIXnZVUujCIiu3GKl0EXRh3ol1EF8WutItuuum4sRTRRXFRFGUyRPxIyVe1mK+ZZD46d968e6+LSduoFw7/c+D+Dv8D5wj+984NDQ4mz6TT/iiAMWCMRanO1urqnaJSZy/u/i12F2H46Qe5XGo6DAOMscSxQWuL1t08imI2NlRpba05CVOz/2qQSJx7+/DhfTPAPUhrQxwbJl54mHemJnCkg20pxh67sFStqlGY2pZd/OOjIyPZmTi+D91t0N+/h/enn2NuFW78aXm6dRvfd3NBIItK8bwEGB5Oz3iei1IxWpt7lrW2vPjKKKoDv65bMr5m4kiOvr4kjUaUh0+OO/DRwSBwR5WKabc1Smnu5zGFwgjfLsIv69CKDL+vG44dGyaKNK5rJ+XAQCqfTifY3Gzumrurp04dom0dlrag3gZtBc2OIZPpIZVK0tubycuxsSfD44VnsQaMBbsTxsDBIx3O/2hRsSAbWFwBf21b8vmn6N83zvz8SijL5YhGo47rguOC0YZsVjI+nuAP7RNpCANLpREzkBYMZly+vhxRLivq9Ri5vLxdqlQaaA1as2MfTp7u4fqGS0dbDvVp6hlBJrD0bFkuXarheaBUpSS1Xii1WvsxJovWXfufnX+QK5uSB3xN0tGkfIdHeyFahddfqxIEAs+DZvPv0s4iXf1CiCcmoQvf2Bvw8oEYAazUBM/sFfz8XZsLnzdRyiKlwJg15uau5XYWafYMpAvvvvd4OD+U4PRDMeYO3F7QbP7W4c1ii1YLPA+CQCBExK1b5Wk4uywArLVDxZ+aX6qeZD5ZiXjrRAXP69qUsqueJ5ASoqjC4uIP07Xaqx8CONbaK9+v2KUDuT3sV2uFky99U3TdJkEgCAJBItFVKSNqtYWlmzevT96FAYS19iiwJYSY3X3S2ewjBd8PQinBcaBaXSnV62989d/j/wcgGYelT45hgQAAAABJRU5ErkJggg==";
 
 function run_test() {
   do_test_pending();
 
   // avoid creating the places smart folder during tests
-  ps.setIntPref("browser.places.smartBookmarksVersion", -1);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1);
 
   // import bookmarks from corrupt file
   var corruptBookmarksFile = do_get_file("bookmarks.corrupt.html");
   try {
     ies.importHTMLFromFile(corruptBookmarksFile, true);
   } catch(ex) { do_throw("couldn't import corrupt bookmarks file: " + ex); }
 
   // Check that every bookmark is correct
--- a/suite/common/places/tests/unit/test_bookmarks_html.js
+++ b/suite/common/places/tests/unit/test_bookmarks_html.js
@@ -86,18 +86,17 @@ const TEST_FAVICON_PAGE_URL = "http://ww
 const TEST_FAVICON_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QwCEiUG/+wAegAAAu5JREFUOMtlk01oXFUUx3/3vfte3kydmeeQJgUTMsEaKX40tREbDHYE6UIXnZVUujCIiu3GKl0EXRh3ol1EF8WutItuuum4sRTRRXFRFGUyRPxIyVe1mK+ZZD46d968e6+LSduoFw7/c+D+Dv8D5wj+984NDQ4mz6TT/iiAMWCMRanO1urqnaJSZy/u/i12F2H46Qe5XGo6DAOMscSxQWuL1t08imI2NlRpba05CVOz/2qQSJx7+/DhfTPAPUhrQxwbJl54mHemJnCkg20pxh67sFStqlGY2pZd/OOjIyPZmTi+D91t0N+/h/enn2NuFW78aXm6dRvfd3NBIItK8bwEGB5Oz3iei1IxWpt7lrW2vPjKKKoDv65bMr5m4kiOvr4kjUaUh0+OO/DRwSBwR5WKabc1Smnu5zGFwgjfLsIv69CKDL+vG44dGyaKNK5rJ+XAQCqfTifY3Gzumrurp04dom0dlrag3gZtBc2OIZPpIZVK0tubycuxsSfD44VnsQaMBbsTxsDBIx3O/2hRsSAbWFwBf21b8vmn6N83zvz8SijL5YhGo47rguOC0YZsVjI+nuAP7RNpCANLpREzkBYMZly+vhxRLivq9Ri5vLxdqlQaaA1as2MfTp7u4fqGS0dbDvVp6hlBJrD0bFkuXarheaBUpSS1Xii1WvsxJovWXfufnX+QK5uSB3xN0tGkfIdHeyFahddfqxIEAs+DZvPv0s4iXf1CiCcmoQvf2Bvw8oEYAazUBM/sFfz8XZsLnzdRyiKlwJg15uau5XYWafYMpAvvvvd4OD+U4PRDMeYO3F7QbP7W4c1ii1YLPA+CQCBExK1b5Wk4uywArLVDxZ+aX6qeZD5ZiXjrRAXP69qUsqueJ5ASoqjC4uIP07Xaqx8CONbaK9+v2KUDuT3sV2uFky99U3TdJkEgCAJBItFVKSNqtYWlmzevT96FAYS19iiwJYSY3X3S2ewjBd8PQinBcaBaXSnV62989d/j/wcgGYelT45hgQAAAABJRU5ErkJggg==";
 
 // main
 function run_test() {
   // get places import/export service
   var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].getService(Ci.nsIPlacesImportExportService);
 
   // avoid creating the places smart folder during tests
-  Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch).
-  setIntPref("browser.places.smartBookmarksVersion", -1);
+  Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1);
 
   // file pointer to legacy bookmarks file
   var bookmarksFileOld = do_get_file("bookmarks.preplaces.html");
   // file pointer to a new places-exported bookmarks file
   var bookmarksFileNew = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
   bookmarksFileNew.append("bookmarks.exported.html");
 
   // create bookmarks.exported.html
--- a/suite/common/places/tests/unit/test_browserGlue_distribution.js
+++ b/suite/common/places/tests/unit/test_browserGlue_distribution.js
@@ -70,21 +70,19 @@ function run_test() {
   }
 
   let testDistributionFile = gTestDir.clone();
   testDistributionFile.append("distribution.ini");
   testDistributionFile.copyTo(distroDir, "distribution.ini");
   do_check_true(testDistributionFile.exists());
 
   // Disable Smart Bookmarks creation.
-  let ps = Cc["@mozilla.org/preferences-service;1"].
-           getService(Ci.nsIPrefBranch);
-  ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, -1);
+  Services.prefs.setIntPref(PREF_SMART_BOOKMARKS_VERSION, -1);
   // Avoid migrateUI, we are just simulating a partial startup.
-  ps.setIntPref("browser.migration.version", 1);
+  Services.prefs.setIntPref("browser.migration.version", 1);
 
   // Initialize Places through the History Service.
   let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
            getService(Ci.nsINavHistoryService);
   // Check a new database has been created.
   // nsSuiteGlue will use databaseStatus to manage initialization.
   do_check_eq(hs.databaseStatus, hs.DATABASE_STATUS_CREATE);
 
@@ -133,22 +131,20 @@ function continue_test() {
   let toolbarItemId = bs.getIdForItemAt(bs.toolbarFolder, 0);
   do_check_neq(toolbarItemId, -1);
   do_check_eq(bs.getItemTitle(toolbarItemId), "Toolbar Link Before");
   toolbarItemId = bs.getIdForItemAt(bs.toolbarFolder, 1 + DEFAULT_BOOKMARKS_ON_TOOLBAR);
   do_check_neq(toolbarItemId, -1);
   do_check_eq(bs.getItemTitle(toolbarItemId), "Toolbar Link After");
 
   // Check the bmprocessed pref has been created.
-  let ps = Cc["@mozilla.org/preferences-service;1"].
-           getService(Ci.nsIPrefBranch);
-  do_check_true(ps.getBoolPref(PREF_BMPROCESSED));
+  do_check_true(Services.prefs.getBoolPref(PREF_BMPROCESSED));
 
   // Check distribution prefs have been created.
-  do_check_eq(ps.getCharPref(PREF_DISTRIBUTION_ID), "516444");
+  do_check_eq(Services.prefs.getCharPref(PREF_DISTRIBUTION_ID), "516444");
 
   do_test_finished();
 }
 
 do_register_cleanup(function() {
   // Remove the distribution file, even if the test failed, otherwise all
   // next tests will import it.
   let iniFile = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
--- a/suite/common/places/tests/unit/test_browserGlue_smartBookmarks.js
+++ b/suite/common/places/tests/unit/test_browserGlue_smartBookmarks.js
@@ -36,26 +36,22 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * Tests that nsSuiteGlue is correctly interpreting the preferences settable
  * by the user or by other components.
  */
 
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 // Initialize Places.
 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
          getService(Ci.nsINavBookmarksService);
 // Get other services.
-var ps = Cc["@mozilla.org/preferences-service;1"].
-         getService(Ci.nsIPrefBranch);
 var os = Cc["@mozilla.org/observer-service;1"].
          getService(Ci.nsIObserverService);
 var as = Cc["@mozilla.org/browser/annotation-service;1"].
          getService(Ci.nsIAnnotationService);
 
 const PREF_SMART_BOOKMARKS_VERSION = "browser.places.smartBookmarksVersion";
 const PREF_AUTO_EXPORT_HTML = "browser.bookmarks.autoExportHTML";
 const PREF_IMPORT_BOOKMARKS_HTML = "browser.places.importBookmarksHTML";
@@ -94,28 +90,28 @@ var tests = [];
 tests.push({
   description: "All smart bookmarks are created if smart bookmarks version is 0.",
   exec: function() {
     // Sanity check: we should have default bookmark.
     do_check_neq(bs.getIdForItemAt(bs.toolbarFolder, 0), -1);
     do_check_neq(bs.getIdForItemAt(bs.bookmarksMenuFolder, 0), -1);
 
     // Set preferences.
-    ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 0);
+    Services.prefs.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 0);
 
     rebuildSmartBookmarks();
 
     // Count items.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Check version has been updated.
-    do_check_eq(ps.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
+    do_check_eq(Services.prefs.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
                 SMART_BOOKMARKS_VERSION);
 
     next_test();
   }
 });
 
 //------------------------------------------------------------------------------
 
@@ -132,34 +128,34 @@ tests.push({
 
     // Sanity check items.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Set preferences.
-    ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 1);
+    Services.prefs.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 1);
 
     rebuildSmartBookmarks();
 
     // Count items.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Check smart bookmark has been replaced, itemId has changed.
     itemId = bs.getIdForItemAt(bs.toolbarFolder, 0);
     do_check_neq(itemId, -1);
     do_check_neq(bs.getItemTitle(itemId), "new title");
     do_check_true(as.itemHasAnnotation(itemId, SMART_BOOKMARKS_ANNO));
 
     // Check version has been updated.
-    do_check_eq(ps.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
+    do_check_eq(Services.prefs.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
                 SMART_BOOKMARKS_VERSION);
 
     next_test();
   }
 });
 
 //------------------------------------------------------------------------------
 
@@ -171,29 +167,29 @@ tests.push({
 
     // Sanity check items.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Set preferences.
-    ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 1);
+    Services.prefs.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 1);
 
     rebuildSmartBookmarks();
 
     // Count items.
     // We should not have recreated the smart bookmark on toolbar.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Check version has been updated.
-    do_check_eq(ps.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
+    do_check_eq(Services.prefs.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
                 SMART_BOOKMARKS_VERSION);
 
     next_test();
   }
 });
 
 //------------------------------------------------------------------------------
 
@@ -202,29 +198,29 @@ tests.push({
   exec: function() {
     // Sanity check items.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Set preferences.
-    ps.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 0);
+    Services.prefs.setIntPref(PREF_SMART_BOOKMARKS_VERSION, 0);
 
     rebuildSmartBookmarks();
 
     // Count items.
     // We should not have recreated the smart bookmark on toolbar.
     do_check_eq(countFolderChildren(bs.toolbarFolder),
                 SMART_BOOKMARKS_ON_TOOLBAR + DEFAULT_BOOKMARKS_ON_TOOLBAR);
     do_check_eq(countFolderChildren(bs.bookmarksMenuFolder),
                 SMART_BOOKMARKS_ON_MENU + DEFAULT_BOOKMARKS_ON_MENU);
 
     // Check version has been updated.
-    do_check_eq(ps.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
+    do_check_eq(Services.prefs.getIntPref(PREF_SMART_BOOKMARKS_VERSION),
                 SMART_BOOKMARKS_VERSION);
 
     next_test();
   }
 });
 //------------------------------------------------------------------------------
 
 function countFolderChildren(aFolderItemId) {
@@ -270,24 +266,24 @@ function run_test() {
   remove_all_JSON_backups();
 
   // Initialize SuiteGlue.
   var bg = Cc["@mozilla.org/suite/suiteglue;1"].
            getService(Ci.nsISuiteGlue);
   bg.QueryInterface(Ci.nsIObserver).observe(null, "places-init-complete", null);
 
   // Ensure preferences status.
-  do_check_false(ps.getBoolPref(PREF_AUTO_EXPORT_HTML));
+  do_check_false(Services.prefs.getBoolPref(PREF_AUTO_EXPORT_HTML));
   // XXXkairo: might get set due to the different logic of SeaMonkey imports
   //           but there could be some real bug so import is set and restore not
   try {
-    do_check_false(ps.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
+    do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
     // do_throw("importBookmarksHTML pref should not exist");
   }
   catch(ex) {}
   try {
-    do_check_false(ps.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
+    do_check_false(Services.prefs.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
   }
   catch(ex) {}
 
   // Kick-off tests.
   next_test();
 }
--- a/suite/common/tests/browser/browser_346337.js
+++ b/suite/common/tests/browser/browser_346337.js
@@ -108,20 +108,17 @@ function test() {
                                        (aValue.indexOf(aIx) > -1) == aOpt.selected);
   }
 
   // test setup
   let tabbrowser = getBrowser();
   waitForExplicitFinish();
 
   // make sure we don't save form data at all (except for tab duplication)
-  var gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
-                        .getService(Components.interfaces.nsIPrefBranch);
-
-  gPrefService.setIntPref("browser.sessionstore.privacy_level", 2);
+  Services.prefs.setIntPref("browser.sessionstore.privacy_level", 2);
 
   let rootDir = getRootDirectory(gTestPath);
   let testURL = rootDir + "browser_346337_sample.html";
   let tab = tabbrowser.addTab(testURL);
   tab.linkedBrowser.addEventListener("load", function loadListener1(aEvent) {
     tab.linkedBrowser.removeEventListener("load", loadListener1, true);
     for (let xpath in fieldList)
       setFormValue(tab, xpath, fieldList[xpath]);
@@ -138,18 +135,18 @@ function test() {
         let tab3 = tabbrowser.undoCloseTab(0);
         tab3.linkedBrowser.addEventListener("pageshow", function pageshowListener4(aEvent) {
           tab3.linkedBrowser.removeEventListener("pageshow", pageshowListener4, true);
           for (let xpath in fieldList)
             if (fieldList[xpath])
               ok(!compareFormValue(tab3, xpath, fieldList[xpath]),
                  "The value for \"" + xpath + "\" was correctly discarded");
 
-        if (gPrefService.prefHasUserValue("browser.sessionstore.privacy_level"))
-          gPrefService.clearUserPref("browser.sessionstore.privacy_level");
+        if (Services.prefs.prefHasUserValue("browser.sessionstore.privacy_level"))
+          Services.prefs.clearUserPref("browser.sessionstore.privacy_level");
           // undoCloseTab can reuse a single blank tab, so we have to
           // make sure not to close the window when closing our last tab
           if (tabbrowser.tabContainer.childNodes.length == 1)
             tabbrowser.addTab();
           tabbrowser.removeTab(tab3);
           finish();
         }, true);
       }, true);
--- a/suite/common/tests/browser/browser_350525.js
+++ b/suite/common/tests/browser/browser_350525.js
@@ -51,31 +51,28 @@ function test() {
   // clean up
   getBrowser().removeTab(tab);
   
   /////////////////////////////////////
   // getClosedTabCount, undoCloseTab //
   /////////////////////////////////////
   
   // get closed tab count
-  var gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
-                               .getService(Components.interfaces.nsIPrefBranch);
-
   let count = ss.getClosedTabCount(window);
-  let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo");
+  let max_tabs_undo = Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo");
   ok(0 <= count && count <= max_tabs_undo,
      "getClosedTabCount returns zero or at most max_tabs_undo");
   
   // create a new tab
   let testURL = "about:";
   tab = getBrowser().addTab(testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     this.removeEventListener("load", arguments.callee, true);
     // make sure that the next closed tab will increase getClosedTabCount
-    gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
+    Services.prefs.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
     
     // remove tab
     getBrowser().removeTab(tab);
     
     // getClosedTabCount
     var newcount = ss.getClosedTabCount(window);
     ok(newcount > count, "after closing a tab, getClosedTabCount has been incremented");
     
@@ -83,15 +80,15 @@ function test() {
     tab = test(function() ss.undoCloseTab(window, 0));
     ok(tab, "undoCloseTab doesn't throw")
     
     tab.linkedBrowser.addEventListener("load", function(aEvent) {
       this.removeEventListener("load", arguments.callee, true);
       is(this.currentURI.spec, testURL, "correct tab was reopened");
       
       // clean up
-      if (gPrefService.prefHasUserValue("browser.sessionstore.max_tabs_undo"))
-        gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
+      if (Services.prefs.prefHasUserValue("browser.sessionstore.max_tabs_undo"))
+        Services.prefs.clearUserPref("browser.sessionstore.max_tabs_undo");
       getBrowser().removeTab(tab);
       finish();
     }, true);
   }, true);
 }
--- a/suite/common/tests/chrome/test_idcheck.xul
+++ b/suite/common/tests/chrome/test_idcheck.xul
@@ -220,18 +220,17 @@
     {
       // fake a mail account to avoid the account creation wizard
       loadLocalMailAccount();
     }
 
     function ExitTest()
     {
       // remove the mailnews data from the test profile
-      const kPrefService = "@mozilla.org/preferences-service;1";
-      Cc[kPrefService].getService(Ci.nsIPrefService).resetPrefs();
+      Services.prefs.resetPrefs();
     }
 
     function FinishTest()
     {
       if (AllWindowsClosed())
       {
         // commented out to fix test failures after this due to missing prefs
         //ExitTest();
--- a/suite/modules/test/browser_sanitizer.js
+++ b/suite/modules/test/browser_sanitizer.js
@@ -76,19 +76,17 @@ var sanTests = {
       }
       return false;
     }
   },
 
   cookies: {
     desc: "Cookie",
     setup: function() {
-      var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                            .getService(Components.interfaces.nsIPrefBranch);
-      prefs.setIntPref("network.cookie.cookieBehavior", 0);
+      Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
       var ios = Components.classes["@mozilla.org/network/io-service;1"]
                           .getService(Components.interfaces.nsIIOService);
       this.uri = ios.newURI("http://sanitizer.test/", null, null);
       this.cs = Components.classes["@mozilla.org/cookieService;1"]
                           .getService(Components.interfaces.nsICookieService);
       this.cs.setCookieString(this.uri, null, "Sanitizer!", null);
       return this.check();
     },
@@ -145,29 +143,27 @@ var sanTests = {
           "INSERT INTO urlbarhistory (url) VALUES ('Sanitizer')");
         connection.close();
       }
 
       // Open location dialog.
       var supStr = Components.classes["@mozilla.org/supports-string;1"]
                              .createInstance(Components.interfaces.nsISupportsString);
       supStr.data = "Sanitizer!";
-      this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                             .getService(Components.interfaces.nsIPrefBranch);
-      this.prefs.setComplexValue("general.open_location.last_url",
-                                 Components.interfaces.nsISupportsString, supStr);
+      Services.prefs.setComplexValue("general.open_location.last_url",
+                                      Components.interfaces.nsISupportsString, supStr);
 
       return this.check(true);
     },
 
     check: function(aCheckAll) {
       var locDialog = false;
       try {
-        locDialog = (this.prefs.getComplexValue("general.open_location.last_url",
-                                                Components.interfaces.nsISupportsString).data == "Sanitizer!");
+        locDialog = (Services.prefs.getComplexValue("general.open_location.last_url",
+                                                     Components.interfaces.nsISupportsString).data == "Sanitizer!");
       } catch(ex) {}
 
       if (locDialog == !aCheckAll)
         return locDialog;
 
       var file = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties)
                            .get("ProfD", Components.interfaces.nsIFile);
@@ -297,22 +293,19 @@ var sanTests = {
       } catch(ex) {}
 
       return (domain.value == "Foo");
     }
   }
 };
 
 function fullSanitize() {
-  var psvc = Components.classes["@mozilla.org/preferences-service;1"]
-                       .getService(Components.interfaces.nsIPrefService);
-  var prefs = psvc.getBranch("privacy.item.");
+  var prefs = Services.prefs.getBranch("privacy.item.");
 
-  var poppref = psvc.getBranch("privacy.sanitize.");
-  poppref.setBoolPref("promptOnSanitize", false);
+  Services.prefs.setBoolPref("privacy.sanitize.promptOnSanitize", false);
 
   for (var testName in sanTests) {
     var test = sanTests[testName];
     ok(test.setup(), test.desc + " test setup successfully for full sanitize");
     prefs.setBoolPref(testName, true);
   }
 
   Sanitizer.sanitize();
@@ -321,17 +314,17 @@ function fullSanitize() {
     var test = sanTests[testName];
     ok(!test.check(), test.desc + " data cleared by full sanitize");
     try {
       prefs.clearUserPref(testName);
     } catch (ex) {}
   }
 
   try {
-    poppref.clearUserPref("promptOnSanitize");
+    Services.prefs.clearUserPref("privacy.sanitize.promptOnSanitize");
   } catch(ex) {}
 }
 
 function test() {
   waitForExplicitFinish();
 
   // Sanitize one item at a time.
   for (var testName in sanTests) {