Bug 1501932 - Enable ESLint for modules/ (manual changes). r=aklotz,njn
authorYa'ar Hever <yhever@gmail.com>
Thu, 21 Feb 2019 00:50:18 +0000
changeset 460243 f473b0c9b01a17a6cc1f371892fa7be49242483d
parent 460242 dc657cbebdaee8927e3d0980e808b28030560321
child 460244 a671f97c000602a78429fc1b4fbbf4b8bc5ce44b
push id112070
push usernbeleuzu@mozilla.com
push dateThu, 21 Feb 2019 16:13:01 +0000
treeherdermozilla-inbound@9c0bb955c19d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, njn
bugs1501932
milestone67.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 1501932 - Enable ESLint for modules/ (manual changes). r=aklotz,njn Differential Revision: https://phabricator.services.mozilla.com/D14647
.eslintignore
modules/libjar/test/mochitest/test_bug1173171.html
modules/libjar/test/unit/test_bug1328865.js
modules/libjar/test/unit/test_bug278262.js
modules/libjar/test/unit/test_bug370103.js
modules/libjar/test/unit/test_bug589292.js
modules/libjar/test/unit/test_bug597702.js
modules/libjar/test/unit/test_bug637286.js
modules/libjar/test/unit/test_bug658093.js
modules/libjar/test/unit/test_corrupt_1211262.js
modules/libjar/test/unit/test_crx.js
modules/libjar/test/unit/test_jarchannel.js
modules/libjar/test/unit/test_jarinput_stream_zipreader_reference.js
modules/libjar/test/unit/test_not_found.js
modules/libjar/test/unit/test_umlaute.js
modules/libjar/zipwriter/test/unit/head_zipwriter.js
modules/libjar/zipwriter/test/unit/test_alignment.js
modules/libjar/zipwriter/test/unit/test_bug419769_1.js
modules/libjar/zipwriter/test/unit/test_bug433248.js
modules/libjar/zipwriter/test/unit/test_bug717061.js
modules/libjar/zipwriter/test/unit/test_deflatedata.js
modules/libjar/zipwriter/test/unit/test_editexisting.js
modules/libjar/zipwriter/test/unit/test_storedata.js
modules/libjar/zipwriter/test/unit/test_sync.js
modules/libjar/zipwriter/test/unit/test_undochange.js
modules/libpref/test/unit/head_libPrefs.js
modules/libpref/test/unit/test_bug1354613.js
modules/libpref/test/unit/test_bug345529.js
modules/libpref/test/unit/test_bug506224.js
modules/libpref/test/unit/test_bug577950.js
modules/libpref/test/unit/test_bug790374.js
modules/libpref/test/unit/test_changeType.js
modules/libpref/test/unit/test_defaultValues.js
modules/libpref/test/unit/test_dirtyPrefs.js
modules/libpref/test/unit/test_libPrefs.js
modules/libpref/test/unit/test_locked_file_prefs.js
modules/libpref/test/unit/test_parser.js
modules/libpref/test/unit/test_stickyprefs.js
modules/libpref/test/unit/test_warnings.js
modules/libpref/test/unit_ipc/test_existing_prefs.js
modules/libpref/test/unit_ipc/test_initial_prefs.js
modules/libpref/test/unit_ipc/test_large_pref.js
modules/libpref/test/unit_ipc/test_locked_prefs.js
modules/libpref/test/unit_ipc/test_observed_prefs.js
modules/libpref/test/unit_ipc/test_sharedMap.js
modules/libpref/test/unit_ipc/test_sharedMap_var_caches.js
modules/libpref/test/unit_ipc/test_update_prefs.js
modules/libpref/test/unit_ipc/test_user_default_prefs.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -17,17 +17,16 @@ obj*/**
 docshell/test/browser/**
 docshell/test/iframesandbox/**
 docshell/test/mochitest/**
 extensions/cookie/**
 extensions/spellcheck/**
 extensions/universalchardet/**
 image/**
 layout/**
-modules/**
 netwerk/cookie/test/browser/**
 netwerk/test/browser/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 tools/update-packaging/**
 uriloader/exthandler/**
 uriloader/exthandler/tests/mochitest/**
 xpfe/**
--- a/modules/libjar/test/mochitest/test_bug1173171.html
+++ b/modules/libjar/test/mochitest/test_bug1173171.html
@@ -18,34 +18,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 1173171 **/
 
 // __xhr(method, url, responseType__.
 // A simple async XMLHttpRequest call.
 // Returns a promise with the response.
 let xhr = function(method, url, responseType) {
   return new Promise(function(resolve, reject) {
-    let xhr = new XMLHttpRequest();
-    xhr.open(method, url, true);
-    xhr.onload = function() {
-      resolve(xhr.response);
+    let xhrInstance = new XMLHttpRequest();
+    xhrInstance.open(method, url, true);
+    xhrInstance.onload = function() {
+      resolve(xhrInstance.response);
     };
-    xhr.onerror = function() {
+    xhrInstance.onerror = function() {
       resolve(null);
     };
-    xhr.responseType = responseType;
-    xhr.send();
+    xhrInstance.responseType = responseType;
+    xhrInstance.send();
   });
 };
 
 let jarURL = "jar:http://mochi.test:8888/tests/modules/libjar/test/mochitest/bug403331.zip!/test.html";
 
 // Test behavior when blocking is deactivated and activated.
 add_task(async function() {
-  let shouldBlock = true;
   let response = await xhr("GET", jarURL, "document");
   is(response, null, "Remote jars should be blocked.");
 });
 
 </script>
 </pre>
 
 </body>
--- a/modules/libjar/test/unit/test_bug1328865.js
+++ b/modules/libjar/test/unit/test_bug1328865.js
@@ -1,45 +1,40 @@
 /* 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/. */
 
 "use strict";
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 // Check that reading non existant inner jars results in the right error
 
 add_task(async function() {
   var file = do_get_file("data/test_bug597702.zip");
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
+  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
   var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello#!/ignore%20this%20part";
   var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
   var instr = goodChannel.open();
 
   ok(!!instr, "Should be able to open channel");
 });
 
 add_task(async function() {
   var file = do_get_file("data/test_bug597702.zip");
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
+  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
   var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore%20this%20part!/";
   var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
   var instr = goodChannel.open();
 
   ok(!!instr, "Should be able to open channel");
 });
 
 add_task(async function() {
   var file = do_get_file("data/test_bug597702.zip");
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
+  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
   var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello?ignore#this!/part";
   var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
   var instr = goodChannel.open();
 
   ok(!!instr, "Should be able to open channel");
 });
--- a/modules/libjar/test/unit/test_bug278262.js
+++ b/modules/libjar/test/unit/test_bug278262.js
@@ -1,31 +1,29 @@
 // Regression test for bug 278262 - JAR URIs should resolve relative URIs in the base section.
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 const path = "data/test_bug333423.zip";
 
 function test_relative_sub() {
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-
+  var ios = Services.io;
   var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
   var base = ios.newURI(spec);
   var uri = ios.newURI("../modules/libjar", null, base);
 
   // This is the URI we expect to see.
   var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
     "!/modules/libjar";
 
   Assert.equal(uri.spec, expected);
 }
 
 function test_relative_base() {
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-
+  var ios = Services.io;
   var base = ios.newFileURI(do_get_file("data/empty"));
   var uri = ios.newURI("jar:../" + path + "!/", null, base);
 
   // This is the URI we expect to see.
   var expected = "jar:" + ios.newFileURI(do_get_file(path)).spec +
     "!/";
 
   Assert.equal(uri.spec, expected);
--- a/modules/libjar/test/unit/test_bug370103.js
+++ b/modules/libjar/test/unit/test_bug370103.js
@@ -1,18 +1,17 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 // Regression test for bug 370103 - crash when passing a null listener to
 // nsIChannel.asyncOpen
 function run_test() {
   // Compose the jar: url
-  var ioService = Cc["@mozilla.org/network/io-service;1"].
-                    getService(Ci.nsIIOService);
   var file = do_get_file("data/test_bug370103.jar");
-  var url = ioService.newFileURI(file).spec;
+  var url = Services.io.newFileURI(file).spec;
   url = "jar:" + url + "!/test_bug370103";
 
   // Try opening channel with null listener
   var channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
 
   var exception = false;
   try {
     channel.asyncOpen(null);
--- a/modules/libjar/test/unit/test_bug589292.js
+++ b/modules/libjar/test/unit/test_bug589292.js
@@ -1,22 +1,20 @@
 // Make sure we behave appropriately when asking for content-disposition
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 const path = "data/test_bug589292.zip";
 
 function run_test() {
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/foo.txt";
+  var spec = "jar:" + Services.io.newFileURI(do_get_file(path)).spec + "!/foo.txt";
   var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
-  instr = channel.open();
-  var val;
+  channel.open();
   try {
-    val = channel.contentDisposition;
+    channel.contentDisposition;
     Assert.ok(false, "The channel has content disposition?!");
   } catch (e) {
     // This is what we want to happen - there's no underlying channel, so no
     // content-disposition header is available
     Assert.ok(true, "How are you reading this?!");
   }
 }
--- a/modules/libjar/test/unit/test_bug597702.js
+++ b/modules/libjar/test/unit/test_bug597702.js
@@ -1,32 +1,30 @@
 /* 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 {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 // Check that reading non existant inner jars results in the right error
 
 function run_test() {
   var file = do_get_file("data/test_bug597702.zip");
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
+  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
   var goodSpec = "jar:" + outerJarBase + "inner.jar!/hello";
   var badSpec = "jar:" + outerJarBase + "jar_that_isnt_in_the.jar!/hello";
   var goodChannel = NetUtil.newChannel({uri: goodSpec, loadUsingSystemPrincipal: true});
   var badChannel = NetUtil.newChannel({uri: badSpec, loadUsingSystemPrincipal: true});
 
   try {
-    instr = goodChannel.open();
+    goodChannel.open();
   } catch (e) {
     do_throw("Failed to open file in inner jar");
   }
 
   try {
-    instr = badChannel.open();
+    badChannel.open();
     do_throw("Failed to report that file doesn't exist");
   } catch (e) {
     Assert.ok(e.name == "NS_ERROR_FILE_NOT_FOUND");
   }
 }
-
--- a/modules/libjar/test/unit/test_bug637286.js
+++ b/modules/libjar/test/unit/test_bug637286.js
@@ -1,26 +1,24 @@
 /* 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 {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 // Check that the zip cache can expire entries from nested jars
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 
 function open_inner_zip(base, idx) {
-    var spec = "jar:" + base + "inner" + idx + ".zip!/foo";
-    var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
-    var stream = channel.open();
+  var spec = "jar:" + base + "inner" + idx + ".zip!/foo";
+  var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
+  channel.open();
 }
 
 function run_test() {
   var file = do_get_file("data/test_bug637286.zip");
-  var outerJarBase = "jar:" + ios.newFileURI(file).spec + "!/";
+  var outerJarBase = "jar:" + Services.io.newFileURI(file).spec + "!/";
 
   for (var i = 0; i < 40; i++) {
     open_inner_zip(outerJarBase, i);
     gc();
   }
 }
-
--- a/modules/libjar/test/unit/test_bug658093.js
+++ b/modules/libjar/test/unit/test_bug658093.js
@@ -1,22 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 // Check that we don't crash on reading a directory entry signature
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
 
 function run_test() {
   var file = do_get_file("data/test_bug658093.zip");
-  var spec = "jar:" + ios.newFileURI(file).spec + "!/0000";
+  var spec = "jar:" + Services.io.newFileURI(file).spec + "!/0000";
   var channel = NetUtil.newChannel({uri: spec, loadUsingSystemPrincipal: true});
   var failed = false;
   try {
-    var stream = channel.open();
+    channel.open();
   } catch (e) {
     failed = true;
   }
   Assert.ok(failed);
 }
--- a/modules/libjar/test/unit/test_corrupt_1211262.js
+++ b/modules/libjar/test/unit/test_corrupt_1211262.js
@@ -3,25 +3,25 @@
  */
 
 // Regression test ensuring that that a STORED entry with differing compressed
 // and uncompressed sizes is considered to be corrupt.
 function run_test() {
   var file = do_get_file("data/test_corrupt3.zip");
 
   var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
-                  createInstance(Ci.nsIZipReader);
+    createInstance(Ci.nsIZipReader);
   zipreader.open(file);
 
   var failed = false;
   for (let entryPath of zipreader.findEntries("*")) {
     let entry = zipreader.getEntry(entryPath);
     if (!entry.isDirectory) {
       try {
-        let inputStream = zipreader.getInputStream(entryPath);
+        zipreader.getInputStream(entryPath);
       } catch (e) {
         failed = true;
       }
     }
   }
 
   Assert.ok(failed);
 }
--- a/modules/libjar/test/unit/test_crx.js
+++ b/modules/libjar/test/unit/test_crx.js
@@ -14,25 +14,25 @@ function wrapInputStream(input) {
 
 // Make sure that we can read from CRX files as if they were ZIP files.
 function run_test() {
   // Note: test_crx_dummy.crx is a dummy crx file created for this test. The
   // public key and signature fields in the header are both empty.
   let file = do_get_file("data/test_crx_dummy.crx");
 
   let zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
-                  createInstance(Ci.nsIZipReader);
+    createInstance(Ci.nsIZipReader);
   zipreader.open(file);
   // do crc stuff
   function check_archive_crc() {
     zipreader.test(null);
     return true;
   }
   Assert.ok(check_archive_crc());
-  let entries = zipreader.findEntries(null);
+  zipreader.findEntries(null);
   let stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"));
   let dirstream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/"));
   zipreader.close();
   zipreader = null;
   Cu.forceGC();
   Assert.ok(stream.read(1024).length > 0);
   Assert.ok(dirstream.read(100).length > 0);
 }
--- a/modules/libjar/test/unit/test_jarchannel.js
+++ b/modules/libjar/test/unit/test_jarchannel.js
@@ -2,31 +2,24 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 /**
  * Tests some basic jar channel functionality
  */
 
 
-const {classes: Cc,
-       interfaces: Ci,
-       results: Cr,
-       utils: Cu,
-       Constructor: ctor,
-       } = Components;
+const {Constructor: ctor} = Components;
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
-const ios = Cc["@mozilla.org/network/io-service;1"].
-                getService(Ci.nsIIOService);
-const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
-                getService(Ci.nsIProperties);
-const obs = Cc["@mozilla.org/observer-service;1"].
-                getService(Ci.nsIObserverService);
+const ios = Services.io;
+const dirSvc = Services.dirsvc;
+const obs = Services.obs;
 
 const nsIBinaryInputStream = ctor("@mozilla.org/binaryinputstream;1",
                                "nsIBinaryInputStream",
                                "setInputStream"
                                );
 
 const fileBase = "test_bug637286.zip";
 const file = do_get_file("data/" + fileBase);
@@ -83,23 +76,23 @@ function testAsync() {
 add_test(testAsync);
 // Run same test again so we test the codepath for a zipcache hit
 add_test(testAsync);
 
 /**
  * Basic test for nsIZipReader.
  */
 function testZipEntry() {
-    var uri = jarBase + "/inner40.zip";
-    var chan = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true})
-                      .QueryInterface(Ci.nsIJARChannel);
-    var entry = chan.zipEntry;
-    Assert.ok(entry.CRC32 == 0x8b635486);
-    Assert.ok(entry.realSize == 184);
-    run_next_test();
+  var uri = jarBase + "/inner40.zip";
+  var chan = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true})
+    .QueryInterface(Ci.nsIJARChannel);
+  var entry = chan.zipEntry;
+  Assert.ok(entry.CRC32 == 0x8b635486);
+  Assert.ok(entry.realSize == 184);
+  run_next_test();
 }
 
 add_test(testZipEntry);
 
 
 /**
  * Basic reading test for synchronously opened jar channels
  */
--- a/modules/libjar/test/unit/test_jarinput_stream_zipreader_reference.js
+++ b/modules/libjar/test/unit/test_jarinput_stream_zipreader_reference.js
@@ -13,25 +13,25 @@ function wrapInputStream(input) {
 }
 
 // Check that files can be read from after closing zipreader
 function run_test() {
   // the build script have created the zip we can test on in the current dir.
   var file = do_get_file("data/test_bug333423.zip");
 
   var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
-                  createInstance(Ci.nsIZipReader);
+    createInstance(Ci.nsIZipReader);
   zipreader.open(file);
   // do crc stuff
   function check_archive_crc() {
     zipreader.test(null);
     return true;
   }
   Assert.ok(check_archive_crc());
-  var entries = zipreader.findEntries(null);
+  zipreader.findEntries(null);
   var stream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/Makefile.in"));
   var dirstream = wrapInputStream(zipreader.getInputStream("modules/libjar/test/"));
   zipreader.close();
   zipreader = null;
   Cu.forceGC();
   Assert.ok(stream.read(1024).length > 0);
   Assert.ok(dirstream.read(100).length > 0);
 }
--- a/modules/libjar/test/unit/test_not_found.js
+++ b/modules/libjar/test/unit/test_not_found.js
@@ -1,20 +1,19 @@
 // Should report file not found on non-existent files
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 const path = "data/test_bug333423.zip";
 
 function run_test() {
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var spec = "jar:" + ios.newFileURI(do_get_file(path)).spec + "!/";
+  var spec = "jar:" + Services.io.newFileURI(do_get_file(path)).spec + "!/";
   var channel = NetUtil.newChannel({
     uri: spec + "file_that_isnt_in.archive",
     loadUsingSystemPrincipal: true,
   });
   try {
-    instr = channel.open();
+    channel.open();
     do_throw("Failed to report that file doesn't exist");
   } catch (e) {
       Assert.ok(e.name == "NS_ERROR_FILE_NOT_FOUND");
   }
 }
--- a/modules/libjar/test/unit/test_umlaute.js
+++ b/modules/libjar/test/unit/test_umlaute.js
@@ -1,12 +1,12 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function run_test() {
-  var dirService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-  var tmpDir = dirService.get("TmpD", Ci.nsIFile);
+  var tmpDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
 
   var zipfile = do_get_file("data/test_umlaute.zip");
 
   var testFile = tmpDir.clone();
   testFile.append("test_\u00FC.txt");
   if (testFile.exists()) {
     testFile.remove(false);
   }
--- a/modules/libjar/zipwriter/test/unit/head_zipwriter.js
+++ b/modules/libjar/zipwriter/test/unit/head_zipwriter.js
@@ -22,23 +22,23 @@ const ZIP_METHOD_DEFLATE = 8;
 const ZIP_EXTENDED_TIMESTAMP_SIZE = 9;
 
 const PR_USEC_PER_MSEC = 1000;
 const PR_USEC_PER_SEC  = 1000000;
 const PR_MSEC_PER_SEC  = 1000;
 
 const DATA_DIR = "data/";
 
-var ioSvc = Cc["@mozilla.org/network/io-service;1"]
-             .getService(Ci.nsIIOService);
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var ioSvc = Services.io;
 
 var ZipWriter = Components.Constructor("@mozilla.org/zipwriter;1",
-                                       "nsIZipWriter");
+  "nsIZipWriter");
 var ZipReader = Components.Constructor("@mozilla.org/libjar/zip-reader;1",
-                                       "nsIZipReader", "open");
+  "nsIZipReader", "open");
 
 var tmpDir = do_get_profile();
 var tmpFile = tmpDir.clone();
 tmpFile.append("zipwriter-test.zip");
 if (tmpFile.exists())
   tmpFile.remove(true);
 
 var zipW = new ZipWriter();
--- a/modules/libjar/zipwriter/test/unit/test_alignment.js
+++ b/modules/libjar/zipwriter/test/unit/test_alignment.js
@@ -16,87 +16,87 @@ var TESTS = [
   {
     name: "test.png",
     compression: Ci.nsIZipWriter.COMPRESSION_NONE,
   },
 ];
 
 function swap16(n) {
   return (((n >> 8) & 0xFF) << 0) |
-         (((n >> 0) & 0xFF) << 8);
+    (((n >> 0) & 0xFF) << 8);
 }
 
 function swap32(n) {
   return (((n >> 24) & 0xFF) << 0) |
-         (((n >> 16) & 0xFF) << 8) |
-         (((n >> 8) & 0xFF) << 16) |
-         (((n >> 0) & 0xFF) << 24);
+    (((n >> 16) & 0xFF) << 8) |
+    (((n >> 8) & 0xFF) << 16) |
+    (((n >> 0) & 0xFF) << 24);
 }
 
 function move_to_data(bis, offset) {
   bis.readBytes(18); // Move to compressed size
   var size = swap32(bis.read32());
   bis.readBytes(4);
   var file_len = swap16(bis.read16());
   var extra_len = swap16(bis.read16());
-  var file = bis.readBytes(file_len);
+  bis.readBytes(file_len);
   bis.readBytes(extra_len);
   offset += ZIP_FILE_HEADER_SIZE + file_len + extra_len;
 
   return {offset, size};
 }
 
 function test_alignment(align_size) {
   // Create zip for testing.
   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
   for (var i = 0; i < TESTS.length; i++) {
     var source = do_get_file(DATA_DIR + TESTS[i].name);
     zipW.addEntryFile(TESTS[i].name, TESTS[i].compression, source, false);
   }
   var stream = Cc["@mozilla.org/io/string-input-stream;1"]
-                .createInstance(Ci.nsIStringInputStream);
+    .createInstance(Ci.nsIStringInputStream);
   stream.setData(DATA, DATA.length);
   zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
-                      Ci.nsIZipWriter.COMPRESSION_NONE, stream, false);
+    Ci.nsIZipWriter.COMPRESSION_NONE, stream, false);
   zipW.alignStoredFiles(align_size);
   zipW.close();
 
   // Check data can be decompressed.
   var zipR = new ZipReader(tmpFile);
-  var stream = Cc["@mozilla.org/scriptableinputstream;1"]
-                .createInstance(Ci.nsIScriptableInputStream);
+  stream = Cc["@mozilla.org/scriptableinputstream;1"]
+    .createInstance(Ci.nsIScriptableInputStream);
   stream.init(zipR.getInputStream(FILENAME));
   var result = stream.read(DATA.length);
   Assert.equal(result, DATA);
   stream.close();
   zipR.close();
 
   // Check data is correct and aligned.
   var fis = Cc["@mozilla.org/network/file-input-stream;1"]
-                 .createInstance(Ci.nsIFileInputStream);
+    .createInstance(Ci.nsIFileInputStream);
   fis.init(tmpFile, -1, -1, null);
   let bis = Cc["@mozilla.org/binaryinputstream;1"]
-              .createInstance(Ci.nsIBinaryInputStream);
+    .createInstance(Ci.nsIBinaryInputStream);
   bis.setInputStream(fis);
   var offset = 0;
 
   var ret = move_to_data(bis, offset); // "test.txt"
   offset = ret.offset;
   bis.readBytes(ret.size);
   offset += ret.size;
 
   ret = move_to_data(bis, offset); // "test.png"
   offset = ret.offset;
   Assert.equal(offset % align_size, 0);
   bis.readBytes(ret.size);
   offset += ret.size;
 
   ret = move_to_data(bis, offset); // "test_data.txt"
   offset = ret.offset;
-  var result = bis.readBytes(DATA.length);
+  result = bis.readBytes(DATA.length);
   Assert.equal(result, DATA);
   Assert.equal(offset % align_size, 0);
 
   fis.close();
   bis.close();
 }
 
 function run_test() {
--- a/modules/libjar/zipwriter/test/unit/test_bug419769_1.js
+++ b/modules/libjar/zipwriter/test/unit/test_bug419769_1.js
@@ -34,35 +34,35 @@ function run_test() {
   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
 
   // Shouldn't be there to start with.
   Assert.ok(!zipW.hasEntry(FILENAME));
 
   Assert.ok(!zipW.inQueue);
 
   var stream = Cc["@mozilla.org/io/string-input-stream;1"]
-                .createInstance(Ci.nsIStringInputStream);
+    .createInstance(Ci.nsIStringInputStream);
   stream.setData(DATA, DATA.length);
   zipW.addEntryStream(FILENAME, time * PR_USEC_PER_MSEC,
-                      Ci.nsIZipWriter.COMPRESSION_BEST, stream, false);
+    Ci.nsIZipWriter.COMPRESSION_BEST, stream, false);
 
   // Check that zip state is right at this stage.
   testpass(zipW);
   zipW.close();
 
   // Check to see if we get the same results loading afresh.
   zipW.open(tmpFile, PR_RDWR);
   testpass(zipW);
   zipW.close();
 
   // Test the stored data with the zipreader
   var zipR = new ZipReader(tmpFile);
   testpass(zipR);
   zipR.test(FILENAME);
-  var stream = Cc["@mozilla.org/scriptableinputstream;1"]
-                .createInstance(Ci.nsIScriptableInputStream);
+  stream = Cc["@mozilla.org/scriptableinputstream;1"]
+    .createInstance(Ci.nsIScriptableInputStream);
   stream.init(zipR.getInputStream(FILENAME));
   var result = stream.read(DATA.length);
   stream.close();
   zipR.close();
 
   Assert.equal(result, DATA);
 }
--- a/modules/libjar/zipwriter/test/unit/test_bug433248.js
+++ b/modules/libjar/zipwriter/test/unit/test_bug433248.js
@@ -1,25 +1,24 @@
 /* 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/.
  */
 
 function run_test() {
-  var test;
   // zipW is an uninitialised zipwriter at this point.
   try {
-    test = zipW.file;
+    zipW.file;
     do_throw("Should have thrown uninitialized error.");
   } catch (e) {
     Assert.equal(e.result, Cr.NS_ERROR_NOT_INITIALIZED);
   }
 
   try {
-    test = zipW.comment;
+    zipW.comment;
     do_throw("Should have thrown uninitialized error.");
   } catch (e) {
     Assert.equal(e.result, Cr.NS_ERROR_NOT_INITIALIZED);
   }
 
   try {
     zipW.comment = "test";
     do_throw("Should have thrown uninitialized error.");
--- a/modules/libjar/zipwriter/test/unit/test_bug717061.js
+++ b/modules/libjar/zipwriter/test/unit/test_bug717061.js
@@ -1,19 +1,19 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0
  */
 
 function BinaryComparer(file, callback) {
   var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
-                createInstance(Ci.nsIFileInputStream);
+    createInstance(Ci.nsIFileInputStream);
   fstream.init(file, -1, 0, 0);
   this.length = file.fileSize;
   this.fileStream = Cc["@mozilla.org/binaryinputstream;1"].
-                    createInstance(Ci.nsIBinaryInputStream);
+    createInstance(Ci.nsIBinaryInputStream);
   this.fileStream.setInputStream(fstream);
   this.offset = 0;
   this.callback = callback;
 }
 
 BinaryComparer.prototype = {
   fileStream: null,
   offset: null,
@@ -27,62 +27,63 @@ BinaryComparer.prototype = {
     this.fileStream.close();
     Assert.equal(aStatusCode, Cr.NS_OK);
     Assert.equal(this.offset, this.length);
     this.callback();
   },
 
   onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
     var stream = Cc["@mozilla.org/binaryinputstream;1"].
-                 createInstance(Ci.nsIBinaryInputStream);
+      createInstance(Ci.nsIBinaryInputStream);
     stream.setInputStream(aInputStream);
     var source, actual;
     for (var i = 0; i < aCount; i++) {
       try {
         source = this.fileStream.read8();
       } catch (e) {
         do_throw("Unable to read from file at offset " + this.offset + " " + e);
       }
       try {
         actual = stream.read8();
       } catch (e) {
-        do_throw("Unable to read from converted stream at offset " + this.offset + " " + e);
+        do_throw("Unable to read from converted stream at offset " +
+          this.offset + " " + e);
       }
       // The byte at offset 9 is the OS byte (see RFC 1952, section 2.3), which
       // can legitimately differ when the source is compressed on different
       // operating systems.  The actual .gz for this test was created on a Unix
       // system, but we want the test to work correctly everywhere.  So ignore
       // the byte at offset 9.
-      if (this.offset == 9)
-	;
-      else if (source != actual)
-        do_throw("Invalid value " + actual + " at offset " + this.offset + ", should have been " + source);
+      if (this.offset != 9 && source != actual) {
+        do_throw("Invalid value " + actual + " at offset " +
+          this.offset + ", should have been " + source);
+      }
       this.offset++;
     }
   },
 };
 
 function comparer_callback() {
   do_test_finished();
 }
 
 function run_test() {
   var source = do_get_file(DATA_DIR + "test_bug717061.html");
   var comparer = new BinaryComparer(do_get_file(DATA_DIR + "test_bug717061.gz"),
-                                    comparer_callback);
+    comparer_callback);
 
   // Prepare the stream converter
   var scs = Cc["@mozilla.org/streamConverters;1"].
-            getService(Ci.nsIStreamConverterService);
+    getService(Ci.nsIStreamConverterService);
   var converter = scs.asyncConvertData("uncompressed", "gzip", comparer, null);
 
   // Open the expected output file
   var fstream = Cc["@mozilla.org/network/file-input-stream;1"].
-                createInstance(Ci.nsIFileInputStream);
+    createInstance(Ci.nsIFileInputStream);
   fstream.init(source, -1, 0, 0);
 
   // Set up a pump to push data from the file to the stream converter
   var pump = Cc["@mozilla.org/network/input-stream-pump;1"].
-             createInstance(Ci.nsIInputStreamPump);
+    createInstance(Ci.nsIInputStreamPump);
   pump.init(fstream, 0, 0, true);
   pump.asyncRead(converter, null);
   do_test_pending();
 }
--- a/modules/libjar/zipwriter/test/unit/test_deflatedata.js
+++ b/modules/libjar/zipwriter/test/unit/test_deflatedata.js
@@ -36,17 +36,17 @@ function run_test() {
   zipW.close();
 
   // Test the stored data with the zipreader
   var zipR = new ZipReader(tmpFile);
   Assert.ok(zipR.hasEntry(FILENAME));
 
   zipR.test(FILENAME);
 
-  var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+  stream = Cc["@mozilla.org/scriptableinputstream;1"]
                 .createInstance(Ci.nsIScriptableInputStream);
   stream.init(zipR.getInputStream(FILENAME));
   var result = stream.read(DATA.length);
   stream.close();
   zipR.close();
 
   Assert.equal(result, DATA);
 }
--- a/modules/libjar/zipwriter/test/unit/test_editexisting.js
+++ b/modules/libjar/zipwriter/test/unit/test_editexisting.js
@@ -24,34 +24,34 @@ function run_test() {
   // Copy our test zip to the tmp dir so we can modify it
   var testzip = do_get_file(DATA_DIR + "test.zip");
   testzip.copyTo(tmpDir, tmpFile.leafName);
 
   Assert.ok(tmpFile.exists());
 
   zipW.open(tmpFile, PR_RDWR);
 
-  for (var i = 0; i < TESTS.length; i++) {
+  for (let i = 0; i < TESTS.length; i++) {
     Assert.ok(zipW.hasEntry(TESTS[i].name));
     var entry = zipW.getEntry(TESTS[i].name);
     Assert.ok(entry != null);
 
     Assert.equal(entry.realSize, TESTS[i].size);
     Assert.equal(entry.CRC32, TESTS[i].crc);
     Assert.equal(entry.lastModifiedTime / PR_USEC_PER_MSEC, TESTS[i].time);
   }
 
   try {
     zipW.removeEntry(BADENTRY, false);
     do_throw("shouldn't be able to remove an entry that doesn't exist");
   } catch (e) {
     Assert.equal(e.result, Cr.NS_ERROR_FILE_NOT_FOUND);
   }
 
-  for (var i = 0; i < TESTS.length; i++) {
+  for (let i = 0; i < TESTS.length; i++) {
     zipW.removeEntry(TESTS[i].name, false);
   }
 
   zipW.close();
 
   // Certain platforms cache the file size so get a fresh file to check.
   tmpFile = tmpFile.clone();
 
--- a/modules/libjar/zipwriter/test/unit/test_storedata.js
+++ b/modules/libjar/zipwriter/test/unit/test_storedata.js
@@ -60,17 +60,17 @@ function run_test() {
   zipW.open(tmpFile, PR_RDWR);
   testpass(zipW);
   zipW.close();
 
   // Test the stored data with the zipreader
   var zipR = new ZipReader(tmpFile);
   testpass(zipR);
   zipR.test(FILENAME);
-  var stream = Cc["@mozilla.org/scriptableinputstream;1"]
+  stream = Cc["@mozilla.org/scriptableinputstream;1"]
                 .createInstance(Ci.nsIScriptableInputStream);
   stream.init(zipR.getInputStream(FILENAME));
   var result = stream.read(DATA.length);
   stream.close();
   zipR.close();
 
   Assert.equal(result, DATA);
 }
--- a/modules/libjar/zipwriter/test/unit/test_sync.js
+++ b/modules/libjar/zipwriter/test/unit/test_sync.js
@@ -16,35 +16,35 @@ var TESTS = [
     crc: 0x504a5c30,
   },
 ];
 
 function run_test() {
   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
 
   var size = 0;
-  for (var i = 0; i < TESTS.length; i++) {
-    var source = do_get_file(DATA_DIR + TESTS[i].name);
+  for (let i = 0; i < TESTS.length; i++) {
+    let source = do_get_file(DATA_DIR + TESTS[i].name);
     zipW.addEntryFile(TESTS[i].name, Ci.nsIZipWriter.COMPRESSION_NONE, source,
                       false);
     size += ZIP_FILE_HEADER_SIZE + ZIP_CDS_HEADER_SIZE +
             (ZIP_EXTENDED_TIMESTAMP_SIZE * 2) +
             (TESTS[i].name.length * 2) + TESTS[i].size;
   }
 
   zipW.close();
   size += ZIP_EOCDR_HEADER_SIZE;
 
   Assert.equal(size, tmpFile.fileSize);
 
   // Test the stored data with the zipreader
   var zipR = new ZipReader(tmpFile);
 
-  for (var i = 0; i < TESTS.length; i++) {
-    var source = do_get_file(DATA_DIR + TESTS[i].name);
+  for (let i = 0; i < TESTS.length; i++) {
+    let source = do_get_file(DATA_DIR + TESTS[i].name);
     Assert.ok(zipR.hasEntry(TESTS[i].name));
 
     var entry = zipR.getEntry(TESTS[i].name);
     Assert.equal(entry.realSize, TESTS[i].size);
     Assert.equal(entry.size, TESTS[i].size);
     Assert.equal(entry.CRC32, TESTS[i].crc);
     Assert.equal(Math.floor(entry.lastModifiedTime / PR_USEC_PER_SEC),
                  Math.floor(source.lastModifiedTime / PR_MSEC_PER_SEC));
--- a/modules/libjar/zipwriter/test/unit/test_undochange.js
+++ b/modules/libjar/zipwriter/test/unit/test_undochange.js
@@ -7,33 +7,33 @@
 var TESTS = [
   "test.txt",
   "test.png",
 ];
 
 function run_test() {
   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
 
-  for (var i = 0; i < TESTS.length; i++) {
-    var source = do_get_file(DATA_DIR + TESTS[i]);
+  for (let i = 0; i < TESTS.length; i++) {
+    let source = do_get_file(DATA_DIR + TESTS[i]);
     zipW.addEntryFile(TESTS[i], Ci.nsIZipWriter.COMPRESSION_NONE, source,
                       false);
   }
 
   try {
-    var source = do_get_file(DATA_DIR + TESTS[0]);
+    let source = do_get_file(DATA_DIR + TESTS[0]);
     zipW.addEntryFile(TESTS[0], Ci.nsIZipWriter.COMPRESSION_NONE, source,
                       false);
     do_throw("Should not be able to add the same file twice");
   } catch (e) {
     Assert.equal(e.result, Cr.NS_ERROR_FILE_ALREADY_EXISTS);
   }
 
   // Remove all the tests and see if we are left with an empty zip
-  for (var i = 0; i < TESTS.length; i++) {
+  for (let i = 0; i < TESTS.length; i++) {
     zipW.removeEntry(TESTS[i], false);
   }
 
   zipW.close();
 
   // Empty zip file should just be the end of central directory marker
   var newTmpFile = tmpFile.clone();
   Assert.equal(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
--- a/modules/libpref/test/unit/head_libPrefs.js
+++ b/modules/libpref/test/unit/head_libPrefs.js
@@ -12,21 +12,21 @@ function do_check_throws(f, result, stac
     f();
   } catch (exc) {
     equal(exc.result, result, "Correct exception was thrown");
     return;
   }
   ok(false, "expected result " + result + ", none thrown");
 }
 
-var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 // Register current test directory as provider for the profile directory.
 var provider = {
   getFile(prop, persistent) {
     persistent.value = true;
     if (prop == NS_APP_USER_PROFILE_50_DIR)
-      return dirSvc.get("CurProcD", Ci.nsIFile);
+      return Services.dirsvc.get("CurProcD", Ci.nsIFile);
     throw Components.Exception("Tried to get test directory '" + prop + "'", Cr.NS_ERROR_FAILURE);
   },
   QueryInterface: ChromeUtils.generateQI(["nsIDirectoryServiceProvider"]),
 };
-dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
+Services.dirsvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider);
--- a/modules/libpref/test/unit/test_bug1354613.js
+++ b/modules/libpref/test/unit/test_bug1354613.js
@@ -4,20 +4,18 @@
 function run_test() {
   const BRANCH = "foo.";
   const PREF_NAME = "testPref";
   const FULL_PREF_NAME = BRANCH + PREF_NAME;
 
   const FLOAT = 9.674;
   const FUDGE = 0.001;
 
-  let ps = Cc["@mozilla.org/preferences-service;1"]
-           .getService(Ci.nsIPrefService);
-  let prefs = ps.getDefaultBranch(null);
+  let prefs = Services.prefs.getDefaultBranch(null);
 
   /* Test with a non-default branch */
   prefs.setCharPref(FULL_PREF_NAME, FLOAT);
-  let pb = ps.getBranch(BRANCH);
+  let pb = Services.prefs.getBranch(BRANCH);
 
   let floatPref = pb.getFloatPref(PREF_NAME);
   Assert.ok(FLOAT + FUDGE >= floatPref);
   Assert.ok(FLOAT - FUDGE <= floatPref);
 }
--- a/modules/libpref/test/unit/test_bug345529.js
+++ b/modules/libpref/test/unit/test_bug345529.js
@@ -1,27 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
 // Regression test for bug 345529 - crash removing an observer during an
 // nsPref:changed notification.
 function run_test() {
   const PREF_NAME = "testPref";
 
-  var prefs = Cc["@mozilla.org/preferences-service;1"]
-              .getService(Ci.nsIPrefBranch);
   var observer = {
     QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
 
     observe: function observe(aSubject, aTopic, aState) {
-      prefs.removeObserver(PREF_NAME, observer);
+      Services.prefs.removeObserver(PREF_NAME, observer);
     },
   };
-  prefs.addObserver(PREF_NAME, observer);
+  Services.prefs.addObserver(PREF_NAME, observer);
 
-  prefs.setCharPref(PREF_NAME, "test0");
+  Services.prefs.setCharPref(PREF_NAME, "test0");
   // This second call isn't needed on a clean profile: it makes sure
   // the observer gets called even if the pref already had the value
   // "test0" before this test.
-  prefs.setCharPref(PREF_NAME, "test1");
+  Services.prefs.setCharPref(PREF_NAME, "test1");
 
   Assert.ok(true);
 }
--- a/modules/libpref/test/unit/test_bug506224.js
+++ b/modules/libpref/test/unit/test_bug506224.js
@@ -1,27 +1,25 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
 function run_test() {
   const PREF_NAME = "testPref";
 
-  var ps = Cc["@mozilla.org/preferences-service;1"]
-           .getService(Ci.nsIPrefService);
-  var prefs = ps.getDefaultBranch(null);
-  var userprefs = ps.getBranch(null);
+  var prefs = Services.prefs.getDefaultBranch(null);
+  var userprefs = Services.prefs.getBranch(null);
 
   prefs.setCharPref(PREF_NAME, "test0");
   prefs.lockPref(PREF_NAME);
   Assert.equal("test0", userprefs.getCharPref(PREF_NAME));
   Assert.equal(false, userprefs.prefHasUserValue(PREF_NAME));
 
   var file = do_get_profile();
   file.append("prefs.js");
-  ps.savePrefFile(file);
+  Services.prefs.savePrefFile(file);
 
   prefs.unlockPref(PREF_NAME);
   prefs.setCharPref(PREF_NAME, "test1");
-  ps.readUserPrefsFromFile(file);
+  Services.prefs.readUserPrefsFromFile(file);
 
   Assert.equal("test1", userprefs.getCharPref(PREF_NAME));
   Assert.equal(false, userprefs.prefHasUserValue(PREF_NAME));
 }
--- a/modules/libpref/test/unit/test_bug577950.js
+++ b/modules/libpref/test/unit/test_bug577950.js
@@ -1,23 +1,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/. */
 
 function run_test() {
-  var ps = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefService);
-
-  var pb = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
-
   var observer = {
     QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
 
     observe: function observe(aSubject, aTopic, aState) {
       // Don't do anything.
     },
   };
 
   /* Set the same pref twice.  This shouldn't leak. */
-  pb.addObserver("UserPref.nonexistent.setIntPref", observer);
-  pb.addObserver("UserPref.nonexistent.setIntPref", observer);
+  Services.prefs.addObserver("UserPref.nonexistent.setIntPref", observer);
+  Services.prefs.addObserver("UserPref.nonexistent.setIntPref", observer);
 }
--- a/modules/libpref/test/unit/test_bug790374.js
+++ b/modules/libpref/test/unit/test_bug790374.js
@@ -1,18 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
 function run_test() {
   const PREF_NAME = "testPref";
 
-  var ps = Cc["@mozilla.org/preferences-service;1"]
-           .getService(Ci.nsIPrefService);
-  var prefs = ps.getDefaultBranch(null);
-  var userprefs = ps.getBranch(null);
+  var prefs = Services.prefs.getDefaultBranch(null);
+  var userprefs = Services.prefs.getBranch(null);
 
   /* First, test to make sure we can parse a float from a string properly. */
   prefs.setCharPref(PREF_NAME, "9.674");
   prefs.lockPref(PREF_NAME);
   var myFloat = 9.674;
   var fudge = 0.001;
   var floatPref = userprefs.getFloatPref(PREF_NAME);
   Assert.ok(myFloat + fudge >= floatPref);
--- a/modules/libpref/test/unit/test_changeType.js
+++ b/modules/libpref/test/unit/test_changeType.js
@@ -5,18 +5,17 @@
 /* Tests for changing the type of a preference (bug 985998) */
 
 const PREF_INVALID = 0;
 const PREF_BOOL    = 128;
 const PREF_INT     = 64;
 const PREF_STRING  = 32;
 
 function run_test() {
-  var ps = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefService);
+  var ps = Services.prefs;
 
   let defaultBranch = ps.getDefaultBranch("");
   let userBranch = ps.getBranch("");
 
   // Prefs that only have a default value -- we can't change their type.
   defaultBranch.setBoolPref("TypeTest.default.bool", true);
   defaultBranch.setIntPref("TypeTest.default.int", 23);
   defaultBranch.setCharPref("TypeTest.default.char", "hey");
@@ -33,88 +32,88 @@ function run_test() {
 
   Assert.equal(userBranch.getBoolPref("TypeTest.user.bool"), false);
   Assert.equal(userBranch.getIntPref("TypeTest.user.int"), 24);
   Assert.equal(userBranch.getCharPref("TypeTest.user.char"), "hi");
 
   // Prefs that have both a default and a user value -- we can't change their
   // type.
   defaultBranch.setBoolPref("TypeTest.both.bool", true);
-     userBranch.setBoolPref("TypeTest.both.bool", false);
+  userBranch.setBoolPref("TypeTest.both.bool", false);
   defaultBranch.setIntPref("TypeTest.both.int", 25);
-     userBranch.setIntPref("TypeTest.both.int", 26);
+  userBranch.setIntPref("TypeTest.both.int", 26);
   defaultBranch.setCharPref("TypeTest.both.char", "yo");
-     userBranch.setCharPref("TypeTest.both.char", "ya");
+  userBranch.setCharPref("TypeTest.both.char", "ya");
 
   Assert.equal(userBranch.getBoolPref("TypeTest.both.bool"), false);
   Assert.equal(userBranch.getIntPref("TypeTest.both.int"), 26);
   Assert.equal(userBranch.getCharPref("TypeTest.both.char"), "ya");
 
   // We only have a default value, and we try to set a default value of a
   // different type --> fails.
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.default.bool", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.default.bool", 5);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.default.int", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.default.int", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.default.char", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.default.char", 6);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // We only have a default value, and we try to set a user value of a
   // different type --> fails.
   do_check_throws(function() {
     userBranch.setCharPref("TypeTest.default.bool", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setIntPref("TypeTest.default.bool", 5);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setCharPref("TypeTest.default.int", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setBoolPref("TypeTest.default.int", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setBoolPref("TypeTest.default.char", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setIntPref("TypeTest.default.char", 6);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // We only have a user value, and we try to set a default value of a
   // different type --> fails.
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.user.bool", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.user.bool", 5);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.user.int", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.user.int", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.user.char", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.user.char", 6);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // We only have a user value, and we try to set a user value of a
   // different type --> SUCCEEDS.
   userBranch.setCharPref("TypeTest.user.bool", "boo");
   Assert.equal(userBranch.getCharPref("TypeTest.user.bool"), "boo");
   userBranch.setIntPref("TypeTest.user.bool", 5);
   Assert.equal(userBranch.getIntPref("TypeTest.user.bool"), 5);
   userBranch.setCharPref("TypeTest.user.int", "boo");
@@ -125,46 +124,46 @@ function run_test() {
   Assert.equal(userBranch.getBoolPref("TypeTest.user.char"), true);
   userBranch.setIntPref("TypeTest.user.char", 6);
   Assert.equal(userBranch.getIntPref("TypeTest.user.char"), 6);
 
   // We have both a default value and user value, and we try to set a default
   // value of a different type --> fails.
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.both.bool", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.both.bool", 5);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setCharPref("TypeTest.both.int", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.both.int", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setBoolPref("TypeTest.both.char", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     defaultBranch.setIntPref("TypeTest.both.char", 6);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // We have both a default value and user value, and we try to set a user
   // value of a different type --> fails.
   do_check_throws(function() {
     userBranch.setCharPref("TypeTest.both.bool", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setIntPref("TypeTest.both.bool", 5);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setCharPref("TypeTest.both.int", "boo");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setBoolPref("TypeTest.both.int", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setBoolPref("TypeTest.both.char", true);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     userBranch.setIntPref("TypeTest.both.char", 6);
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 }
--- a/modules/libpref/test/unit/test_defaultValues.js
+++ b/modules/libpref/test/unit/test_defaultValues.js
@@ -1,19 +1,16 @@
 /* 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/. */
 
 /* Tests for providing a default value to get{Bool,Char,Float,Int}Pref */
 
 function run_test() {
-  var ps = Cc["@mozilla.org/preferences-service;1"]
-             .getService(Ci.nsIPrefService)
-             .QueryInterface(Ci.nsIPrefBranch);
-
+  const ps = Services.prefs;
   let prefName = "test.default.values.bool";
   do_check_throws(function() { ps.getBoolPref(prefName); },
                   Cr.NS_ERROR_UNEXPECTED);
   strictEqual(ps.getBoolPref(prefName, false), false);
   strictEqual(ps.getBoolPref(prefName, true), true);
   ps.setBoolPref(prefName, true);
   strictEqual(ps.getBoolPref(prefName), true);
   strictEqual(ps.getBoolPref(prefName, false), true);
--- a/modules/libpref/test/unit/test_dirtyPrefs.js
+++ b/modules/libpref/test/unit/test_dirtyPrefs.js
@@ -5,18 +5,17 @@
 /* Tests for handling of the preferences 'dirty' flag (bug 985998) */
 
 const PREF_INVALID = 0;
 const PREF_BOOL    = 128;
 const PREF_INT     = 64;
 const PREF_STRING  = 32;
 
 function run_test() {
-  var ps = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefService);
+  const ps = Services.prefs;
 
   let defaultBranch = ps.getDefaultBranch("");
   let userBranch = ps.getBranch("");
 
   let prefFile = do_get_profile();
   prefFile.append("prefs.js");
 
   //* *************************************************************************//
--- a/modules/libpref/test/unit/test_libPrefs.js
+++ b/modules/libpref/test/unit/test_libPrefs.js
@@ -13,204 +13,197 @@ function makeList(a) {
   var o = {};
   for (var i = 0; i < a.length; i++) {
     o[a[i]] = "";
   }
   return o;
 }
 
 function run_test() {
-  var ps = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefService);
-
-  var pb2 = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
-
-  var pb = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
+  const ps = Services.prefs;
 
   //* *************************************************************************//
   // Nullsafety
 
   do_check_throws(function() {
-    pb.getPrefType(null);
+    ps.getPrefType(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.getBoolPref(null);
+    ps.getBoolPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.setBoolPref(null, false);
+    ps.setBoolPref(null, false);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.getIntPref(null);
+    ps.getIntPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.setIntPref(null, 0);
+    ps.setIntPref(null, 0);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.getCharPref(null);
+    ps.getCharPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.setCharPref(null, null);
+    ps.setCharPref(null, null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.getStringPref(null);
+    ps.getStringPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.setStringPref(null, null);
+    ps.setStringPref(null, null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.clearUserPref(null);
+    ps.clearUserPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.prefHasUserValue(null);
+    ps.prefHasUserValue(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.lockPref(null);
+    ps.lockPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.prefIsLocked(null);
+    ps.prefIsLocked(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.unlockPref(null);
+    ps.unlockPref(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.deleteBranch(null);
+    ps.deleteBranch(null);
 }, Cr.NS_ERROR_INVALID_ARG);
   do_check_throws(function() {
-    pb.getChildList(null);
+    ps.getChildList(null);
 }, Cr.NS_ERROR_INVALID_ARG);
 
   //* *************************************************************************//
   // Nonexisting user preferences
 
-  Assert.equal(pb.prefHasUserValue("UserPref.nonexistent.hasUserValue"), false);
-  pb.clearUserPref("UserPref.nonexistent.clearUserPref"); // shouldn't throw
-  Assert.equal(pb.getPrefType("UserPref.nonexistent.getPrefType"), PREF_INVALID);
-  Assert.equal(pb.root, "");
+  Assert.equal(ps.prefHasUserValue("UserPref.nonexistent.hasUserValue"), false);
+  ps.clearUserPref("UserPref.nonexistent.clearUserPref"); // shouldn't throw
+  Assert.equal(ps.getPrefType("UserPref.nonexistent.getPrefType"), PREF_INVALID);
+  Assert.equal(ps.root, "");
 
   // bool...
   do_check_throws(function() {
-    pb.getBoolPref("UserPref.nonexistent.getBoolPref");
-}, Cr.NS_ERROR_UNEXPECTED);
-  pb.setBoolPref("UserPref.nonexistent.setBoolPref", false);
-  Assert.equal(pb.getBoolPref("UserPref.nonexistent.setBoolPref"), false);
+    ps.getBoolPref("UserPref.nonexistent.getBoolPref");
+  }, Cr.NS_ERROR_UNEXPECTED);
+  ps.setBoolPref("UserPref.nonexistent.setBoolPref", false);
+  Assert.equal(ps.getBoolPref("UserPref.nonexistent.setBoolPref"), false);
 
   // int...
   do_check_throws(function() {
-    pb.getIntPref("UserPref.nonexistent.getIntPref");
-}, Cr.NS_ERROR_UNEXPECTED);
-  pb.setIntPref("UserPref.nonexistent.setIntPref", 5);
-  Assert.equal(pb.getIntPref("UserPref.nonexistent.setIntPref"), 5);
+    ps.getIntPref("UserPref.nonexistent.getIntPref");
+  }, Cr.NS_ERROR_UNEXPECTED);
+  ps.setIntPref("UserPref.nonexistent.setIntPref", 5);
+  Assert.equal(ps.getIntPref("UserPref.nonexistent.setIntPref"), 5);
 
   // char
   do_check_throws(function() {
-    pb.getCharPref("UserPref.nonexistent.getCharPref");
-}, Cr.NS_ERROR_UNEXPECTED);
-  pb.setCharPref("UserPref.nonexistent.setCharPref", "_test");
-  Assert.equal(pb.getCharPref("UserPref.nonexistent.setCharPref"), "_test");
+    ps.getCharPref("UserPref.nonexistent.getCharPref");
+  }, Cr.NS_ERROR_UNEXPECTED);
+  ps.setCharPref("UserPref.nonexistent.setCharPref", "_test");
+  Assert.equal(ps.getCharPref("UserPref.nonexistent.setCharPref"), "_test");
 
   //* *************************************************************************//
   // Existing user Prefs and data integrity test (round-trip match)
 
-  pb.setBoolPref("UserPref.existing.bool", true);
-  pb.setIntPref("UserPref.existing.int", 23);
-  pb.setCharPref("UserPref.existing.char", "hey");
+  ps.setBoolPref("UserPref.existing.bool", true);
+  ps.setIntPref("UserPref.existing.int", 23);
+  ps.setCharPref("UserPref.existing.char", "hey");
 
   // getPref should return the pref value
-  Assert.equal(pb.getBoolPref("UserPref.existing.bool"), true);
-  Assert.equal(pb.getIntPref("UserPref.existing.int"), 23);
-  Assert.equal(pb.getCharPref("UserPref.existing.char"), "hey");
+  Assert.equal(ps.getBoolPref("UserPref.existing.bool"), true);
+  Assert.equal(ps.getIntPref("UserPref.existing.int"), 23);
+  Assert.equal(ps.getCharPref("UserPref.existing.char"), "hey");
 
   // setPref should not complain and should change the value of the pref
-  pb.setBoolPref("UserPref.existing.bool", false);
-  Assert.equal(pb.getBoolPref("UserPref.existing.bool"), false);
-  pb.setIntPref("UserPref.existing.int", 24);
-  Assert.equal(pb.getIntPref("UserPref.existing.int"), 24);
-  pb.setCharPref("UserPref.existing.char", "hej då!");
-  Assert.equal(pb.getCharPref("UserPref.existing.char"), "hej då!");
+  ps.setBoolPref("UserPref.existing.bool", false);
+  Assert.equal(ps.getBoolPref("UserPref.existing.bool"), false);
+  ps.setIntPref("UserPref.existing.int", 24);
+  Assert.equal(ps.getIntPref("UserPref.existing.int"), 24);
+  ps.setCharPref("UserPref.existing.char", "hej då!");
+  Assert.equal(ps.getCharPref("UserPref.existing.char"), "hej då!");
 
   // prefHasUserValue should return true now
-  Assert.ok(pb.prefHasUserValue("UserPref.existing.bool"));
-  Assert.ok(pb.prefHasUserValue("UserPref.existing.int"));
-  Assert.ok(pb.prefHasUserValue("UserPref.existing.char"));
+  Assert.ok(ps.prefHasUserValue("UserPref.existing.bool"));
+  Assert.ok(ps.prefHasUserValue("UserPref.existing.int"));
+  Assert.ok(ps.prefHasUserValue("UserPref.existing.char"));
 
   // clearUserPref should remove the pref
-  pb.clearUserPref("UserPref.existing.bool");
-  Assert.ok(!pb.prefHasUserValue("UserPref.existing.bool"));
-  pb.clearUserPref("UserPref.existing.int");
-  Assert.ok(!pb.prefHasUserValue("UserPref.existing.int"));
-  pb.clearUserPref("UserPref.existing.char");
-  Assert.ok(!pb.prefHasUserValue("UserPref.existing.char"));
+  ps.clearUserPref("UserPref.existing.bool");
+  Assert.ok(!ps.prefHasUserValue("UserPref.existing.bool"));
+  ps.clearUserPref("UserPref.existing.int");
+  Assert.ok(!ps.prefHasUserValue("UserPref.existing.int"));
+  ps.clearUserPref("UserPref.existing.char");
+  Assert.ok(!ps.prefHasUserValue("UserPref.existing.char"));
 
   //* *************************************************************************//
   // Large value test
 
   let largeStr = new Array(MAX_PREF_LENGTH + 1).join("x");
-  pb.setCharPref("UserPref.large.char", largeStr);
+  ps.setCharPref("UserPref.large.char", largeStr);
   largeStr += "x";
   do_check_throws(function() {
-    pb.setCharPref("UserPref.large.char", largeStr);
-}, Cr.NS_ERROR_ILLEGAL_VALUE);
+    ps.setCharPref("UserPref.large.char", largeStr);
+  }, Cr.NS_ERROR_ILLEGAL_VALUE);
 
   //* *************************************************************************//
   // getPrefType test
 
   // bool...
-  pb.setBoolPref("UserPref.getPrefType.bool", true);
-  Assert.equal(pb.getPrefType("UserPref.getPrefType.bool"), PREF_BOOL);
+  ps.setBoolPref("UserPref.getPrefType.bool", true);
+  Assert.equal(ps.getPrefType("UserPref.getPrefType.bool"), PREF_BOOL);
 
   // int...
-  pb.setIntPref("UserPref.getPrefType.int", -234);
-  Assert.equal(pb.getPrefType("UserPref.getPrefType.int"), PREF_INT);
+  ps.setIntPref("UserPref.getPrefType.int", -234);
+  Assert.equal(ps.getPrefType("UserPref.getPrefType.int"), PREF_INT);
 
   // char...
-  pb.setCharPref("UserPref.getPrefType.char", "testing1..2");
-  Assert.equal(pb.getPrefType("UserPref.getPrefType.char"), PREF_STRING);
+  ps.setCharPref("UserPref.getPrefType.char", "testing1..2");
+  Assert.equal(ps.getPrefType("UserPref.getPrefType.char"), PREF_STRING);
 
   //* *************************************************************************//
   // getBranch tests
 
   Assert.equal(ps.root, "");
 
   // bool ...
-  pb.setBoolPref("UserPref.root.boolPref", true);
+  ps.setBoolPref("UserPref.root.boolPref", true);
   let pb_1 = ps.getBranch("UserPref.root.");
   Assert.equal(pb_1.getBoolPref("boolPref"), true);
   let pb_2 = ps.getBranch("UserPref.root.boolPref");
   Assert.equal(pb_2.getBoolPref(""), true);
   pb_2.setBoolPref(".anotherPref", false);
   let pb_3 = ps.getBranch("UserPref.root.boolPre");
   Assert.equal(pb_3.getBoolPref("f.anotherPref"), false);
 
   // int ...
-  pb.setIntPref("UserPref.root.intPref", 23);
+  ps.setIntPref("UserPref.root.intPref", 23);
   pb_1 = ps.getBranch("UserPref.root.");
   Assert.equal(pb_1.getIntPref("intPref"), 23);
   pb_2 = ps.getBranch("UserPref.root.intPref");
   Assert.equal(pb_2.getIntPref(""), 23);
   pb_2.setIntPref(".anotherPref", 69);
   pb_3 = ps.getBranch("UserPref.root.intPre");
   Assert.equal(pb_3.getIntPref("f.anotherPref"), 69);
 
   // char...
-  pb.setCharPref("UserPref.root.charPref", "_char");
+  ps.setCharPref("UserPref.root.charPref", "_char");
   pb_1 = ps.getBranch("UserPref.root.");
   Assert.equal(pb_1.getCharPref("charPref"), "_char");
   pb_2 = ps.getBranch("UserPref.root.charPref");
   Assert.equal(pb_2.getCharPref(""), "_char");
   pb_2.setCharPref(".anotherPref", "_another");
   pb_3 = ps.getBranch("UserPref.root.charPre");
   Assert.equal(pb_3.getCharPref("f.anotherPref"), "_another");
 
   //* *************************************************************************//
   // getChildlist tests
 
   // get an already set prefBranch
-  pb1 = ps.getBranch("UserPref.root.");
+  let pb1 = ps.getBranch("UserPref.root.");
   let prefList = pb1.getChildList("");
   Assert.equal(prefList.length, 6);
 
   // check for specific prefs in the array : the order is not important
   Assert.ok("boolPref" in makeList(prefList));
   Assert.ok("intPref" in makeList(prefList));
   Assert.ok("charPref" in makeList(prefList));
   Assert.ok("boolPref.anotherPref" in makeList(prefList));
@@ -248,20 +241,20 @@ function run_test() {
   Assert.equal(ps.getCharPref("DefaultPref.char"), "_user");
 
   //* *************************************************************************//
   // pref Locking/Unlocking tests
 
   // locking and unlocking a nonexistent pref should throw
   do_check_throws(function() {
     ps.lockPref("DefaultPref.nonexistent");
-}, Cr.NS_ERROR_ILLEGAL_VALUE);
+  }, Cr.NS_ERROR_ILLEGAL_VALUE);
   do_check_throws(function() {
     ps.unlockPref("DefaultPref.nonexistent");
-}, Cr.NS_ERROR_ILLEGAL_VALUE);
+  }, Cr.NS_ERROR_ILLEGAL_VALUE);
 
   // getting a locked pref branch should return the "default" value
   Assert.ok(!ps.prefIsLocked("DefaultPref.char"));
   ps.lockPref("DefaultPref.char");
   Assert.equal(ps.getCharPref("DefaultPref.char"), "_default");
   Assert.ok(ps.prefIsLocked("DefaultPref.char"));
 
   // getting an unlocked pref branch should return the "user" value
@@ -292,40 +285,40 @@ function run_test() {
   //* *************************************************************************//
   // deleteBranch tests
 
   // TODO : Really, this should throw!, by documentation.
   // do_check_throws(function() {
   // ps.deleteBranch("UserPref.nonexistent.deleteBranch");}, Cr.NS_ERROR_UNEXPECTED);
 
   ps.deleteBranch("DefaultPref");
-  pb = ps.getBranch("DefaultPref");
+  let pb = ps.getBranch("DefaultPref");
   pb1 = ps.getDefaultBranch("DefaultPref");
 
   // getting prefs on deleted user branches should throw
   do_check_throws(function() {
     pb.getBoolPref("DefaultPref.bool");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb.getIntPref("DefaultPref.int");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb.getCharPref("DefaultPref.char");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // getting prefs on deleted default branches should throw
   do_check_throws(function() {
     pb1.getBoolPref("DefaultPref.bool");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb1.getIntPref("DefaultPref.int");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb1.getCharPref("DefaultPref.char");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   //* *************************************************************************//
   // savePrefFile & readPrefFile tests
 
   // set some prefs
   ps.setBoolPref("ReadPref.bool", true);
   ps.setIntPref("ReadPref.int", 230);
   ps.setCharPref("ReadPref.char", "hello");
@@ -343,23 +336,23 @@ function run_test() {
 
   // load a preexisting pref file
   let prefFile = do_get_file("data/testPref.js");
   ps.readUserPrefsFromFile(prefFile);
 
   // former prefs should have been replaced/lost
   do_check_throws(function() {
     pb.getBoolPref("ReadPref.bool");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb.getIntPref("ReadPref.int");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
   do_check_throws(function() {
     pb.getCharPref("ReadPref.char");
-}, Cr.NS_ERROR_UNEXPECTED);
+  }, Cr.NS_ERROR_UNEXPECTED);
 
   // loaded prefs should read ok.
   pb = ps.getBranch("testPref.");
   Assert.equal(pb.getBoolPref("bool1"), true);
   Assert.equal(pb.getBoolPref("bool2"), false);
   Assert.equal(pb.getIntPref("int1"), 23);
   Assert.equal(pb.getIntPref("int2"), -1236);
   Assert.equal(pb.getCharPref("char1"), "_testPref");
@@ -400,17 +393,17 @@ function run_test() {
       this.value = expectedValue;
 
       prefBranch.addObserver(expectedName, this);
     }
 
     QueryInterface(aIID) {
       if (aIID.equals(Ci.nsIObserver) ||
           aIID.equals(Ci.nsISupports))
-         return this;
+        return this;
       throw Cr.NS_NOINTERFACE;
     }
 
     observe(aSubject, aTopic, aState) {
       Assert.equal(aTopic, "nsPref:changed");
       Assert.equal(aState, this.name);
       Assert.equal(this.pb.getIntPref(aState), this.value);
       pb.removeObserver(aState, this);
@@ -421,24 +414,24 @@ function run_test() {
   }
 
   // Indicate that we'll have 3 more async tests pending so that they all
   // actually get a chance to run.
   do_test_pending();
   do_test_pending();
   do_test_pending();
 
-  let observer = new PrefObserver(pb2, "ReadPref.int", 76);
+  let observer = new PrefObserver(ps, "ReadPref.int", 76);
   ps.setIntPref("ReadPref.int", 76);
 
   // removed observer should not fire
-  pb2.removeObserver("ReadPref.int", observer);
+  ps.removeObserver("ReadPref.int", observer);
   ps.setIntPref("ReadPref.int", 32);
 
   // let's test observers once more with a non-root prefbranch
-  pb = pb2.getBranch("ReadPref.");
+  pb = ps.getBranch("ReadPref.");
   observer = new PrefObserver(pb, "int", 76);
   ps.setIntPref("ReadPref.int", 76);
 
   // Let's try that again with different pref.
   observer = new PrefObserver(pb, "another_int", 76);
   ps.setIntPref("ReadPref.another_int", 76);
 }
--- a/modules/libpref/test/unit/test_locked_file_prefs.js
+++ b/modules/libpref/test/unit/test_locked_file_prefs.js
@@ -1,16 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
 // This file tests the `locked` attribute in default pref files.
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
 const ps = Services.prefs;
 
 add_test(function notChangedFromAPI() {
   ps.resetPrefs();
   ps.readDefaultPrefsFromFile(do_get_file("data/testPrefLocked.js"));
   Assert.strictEqual(ps.getIntPref("testPref.unlocked.int"), 333);
   Assert.strictEqual(ps.getIntPref("testPref.locked.int"), 444);
 
--- a/modules/libpref/test/unit/test_parser.js
+++ b/modules/libpref/test/unit/test_parser.js
@@ -1,18 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
 function run_test() {
-  const PREF_NAME = "testPref";
-
-  var ps = Cc["@mozilla.org/preferences-service;1"]
-           .getService(Ci.nsIPrefService);
-  var defaultPrefs = ps.getDefaultBranch(null);
-  var prefs = ps.getBranch(null);
+  const ps = Services.prefs;
 
   ps.resetPrefs();
   ps.readDefaultPrefsFromFile(do_get_file("data/testParser.js"));
 
   Assert.equal(ps.getBoolPref("comment1"), true);
   Assert.equal(ps.getBoolPref("comment2"), true);
   Assert.equal(ps.getBoolPref("spaced-out"), true);
 
@@ -30,31 +25,31 @@ function run_test() {
 
   Assert.equal(ps.getIntPref("int.0"), 0);
   Assert.equal(ps.getIntPref("int.1"), 1);
   Assert.equal(ps.getIntPref("int.123"), 123);
   Assert.equal(ps.getIntPref("int.+234"), 234);
   Assert.equal(ps.getIntPref("int.+  345"), 345);
   Assert.equal(ps.getIntPref("int.-0"), -0);
   Assert.equal(ps.getIntPref("int.-1"), -1);
-  Assert.equal(ps.getIntPref("int.- /* hmm */	456"), -456);
+  Assert.equal(ps.getIntPref("int.- /* hmm */\t456"), -456);
   Assert.equal(ps.getIntPref("int.-\n567"), -567);
   Assert.equal(ps.getIntPref("int.INT_MAX-1"), 2147483646);
   Assert.equal(ps.getIntPref("int.INT_MAX"), 2147483647);
   Assert.equal(ps.getIntPref("int.INT_MIN+2"), -2147483646);
   Assert.equal(ps.getIntPref("int.INT_MIN+1"), -2147483647);
   Assert.equal(ps.getIntPref("int.INT_MIN"), -2147483648);
 
   Assert.equal(ps.getCharPref("string.empty"), "");
   Assert.equal(ps.getCharPref("string.abc"), "abc");
   Assert.equal(ps.getCharPref("string.long"), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
   Assert.equal(ps.getCharPref("string.single-quotes"), '"abc"');
   Assert.equal(ps.getCharPref("string.double-quotes"), "'abc'");
   Assert.equal(ps.getCharPref("string.weird-chars"),
-               "\x0d \x09 \x0b \x0c \x06 \x16");
+              "\x0d \x09 \x0b \x0c \x06 \x16");
   Assert.equal(ps.getCharPref("string.escapes"), "\" \' \\ \n \r");
 
   // This one is ASCII, so we can use getCharPref() and getStringPref
   // interchangeably.
   Assert.equal(ps.getCharPref("string.x-escapes1"),
                "Mozilla0\x4d\x6F\x7a\x69\x6c\x6C\x610");
   Assert.equal(ps.getStringPref("string.x-escapes1"),
                "Mozilla0Mozilla0");
--- a/modules/libpref/test/unit/test_stickyprefs.js
+++ b/modules/libpref/test/unit/test_stickyprefs.js
@@ -1,13 +1,11 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/  */
 
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
 const ps = Services.prefs;
 
 // A little helper to reset the service and load one pref file.
 function resetAndLoadDefaults() {
   ps.resetPrefs();
   ps.readDefaultPrefsFromFile(do_get_file("data/testPrefSticky.js"));
 }
 
--- a/modules/libpref/test/unit/test_warnings.js
+++ b/modules/libpref/test/unit/test_warnings.js
@@ -1,18 +1,12 @@
 /* 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 cs = Cc["@mozilla.org/consoleservice;1"].
-  getService(Ci.nsIConsoleService);
-var ps = Cc["@mozilla.org/preferences-service;1"].
-  getService(Ci.nsIPrefService);
-
 function makeBuffer(length) {
   return new Array(length + 1).join("x");
 }
 
 /**
  * @resolves |true| if execution proceeded without warning,
  * |false| if there was a warning.
  */
@@ -26,31 +20,31 @@ function checkWarning(pref, buffer) {
               && message.includes(pref))) {
           return;
         }
         if (complete) {
           return;
         }
         complete = true;
         info("Warning while setting " + pref);
-        cs.unregisterListener(listener);
+        Services.console.unregisterListener(listener);
         resolve(true);
       },
     };
     do_timeout(1000, function() {
       if (complete) {
         return;
       }
       complete = true;
       info("No warning while setting " + pref);
-      cs.unregisterListener(listener);
+      Services.console.unregisterListener(listener);
       resolve(false);
     });
-    cs.registerListener(listener);
-    ps.setCharPref(pref, buffer);
+    Services.console.registerListener(listener);
+    Services.prefs.setCharPref(pref, buffer);
   });
 }
 
 add_task(async function() {
   // Simple change, shouldn't cause a warning
   info("Checking that a simple change doesn't cause a warning");
   let buf = makeBuffer(100);
   let warned = await checkWarning("string.accept", buf);
--- a/modules/libpref/test/unit_ipc/test_existing_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_existing_prefs.js
@@ -1,17 +1,19 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function isParentProcess() {
     let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+    return (!appInfo || Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
 }
 
 function run_test() {
-  if (isParentProcess() == false) {
+  if (!isParentProcess()) {
     do_load_child_test_harness();
 
-    var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+    var pb = Services.prefs;
     pb.setBoolPref("Test.IPC.bool.new", true);
     pb.setIntPref("Test.IPC.int.new", 23);
     pb.setCharPref("Test.IPC.char.new", "hey");
 
     run_test_in_child("test_observed_prefs.js");
   }
 }
--- a/modules/libpref/test/unit_ipc/test_initial_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_initial_prefs.js
@@ -1,15 +1,16 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function isParentProcess() {
-    let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
 }
 
 function run_test() {
-  if (isParentProcess() == false) {
-      var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-      pb.setBoolPref("Test.IPC.bool", true);
-      pb.setIntPref("Test.IPC.int", 23);
-      pb.setCharPref("Test.IPC.char", "hey");
+  if (!isParentProcess()) {
+    const pb = Services.prefs;
+    pb.setBoolPref("Test.IPC.bool", true);
+    pb.setIntPref("Test.IPC.int", 23);
+    pb.setCharPref("Test.IPC.char", "hey");
 
-      run_test_in_child("test_existing_prefs.js");
+    run_test_in_child("test_existing_prefs.js");
   }
 }
--- a/modules/libpref/test/unit_ipc/test_large_pref.js
+++ b/modules/libpref/test/unit_ipc/test_large_pref.js
@@ -1,30 +1,31 @@
 /* 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/. */
 
 // Large preferences should not be set in the child process.
 // Non-string preferences are not tested here, because their behavior
 // should not be affected by this filtering.
+//
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function isParentProcess() {
-    let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
 }
 
 function makeBuffer(length) {
-    let string = "x";
-    while (string.length < length) {
-      string = string + string;
-    }
-    if (string.length > length) {
-      string = string.substring(length - string.length);
-    }
-    return string;
+  let string = "x";
+  while (string.length < length) {
+    string = string + string;
+  }
+  if (string.length > length) {
+    string = string.substring(length - string.length);
+  }
+  return string;
 }
 
 // from prefapi.h
 const MAX_ADVISABLE_PREF_LENGTH = 4 * 1024;
 
 const largeString = makeBuffer(MAX_ADVISABLE_PREF_LENGTH + 1);
 const smallString = makeBuffer(4);
 
@@ -41,19 +42,18 @@ function prefName(def, user) {
 function expectedPrefValue(def, user) {
   if (user.value) {
     return user.value;
   }
   return def.value;
 }
 
 function run_test() {
-  let pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-  let ps = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
-  let defaultBranch = ps.getDefaultBranch("");
+  const pb = Services.prefs;
+  let defaultBranch = pb.getDefaultBranch("");
 
   let isParent = isParentProcess();
   if (isParent) {
     // Preferences with large values will still appear in the shared memory
     // snapshot that we share with all processes. They should not, however, be
     // sent with the list of changes on top of the snapshot.
     //
     // So, make sure we've generated the initial snapshot before we set the
@@ -91,13 +91,13 @@ function run_test() {
         let prefExists;
         try {
           let val = pb.getCharPref(pref_name);
           prefExists = val.length > 128;
         } catch (e) {
           prefExists = false;
         }
         ok(!prefExists,
-           "Pref " + pref_name + " should not be set in the child");
+          "Pref " + pref_name + " should not be set in the child");
       }
     }
   }
 }
--- a/modules/libpref/test/unit_ipc/test_locked_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_locked_prefs.js
@@ -1,21 +1,22 @@
 /* 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/. */
 
 // Locked status should be communicated to children.
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function isParentProcess() {
-    let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
 }
 
 function run_test() {
-  let pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+  const pb = Services.prefs;
 
   let bprefname = "Test.IPC.locked.bool";
   let iprefname = "Test.IPC.locked.int";
   let sprefname = "Test.IPC.locked.string";
 
   let isParent = isParentProcess();
   if (isParent) {
     pb.setBoolPref(bprefname, true);
--- a/modules/libpref/test/unit_ipc/test_observed_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_observed_prefs.js
@@ -1,13 +1,14 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function isParentProcess() {
-    let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  return (Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
 }
 
 function run_test() {
-  if (isParentProcess() == false) {
-      var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-      Assert.equal(pb.getBoolPref("Test.IPC.bool.new"), true);
-      Assert.equal(pb.getIntPref("Test.IPC.int.new"), 23);
-      Assert.equal(pb.getCharPref("Test.IPC.char.new"), "hey");
+  if (!isParentProcess()) {
+    const pb = Services.prefs;
+    Assert.equal(pb.getBoolPref("Test.IPC.bool.new"), true);
+    Assert.equal(pb.getIntPref("Test.IPC.int.new"), 23);
+    Assert.equal(pb.getCharPref("Test.IPC.char.new"), "hey");
   }
 }
--- a/modules/libpref/test/unit_ipc/test_sharedMap.js
+++ b/modules/libpref/test/unit_ipc/test_sharedMap.js
@@ -147,17 +147,16 @@ const TESTS = {
 const PREFS = [
   {type: "Bool", values: [true, false, true]},
   {type: "Int", values: [24, 42, 73]},
   {type: "String", values: ["meh", "hem", "hrm"]},
 ];
 
 for (let {type, values} of PREFS) {
   let set = `set${type}Pref`;
-  let get = `get${type}Pref`;
 
   function prefTest(opts) {
     function check(pref, proc, val, {expectedVal, defaultVal = undefined, expectedDefault = defaultVal, expectedFlags = {}}) {
       checkPref(pref, proc, val, type, expectedVal, expectedDefault, expectedFlags);
     }
 
     function updatePref(PREF,
                         {userVal = undefined,
--- a/modules/libpref/test/unit_ipc/test_sharedMap_var_caches.js
+++ b/modules/libpref/test/unit_ipc/test_sharedMap_var_caches.js
@@ -25,18 +25,16 @@ const PREF1_VALUE = false;
 const PREF2_NAME = "dom.mutation-events.cssom.disabled";
 const PREF2_VALUE = true;
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {ExtensionTestUtils} = ChromeUtils.import("resource://testing-common/ExtensionXPCShellUtils.jsm");
 
 ExtensionTestUtils.init(this);
 
-let contentPage;
-
 const {prefs} = Services;
 const defaultPrefs = prefs.getDefaultBranch("");
 
 add_task(async function test_sharedMap_var_caches() {
   equal(prefs.getBoolPref(PREF1_NAME), PREF1_VALUE,
         `Expected initial value for ${PREF1_NAME}`);
   equal(prefs.getBoolPref(PREF2_NAME), PREF2_VALUE,
         `Expected initial value for ${PREF2_NAME}`);
@@ -47,19 +45,20 @@ add_task(async function test_sharedMap_v
   equal(prefs.getBoolPref(PREF1_NAME), !PREF1_VALUE,
         `Expected updated value for ${PREF1_NAME}`);
   equal(prefs.getBoolPref(PREF2_NAME), !PREF2_VALUE,
         `Expected updated value for ${PREF2_NAME}`);
 
   let contentPage = await ExtensionTestUtils.loadContentPage("about:blank", {remote: true});
   registerCleanupFunction(() => contentPage.close());
 
+  /* eslint-disable no-shadow */
   let values = await contentPage.spawn([PREF1_NAME, PREF2_NAME], (prefs) => {
     const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
     return prefs.map(pref => Services.prefs.getBoolPref(pref));
   });
+  /* eslint-enable no-shadow */
 
   equal(values[0], !PREF1_VALUE,
         `Expected content value for ${PREF1_NAME}`);
   equal(values[1], !PREF2_VALUE,
         `Expected content value for ${PREF2_NAME}`);
 });
-
--- a/modules/libpref/test/unit_ipc/test_update_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_update_prefs.js
@@ -1,30 +1,31 @@
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function isParentProcess() {
-    let appInfo = Cc["@mozilla.org/xre/app-info;1"];
-    return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
+  return Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function run_test() {
   if (isParentProcess()) {
     do_load_child_test_harness();
 
-    var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+    var pb = Services.prefs;
 
     // these prefs are set after the child has been created.
     pb.setBoolPref("Test.IPC.bool.new", true);
     pb.setIntPref("Test.IPC.int.new", 23);
     pb.setCharPref("Test.IPC.char.new", "hey");
 
     run_test_in_child("test_observed_prefs.js", testPrefClear);
   }
 }
 
 function testPrefClear() {
-  var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+  var pb = Services.prefs;
   pb.clearUserPref("Test.IPC.bool.new");
 
   sendCommand(
 'var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);\n' +
 'pb.prefHasUserValue("Test.IPC.bool.new");\n',
     checkWasCleared);
 }
 
--- a/modules/libpref/test/unit_ipc/test_user_default_prefs.js
+++ b/modules/libpref/test/unit_ipc/test_user_default_prefs.js
@@ -1,67 +1,68 @@
-var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const pb = Services.prefs;
 
 // This pref is chosen somewhat arbitrarily --- we just need one
 // that's guaranteed to have a default value.
 const kPrefName = "intl.accept_languages"; // of type char, which we
                                            // assume below
 var initialValue = null;
 
 function check_child_pref_info_eq(continuation) {
-    sendCommand(
-        'var pb = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);\n' +
-        // Returns concatenation "[value],[isUser]"
-        'pb.getCharPref("' + kPrefName + '")+ "," +' +
-        'pb.prefHasUserValue("' + kPrefName + '");',
-        function(info) {
-            let [ value, isUser ] = info.split(",");
-            Assert.equal(pb.getCharPref(kPrefName), value);
-            Assert.equal(pb.prefHasUserValue(kPrefName), isUser == "true");
-            continuation();
-        });
+  sendCommand(
+    'var pb = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);\n' +
+    // Returns concatenation "[value],[isUser]"
+    'pb.getCharPref("' + kPrefName + '")+ "," +' +
+    'pb.prefHasUserValue("' + kPrefName + '");',
+    function(info) {
+      let [ value, isUser ] = info.split(",");
+      Assert.equal(pb.getCharPref(kPrefName), value);
+      Assert.equal(pb.prefHasUserValue(kPrefName), isUser == "true");
+      continuation();
+    });
 }
 
 function run_test() {
-    // We finish in clean_up()
-    do_test_pending();
+  // We finish in clean_up()
+  do_test_pending();
 
-    initialValue = pb.getCharPref(kPrefName);
+  initialValue = pb.getCharPref(kPrefName);
 
-    test_user_setting();
+  test_user_setting();
 }
 
 function test_user_setting() {
-    // We rely on setting this before the content process starts up.
-    // When it starts up, it should recognize this as a user pref, not
-    // a default pref.
-    pb.setCharPref(kPrefName, "i-imaginarylanguage");
-    // NB: processing of the value-change notification in the child
-    // process triggered by the above set happens-before the remaining
-    // code here
-    check_child_pref_info_eq(function() {
-            Assert.equal(pb.prefHasUserValue(kPrefName), true);
+  // We rely on setting this before the content process starts up.
+  // When it starts up, it should recognize this as a user pref, not
+  // a default pref.
+  pb.setCharPref(kPrefName, "i-imaginarylanguage");
+  // NB: processing of the value-change notification in the child
+  // process triggered by the above set happens-before the remaining
+  // code here
+  check_child_pref_info_eq(function() {
+    Assert.equal(pb.prefHasUserValue(kPrefName), true);
 
-            test_cleared_is_default();
-        });
+    test_cleared_is_default();
+  });
 }
 
 function test_cleared_is_default() {
-    pb.clearUserPref(kPrefName);
-    // NB: processing of the value-change notification in the child
-    // process triggered by the above set happens-before the remaining
-    // code here
-    check_child_pref_info_eq(function() {
-            Assert.equal(pb.prefHasUserValue(kPrefName), false);
+  pb.clearUserPref(kPrefName);
+  // NB: processing of the value-change notification in the child
+  // process triggered by the above set happens-before the remaining
+  // code here
+  check_child_pref_info_eq(function() {
+    Assert.equal(pb.prefHasUserValue(kPrefName), false);
 
-            clean_up();
-        });
+    clean_up();
+  });
 }
 
 function clean_up() {
-    pb.setCharPref(kPrefName, initialValue);
-    // NB: processing of the value-change notification in the child
-    // process triggered by the above set happens-before the remaining
-    // code here
-    check_child_pref_info_eq(function() {
-            do_test_finished();
-        });
+  pb.setCharPref(kPrefName, initialValue);
+  // NB: processing of the value-change notification in the child
+  // process triggered by the above set happens-before the remaining
+  // code here
+  check_child_pref_info_eq(function() {
+    do_test_finished();
+  });
 }