Bug 1497604 - Enable ESLint for dom/cache (manual changes) r=Standard8,hsivonen
authormonmanuela <manuela.monika97@gmail.com>
Wed, 06 Mar 2019 08:03:42 +0000
changeset 462561 0077a71108eb4bd58348a697fafb7e43eddedf50
parent 462560 36052e9424f7f356a197707303874940652f4eae
child 462562 4348e60c81ed02630b24c9dfa4b49cf5d0a2b696
push id35655
push userncsoregi@mozilla.com
push dateWed, 06 Mar 2019 16:12:01 +0000
treeherdermozilla-central@0d659b1c6de3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, hsivonen
bugs1497604
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 1497604 - Enable ESLint for dom/cache (manual changes) r=Standard8,hsivonen Depends on D20943 Differential Revision: https://phabricator.services.mozilla.com/D20944
.eslintignore
dom/cache/test/mochitest/browser_cache_pb_window.js
dom/cache/test/mochitest/driver.js
dom/cache/test/mochitest/test_cache.js
dom/cache/test/mochitest/test_cache_add.js
dom/cache/test/mochitest/test_cache_delete.js
dom/cache/test/mochitest/test_cache_https.js
dom/cache/test/mochitest/test_cache_keys.js
dom/cache/test/mochitest/test_cache_matchAll_request.js
dom/cache/test/mochitest/test_cache_match_request.js
dom/cache/test/mochitest/test_cache_match_vary.js
dom/cache/test/mochitest/test_cache_orphaned_body.html
dom/cache/test/mochitest/test_cache_orphaned_cache.html
dom/cache/test/mochitest/test_cache_overwrite.js
dom/cache/test/mochitest/test_cache_padding.html
dom/cache/test/mochitest/test_cache_put.js
dom/cache/test/mochitest/test_cache_put_reorder.js
dom/cache/test/mochitest/test_cache_redirect.js
dom/cache/test/mochitest/test_cache_requestCache.js
dom/cache/test/mochitest/test_cache_updateUsage.html
dom/cache/test/mochitest/test_caches.js
dom/cache/test/mochitest/worker_driver.js
dom/cache/test/mochitest/worker_wrapper.js
dom/cache/test/xpcshell/head.js
dom/cache/test/xpcshell/make_profile.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -165,18 +165,16 @@ devtools/server/tests/unit/xpcshell_debu
 dom/animation/**
 dom/base/*.*
 dom/base/test/*.*
 dom/base/test/unit/test_serializers_entities*.js
 dom/base/test/unit_ipc/**
 dom/base/test/jsmodules/**
 dom/bindings/**
 dom/browser-element/**
-dom/cache/test/mochitest/**
-dom/cache/test/xpcshell/**
 dom/canvas/**
 dom/encoding/**
 dom/events/**
 dom/fetch/**
 dom/file/**
 dom/flex/**
 dom/grid/**
 dom/html/**
--- a/dom/cache/test/mochitest/browser_cache_pb_window.js
+++ b/dom/cache/test/mochitest/browser_cache_pb_window.js
@@ -1,8 +1,9 @@
+/* eslint-disable no-shadow */
 var name = "pb-window-cache";
 
 function testMatch(browser) {
   return ContentTask.spawn(browser, name, function(name) {
     return new Promise((resolve, reject) => {
       content.caches.match("http://foo.com").then(function(response) {
         ok(false, "caches.match() should not return success");
         reject();
--- a/dom/cache/test/mochitest/driver.js
+++ b/dom/cache/test/mochitest/driver.js
@@ -44,16 +44,18 @@ function runTests(testFile, order) {
       s.src = script;
       s.onerror = reject;
       s.onload = resolve;
       document.body.appendChild(s);
     });
   }
 
   function importDrivers() {
+    /* import-globals-from worker_driver.js */
+    /* import-globals-from serviceworker_driver.js */
     return Promise.all([loadScript("worker_driver.js"),
                         loadScript("serviceworker_driver.js")]);
   }
 
   function runWorkerTest() {
     return workerTestExec(testFile);
   }
 
--- a/dom/cache/test/mochitest/test_cache.js
+++ b/dom/cache/test/mochitest/test_cache.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var c = null;
 var request = "http://example.com/hmm?q=foobar" + context;
 var response = new Response("This is some Response!");
 var name = "snafu" + context;
 var foobar = "foobar" + context;
 
 ok(!!caches, "caches object should be available on global");
 caches.open(name).then(function(openCache) {
@@ -46,26 +48,26 @@ caches.open(name).then(function(openCach
   var snafu = args[0];
   var keys = args[1];
   is(1, keys.length, "cache.keys() should resolve to an array of length 1");
   ok(keys[0] instanceof Request, "key should be a Request");
   ok(keys[0].url.match(/cachekey$/), "Request URL should match original");
   return Promise.all([snafu, snafu.match(keys[0]), snafu.match("ftp://invalid")]);
 }).then(function(args) {
   var snafu = args[0];
-  var response = args[1];
-  ok(response instanceof Response, "value should be a Response");
-  is(response.status, 200, "Response status should be 200");
+  var res = args[1];
+  ok(res instanceof Response, "value should be a Response");
+  is(res.status, 200, "Response status should be 200");
   is(undefined, args[2], "Match with invalid scheme should resolve undefined");
-  return Promise.all([snafu, snafu.put("./cachekey2", response)]);
+  return Promise.all([snafu, snafu.put("./cachekey2", res)]);
 }).then(function(args) {
   var snafu = args[0];
   return snafu.match("./cachekey2");
-}).then(function(response) {
-  return response.text().then(function(v) {
+}).then(function(res) {
+  return res.text().then(function(v) {
     is(v, "Hello world", "Response body should match original");
   });
 }).then(function() {
   // FIXME(nsm): Can't use a Request object for now since the operations
   // consume it's 'body'. See
   // https://github.com/slightlyoff/ServiceWorker/issues/510.
   return caches.open(foobar);
 }).then(function(openCache) {
--- a/dom/cache/test/mochitest/test_cache_add.js
+++ b/dom/cache/test/mochitest/test_cache_add.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var singleUrl = "./test_cache_add.js";
 var urlList = [
   "./empty.html",
   "./frame.html",
   "./test_cache.js",
 ];
 var cache;
 var name = "adder" + context;
--- a/dom/cache/test/mochitest/test_cache_delete.js
+++ b/dom/cache/test/mochitest/test_cache_delete.js
@@ -1,10 +1,11 @@
+/* global context testDone:true */
+
 var name = "delete" + context;
-var c;
 
 function setupTest(reqs) {
   return new Promise(function(resolve, reject) {
     var cache;
     caches.open(name).then(function(c) {
         cache = c;
         return c.addAll(reqs);
       }).then(function() {
--- a/dom/cache/test/mochitest/test_cache_https.js
+++ b/dom/cache/test/mochitest/test_cache_https.js
@@ -1,17 +1,19 @@
+/* global context testDone:true */
+
 var cache = null;
 var name = "https_" + context;
 var urlBase = "https://example.com/tests/dom/cache/test/mochitest";
 var url1 = urlBase + "/test_cache.js";
 var url2 = urlBase + "/test_cache_add.js";
 
-function addOpaque(cache, url) {
+function addOpaque(c, url) {
   return fetch(new Request(url, { mode: "no-cors" })).then(function(response) {
-    return cache.put(url, response);
+    return c.put(url, response);
   });
 }
 
 caches.open(name).then(function(c) {
   cache = c;
   return Promise.all([
     addOpaque(cache, url1),
     addOpaque(cache, url2),
--- a/dom/cache/test/mochitest/test_cache_keys.js
+++ b/dom/cache/test/mochitest/test_cache_keys.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var name = "keys" + context;
 var c;
 
 var tests = [
   "//mochi.test:8888/?page" + context,
   "//mochi.test:8888/?another" + context,
 ];
 
@@ -30,19 +32,19 @@ caches.open(name).then(function(cache) {
   });
   // Try searching for just one request
   return c.keys(tests[1]);
 }).then(function(keys) {
   is(keys.length, 1, "One match should be found");
   ok(keys[0].url.includes(tests[1]), "Valid URL");
   // Try to see if ignoreSearch works as expected.
   return c.keys(new Request("//mochi.test:8888/?foo"), {ignoreSearch: true});
-}).then(function(keys) {
-  is(keys.length, tests.length, "Same number of elements");
-  keys.forEach(function(r, i) {
+}).then(function(key_arr) {
+  is(key_arr.length, tests.length, "Same number of elements");
+  key_arr.forEach(function(r, i) {
     ok(r instanceof Request, "Valid request object");
     ok(r.url.includes(tests[i]), "Valid URL");
   });
   // Try to see if ignoreMethod works as expected
   return Promise.all(
     ["POST", "PUT", "DELETE", "OPTIONS"]
       .map(function(method) {
         var req = new Request(tests[2], {method});
--- a/dom/cache/test/mochitest/test_cache_matchAll_request.js
+++ b/dom/cache/test/mochitest/test_cache_matchAll_request.js
@@ -1,11 +1,13 @@
-var request1 = new Request("//mochi.test:8888/?1&" + context + "#fragment");
-var request2 = new Request("//mochi.test:8888/?2&" + context);
-var request3 = new Request("//mochi.test:8888/?3&" + context);
+/* global context testDone:true */
+
+var req1 = new Request("//mochi.test:8888/?1&" + context + "#fragment");
+var req2 = new Request("//mochi.test:8888/?2&" + context);
+var req3 = new Request("//mochi.test:8888/?3&" + context);
 var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
 var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
 var response1, response3;
 var c;
 var response1Text, response3Text;
 var name = "matchAll-request" + context;
 
 function checkResponse(r, response, responseText) {
@@ -20,40 +22,40 @@ function checkResponse(r, response, resp
   return r.text().then(function(text) {
     // Avoid dumping out the large response text to the log if they're equal.
     if (text !== responseText) {
       is(text, responseText, "The response body should be correct");
     }
   });
 }
 
-fetch(new Request(request1)).then(function(r) {
+fetch(new Request(req1)).then(function(r) {
   response1 = r;
   return response1.text();
 }).then(function(text) {
   response1Text = text;
-  return fetch(new Request(request3));
+  return fetch(new Request(req3));
 }).then(function(r) {
   response3 = r;
   return response3.text();
 }).then(function(text) {
   response3Text = text;
-  return testRequest(request1, request2, request3, unknownRequest,
+  return testRequest(req1, req2, req3, unknownRequest,
                      requestWithAltQS,
-                     request1.url.replace("#fragment", "#other"));
+                     req1.url.replace("#fragment", "#other"));
 }).then(function() {
-  return testRequest(request1.url, request2.url, request3.url,
+  return testRequest(req1.url, req2.url, req3.url,
                      unknownRequest.url, requestWithAltQS.url,
-                     request1.url.replace("#fragment", "#other"));
+                     req1.url.replace("#fragment", "#other"));
 }).then(function() {
   testDone();
 });
 
 // The request arguments can either be a URL string, or a Request object.
-function testRequest(request1, request2, request3, unknownRequest,
+function testRequest(request1, request2, request3, unknownReq,
                      requestWithAlternateQueryString,
                      requestWithDifferentFragment) {
   return caches.open(name).then(function(cache) {
     c = cache;
     return c.add(request1);
   }).then(function() {
     return c.add(request3);
   }).then(function() {
@@ -128,20 +130,20 @@ function testRequest(request1, request2,
     return caches.match(request1, {cacheName: name + "mambojambo"})
       .then(function() {
         is(typeof r, "undefined", "Searching in the wrong cache should resolve to undefined");
         return caches.has(name + "mambojambo");
       }).then(function(hasCache) {
         ok(!hasCache, "The wrong cache should still not exist");
       });
   }).then(function() {
-    return c.matchAll(unknownRequest);
+    return c.matchAll(unknownReq);
   }).then(function(r) {
     is(r.length, 0, "Searching for an unknown request should not succeed");
-    return caches.match(unknownRequest, {cacheName: name});
+    return caches.match(unknownReq, {cacheName: name});
   }).then(function(r) {
     is(typeof r, "undefined", "Searching for an unknown request should not succeed");
     // Make sure that cacheName is ignored on Cache
     return c.matchAll(request1, {cacheName: name + "mambojambo"});
   }).then(function(r) {
     is(r.length, 1, "Should only find 1 item");
     return checkResponse(r[0], response1, response1Text);
   }).then(function() {
--- a/dom/cache/test/mochitest/test_cache_match_request.js
+++ b/dom/cache/test/mochitest/test_cache_match_request.js
@@ -1,11 +1,13 @@
-var request = new Request("//mochi.test:8888/?" + context + "#fragment");
+/* global context testDone:true */
+
+var req = new Request("//mochi.test:8888/?" + context + "#fragment");
 var requestWithAltQS = new Request("//mochi.test:8888/?queryString");
-var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
+var unknownReq = new Request("//mochi.test:8888/non/existing/path?" + context);
 var response;
 var c;
 var responseText;
 var name = "match-request" + context;
 
 function checkResponse(r, expectedBody) {
   if (expectedBody === undefined) {
     expectedBody = responseText;
@@ -20,26 +22,26 @@ function checkResponse(r, expectedBody) 
      "Both responses should have the same status text");
   return r.text().then(function(text) {
     // Avoid dumping out the large response text to the log if they're equal.
     if (text !== expectedBody) {
       is(text, responseText, "The response body should be correct");
     }
   });
 }
-fetch(new Request(request)).then(function(r) {
+fetch(new Request(req)).then(function(r) {
   response = r;
   return response.text();
 }).then(function(text) {
   responseText = text;
-  return testRequest(request, unknownRequest, requestWithAltQS,
-                     request.url.replace("#fragment", "#other"));
+  return testRequest(req, unknownReq, requestWithAltQS,
+                     req.url.replace("#fragment", "#other"));
 }).then(function() {
-  return testRequest(request.url, unknownRequest.url, requestWithAltQS.url,
-                     request.url.replace("#fragment", "#other"));
+  return testRequest(req.url, unknownReq.url, requestWithAltQS.url,
+                     req.url.replace("#fragment", "#other"));
 }).then(function() {
   testDone();
 });
 // The request argument can either be a URL string, or a Request object.
 function testRequest(request, unknownRequest, requestWithAlternateQueryString,
                      requestWithDifferentFragment) {
   return caches.open(name).then(function(cache) {
     c = cache;
@@ -67,21 +69,21 @@ function testRequest(request, unknownReq
     is(typeof r, "undefined", "Searching for an HEAD request should not succeed");
     return c.match(new Request(request, {method: "HEAD"}), {ignoreMethod: true});
   }).then(function(r) {
     return checkResponse(r);
   }).then(function() {
     return Promise.all(
       ["HEAD", "POST", "PUT", "DELETE", "OPTIONS"]
         .map(function(method) {
-          var req = new Request(request, {method});
-          return c.match(req)
+          var req1 = new Request(request, {method});
+          return c.match(req1)
             .then(function(r) {
               is(typeof r, "undefined", "Searching for a request with a non-GET method should not succeed");
-              return c.match(req, {ignoreMethod: true});
+              return c.match(req1, {ignoreMethod: true});
             }).then(function(r) {
               return checkResponse(r);
             });
         })
     );
   }).then(function() {
     return caches.match(request);
   }).then(function(r) {
--- a/dom/cache/test/mochitest/test_cache_match_vary.js
+++ b/dom/cache/test/mochitest/test_cache_match_vary.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var requestURL = "//mochi.test:8888/tests/dom/cache/test/mochitest/vary.sjs?" + context;
 var name = "match-vary" + context;
 
 function checkResponse(r, response, responseText) {
   ok(r !== response, "The objects should not be the same");
   is(r.url, response.url.replace("#fragment", ""),
      "The URLs should be the same");
   is(r.status, response.status, "The status codes should be the same");
@@ -31,18 +33,18 @@ function setupTest(headers) {
   });
 }
 function setupTestMultipleEntries(headers) {
   ok(Array.isArray(headers), "headers should be an array");
   return new Promise(function(resolve, reject) {
     var response, responseText, cache;
     Promise.all(headers.map(function(h) {
       return fetch(requestURL, {headers: h});
-    })).then(function(r) {
-        response = r;
+    })).then(function(res) {
+        response = res;
         return Promise.all(response.map(function(r) {
           return r.text();
         }));
       }).then(function(text) {
         responseText = text;
         return caches.open(name);
       }).then(function(c) {
         cache = c;
@@ -110,17 +112,16 @@ function testStar() {
   function ensurePromiseRejected(promise) {
     return promise
       .then(function() {
         ok(false, "Promise should be rejected");
       }, function(err) {
         is(err.name, "TypeError", "Attempting to store a Response with a Vary:* header must fail");
       });
   }
-  var test;
   return new Promise(function(resolve, reject) {
     var cache;
     caches.open(name).then(function(c) {
       cache = c;
       Promise.all([
         ensurePromiseRejected(
           cache.add(new Request(requestURL + "1", {headers: {"WhatToVary": "*"}}))),
         ensurePromiseRejected(
--- a/dom/cache/test/mochitest/test_cache_orphaned_body.html
+++ b/dom/cache/test/mochitest/test_cache_orphaned_body.html
@@ -92,17 +92,16 @@ SpecialPowers.pushPrefEnv({
           ["dom.quotaManager.testing", true],
           ["dom.storageManager.enabled", true]],
 }, function() {
   var name = "orphanedBodyOwner";
   var cache = null;
   var response = null;
   var initialUsage = 0;
   var fullUsage = 0;
-  var resetUsage = 0;
   var endUsage = 0;
   var url = "test_cache_add.js";
 
   // start from a fresh origin directory so other tests do not influence our
   // results
   setupTestIframe().then(function() {
     return clearStorage();
   }).then(function() {
--- a/dom/cache/test/mochitest/test_cache_orphaned_cache.html
+++ b/dom/cache/test/mochitest/test_cache_orphaned_cache.html
@@ -64,17 +64,16 @@ SpecialPowers.pushPrefEnv({
   "set": [["dom.caches.enabled", true],
           ["dom.caches.testing.enabled", true],
           ["dom.quotaManager.testing", true]],
 }, function() {
   var name = "toBeOrphaned";
   var cache = null;
   var initialUsage = 0;
   var fullUsage = 0;
-  var resetUsage = 0;
   var endUsage = 0;
   var url = "test_cache_add.js";
 
   // start from a fresh origin directory so other tests do not influence our
   // results
   setupTestIframe().then(function() {
     return clearStorage();
   }).then(function() {
--- a/dom/cache/test/mochitest/test_cache_overwrite.js
+++ b/dom/cache/test/mochitest/test_cache_overwrite.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var requestURL = "//mochi.test:8888/tests/dom/cache/test/mochitest/mirror.sjs?" + context;
 var response;
 var c;
 var responseText;
 var name = "match-mirror" + context;
 
 function checkResponse(r) {
   ok(r !== response, "The objects should not be the same");
--- a/dom/cache/test/mochitest/test_cache_padding.html
+++ b/dom/cache/test/mochitest/test_cache_padding.html
@@ -71,17 +71,17 @@ async function verifyUsage() {
 
 async function waitForIOToComplete(cache, request) {
   info("Wait for IO complete.");
   // The following lines ensure we've deleted orphaned body.
   // First, wait for cache operation delete the orphaned body.
   await cache.match(request);
 
   // Finally, wait for -wal file finish its job.
-  return await resetStorage();
+  return resetStorage();
 }
 
 function fetchOpaqueResponse(url) {
   return fetch(url, { mode: "no-cors" });
 }
 
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.pushPrefEnv({
--- a/dom/cache/test/mochitest/test_cache_put.js
+++ b/dom/cache/test/mochitest/test_cache_put.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var url = "test_cache.js";
 var cache;
 var fetchResponse;
 Promise.all([fetch(url),
              caches.open("putter" + context)]).then(function(results) {
   fetchResponse = results[0];
   cache = results[1];
   return cache.put(url, fetchResponse.clone());
--- a/dom/cache/test/mochitest/test_cache_put_reorder.js
+++ b/dom/cache/test/mochitest/test_cache_put_reorder.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var name = "putreorder" + context;
 var c;
 
 var reqs = [
   "//mochi.test:8888/?foo" + context,
   "//mochi.test:8888/?bar" + context,
   "//mochi.test:8888/?baz" + context,
 ];
--- a/dom/cache/test/mochitest/test_cache_redirect.js
+++ b/dom/cache/test/mochitest/test_cache_redirect.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 let cache;
 let url = "foo.html";
 let redirectURL = "http://example.com/foo-bar.html";
 caches.open("redirect-" + context).then(c => {
   cache = c;
   var response = Response.redirect(redirectURL);
   is(response.headers.get("Location"), redirectURL);
   return cache.put(url, response);
--- a/dom/cache/test/mochitest/test_cache_requestCache.js
+++ b/dom/cache/test/mochitest/test_cache_requestCache.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 var name = "requestCache" + context;
 var c;
 
 var reqWithoutCache = new Request("//mochi.test:8888/?noCache" + context);
 var reqWithCache = new Request("//mochi.test:8888/?withCache" + context,
                                {cache: "force-cache"});
 
 // Sanity check
--- a/dom/cache/test/mochitest/test_cache_updateUsage.html
+++ b/dom/cache/test/mochitest/test_cache_updateUsage.html
@@ -71,17 +71,17 @@ async function verifyUsage() {
 
 async function waitForIOToComplete(cache, request) {
   info("Wait for IO complete.");
   // The following lines ensure we've deleted orphaned body.
   // First, wait for cache operation delete the orphaned body.
   await cache.match(request);
 
   // Finally, wait for -wal file finish its job.
-  return await resetStorage();
+  return resetStorage();
 }
 
 SimpleTest.waitForExplicitFinish();
 SpecialPowers.pushPrefEnv({
   "set": [["dom.caches.enabled", true],
           ["dom.caches.testing.enabled", true],
           ["dom.quotaManager.testing", true]],
 }, async function() {
@@ -132,17 +132,17 @@ SpecialPowers.pushPrefEnv({
   await verifyUsage();
   info("Stage 3.2.1: Delete cache.");
   await cache.delete(url);
   await waitForIOToComplete(cache, url);
   let emptyUsage2 = await verifyUsage();
 
   info("Stage 3.3: Verify cache.put.");
   cache = await caches.open(name);
-  response = await fetch(other_url);
+  let response = await fetch(other_url);
   await cache.put(other_url, response);
   await verifyUsage();
   info("Stage 3.3.1: Delete cache.");
   await cache.delete(other_url);
   await waitForIOToComplete(cache, other_url);
   let emptyUsage3 = await verifyUsage();
 
   // Adding same requests twice will make Cache create morgue file twice, and
--- a/dom/cache/test/mochitest/test_caches.js
+++ b/dom/cache/test/mochitest/test_caches.js
@@ -1,8 +1,10 @@
+/* global context testDone:true */
+
 function arraysHaveSameContent(arr1, arr2) {
   if (arr1.length != arr2.length) {
     return false;
   }
   return arr1.every(function(value, index) {
     return arr2[index] === value;
   });
 }
--- a/dom/cache/test/mochitest/worker_driver.js
+++ b/dom/cache/test/mochitest/worker_driver.js
@@ -34,37 +34,37 @@ function workerTestExec(script) {
          "Correct context for messages received on the worker");
       if (event.data.type == "finish") {
         worker.terminate();
         SpecialPowers.forceGC();
         resolve();
       } else if (event.data.type == "status") {
         ok(event.data.status, event.data.context + ": " + event.data.msg);
       } else if (event.data.type == "getPrefs") {
-        var result = {};
+        let result = {};
         event.data.prefs.forEach(function(pref) {
           result[pref] = SpecialPowers.Services.prefs.getBoolPref(pref);
         });
         worker.postMessage({
           type: "returnPrefs",
           prefs: event.data.prefs,
           result,
         });
       } else if (event.data.type == "getPermissions") {
-        var result = {};
+        let result = {};
         event.data.permissions.forEach(function(permission) {
           result[permission] = SpecialPowers.hasPermission(permission, window.document);
         });
         worker.postMessage({
           type: "returnPermissions",
           permissions: event.data.permissions,
           result,
         });
       } else if (event.data.type == "getVersion") {
-        var result = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
+        let result = Services.appinfo.version;
         worker.postMessage({
           type: "returnVersion",
           result,
         });
       } else if (event.data.type == "getUserAgent") {
         worker.postMessage({
           type: "returnUserAgent",
           result: navigator.userAgent,
--- a/dom/cache/test/mochitest/worker_wrapper.js
+++ b/dom/cache/test/mochitest/worker_wrapper.js
@@ -1,8 +1,10 @@
+/* eslint-env worker */
+
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/publicdomain/zero/1.0/
 //
 // ServiceWorker equivalent of worker_wrapper.js.
 
 var client;
 var context;
 
@@ -95,22 +97,22 @@ function workerTestGetUserAgent(cb) {
 var completeInstall = null;
 
 addEventListener("message", function workerWrapperOnMessage(e) {
   removeEventListener("message", workerWrapperOnMessage);
   var data = e.data;
   function runScript() {
     try {
       importScripts(data.script);
-    } catch (e) {
+    } catch (err) {
       client.postMessage({
         type: "status",
         status: false,
         context,
-        msg: "worker failed to import " + data.script + "; error: " + e.message,
+        msg: "worker failed to import " + data.script + "; error: " + err.message,
       });
     }
   }
   if ("ServiceWorker" in self) {
     self.clients.matchAll({ includeUncontrolled: true }).then(function(clients) {
       for (var i = 0; i < clients.length; ++i) {
         if (clients[i].url.indexOf("message_receiver.html") > -1) {
           client = clients[i];
--- a/dom/cache/test/xpcshell/head.js
+++ b/dom/cache/test/xpcshell/head.js
@@ -1,33 +1,35 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  *
  * All images in schema_15_profile.zip are from https://github.com/mdn/sw-test/
  * and are CC licensed by https://www.flickr.com/photos/legofenris/.
  */
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 // services required be initialized in order to run CacheStorage
 var ss = Cc["@mozilla.org/storage/service;1"]
          .createInstance(Ci.mozIStorageService);
 var sts = Cc["@mozilla.org/network/stream-transport-service;1"]
           .getService(Ci.nsIStreamTransportService);
 var hash = Cc["@mozilla.org/security/hash;1"]
            .createInstance(Ci.nsICryptoHash);
 
 // Expose Cache and Fetch symbols on the global
 Cu.importGlobalProperties(["caches", "File", "fetch"]);
 
 // Extract a zip file into the profile
 function create_test_profile(zipFileName) {
   do_get_profile();
 
-  var directoryService = Cc["@mozilla.org/file/directory_service;1"]
-                         .getService(Ci.nsIProperties);
+  var directoryService = Services.dirsvc;
+
   var profileDir = directoryService.get("ProfD", Ci.nsIFile);
   var currentDir = directoryService.get("CurWorkD", Ci.nsIFile);
 
   var packageFile = currentDir.clone();
   packageFile.append(zipFileName);
 
   var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"]
                   .createInstance(Ci.nsIZipReader);
@@ -63,18 +65,17 @@ function create_test_profile(zipFileName
       bostream.close();
     }
   }
 
   zipReader.close();
 }
 
 function getCacheDir() {
-  let dirService = Cc["@mozilla.org/file/directory_service;1"]
-                   .getService(Ci.nsIProperties);
+  let dirService = Services.dirsvc;
 
   let profileDir = dirService.get("ProfD", Ci.nsIFile);
   let cacheDir = profileDir.clone();
   cacheDir.append("storage");
   cacheDir.append("default");
   cacheDir.append("chrome");
   cacheDir.append("cache");
 
--- a/dom/cache/test/xpcshell/make_profile.js
+++ b/dom/cache/test/xpcshell/make_profile.js
@@ -1,16 +1,18 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  *
  * All images in schema_15_profile.zip are from https://github.com/mdn/sw-test/
  * and are CC licensed by https://www.flickr.com/photos/legofenris/.
  */
 
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 // Enumerate the directory tree and store results in entryList as
 //
 //  { path: 'a/b/c', file: <nsIFile> }
 //
 // The algorithm starts with the first entry already in entryList.
 function enumerate_tree(entryList) {
   for (var index = 0; index < entryList.length; ++index) {
     var path = entryList[index].path;
@@ -76,18 +78,17 @@ function exactGC() {
   });
 }
 
 function resetQuotaManager() {
   return new Promise(function(resolve) {
     var qm = Cc["@mozilla.org/dom/quota/manager;1"]
              .getService(Ci.nsIQuotaManager);
 
-    var prefService = Cc["@mozilla.org/preferences-service;1"]
-                      .getService(Ci.nsIPrefService);
+    var prefService = Services.prefs;
 
     // enable quota manager testing mode
     var pref = "dom.quotaManager.testing";
     prefService.getBranch(null).setBoolPref(pref, true);
 
     var request = qm.reset();
     request.callback = resolve;
 
@@ -95,18 +96,17 @@ function resetQuotaManager() {
     // prefService.getBranch(null).setBoolPref(pref, false);
   });
 }
 
 function run_test() {
   do_test_pending();
   do_get_profile();
 
-  var directoryService = Cc["@mozilla.org/file/directory_service;1"]
-                         .getService(Ci.nsIProperties);
+  var directoryService = Services.dirsvc;
   var profileDir = directoryService.get("ProfD", Ci.nsIFile);
   var currentDir = directoryService.get("CurWorkD", Ci.nsIFile);
 
   var zipFile = currentDir.clone();
   zipFile.append("new_profile.zip");
   if (zipFile.exists()) {
     zipFile.remove(false);
   }