Bug 1417944 - Enable ESLint rule mozilla/use-services for toolkit/mozapps/extensions. r=aswan
authorMark Banner <standard8@mozilla.com>
Wed, 22 Nov 2017 13:35:52 +0000
changeset 393791 3f946c460cd14bb1b05fdcac4d1c59c7d41d7d47
parent 393790 e576f9269c5745636fff03b12e21030d7c8cad23
child 393792 f7e3a378ee3dfa35a065a30385d66d20746c9fa1
push id56045
push usermbanner@mozilla.com
push dateMon, 27 Nov 2017 10:02:44 +0000
treeherderautoland@f7e3a378ee3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1417944
milestone59.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 1417944 - Enable ESLint rule mozilla/use-services for toolkit/mozapps/extensions. r=aswan MozReview-Commit-ID: 6nK45TknN9x
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/amContentHandler.js
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/content/newaddon.js
toolkit/mozapps/extensions/content/xpinstallConfirm.js
toolkit/mozapps/extensions/internal/AddonRepository.jsm
toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/internal/PluginProvider.jsm
toolkit/mozapps/extensions/nsBlocklistService.js
toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
toolkit/mozapps/extensions/test/browser/browser_bug567127.js
toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
toolkit/mozapps/extensions/test/browser/browser_list.js
toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
toolkit/mozapps/extensions/test/xpcshell/test_startup.js
toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js
toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js
toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -9,16 +9,17 @@ const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 // Cannot use Services.appinfo here, or else xpcshell-tests will blow up, as
 // most tests later register different nsIAppInfo implementations, which
 // wouldn't be reflected in Services.appinfo anymore, as the lazy getter
 // underlying it would have been initialized if we used it here.
 if ("@mozilla.org/xre/app-info;1" in Cc) {
+  // eslint-disable-next-line mozilla/use-services
   let runtime = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime);
   if (runtime.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
     // Refuse to run in child processes.
     throw new Error("You cannot use the AddonManager in child processes!");
   }
 }
 
 Cu.import("resource://gre/modules/AppConstants.jsm");
@@ -2855,20 +2856,18 @@ var AddonManagerInternal = {
         }
 
         let args = {};
         args.url = url;
         args.installs = [proxy];
         args.wrappedJSObject = args;
 
         try {
-          Cc["@mozilla.org/base/telemetry;1"].
-                       getService(Ci.nsITelemetry).
-                       getHistogramById("SECURITY_UI").
-                       add(Ci.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL);
+          Services.telemetry.getHistogramById("SECURITY_UI")
+                  .add(Ci.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL);
           let parentWindow = null;
           if (browser) {
             // Find the outer browser
             let docShell = browser.ownerGlobal
                                   .QueryInterface(Ci.nsIInterfaceRequestor)
                                   .getInterface(Ci.nsIDocShell)
                                   .QueryInterface(Ci.nsIDocShellTreeItem);
             if (docShell.itemType == Ci.nsIDocShellTreeItem.typeContent)
--- a/toolkit/mozapps/extensions/amContentHandler.js
+++ b/toolkit/mozapps/extensions/amContentHandler.js
@@ -86,15 +86,14 @@ amContentHandler.prototype = {
     messageManager.sendAsyncMessage(MSG_INSTALL_ADDON, install);
   },
 
   classID: Components.ID("{7beb3ba8-6ec3-41b4-b67c-da89b8518922}"),
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler]),
 
   log(aMsg) {
     let msg = "amContentHandler.js: " + (aMsg.join ? aMsg.join("") : aMsg);
-    Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).
-      logStringMessage(msg);
+    Services.console.logStringMessage(msg);
     dump(msg + "\n");
   }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([amContentHandler]);
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -951,19 +951,17 @@ var gViewController = {
       doCommand() {
         let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].
                          createInstance(Ci.nsISupportsPRBool);
         Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
                                      "restart");
         if (cancelQuit.data)
           return; // somebody canceled our quit request
 
-        let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].
-                         getService(Ci.nsIAppStartup);
-        appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
+        Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
       }
     },
 
     cmd_enableCheckCompatibility: {
       isEnabled() {
         return true;
       },
       doCommand() {
--- a/toolkit/mozapps/extensions/content/newaddon.js
+++ b/toolkit/mozapps/extensions/content/newaddon.js
@@ -119,19 +119,17 @@ function restartClicked() {
                    createInstance(Ci.nsISupportsPRBool);
   Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
                                "restart");
   if (cancelQuit.data)
     return; // somebody canceled our quit request
 
   window.close();
 
-  let appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
-                   getService(Components.interfaces.nsIAppStartup);
-  appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
+  Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
 }
 
 function cancelClicked() {
   gAddon.userDisabled = true;
   AddonManager.addAddonListener(EnableListener);
 
   document.getElementById("allow").disabled = false;
   document.getElementById("buttonDeck").selectedPanel = document.getElementById("continuePanel");
--- a/toolkit/mozapps/extensions/content/xpinstallConfirm.js
+++ b/toolkit/mozapps/extensions/content/xpinstallConfirm.js
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var XPInstallConfirm = {};
 
 XPInstallConfirm.init = function() {
   Components.utils.import("resource://gre/modules/AddonManager.jsm");
+  Components.utils.import("resource://gre/modules/Services.jsm");
 
   var _installCountdown;
   var _installCountdownInterval;
   var _focused;
   var _timeout;
 
   // Default to cancelling the install when the window unloads
   XPInstallConfirm._installOK = false;
@@ -25,19 +26,17 @@ XPInstallConfirm.init = function() {
   // the window
   if (args.installs.every(i => i.state != AddonManager.STATE_DOWNLOADED)) {
     window.close();
     return;
   }
 
   var _installCountdownLength = 5;
   try {
-    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                          .getService(Components.interfaces.nsIPrefBranch);
-    var delay_in_milliseconds = prefs.getIntPref("security.dialog_enable_delay");
+    var delay_in_milliseconds = Services.prefs.getIntPref("security.dialog_enable_delay");
     _installCountdownLength = Math.round(delay_in_milliseconds / 500);
   } catch (ex) { }
 
   var itemList = document.getElementById("itemList");
 
   let installMap = new WeakMap();
   let installListener = {
     onDownloadCancelled(install) {
@@ -162,20 +161,18 @@ XPInstallConfirm.init = function() {
 
     okButton.disabled = true;
     setWidgetsAfterFocus();
   } else
     okButton.label = bundle.getString("installButtonLabel");
 };
 
 XPInstallConfirm.onOK = function() {
-  Components.classes["@mozilla.org/base/telemetry;1"].
-    getService(Components.interfaces.nsITelemetry).
-    getHistogramById("SECURITY_UI").
-    add(Components.interfaces.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL_CLICK_THROUGH);
+  Services.telemetry.getHistogramById("SECURITY_UI")
+    .add(Components.interfaces.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL_CLICK_THROUGH);
   // Perform the install or cancel after the window has unloaded
   XPInstallConfirm._installOK = true;
   return true;
 };
 
 XPInstallConfirm.onCancel = function() {
   // Perform the install or cancel after the window has unloaded
   XPInstallConfirm._installOK = false;
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -767,19 +767,17 @@ this.AddonRepository = {
 
     let pref = PREF_GETADDONS_BYIDS;
 
     if (aSendPerformance) {
       let type = Services.prefs.getPrefType(PREF_GETADDONS_BYIDS_PERFORMANCE);
       if (type == Services.prefs.PREF_STRING) {
         pref = PREF_GETADDONS_BYIDS_PERFORMANCE;
 
-        let startupInfo = Cc["@mozilla.org/toolkit/app-startup;1"].
-                          getService(Ci.nsIAppStartup).
-                          getStartupInfo();
+        let startupInfo = Services.startup.getStartupInfo();
 
         params.TIME_MAIN = "";
         params.TIME_FIRST_PAINT = "";
         params.TIME_SESSION_RESTORED = "";
         if (startupInfo.process) {
           if (startupInfo.main) {
             params.TIME_MAIN = startupInfo.main - startupInfo.process;
           }
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
@@ -847,24 +847,21 @@ this.AddonUpdateChecker = {
   getNewestCompatibleUpdate(aUpdates, aAppVersion, aPlatformVersion,
                                       aIgnoreMaxVersion, aIgnoreStrictCompat,
                                       aCompatOverrides) {
     if (!aAppVersion)
       aAppVersion = Services.appinfo.version;
     if (!aPlatformVersion)
       aPlatformVersion = Services.appinfo.platformVersion;
 
-    let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
-                    getService(Ci.nsIBlocklistService);
-
     let newest = null;
     for (let update of aUpdates) {
       if (!update.updateURL)
         continue;
-      let state = blocklist.getAddonBlocklistState(update, aAppVersion, aPlatformVersion);
+      let state = Services.blocklist.getAddonBlocklistState(update, aAppVersion, aPlatformVersion);
       if (state != Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
         continue;
       if ((newest == null || (Services.vc.compare(newest.version, update.version) < 0)) &&
           matchesVersions(update, aAppVersion, aPlatformVersion,
                           aIgnoreMaxVersion, aIgnoreStrictCompat,
                           aCompatOverrides)) {
         newest = update;
       }
--- a/toolkit/mozapps/extensions/internal/PluginProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/PluginProvider.jsm
@@ -376,26 +376,22 @@ PluginWrapper.prototype = {
       AddonManagerPrivate.callAddonListeners("onPropertyChanged", this, ["userDisabled"]);
     }
 
     return val;
   },
 
   get blocklistState() {
     let { tags: [tag] } = pluginFor(this);
-    let bs = Cc["@mozilla.org/extensions/blocklist;1"].
-             getService(Ci.nsIBlocklistService);
-    return bs.getPluginBlocklistState(tag);
+    return Services.blocklist.getPluginBlocklistState(tag);
   },
 
   get blocklistURL() {
     let { tags: [tag] } = pluginFor(this);
-    let bs = Cc["@mozilla.org/extensions/blocklist;1"].
-             getService(Ci.nsIBlocklistService);
-    return bs.getPluginBlocklistURL(tag);
+    return Services.blocklist.getPluginBlocklistURL(tag);
   },
 
   get size() {
     function getDirectorySize(aFile) {
       let size = 0;
       let entries = aFile.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
       let entry;
       while ((entry = entries.nextFile)) {
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -75,26 +75,22 @@ var gBlocklistLevel = DEFAULT_LEVEL;
 XPCOMUtils.defineLazyServiceGetter(this, "gConsole",
                                    "@mozilla.org/consoleservice;1",
                                    "nsIConsoleService");
 
 XPCOMUtils.defineLazyServiceGetter(this, "gVersionChecker",
                                    "@mozilla.org/xpcom/version-comparator;1",
                                    "nsIVersionComparator");
 
-XPCOMUtils.defineLazyGetter(this, "gPref", function() {
-  return Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).
-         QueryInterface(Ci.nsIPrefBranch);
-});
-
 // From appinfo in Services.jsm. It is not possible to use the one in
 // Services.jsm since it will not successfully QueryInterface nsIXULAppInfo in
 // xpcshell tests due to other code calling Services.appinfo before the
 // nsIXULAppInfo is created by the tests.
 XPCOMUtils.defineLazyGetter(this, "gApp", function() {
+  // eslint-disable-next-line mozilla/use-services
   let appinfo = Cc["@mozilla.org/xre/app-info;1"]
                   .getService(Ci.nsIXULRuntime);
   try {
     appinfo.QueryInterface(Ci.nsIXULAppInfo);
   } catch (ex) {
     // Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
     if (!(ex instanceof Components.Exception) ||
         ex.result != Cr.NS_NOINTERFACE)
@@ -120,27 +116,25 @@ XPCOMUtils.defineLazyGetter(this, "gABI"
     if (macutils.isUniversalBinary)
       abi += "-u-" + macutils.architecturesInBinary;
   }
   return abi;
 });
 
 XPCOMUtils.defineLazyGetter(this, "gOSVersion", function() {
   let osVersion;
-  let sysInfo = Cc["@mozilla.org/system-info;1"].
-                getService(Ci.nsIPropertyBag2);
   try {
-    osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
+    osVersion = Services.sysinfo.getProperty("name") + " " + Services.sysinfo.getProperty("version");
   } catch (e) {
     LOG("BlockList Global gOSVersion: OS Version unknown.");
   }
 
   if (osVersion) {
     try {
-      osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
+      osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
     } catch (e) {
       // Not all platforms have a secondary widget library, so an error is nothing to worry about.
     }
     osVersion = encodeURIComponent(osVersion);
   }
   return osVersion;
 });
 
@@ -172,50 +166,34 @@ function LOG(string) {
  * @param   defaultValue
  *          The default value to return in the event the preference has
  *          no setting
  * @returns The value of the preference, or undefined if there was no
  *          user or default value.
  */
 function getPref(func, preference, defaultValue) {
   try {
-    return gPref[func](preference);
+    return Services.prefs[func](preference);
   } catch (e) {
   }
   return defaultValue;
 }
 
-/**
- * Constructs a URI to a spec.
- * @param   spec
- *          The spec to construct a URI to
- * @returns The nsIURI constructed.
- */
-function newURI(spec) {
-  var ioServ = Cc["@mozilla.org/network/io-service;1"].
-               getService(Ci.nsIIOService);
-  return ioServ.newURI(spec);
-}
-
 // Restarts the application checking in with observers first
 function restartApp() {
   // Notify all windows that an application quit has been requested.
-  var os = Cc["@mozilla.org/observer-service;1"].
-           getService(Ci.nsIObserverService);
   var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].
                    createInstance(Ci.nsISupportsPRBool);
-  os.notifyObservers(cancelQuit, "quit-application-requested");
+  Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
 
   // Something aborted the quit process.
   if (cancelQuit.data)
     return;
 
-  var as = Cc["@mozilla.org/toolkit/app-startup;1"].
-           getService(Ci.nsIAppStartup);
-  as.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
+  Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
 }
 
 /**
  * Checks whether this blocklist element is valid for the current OS and ABI.
  * If the element has an "os" attribute then the current OS must appear in
  * its comma separated list for the element to be valid. Similarly for the
  * xpcomabi attribute.
  */
@@ -241,17 +219,17 @@ function matchesOSABI(blocklistElement) 
  * exists in nsHttpHandler.cpp when building the UA string.
  */
 function getLocale() {
   return Services.locale.getRequestedLocale();
 }
 
 /* Get the distribution pref values, from defaults only */
 function getDistributionPrefValue(aPrefName) {
-  return gPref.getDefaultBranch(null).getCharPref(aPrefName, "default");
+  return Services.prefs.getDefaultBranch(null).getCharPref(aPrefName, "default");
 }
 
 /**
  * Parse a string representation of a regular expression. Needed because we
  * use the /pattern/flags form (because it's detectable), which is only
  * supported as a literal in JS.
  *
  * @param  aStr
@@ -274,18 +252,18 @@ function parseRegExp(aStr) {
 
 function Blocklist() {
   Services.obs.addObserver(this, "xpcom-shutdown");
   Services.obs.addObserver(this, "sessionstore-windows-restored");
   gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false);
   gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true);
   gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
                                      MAX_BLOCK_LEVEL);
-  gPref.addObserver("extensions.blocklist.", this);
-  gPref.addObserver(PREF_EM_LOGGING_ENABLED, this);
+  Services.prefs.addObserver("extensions.blocklist.", this);
+  Services.prefs.addObserver(PREF_EM_LOGGING_ENABLED, this);
   this.wrappedJSObject = this;
   // requests from child processes come in here, see receiveMessage.
   Services.ppmm.addMessageListener("Blocklist:getPluginBlocklistState", this);
   Services.ppmm.addMessageListener("Blocklist:content-blocklist-updated", this);
 }
 
 Blocklist.prototype = {
   /**
@@ -306,18 +284,18 @@ Blocklist.prototype = {
   _addonEntries: null,
   _gfxEntries: null,
   _pluginEntries: null,
 
   shutdown() {
     Services.obs.removeObserver(this, "xpcom-shutdown");
     Services.ppmm.removeMessageListener("Blocklist:getPluginBlocklistState", this);
     Services.ppmm.removeMessageListener("Blocklist:content-blocklist-updated", this);
-    gPref.removeObserver("extensions.blocklist.", this);
-    gPref.removeObserver(PREF_EM_LOGGING_ENABLED, this);
+    Services.prefs.removeObserver("extensions.blocklist.", this);
+    Services.prefs.removeObserver(PREF_EM_LOGGING_ENABLED, this);
   },
 
   observe(aSubject, aTopic, aData) {
     switch (aTopic) {
     case "xpcom-shutdown":
       this.shutdown();
       break;
     case "nsPref:changed":
@@ -522,17 +500,17 @@ Blocklist.prototype = {
     return url;
   },
 
   notify(aTimer) {
     if (!gBlocklistEnabled)
       return;
 
     try {
-      var dsURI = gPref.getCharPref(PREF_BLOCKLIST_URL);
+      var dsURI = Services.prefs.getCharPref(PREF_BLOCKLIST_URL);
     } catch (e) {
       LOG("Blocklist::notify: The " + PREF_BLOCKLIST_URL + " preference" +
           " is missing!");
       return;
     }
 
     var pingCountVersion = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTVERSION, 0);
     var pingCountTotal = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTTOTAL, 1);
@@ -589,32 +567,32 @@ Blocklist.prototype = {
     // so this code doesn't bother trying to do the "right thing" here.
     if (pingCountVersion != "invalid") {
       pingCountVersion++;
       if (pingCountVersion > 2147483647) {
         // Rollover to -1 if the value is greater than what is support by an
         // integer preference. The -1 indicates that the counter has been reset.
         pingCountVersion = -1;
       }
-      gPref.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, pingCountVersion);
+      Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, pingCountVersion);
     }
 
     if (pingCountTotal != "invalid") {
       pingCountTotal++;
       if (pingCountTotal > 2147483647) {
         // Rollover to 1 if the value is greater than what is support by an
         // integer preference.
         pingCountTotal = -1;
       }
-      gPref.setIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, pingCountTotal);
+      Services.prefs.setIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, pingCountTotal);
     }
 
     // Verify that the URI is valid
     try {
-      var uri = newURI(dsURI);
+      var uri = Services.io.newURI(dsURI);
     } catch (e) {
       LOG("Blocklist::notify: There was an error creating the blocklist URI\r\n" +
           "for: " + dsURI + ", error: " + e);
       return;
     }
 
     LOG("Blocklist::notify: Requesting " + uri.spec);
     let request = new ServiceRequest();
@@ -629,17 +607,17 @@ Blocklist.prototype = {
 
     // When the blocklist loads we need to compare it to the current copy so
     // make sure we have loaded it.
     if (!this._isBlocklistLoaded())
       this._loadBlocklist();
 
     // If blocklist update via Kinto is enabled, poll for changes and sync.
     // Currently certificates blocklist relies on it by default.
-    if (gPref.getBoolPref(PREF_BLOCKLIST_UPDATE_ENABLED)) {
+    if (Services.prefs.getBoolPref(PREF_BLOCKLIST_UPDATE_ENABLED)) {
       BlocklistUpdater.checkVersions().catch(() => {
         // Bug 1254099 - Telemetry (success or errors) will be collected during this process.
       });
     }
   },
 
   async onXMLLoad(aEvent) {
     let request = aEvent.target;
@@ -1276,17 +1254,17 @@ Blocklist.prototype = {
   },
 
   _blocklistUpdated(oldAddonEntries, oldPluginEntries) {
     var addonList = [];
 
     // A helper function that reverts the prefs passed to default values.
     function resetPrefs(prefs) {
       for (let pref of prefs)
-        gPref.clearUserPref(pref);
+        Services.prefs.clearUserPref(pref);
     }
     const types = ["extension", "theme", "locale", "dictionary", "service"];
     AddonManager.getAddonsByTypes(types, addons => {
       for (let addon of addons) {
         let oldState = addon.blocklistState;
         if (addon.updateBlocklistState) {
           addon.updateBlocklistState(false);
         } else if (oldAddonEntries) {
--- a/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_addonrepository_performance.js
@@ -3,17 +3,16 @@
  */
 
 // Tests that the metadata request includes startup time measurements
 
 var tmp = {};
 Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", tmp);
 var AddonRepository = tmp.AddonRepository;
 
-var gTelemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 var gProvider;
 
 function parseParams(aQuery) {
   let params = {};
 
   for (let param of aQuery.split("&")) {
     let [key, value] = param.split("=");
     params[key] = value;
@@ -38,18 +37,18 @@ function test() {
     let url = aSubject.URI.QueryInterface(Ci.nsIURL);
     if (url.filePath != "/extensions-dummy/metadata") {
       return;
     }
     info(url.query);
 
     // Check if we encountered telemetry errors and turn the tests for which
     // we don't have valid data into known failures.
-    let snapshot = gTelemetry.getHistogramById("STARTUP_MEASUREMENT_ERRORS")
-                             .snapshot();
+    let snapshot = Services.telemetry.getHistogramById("STARTUP_MEASUREMENT_ERRORS")
+                           .snapshot();
 
     let tProcessValid = (snapshot.counts[0] == 0);
     let tMainValid = tProcessValid && (snapshot.counts[2] == 0);
     let tFirstPaintValid = tProcessValid && (snapshot.counts[5] == 0);
     let tSessionRestoredValid = tProcessValid && (snapshot.counts[6] == 0);
 
     let params = parseParams(url.query);
 
@@ -90,9 +89,8 @@ function test() {
 
   AddonRepository._beginGetAddons(["test1@tests.mozilla.org"], {
     searchFailed() {
       ok(gSeenRequest, "Should have seen metadata request");
       finish();
     }
   }, true);
 }
-
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
@@ -59,30 +59,26 @@ function checkInstallConfirmation(...url
         windows.delete(window);
 
         if (windows.size > 0) {
           return;
         }
 
         is(urls.length, 0, "Saw install dialogs for all expected urls");
 
-        let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-                             .getService(Ci.nsIWindowMediator);
-        wm.removeListener(listener);
+        Services.wm.removeListener(listener);
 
         is(notificationCount, nurls, `Saw ${nurls} addon-install-started notifications`);
         Services.obs.removeObserver(observer, "addon-install-started");
 
         resolve();
       }
     };
 
-    let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-                         .getService(Ci.nsIWindowMediator);
-    wm.addListener(listener);
+    Services.wm.addListener(listener);
   });
 }
 
 add_task(async function test_install_from_file() {
   gManagerWindow = await open_manager("addons://list/extension");
 
   var filePaths = [
                    get_addon_file_url("browser_bug567127_1.xpi"),
--- a/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_dragdrop.js
@@ -7,19 +7,17 @@
 // in its own window.
 // Tests are only simulations of the drag and drop events, we cannot really do
 // this automatically.
 
 // Instead of loading EventUtils.js into the test scope in browser-test.js for all tests,
 // we only need EventUtils.js for a few files which is why we are using loadSubScript.
 var gManagerWindow;
 var EventUtils = {};
-this._scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
-                     getService(Ci.mozIJSSubScriptLoader);
-this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
+Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
 
 function checkInstallConfirmation(...urls) {
   let nurls = urls.length;
 
   let notificationCount = 0;
   let observer = {
     observe(aSubject, aTopic, aData) {
       var installInfo = aSubject.wrappedJSObject;
@@ -63,30 +61,26 @@ function checkInstallConfirmation(...url
         return;
       }
       windows.delete(window);
 
       if (windows.size > 0 || urls.length > 0) {
         return;
       }
 
-      let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-                           .getService(Ci.nsIWindowMediator);
-      wm.removeListener(listener);
+      Services.wm.removeListener(listener);
 
       is(notificationCount, nurls, `Saw ${nurls} addon-install-started notifications`);
       Services.obs.removeObserver(observer, "addon-install-started");
 
       executeSoon(run_next_test);
     }
   };
 
-  let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
-                       .getService(Ci.nsIWindowMediator);
-  wm.addListener(listener);
+  Services.wm.addListener(listener);
 }
 
 function test() {
   waitForExplicitFinish();
 
   open_manager("addons://list/extension", function(aWindow) {
     gManagerWindow = aWindow;
     run_next_test();
--- a/toolkit/mozapps/extensions/test/browser/browser_list.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_list.js
@@ -734,48 +734,45 @@ add_task(async function() {
     return false;
   }
 
   // Ignore the OSX full keyboard access setting
   Services.prefs.setBoolPref("accessibility.tabfocus_applies_to_xul", false);
 
   let items = get_test_items();
 
-  var fm = Cc["@mozilla.org/focus-manager;1"].
-           getService(Ci.nsIFocusManager);
-
   let addon = items["Test add-on 6"];
   addon.parentNode.ensureElementIsVisible(addon);
   EventUtils.synthesizeMouseAtCenter(addon, { }, gManagerWindow);
-  is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
+  is(Services.focus.focusedElement, addon.parentNode, "Focus should have moved to the list");
 
   EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
-  is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
+  is(Services.focus.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
 
   EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
-  is(fm.focusedElement, get_node(addon, "disable-btn"), "Focus should have moved to the disable button");
+  is(Services.focus.focusedElement, get_node(addon, "disable-btn"), "Focus should have moved to the disable button");
 
   EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
-  is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
+  is(Services.focus.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
 
   EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
-  ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
+  ok(!is_node_in_list(Services.focus.focusedElement), "Focus should be outside the list");
 
   EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
-  is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
+  is(Services.focus.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
 
   EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
   EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
-  is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
+  is(Services.focus.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
 
   EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
-  is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
+  is(Services.focus.focusedElement, addon.parentNode, "Focus should have moved to the list");
 
   EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
-  ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
+  ok(!is_node_in_list(Services.focus.focusedElement), "Focus should be outside the list");
 
   try {
     Services.prefs.clearUserPref("accessibility.tabfocus_applies_to_xul");
   } catch (e) { }
 });
 
 
 add_task(async function() {
--- a/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
+++ b/toolkit/mozapps/extensions/test/mochitest/test_bug687194.html
@@ -15,28 +15,28 @@
     SimpleTest.waitForExplicitFinish();
 
     const childFrameURL =
       "data:text/html,<!DOCTYPE HTML><html><body></body></html>";
 
     function childFrameScript() {
       "use strict";
 
-      var ios =
-          Components.classes["@mozilla.org/network/io-service;1"]
-                    .getService(Components.interfaces.nsIIOService);
-      /* global Ci, addMessageListener */
+      /* global Ci, Cu, addMessageListener */
+
+      Cu.import("resource://gre/modules/Services.jsm");
+
       let cr =
           Components.classes["@mozilla.org/chrome/chrome-registry;1"]
                     .getService(Ci.nsIXULChromeRegistry);
       addMessageListener("test687194:resolveChromeURI", function(message) {
         let result;
         let threw = false;
         try {
-            let uri = ios.newURI(message.data.URI);
+            let uri = Services.io.newURI(message.data.URI);
             result = cr.convertChromeURL(uri).spec;
         } catch (e) {
             threw = true;
             result = "EXCEPTION: " + e;
         }
 
         message.target.sendAsyncMessage("test687194:resolveChromeURI:Answer",
                                         { threw, result });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
@@ -375,56 +375,54 @@ function run_test() {
   } catch (e) {
     // Expected exception
   }
 
   do_check_eq(ltm.usedThemes.length, 0);
   do_check_eq(ltm.currentTheme, null);
 
   // Force the theme into the prefs anyway
-  let prefs = Cc["@mozilla.org/preferences-service;1"].
-              getService(Ci.nsIPrefBranch);
   let themes = [data];
-  prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
+  Services.prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
   do_check_eq(ltm.usedThemes.length, 1);
 
   // This should silently drop the bad theme.
   ltm.currentTheme = dummy();
   do_check_eq(ltm.usedThemes.length, 1);
   ltm.forgetUsedTheme(ltm.currentTheme.id);
   do_check_eq(ltm.usedThemes.length, 0);
   do_check_eq(ltm.currentTheme, null);
 
   // Add one broken and some working.
   themes = [data, dummy("x1"), dummy("x2")];
-  prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
+  Services.prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
   do_check_eq(ltm.usedThemes.length, 3);
 
   // Switching to an existing theme should drop the bad theme.
   ltm.currentTheme = ltm.getUsedTheme("x1");
   do_check_eq(ltm.usedThemes.length, 2);
   ltm.forgetUsedTheme("x1");
   ltm.forgetUsedTheme("x2");
   do_check_eq(ltm.usedThemes.length, 0);
   do_check_eq(ltm.currentTheme, null);
 
-  prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
+  Services.prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes));
   do_check_eq(ltm.usedThemes.length, 3);
 
   // Forgetting an existing theme should drop the bad theme.
   ltm.forgetUsedTheme("x1");
   do_check_eq(ltm.usedThemes.length, 1);
   ltm.forgetUsedTheme("x2");
   do_check_eq(ltm.usedThemes.length, 0);
   do_check_eq(ltm.currentTheme, null);
 
   // Test whether a JSON set with setCharPref can be retrieved with usedThemes
   ltm.currentTheme = dummy("x0");
   ltm.currentTheme = dummy("x1");
-  prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(ltm.usedThemes));
+  Services.prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(ltm.usedThemes));
   do_check_eq(ltm.usedThemes.length, 2);
   do_check_eq(ltm.currentTheme.id, "x1");
   do_check_eq(ltm.usedThemes[1].id, "x0");
   do_check_eq(ltm.usedThemes[0].id, "x1");
 
   ltm.forgetUsedTheme("x0");
   do_check_eq(ltm.usedThemes.length, 1);
   do_check_neq(ltm.currentTheme, null);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
@@ -4,21 +4,16 @@
 
 // Tests resetting of preferences in blocklist entry when an add-on is blocked.
 // See bug 802434.
 
 var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
 
-XPCOMUtils.defineLazyGetter(this, "gPref", function bls_gPref() {
-  return Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).
-         QueryInterface(Ci.nsIPrefBranch);
-});
-
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://testing-common/MockRegistrar.jsm");
 var testserver = new HttpServer();
 testserver.start(-1);
 gPort = testserver.identity.primaryPort;
 
 // register static files with server and interpolate port numbers in them
 mapFile("/data/test_blocklist_prefs_1.xml", testserver);
@@ -99,33 +94,33 @@ function run_test() {
     targetApplications: [{
       id: "xpcshell@tests.mozilla.org",
       minVersion: "1",
       maxVersion: "3"
     }]
   }, profileDir);
 
   // Pre-set the preferences that we expect to get reset.
-  gPref.setIntPref("test.blocklist.pref1", 15);
-  gPref.setIntPref("test.blocklist.pref2", 15);
-  gPref.setBoolPref("test.blocklist.pref3", true);
-  gPref.setBoolPref("test.blocklist.pref4", true);
+  Services.prefs.setIntPref("test.blocklist.pref1", 15);
+  Services.prefs.setIntPref("test.blocklist.pref2", 15);
+  Services.prefs.setBoolPref("test.blocklist.pref3", true);
+  Services.prefs.setBoolPref("test.blocklist.pref4", true);
 
   startupManager();
 
   // Before blocklist is loaded.
   AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                "block2@tests.mozilla.org"], function([a1, a2]) {
     do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
     do_check_eq(a2.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
 
-    do_check_eq(gPref.getIntPref("test.blocklist.pref1"), 15);
-    do_check_eq(gPref.getIntPref("test.blocklist.pref2"), 15);
-    do_check_eq(gPref.getBoolPref("test.blocklist.pref3"), true);
-    do_check_eq(gPref.getBoolPref("test.blocklist.pref4"), true);
+    do_check_eq(Services.prefs.getIntPref("test.blocklist.pref1"), 15);
+    do_check_eq(Services.prefs.getIntPref("test.blocklist.pref2"), 15);
+    do_check_eq(Services.prefs.getBoolPref("test.blocklist.pref3"), true);
+    do_check_eq(Services.prefs.getBoolPref("test.blocklist.pref4"), true);
     run_test_1();
   });
 }
 
 function run_test_1() {
   load_blocklist("test_blocklist_prefs_1.xml", function() {
     restartManager();
 
@@ -133,16 +128,16 @@ function run_test_1() {
     AddonManager.getAddonsByIDs(["block1@tests.mozilla.org",
                                  "block2@tests.mozilla.org"], function([a1, a2]) {
       do_check_neq(a1, null);
       do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
       do_check_neq(a2, null);
       do_check_eq(a2.blocklistState, Ci.nsIBlocklistService.STATE_BLOCKED);
 
       // All these prefs must be reset to defaults.
-      do_check_eq(gPref.prefHasUserValue("test.blocklist.pref1"), false);
-      do_check_eq(gPref.prefHasUserValue("test.blocklist.pref2"), false);
-      do_check_eq(gPref.prefHasUserValue("test.blocklist.pref3"), false);
-      do_check_eq(gPref.prefHasUserValue("test.blocklist.pref4"), false);
+      do_check_eq(Services.prefs.prefHasUserValue("test.blocklist.pref1"), false);
+      do_check_eq(Services.prefs.prefHasUserValue("test.blocklist.pref2"), false);
+      do_check_eq(Services.prefs.prefHasUserValue("test.blocklist.pref3"), false);
+      do_check_eq(Services.prefs.prefHasUserValue("test.blocklist.pref4"), false);
       end_test();
     });
   });
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
@@ -264,53 +264,50 @@ function run_test() {
     run_test_1();
   });
 }
 
 function run_test_1() {
   load_blocklist("test_bug393285.xml", function() {
     restartManager();
 
-    var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]
-                    .getService(Ci.nsIBlocklistService);
-
     AddonManager.getAddonsByIDs(addonIDs,
                                function([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
                                          a11, a12, a13, a14, a15]) {
       // No info in blocklist, shouldn't be blocked
-      do_check_false(blocklist.isAddonBlocklisted(a1, "1", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a1, "1", "1.9"));
 
       // Should always be blocked
-      do_check_true(blocklist.isAddonBlocklisted(a2, "1", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a2, "1", "1.9"));
 
       // Only version 1 should be blocked
-      do_check_true(blocklist.isAddonBlocklisted(a3, "1", "1.9"));
-      do_check_false(blocklist.isAddonBlocklisted(a4, "1", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a3, "1", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a4, "1", "1.9"));
 
       // Should be blocked for app version 1
-      do_check_true(blocklist.isAddonBlocklisted(a5, "1", "1.9"));
-      do_check_false(blocklist.isAddonBlocklisted(a5, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a5, "1", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a5, "2", "1.9"));
 
       // Not blocklisted because we are a different OS
-      do_check_false(blocklist.isAddonBlocklisted(a6, "2", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a6, "2", "1.9"));
 
       // Blocklisted based on OS
-      do_check_true(blocklist.isAddonBlocklisted(a7, "2", "1.9"));
-      do_check_true(blocklist.isAddonBlocklisted(a8, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a7, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a8, "2", "1.9"));
 
       // Not blocklisted because we are a different ABI
-      do_check_false(blocklist.isAddonBlocklisted(a9, "2", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a9, "2", "1.9"));
 
       // Blocklisted based on ABI
-      do_check_true(blocklist.isAddonBlocklisted(a10, "2", "1.9"));
-      do_check_true(blocklist.isAddonBlocklisted(a11, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a10, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a11, "2", "1.9"));
 
       // Doesnt match both os and abi so not blocked
-      do_check_false(blocklist.isAddonBlocklisted(a12, "2", "1.9"));
-      do_check_false(blocklist.isAddonBlocklisted(a13, "2", "1.9"));
-      do_check_false(blocklist.isAddonBlocklisted(a14, "2", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a12, "2", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a13, "2", "1.9"));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a14, "2", "1.9"));
 
       // Matches both os and abi so blocked
-      do_check_true(blocklist.isAddonBlocklisted(a15, "2", "1.9"));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a15, "2", "1.9"));
       end_test();
     });
   });
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
@@ -131,25 +131,22 @@ function run_test() {
     run_test_1();
   });
 }
 
 function run_test_1() {
   load_blocklist("test_bug393285.xml", function() {
     restartManager();
 
-    var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]
-                    .getService(Ci.nsIBlocklistService);
-
     AddonManager.getAddonsByIDs(addonIDs,
                                function([a1, a2, a3, a4]) {
       // No info in blocklist, shouldn't be blocked
-      do_check_false(blocklist.isAddonBlocklisted(a1, null, null));
+      do_check_false(Services.blocklist.isAddonBlocklisted(a1, null, null));
 
       // All these should be blocklisted for the current app.
-      do_check_true(blocklist.isAddonBlocklisted(a2, null, null));
-      do_check_true(blocklist.isAddonBlocklisted(a3, null, null));
-      do_check_true(blocklist.isAddonBlocklisted(a4, null, null));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a2, null, null));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a3, null, null));
+      do_check_true(Services.blocklist.isAddonBlocklisted(a4, null, null));
 
       end_test();
     });
   });
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
@@ -72,42 +72,38 @@ function pathHandler(metadata, response)
               gOSVersion + "&1.9&distribution&distribution-version");
   gBlocklist.observe(null, "quit-application", "");
   gBlocklist.observe(null, "xpcom-shutdown", "");
   testserver.stop(do_test_finished);
 }
 
 function run_test() {
   var osVersion;
-  var sysInfo = Components.classes["@mozilla.org/system-info;1"]
-                          .getService(Components.interfaces.nsIPropertyBag2);
   try {
-    osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
+    osVersion = Services.sysinfo.getProperty("name") + " " + Services.sysinfo.getProperty("version");
     if (osVersion) {
       try {
-        osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
+        osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
       } catch (e) {
       }
       gOSVersion = encodeURIComponent(osVersion);
     }
   } catch (e) {
   }
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
   testserver = new HttpServer();
   testserver.registerPathHandler("/1", failHandler);
   testserver.registerPathHandler("/2", pathHandler);
   testserver.start(-1);
   gPort = testserver.identity.primaryPort;
 
   // Initialise the blocklist service
-  gBlocklist = Components.classes["@mozilla.org/extensions/blocklist;1"]
-                         .getService(Components.interfaces.nsIBlocklistService)
-                         .QueryInterface(Components.interfaces.nsIObserver);
+  gBlocklist = Services.blocklist.QueryInterface(Components.interfaces.nsIObserver);
   gBlocklist.observe(null, "profile-after-change", "");
 
   do_check_true(timerService.hasTimer(BLOCKLIST_TIMER));
 
   do_test_pending();
 
   // This should have no effect as the blocklist is disabled
   Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "http://localhost:" + gPort + "/1");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
@@ -191,18 +191,17 @@ function MockPluginTag(name, version, st
   this.name = name;
   this.version = version;
   this.start = start;
   this.appBlocks = appBlocks;
   this.toolkitBlocks = toolkitBlocks;
 }
 Object.defineProperty(MockPluginTag.prototype, "blocklisted", {
   get: function MockPluginTag_getBlocklisted() {
-    let bls = AM_Cc["@mozilla.org/extensions/blocklist;1"].getService(Ci.nsIBlocklistService);
-    return bls.getPluginBlocklistState(this) == bls.STATE_BLOCKED;
+    return Services.blocklist.getPluginBlocklistState(this) == Services.blocklist.STATE_BLOCKED;
   }
 });
 
 var PLUGINS = [
   new MockPluginTag("test_bug449027_1", "5", false, false, false),
   new MockPluginTag("test_bug449027_2", "5", false, true, false),
   new MockPluginTag("test_bug449027_3", "5", false, true, false),
   new MockPluginTag("test_bug449027_4", "5", false, false, false),
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
@@ -84,18 +84,17 @@ var ADDONS = [{
 
 function MockPlugin(name, version, enabledState) {
   this.name = name;
   this.version = version;
   this.enabledState = enabledState;
 }
 Object.defineProperty(MockPlugin.prototype, "blocklisted", {
   get: function MockPlugin_getBlocklisted() {
-    let bls = Cc["@mozilla.org/extensions/blocklist;1"].getService(Ci.nsIBlocklistService);
-    return bls.getPluginBlocklistState(this) == bls.STATE_BLOCKED;
+    return Services.blocklist.getPluginBlocklistState(this) == Services.blocklist.STATE_BLOCKED;
   }
 });
 Object.defineProperty(MockPlugin.prototype, "disabled", {
   get: function MockPlugin_getDisabled() {
     return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
   }
 });
 
@@ -411,47 +410,44 @@ function check_notification_pt3(args) {
     }
   }
 }
 
 function check_test_pt3() {
   restartManager();
   dump("Checking results pt 3\n");
 
-  let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
-                  getService(Ci.nsIBlocklistService);
-
   AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
     // All should have gained the blocklist state, user disabled as previously
     do_check_eq(check_addon_state(addons[0]), "true,false,true");
     do_check_eq(check_addon_state(addons[1]), "false,false,true");
     do_check_eq(check_addon_state(addons[2]), "false,false,true");
     do_check_eq(check_addon_state(addons[4]), "false,false,true");
     do_check_eq(check_plugin_state(PLUGINS[0]), "true,true");
     do_check_eq(check_plugin_state(PLUGINS[1]), "false,true");
     do_check_eq(check_plugin_state(PLUGINS[2]), "false,true");
     do_check_eq(check_plugin_state(PLUGINS[3]), "true,true");
     do_check_eq(check_plugin_state(PLUGINS[4]), "false,true");
 
     // Should have gained the blocklist state but no longer be soft disabled
     do_check_eq(check_addon_state(addons[3]), "false,false,true");
 
     // Check blockIDs are correct
-    do_check_eq(blocklist.getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
-    do_check_eq(blocklist.getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
-    do_check_eq(blocklist.getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
-    do_check_eq(blocklist.getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
-    do_check_eq(blocklist.getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
+    do_check_eq(Services.blocklist.getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
+    do_check_eq(Services.blocklist.getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
+    do_check_eq(Services.blocklist.getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
+    do_check_eq(Services.blocklist.getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
+    do_check_eq(Services.blocklist.getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
 
     // All plugins have the same blockID on the test
-    do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[0]), create_blocklistURL("test_bug455906_plugin"));
-    do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[1]), create_blocklistURL("test_bug455906_plugin"));
-    do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[2]), create_blocklistURL("test_bug455906_plugin"));
-    do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[3]), create_blocklistURL("test_bug455906_plugin"));
-    do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[4]), create_blocklistURL("test_bug455906_plugin"));
+    do_check_eq(Services.blocklist.getPluginBlocklistURL(PLUGINS[0]), create_blocklistURL("test_bug455906_plugin"));
+    do_check_eq(Services.blocklist.getPluginBlocklistURL(PLUGINS[1]), create_blocklistURL("test_bug455906_plugin"));
+    do_check_eq(Services.blocklist.getPluginBlocklistURL(PLUGINS[2]), create_blocklistURL("test_bug455906_plugin"));
+    do_check_eq(Services.blocklist.getPluginBlocklistURL(PLUGINS[3]), create_blocklistURL("test_bug455906_plugin"));
+    do_check_eq(Services.blocklist.getPluginBlocklistURL(PLUGINS[4]), create_blocklistURL("test_bug455906_plugin"));
 
     // Shouldn't be changed
     do_check_eq(check_addon_state(addons[5]), "false,false,true");
     do_check_eq(check_addon_state(addons[6]), "false,false,true");
     do_check_eq(check_plugin_state(PLUGINS[5]), "false,true");
 
     // Back to starting state
     gNotificationCheck = null;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
@@ -19,19 +19,18 @@ function get_test_plugintag() {
 }
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
   copyBlocklistToProfile(do_get_file("data/test_bug514327_2.xml"));
 
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
-  var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
 
-  prefs.setBoolPref("plugin.load_flash_only", false);
+  Services.prefs.setBoolPref("plugin.load_flash_only", false);
 
   var plugin = get_test_plugintag();
   if (!plugin)
     do_throw("Plugin tag not found");
 
   // run the code after the blocklist is closed
   Services.obs.notifyObservers(null, "addon-blocklist-closed");
   do_execute_soon(function() {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
@@ -9,17 +9,16 @@ var Cr = Components.results;
 
 Cu.import("resource://testing-common/httpd.js");
 Cu.import("resource://testing-common/MockRegistrar.jsm");
 
 const nsIBLS = Ci.nsIBlocklistService;
 const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
 
 var gBlocklist = null;
-var gPrefs = null;
 var gTestserver = null;
 
 var gNextTestPart = null;
 
 
 var PLUGINS = [{
   // Tests a plugin whose state goes from not-blocked, to outdated
   name: "test_bug514327_outdated",
@@ -85,34 +84,33 @@ var WindowWatcher = {
 
 MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
 MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
 
 
 function do_update_blocklist(aDatafile, aNextPart) {
   gNextTestPart = aNextPart;
 
-  gPrefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/" + aDatafile);
+  Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/" + aDatafile);
   gBlocklist.QueryInterface(Ci.nsITimerCallback).notify(null);
 }
 
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
   gTestserver = new HttpServer();
   gTestserver.registerDirectory("/data/", do_get_file("data"));
   gTestserver.start(-1);
   gPort = gTestserver.identity.primaryPort;
 
   startupManager();
 
   // initialize the blocklist with no entries
   copyBlocklistToProfile(do_get_file("data/test_bug514327_3_empty.xml"));
 
-  gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
   gBlocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
 
   // should NOT be marked as outdated by the blocklist
   do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
 
   do_test_pending();
 
   // update blocklist with data that marks the plugin as outdated
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x9876");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2202");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xdcdc");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.1112");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xdcdc");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.1110");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xdcdc");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.1111");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabab");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabab");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2202");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -41,17 +35,17 @@ function run_test() {
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   gfxInfo.spoofVendorID("0xabcd");
   gfxInfo.spoofDeviceID("0x6666");
 
   // Spoof the OS version so it matches the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
       break;
     case "Darwin":
       gfxInfo.spoofOSVersion(0x1090);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows Vista
       gfxInfo.spoofOSVersion(0x60000);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
@@ -10,22 +10,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -42,17 +36,17 @@ function run_test() {
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
   gfxInfo.spoofDriverVersion("8.52.322.2201");
   gfxInfo.spoofVendorID("0xabcd");
   gfxInfo.spoofDeviceID("0x1234");
 
   // Spoof the version of the OS appropriately to test the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       // Windows 8
       gfxInfo.spoofOSVersion(0x60002);
       break;
     case "Linux":
       // We don't have any OS versions on Linux, just "Linux".
       do_test_finished();
       return;
@@ -68,20 +62,20 @@ function run_test() {
   }
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
   startupManager();
 
   do_test_pending();
 
   function checkBlacklist() {
-    if (get_platform() == "WINNT") {
+    if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-    } else if (get_platform() == "Darwin") {
+    } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
     }
 
     gTestserver.stop(do_test_finished);
   }
 
   Services.obs.addObserver(function(aSubject, aTopic, aData) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -43,17 +37,17 @@ function run_test() {
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
   gfxInfo.spoofDriverVersion("8.52.322.2202");
   gfxInfo.spoofVendorID("0xabcd");
   gfxInfo.spoofDeviceID("0x1234");
 
   // Spoof the version of the OS appropriately to test the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       // Windows 8
       gfxInfo.spoofOSVersion(0x60002);
       break;
     case "Linux":
       // We don't have any OS versions on Linux, just "Linux".
       do_test_finished();
       return;
@@ -68,20 +62,20 @@ function run_test() {
   }
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
   startupManager();
 
   do_test_pending();
 
   function checkBlacklist() {
-    if (get_platform() == "WINNT") {
+    if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-    } else if (get_platform() == "Darwin") {
+    } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
     }
 
     gTestserver.stop(do_test_finished);
   }
 
   Services.obs.addObserver(function(aSubject, aTopic, aData) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -43,17 +37,17 @@ function run_test() {
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
   gfxInfo.spoofDriverVersion("8.52.322.2201");
   gfxInfo.spoofVendorID("0xabcd");
   gfxInfo.spoofDeviceID("0x1234");
 
   // Spoof the version of the OS appropriately to test the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
       // We don't have any OS versions on Linux, just "Linux".
       do_test_finished();
       return;
@@ -69,20 +63,20 @@ function run_test() {
   }
 
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
   startupManager();
 
   do_test_pending();
 
   function checkBlacklist() {
-    if (get_platform() == "WINNT") {
+    if (Services.appinfo.OS == "WINNT") {
       var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-    } else if (get_platform() == "Darwin") {
+    } else if (Services.appinfo.OS == "Darwin") {
       status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
       do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
     }
 
     gTestserver.stop(do_test_finished);
   }
 
   Services.obs.addObserver(function(aSubject, aTopic, aData) {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -38,17 +32,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xdcba");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
@@ -10,22 +10,16 @@ var { classes: Cc, interfaces: Ci, utils
 
 Cu.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist_AllOS.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
-                             .getService(Ci.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -37,17 +31,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
@@ -11,22 +11,16 @@ var { classes: Cc, interfaces: Ci } = Co
 Components.utils.import("resource://testing-common/httpd.js");
 
 var gTestserver = new HttpServer();
 gTestserver.start(-1);
 gPort = gTestserver.identity.primaryPort;
 mapFile("/data/test_gfxBlacklist.xml", gTestserver);
 mapFile("/data/test_gfxBlacklist2.xml", gTestserver);
 
-function get_platform() {
-  var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
-                             .getService(Components.interfaces.nsIXULRuntime);
-  return xulRuntime.OS;
-}
-
 function load_blocklist(file) {
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
                              gPort + "/data/" + file);
   var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
                   getService(Ci.nsITimerCallback);
   blocklist.notify(null);
 }
 
@@ -43,17 +37,17 @@ function run_test() {
   if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
     do_test_finished();
     return;
   }
 
   gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
 
   // Set the vendor/device ID, etc, to match the test file.
-  switch (get_platform()) {
+  switch (Services.appinfo.OS) {
     case "WINNT":
       gfxInfo.spoofVendorID("0xabcd");
       gfxInfo.spoofDeviceID("0x1234");
       gfxInfo.spoofDriverVersion("8.52.322.2201");
       // Windows 7
       gfxInfo.spoofOSVersion(0x60001);
       break;
     case "Linux":
@@ -85,19 +79,17 @@ function run_test() {
   function ensureBlacklistSet() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
-    var prefs = Cc["@mozilla.org/preferences-service;1"].
-          getService(Ci.nsIPrefBranch);
-    do_check_eq(prefs.getIntPref("gfx.blacklist.direct2d"),
+    do_check_eq(Services.prefs.getIntPref("gfx.blacklist.direct2d"),
                 Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
 
     Services.obs.removeObserver(blacklistAdded, "blocklist-data-gfxItems");
     Services.obs.addObserver(blacklistRemoved, "blocklist-data-gfxItems");
     load_blocklist("test_gfxBlacklist2.xml");
   }
 
   function blacklistRemoved(aSubject, aTopic, aData) {
@@ -108,21 +100,19 @@ function run_test() {
   function ensureBlacklistUnset() {
     var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
     do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
     // Make sure unrelated features aren't affected
     status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
     do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
 
-    var prefs = Cc["@mozilla.org/preferences-service;1"].
-          getService(Ci.nsIPrefBranch);
     var exists = false;
     try {
-      prefs.getIntPref("gfx.blacklist.direct2d");
+      Services.prefs.getIntPref("gfx.blacklist.direct2d");
       exists = true;
     } catch (e) {}
 
     do_check_false(exists);
 
     gTestserver.stop(do_test_finished);
   }
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
@@ -88,88 +88,84 @@ function run_test() {
 add_test(function test_copy() {
   clearBlocklists();
   copyToApp(OLD);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
-  let blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
-                  getService(AM_Ci.nsIBlocklistService);
-  do_check_false(blocklist.isAddonBlocklisted(invalidAddon));
-  do_check_false(blocklist.isAddonBlocklisted(ancientAddon));
-  do_check_true(blocklist.isAddonBlocklisted(oldAddon));
-  do_check_false(blocklist.isAddonBlocklisted(newAddon));
+
+  do_check_false(Services.blocklist.isAddonBlocklisted(invalidAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(ancientAddon));
+  do_check_true(Services.blocklist.isAddonBlocklisted(oldAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // An ancient blocklist should be ignored
 add_test(function test_ancient() {
   clearBlocklists();
   copyToApp(ANCIENT);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
-  let blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
-                  getService(AM_Ci.nsIBlocklistService);
-  do_check_false(blocklist.isAddonBlocklisted(invalidAddon));
-  do_check_false(blocklist.isAddonBlocklisted(ancientAddon));
-  do_check_true(blocklist.isAddonBlocklisted(oldAddon));
-  do_check_false(blocklist.isAddonBlocklisted(newAddon));
+
+  do_check_false(Services.blocklist.isAddonBlocklisted(invalidAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(ancientAddon));
+  do_check_true(Services.blocklist.isAddonBlocklisted(oldAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // A new blocklist should override an old blocklist
 add_test(function test_override() {
   clearBlocklists();
   copyToApp(NEW);
   copyToProfile(OLD, OLD_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
-  let blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
-                  getService(AM_Ci.nsIBlocklistService);
-  do_check_false(blocklist.isAddonBlocklisted(invalidAddon));
-  do_check_false(blocklist.isAddonBlocklisted(ancientAddon));
-  do_check_false(blocklist.isAddonBlocklisted(oldAddon));
-  do_check_true(blocklist.isAddonBlocklisted(newAddon));
+
+  do_check_false(Services.blocklist.isAddonBlocklisted(invalidAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(ancientAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(oldAddon));
+  do_check_true(Services.blocklist.isAddonBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // An old blocklist shouldn't override a new blocklist
 add_test(function test_retain() {
   clearBlocklists();
   copyToApp(OLD);
   copyToProfile(NEW, NEW_TSTAMP);
 
   incrementAppVersion();
   startupManager();
 
   reloadBlocklist();
-  let blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
-                  getService(AM_Ci.nsIBlocklistService);
-  do_check_false(blocklist.isAddonBlocklisted(invalidAddon));
-  do_check_false(blocklist.isAddonBlocklisted(ancientAddon));
-  do_check_false(blocklist.isAddonBlocklisted(oldAddon));
-  do_check_true(blocklist.isAddonBlocklisted(newAddon));
+
+  do_check_false(Services.blocklist.isAddonBlocklisted(invalidAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(ancientAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(oldAddon));
+  do_check_true(Services.blocklist.isAddonBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
 
 // A missing blocklist in the profile should still load an app-shipped blocklist
 add_test(function test_missing() {
@@ -181,19 +177,18 @@ add_test(function test_missing() {
   startupManager();
   shutdownManager();
 
   let blocklist = FileUtils.getFile(KEY_PROFILEDIR, [FILE_BLOCKLIST]);
   blocklist.remove(true);
   startupManager(false);
 
   reloadBlocklist();
-  blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
-              getService(AM_Ci.nsIBlocklistService);
-  do_check_false(blocklist.isAddonBlocklisted(invalidAddon));
-  do_check_false(blocklist.isAddonBlocklisted(ancientAddon));
-  do_check_true(blocklist.isAddonBlocklisted(oldAddon));
-  do_check_false(blocklist.isAddonBlocklisted(newAddon));
+
+  do_check_false(Services.blocklist.isAddonBlocklisted(invalidAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(ancientAddon));
+  do_check_true(Services.blocklist.isAddonBlocklisted(oldAddon));
+  do_check_false(Services.blocklist.isAddonBlocklisted(newAddon));
 
   shutdownManager();
 
   run_next_test();
 });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
@@ -1,16 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const nsIBLS = Components.interfaces.nsIBlocklistService;
 Components.utils.import("resource://testing-common/httpd.js");
 
-var gBlocklistService = null;
 var gNotifier = null;
 var gNextTest = null;
 var gPluginHost = null;
 
 var gServer = new HttpServer();
 gServer.start(-1);
 gPort = gServer.identity.primaryPort;
 mapFile("/data/test_pluginBlocklistCtp.xml", gServer);
@@ -87,60 +86,60 @@ function get_test_plugin() {
   do_check_true(false);
   return null;
 }
 
 // At this time, the blocklist does not have an entry for the test plugin,
 // so it shouldn't be click-to-play.
 function test_is_not_clicktoplay() {
   var plugin = get_test_plugin();
-  var blocklistState = gBlocklistService.getPluginBlocklistState(plugin, "1", "1.9");
+  var blocklistState = Services.blocklist.getPluginBlocklistState(plugin, "1", "1.9");
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
 
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/test_pluginBlocklistCtpUndo.xml");
   gNextTest = test_is_clicktoplay;
   gNotifier.notify(null);
 }
 
 // Here, we've updated the blocklist to have a block for the test plugin,
 // so it should be click-to-play.
 function test_is_clicktoplay() {
   var plugin = get_test_plugin();
-  var blocklistState = gBlocklistService.getPluginBlocklistState(plugin, "1", "1.9");
+  var blocklistState = Services.blocklist.getPluginBlocklistState(plugin, "1", "1.9");
   do_check_eq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
 
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/test_pluginBlocklistCtp.xml");
   gNextTest = test_is_not_clicktoplay2;
   gNotifier.notify(null);
 }
 
 // But now we've removed that entry from the blocklist (really we've gone back
 // to the old one), so the plugin shouldn't be click-to-play any more.
 function test_is_not_clicktoplay2() {
   var plugin = get_test_plugin();
-  var blocklistState = gBlocklistService.getPluginBlocklistState(plugin, "1", "1.9");
+  var blocklistState = Services.blocklist.getPluginBlocklistState(plugin, "1", "1.9");
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
 
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/test_pluginBlocklistCtpUndo.xml");
   gNextTest = test_disable_blocklist;
   gNotifier.notify(null);
 }
 
 // Test that disabling the blocklist when a plugin is ctp-blocklisted will
 // result in the plugin not being click-to-play.
 function test_disable_blocklist() {
   var plugin = get_test_plugin();
-  var blocklistState = gBlocklistService.getPluginBlocklistState(plugin, "1", "1.9");
+  var blocklistState = Services.blocklist.getPluginBlocklistState(plugin, "1", "1.9");
   do_check_eq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
 
   gNextTest = null;
   Services.prefs.setBoolPref("extensions.blocklist.enabled", false);
-  blocklistState = gBlocklistService.getPluginBlocklistState(plugin, "1", "1.9");
+  blocklistState = Services.blocklist.getPluginBlocklistState(plugin, "1", "1.9");
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE);
   do_check_neq(blocklistState, Components.interfaces.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE);
 
   // it should still be possible to make a plugin click-to-play via the pref
   // and setting that plugin's enabled state to click-to-play
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   let previousEnabledState = plugin.enabledState;
   plugin.enabledState = Components.interfaces.nsIPluginTag.STATE_CLICKTOPLAY;
@@ -160,17 +159,16 @@ function observer() {
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
 
   Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/test_pluginBlocklistCtp.xml");
   Services.prefs.setBoolPref("plugin.load_flash_only", false);
   startupManager();
 
   gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
-  gBlocklistService = Components.classes["@mozilla.org/extensions/blocklist;1"].getService(Components.interfaces.nsIBlocklistService);
   gNotifier = Components.classes["@mozilla.org/extensions/blocklist;1"].getService(Components.interfaces.nsITimerCallback);
   Services.obs.addObserver(observer, "blocklist-updated");
 
   do_register_cleanup(function() {
     Services.prefs.clearUserPref("extensions.blocklist.url");
     Services.prefs.clearUserPref("extensions.blocklist.enabled");
     Services.prefs.clearUserPref("plugins.click_to_play");
     Services.obs.removeObserver(observer, "blocklist-updated");
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
@@ -32,18 +32,16 @@ var METADATA = {
   version: "2.0",
   targetApplications: [{
     id: "xpcshell@tests.mozilla.org",
     minVersion: "2",
     maxVersion: "2"
   }]
 };
 
-const ios = AM_Cc["@mozilla.org/network/io-service;1"].getService(AM_Ci.nsIIOService);
-
 const gHaveSymlinks = AppConstants.platform != "win";
 
 
 function createSymlink(aSource, aDest) {
   if (aSource instanceof AM_Ci.nsIFile)
     aSource = aSource.path;
   if (aDest instanceof AM_Ci.nsIFile)
     aDest = aDest.path;
@@ -135,24 +133,24 @@ async function run_proxy_tests() {
               return url.replace(RegExp(`^file:///private/`), "file:///");
             return url;
           };
 
           // Check that proxied add-ons do not have upgrade permissions.
           do_check_eq(addon.permissions & AddonManager.PERM_CAN_UPGRADE, 0);
 
           // Check that getResourceURI points to the right place.
-          do_check_eq(ios.newFileURI(ADDONS[i].directory).spec,
+          do_check_eq(Services.io.newFileURI(ADDONS[i].directory).spec,
                       fixURL(addon.getResourceURI().spec),
                       `Base resource URL resolves as expected`);
 
           let file = ADDONS[i].directory.clone();
           file.append("install.rdf");
 
-          do_check_eq(ios.newFileURI(file).spec,
+          do_check_eq(Services.io.newFileURI(file).spec,
                       fixURL(addon.getResourceURI("install.rdf").spec),
                       `Resource URLs resolve as expected`);
 
           addon.uninstall();
         }
       }
 
       // Check that original sources still exist after explicit uninstall.
@@ -221,9 +219,8 @@ async function run_symlink_tests() {
     do_check_false(addonDirectory.exists());
 
     // Check that the temp file is not gone.
     do_check_true(tempFile.exists());
 
     tempDirectory.remove(true);
   });
 }
-
--- a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
@@ -112,19 +112,17 @@ const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
 var gCachePurged = false;
 
 // Set up the profile
 function run_test() {
   do_test_pending("test_startup main");
 
-  let obs = AM_Cc["@mozilla.org/observer-service;1"].
-    getService(AM_Ci.nsIObserverService);
-  obs.addObserver({
+  Services.obs.addObserver({
     observe(aSubject, aTopic, aData) {
       gCachePurged = true;
     }
   }, "startupcache-invalidate");
 
   startupManager();
   check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
   check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_auth.js
@@ -3,19 +3,17 @@
 // This verifies bug 312473
 function test() {
   Harness.authenticationCallback = get_auth_info;
   Harness.downloadFailedCallback = download_failed;
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
-  var prefs = Cc["@mozilla.org/preferences-service;1"].
-                        getService(Ci.nsIPrefBranch);
-  prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
+  Services.prefs.setIntPref("network.auth.subresource-http-auth-allow", 2);
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "amosigned.xpi"
   }));
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies2.js
@@ -2,20 +2,18 @@
 // Test that an install that requires cookies to be sent succeeds when cookies
 // are set
 // This verifies bug 462739
 function test() {
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
-         false, true, (Date.now() / 1000) + 60, {});
+  Services.cookies.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall",
+    "true", false, false, true, (Date.now() / 1000) + 60, {});
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi"
   }));
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
@@ -24,17 +22,16 @@ function test() {
 
 function install_ended(install, addon) {
   install.cancel();
 }
 
 function finish_test(count) {
   is(count, 1, "1 Add-on should have been successfully installed");
 
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
+  Services.cookies.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR,
+    false, {});
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
   gBrowser.removeCurrentTab();
   Harness.finish();
 }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies3.js
@@ -2,20 +2,18 @@
 // Test that an install that requires cookies to be sent succeeds when cookies
 // are set and third party cookies are disabled.
 // This verifies bug 462739
 function test() {
   Harness.installEndedCallback = install_ended;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
-         false, true, (Date.now() / 1000) + 60, {});
+  Services.cookies.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall",
+    "true", false, false, true, (Date.now() / 1000) + 60, {});
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi"
@@ -26,19 +24,18 @@ function test() {
 
 function install_ended(install, addon) {
   install.cancel();
 }
 
 function finish_test(count) {
   is(count, 1, "1 Add-on should have been successfully installed");
 
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
+  Services.cookies.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR,
+    false, {});
 
   Services.prefs.clearUserPref("network.cookie.cookieBehavior");
 
   Services.perms.remove(makeURI("http://example.com"), "install");
 
   gBrowser.removeCurrentTab();
   Harness.finish();
 }
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.js
@@ -3,20 +3,18 @@
 // are set and third party cookies are disabled and the request is to a third
 // party.
 // This verifies bug 462739
 function test() {
   Harness.downloadFailedCallback = download_failed;
   Harness.installsCompletedCallback = finish_test;
   Harness.setup();
 
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.add("example.org", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
-         false, true, (Date.now() / 1000) + 60, {});
+  Services.cookies.add("example.org", "/browser/" + RELATIVE_DIR, "xpinstall",
+    "true", false, false, true, (Date.now() / 1000) + 60, {});
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
   Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
 
   var triggers = encodeURIComponent(JSON.stringify({
     "Cookie check": TESTROOT2 + "cookieRedirect.sjs?" + TESTROOT + "amosigned.xpi"
@@ -26,18 +24,18 @@ function test() {
 }
 
 function download_failed(install) {
   is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should fail");
 }
 
 function finish_test(count) {
   is(count, 0, "No add-ons should have been installed");
-  var cm = Components.classes["@mozilla.org/cookiemanager;1"]
-                     .getService(Components.interfaces.nsICookieManager);
-  cm.remove("example.org", "xpinstall", "/browser/" + RELATIVE_DIR, false, {});
+
+  Services.cookies.remove("example.org", "xpinstall", "/browser/" + RELATIVE_DIR,
+    false, {});
 
   Services.prefs.clearUserPref("network.cookie.cookieBehavior");
   Services.perms.remove(makeURI("http://example.com"), "install");
 
   gBrowser.removeCurrentTab();
   Harness.finish();
 }