Bug 1496082: Enable ESLint for docshell/test/navigation and docshell/test/unit (manual fixes) r=bzbarsky
☠☠ backed out by 1942bfe9ee2d ☠ ☠
authorToby Ward <tobyfrederickward@gmail.com>
Tue, 06 Nov 2018 17:03:39 +0000
changeset 444718 776b54474da922d36446aa7cb6e93354767d0913
parent 444717 0852730f9ecda10bce8839574a9c9be374e6a7fa
child 444719 2f15ccbf77a6bf615fe880ab2044fe96d9021381
push id109636
push userncsoregi@mozilla.com
push dateWed, 07 Nov 2018 10:00:15 +0000
treeherdermozilla-inbound@64e32a13c482 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1496082
milestone65.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 1496082: Enable ESLint for docshell/test/navigation and docshell/test/unit (manual fixes) r=bzbarsky Implemented the manual linting fixes for docshell/test/navigation, docshell/test/unit and docshell/test/unit_ipc Depends on D9430 Differential Revision: https://phabricator.services.mozilla.com/D10080
docshell/test/navigation/.eslintrc.js
docshell/test/navigation/NavigationUtils.js
docshell/test/navigation/browser_bug343515.js
docshell/test/navigation/file_bug1326251.html
docshell/test/navigation/file_bug1379762-1.html
docshell/test/navigation/file_bug1379762-2.html
docshell/test/navigation/file_bug462076_1.html
docshell/test/navigation/file_bug462076_2.html
docshell/test/navigation/file_bug462076_3.html
docshell/test/navigation/file_bug508537_1.html
docshell/test/navigation/file_scrollRestoration.html
docshell/test/navigation/file_static_and_dynamic_1.html
docshell/test/navigation/file_triggeringprincipal_subframe_nav.html
docshell/test/navigation/navigate.html
docshell/test/navigation/test_bug270414.html
docshell/test/navigation/test_bug430624.html
docshell/test/navigation/test_bug430723.html
docshell/test/navigation/test_contentpolicy_block_window.html
docshell/test/navigation/test_not-opener.html
docshell/test/navigation/test_popup-navigates-children.html
docshell/test/navigation/test_reserved.html
docshell/test/navigation/test_triggeringprincipal_frame_nav.html
docshell/test/navigation/test_triggeringprincipal_parent_iframe_window_open.html
docshell/test/unit/head_docshell.js
docshell/test/unit/test_bug442584.js
docshell/test/unit/test_nsDefaultURIFixup.js
docshell/test/unit/test_nsDefaultURIFixup_info.js
docshell/test/unit/test_nsDefaultURIFixup_search.js
docshell/test/unit/test_pb_notification.js
docshell/test/unit_ipc/test_pb_notification_ipc.js
--- a/docshell/test/navigation/.eslintrc.js
+++ b/docshell/test/navigation/.eslintrc.js
@@ -1,8 +1,16 @@
 "use strict";
 
 module.exports = {
   "extends": [
     "plugin:mozilla/browser-test",
     "plugin:mozilla/mochitest-test",
-  ]
+  ],
+  
+  "plugins": [
+    "no-unsanitized",
+  ],
+
+  "rules": {
+    "no-unsanitized/method": "off",
+  },
 };
--- a/docshell/test/navigation/NavigationUtils.js
+++ b/docshell/test/navigation/NavigationUtils.js
@@ -91,17 +91,18 @@ function isInaccessible(wnd, message) {
   } catch (ex) {
     ok(true, message);
   }
 }
 
 // /////////////////////////////////////////////////////////////////////////
 // Functions that require UniversalXPConnect privilege
 // /////////////////////////////////////////////////////////////////////////
-
+// Replacing the getService with Services.ww format causes test errors, so ignore for now
+/* eslint-disable mozilla/use-services */
 function xpcEnumerateContentWindows(callback) {
 
   var Ci = SpecialPowers.Ci;
   var ww = SpecialPowers.Cc["@mozilla.org/embedcomp/window-watcher;1"]
                         .getService(Ci.nsIWindowWatcher);
 
   var contentWindows = [];
 
@@ -122,16 +123,17 @@ function xpcEnumerateContentWindows(call
     } else {
       contentWindows.push(win);
     }
   }
 
   while (contentWindows.length > 0)
     callback(contentWindows.pop());
 }
+/* eslint-enable mozilla/use-services */
 
 // Note: This only searches for top-level frames with this name.
 function xpcGetFramesByName(name) {
   var results = [];
 
   xpcEnumerateContentWindows(function(win) {
     if (win.name == name)
       results.push(win);
@@ -202,9 +204,8 @@ function xpcWaitForFinishedFrames(callba
     } catch (ex) {
       // We might be accessing windows before they are fully constructed,
       // which can throw.  We'll find those frames on our next poll().
     }
   }
 
   var frameWaitInterval = setInterval(poll, 500);
 }
-
--- a/docshell/test/navigation/browser_bug343515.js
+++ b/docshell/test/navigation/browser_bug343515.js
@@ -90,31 +90,31 @@ function step3() {
   ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
 
   // Tab 2's window _and_ its iframes should be inactive
   ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
   ContentTask.spawn(ctx.tab2Browser, null, async function() {
     Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes");
     for (var i = 0; i < content.frames.length; i++) {
       info("step 3, frame " + i + " info: " + content.frames[i].location);
-      let docshell = content.frames[i].docShell;
-
+      let docShell = content.frames[i].docShell;
       Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
     }
   }).then(() => {
     // Navigate tab 2 to a different page
     BrowserTestUtils.loadURI(ctx.tab2Browser, testPath + "bug343515_pg3.html");
 
     // bug343515_pg3.html consists of a page with two iframes, one of which
     // contains another iframe, so there'll be a total of 4 load events
     nShotsListener(ctx.tab2Browser, "load", step4, 4);
   });
 }
 
 function step4() {
+  /* eslint-disable no-shadow */
   function checkTab2Active(expected) {
     return ContentTask.spawn(ctx.tab2Browser, expected, async function(expected) {
       function isActive(aWindow) {
         var docshell = aWindow.docShell;
         return docshell.isActive;
       }
 
       let active = expected ? "active" : "inactive";
@@ -123,17 +123,17 @@ function step4() {
         info("step 4, frame " + i + " info: " + content.frames[i].location);
       Assert.equal(content.frames[0].frames.length, 1, "Tab 2 iframe 0 should have 1 iframes");
       Assert.equal(isActive(content.frames[0]), expected, `Tab2 iframe 0 should be ${active}`);
       Assert.equal(isActive(content.frames[0].frames[0]), expected,
          `Tab2 iframe 0 subiframe 0 should be ${active}`);
       Assert.equal(isActive(content.frames[1]), expected, `Tab2 iframe 1 should be ${active}`);
     });
   }
-
+  /* eslint-enable no-shadow */
   is(testPath + "bug343515_pg3.html", ctx.tab2Browser.currentURI.spec,
      "Got expected tab 2 url in step 4");
 
   // Tab 0 should be inactive, Tab 1 should be active
   ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
   ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
 
   // Tab2 and all descendants should be inactive
@@ -156,18 +156,17 @@ function step4() {
 
 function step5() {
   // Check everything
   ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
   ok(!ctx.tab1Browser.docShellIsActive, "Tab 1 should be inactive");
   ok(ctx.tab2Browser.docShellIsActive, "Tab 2 should be active");
   ContentTask.spawn(ctx.tab2Browser, null, async function() {
     for (var i = 0; i < content.frames.length; i++) {
-      let docshell = content.frames[i].docShell;
-
+      let docShell = content.frames[i].docShell;
       Assert.ok(docShell.isActive, `Tab2 iframe ${i} should be active`);
     }
   }).then(() => {
     // Switch to tab 1
     return BrowserTestUtils.switchTab(gBrowser, ctx.tab1);
   }).then(() => {
     // Navigate to page 3
     BrowserTestUtils.loadURI(ctx.tab1Browser, testPath + "bug343515_pg3.html");
@@ -191,29 +190,29 @@ function step6() {
 
     Assert.ok(isActive(content.frames[0]), "Tab1 iframe 0 should be active");
     Assert.ok(isActive(content.frames[0].frames[0]), "Tab1 iframe 0 subiframe 0 should be active");
     Assert.ok(isActive(content.frames[1]), "Tab1 iframe 1 should be active");
   }).then(() => {
     ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
     return ContentTask.spawn(ctx.tab2Browser, null, async function() {
       for (var i = 0; i < content.frames.length; i++) {
-        let docshell = content.frames[i].docShell;
-
+        let docShell = content.frames[i].docShell;
         Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`);
       }
     });
   }).then(() => {
     // Go forward on tab 2
     waitForPageshow(ctx.tab2Browser, step7);
     ctx.tab2Browser.goForward();
   });
 }
 
 function step7() {
+  /* eslint-disable no-shadow */
   function checkBrowser(browser, tabNum, active) {
     return ContentTask.spawn(browser, { tabNum, active },
                              async function({ tabNum, active }) {
              function isActive(aWindow) {
                var docshell = aWindow.docShell;
                return docshell.isActive;
              }
 
@@ -221,29 +220,30 @@ function step7() {
              Assert.equal(isActive(content.frames[0]), active,
                 `Tab${tabNum} iframe 0 should be ${activestr}`);
              Assert.equal(isActive(content.frames[0].frames[0]), active,
                 `Tab${tabNum} iframe 0 subiframe 0 should be ${activestr}`);
              Assert.equal(isActive(content.frames[1]), active,
                 `Tab${tabNum} iframe 1 should be ${activestr}`);
            });
   }
-
+  /* eslint-enable no-shadow */
   // Check everything
   ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
   ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
   checkBrowser(ctx.tab1Browser, 1, true).then(() => {
     ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive");
     return checkBrowser(ctx.tab2Browser, 2, false);
   }).then(() => {
     // That's probably enough
     allDone();
   });
 }
 
+
 function allDone() {
 
   // Close the tabs we made
   gBrowser.removeTab(ctx.tab1);
   gBrowser.removeTab(ctx.tab2);
 
   // Tell the framework we're done
   finish();
--- a/docshell/test/navigation/file_bug1326251.html
+++ b/docshell/test/navigation/file_bug1326251.html
@@ -7,17 +7,17 @@
     const BASE_URL = "http://mochi.test:8888/tests/docshell/test/navigation/";
     let testSteps = [
       async function() {
         // Test 1: Create dynamic iframe with bfcache enabled.
         // Navigate static / dynamic iframes, then navigate top level window
         // and navigate back. Both iframes should still exist with history
         // entries preserved.
         window.onunload = null; // enable bfcache
-        let dynamicFrame = await createDynamicFrame(document);
+        await createDynamicFrame(document);
         await loadUriInFrame(document.getElementById("staticFrame"), "frame1.html");
         await loadUriInFrame(document.getElementById("dynamicFrame"), "frame1.html");
         await loadUriInFrame(document.getElementById("staticFrame"), "frame2.html");
         await loadUriInFrame(document.getElementById("dynamicFrame"), "frame2.html");
         opener.is(history.length, 5, "history.length");
         window.location = "goback.html";
       },
       async function() {
--- a/docshell/test/navigation/file_bug1379762-1.html
+++ b/docshell/test/navigation/file_bug1379762-1.html
@@ -9,16 +9,17 @@
     onunload = null; // enable bfcache
     opener.is(opener.testCount, 0,
               "We should only run once; otherwise the loadCount variable makes no sense");
     var loadCount = 0;
     onpageshow = function() {
       ++opener.testCount;
       if (opener.testCount == 1) {
         // Navigate forward and then back.
+        // eslint-disable-next-line no-global-assign
         setTimeout(function() { location = "goback.html"; }, 0);
       } else if (opener.testCount == 2) {
         // Do this async so our load event gets a chance to fire if it plans to
         // do it.
         setTimeout(function() {
           opener.nextTest();
           window.close();
         });
--- a/docshell/test/navigation/file_bug1379762-2.html
+++ b/docshell/test/navigation/file_bug1379762-2.html
@@ -32,12 +32,13 @@
         window.close();
       }
     }
   </script>
   <script>
     var data = document.querySelector("script[type='text/just-data']").textContent;
     // Store the string that does all out work in a global variable, so we can
     // get at it later.
+    // eslint-disable-next-line no-useless-concat
     var testScript = "<script>" + data + "</" + "script>";
     document.write(testScript);
   </script>
 </html>
--- a/docshell/test/navigation/file_bug462076_1.html
+++ b/docshell/test/navigation/file_bug462076_1.html
@@ -16,24 +16,24 @@
         document.getElementById("container" + index).appendChild(ifr);
       }
 
       function runTest() {
         var randomNumber = Math.floor(Math.random() * 4);
         for (var i = randomNumber; i < 4; ++i) {
           makeFrame(i);
         }
-        for (var i = 0; i < randomNumber; ++i) {
-          makeFrame(i);
+        for (var k = 0; k < randomNumber; ++k) {
+          makeFrame(k);
         }
       }
 
       function checkFrame(evt) {
         var ifr = evt.target;
-        opener.ok(new String(ifr.contentWindow.location).includes(ifr.src),
+        opener.ok(String(ifr.contentWindow.location).includes(ifr.src),
            "Wrong document loaded (" + ifr.src + ", " +
            ifr.contentWindow.location + ")!");
 
         if (++checkCount == 4) {
           if (++opener.testCount == 10) {
             opener.nextTest();
             window.close();
           } else {
--- a/docshell/test/navigation/file_bug462076_2.html
+++ b/docshell/test/navigation/file_bug462076_2.html
@@ -16,24 +16,24 @@
         document.getElementById("container" + index).appendChild(ifr);
       }
 
       function runTest() {
         var randomNumber = Math.floor(Math.random() * 4);
         for (var i = randomNumber; i < 4; ++i) {
           makeFrame(i);
         }
-        for (var i = 0; i < randomNumber; ++i) {
-          makeFrame(i);
+        for (var k = 0; k < randomNumber; ++k) {
+          makeFrame(k);
         }
       }
 
       function checkFrame(evt) {
         var ifr = evt.target;
-        opener.ok(new String(ifr.contentWindow.location).includes(ifr.src),
+        opener.ok(String(ifr.contentWindow.location).includes(ifr.src),
            "Wrong document loaded (" + ifr.src + ", " +
            ifr.contentWindow.location + ")!");
 
         if (++checkCount == 4) {
           if (++opener.testCount == 10) {
             opener.nextTest();
             window.close();
           } else {
--- a/docshell/test/navigation/file_bug462076_3.html
+++ b/docshell/test/navigation/file_bug462076_3.html
@@ -16,24 +16,24 @@
         document.getElementById("container" + index).appendChild(ifr);
       }
 
       function runTest() {
         var randomNumber = Math.floor(Math.random() * 4);
         for (var i = randomNumber; i < 4; ++i) {
           makeFrame(i);
         }
-        for (var i = 0; i < randomNumber; ++i) {
-          makeFrame(i);
+        for (var k = 0; k < randomNumber; ++k) {
+          makeFrame(k);
         }
       }
 
       function checkFrame(evt) {
         var ifr = evt.target;
-        opener.ok(new String(ifr.contentWindow.location).includes(ifr.src),
+        opener.ok(String(ifr.contentWindow.location).includes(ifr.src),
            "Wrong document loaded (" + ifr.src + ", " +
            ifr.contentWindow.location + ")!");
 
         if (++checkCount == 4) {
           if (++opener.testCount == 10) {
             opener.nextTest();
             window.close();
           } else {
--- a/docshell/test/navigation/file_bug508537_1.html
+++ b/docshell/test/navigation/file_bug508537_1.html
@@ -1,16 +1,16 @@
 <html>
   <head>
     <script>
       function dynFrameLoad() {
         var ifrs = document.getElementsByTagName("iframe");
-        opener.ok(new String(ifrs[0].contentWindow.location).includes(ifrs[0].src),
+        opener.ok(String(ifrs[0].contentWindow.location).includes(ifrs[0].src),
                   "Wrong document loaded (1)\n");
-        opener.ok(new String(ifrs[1].contentWindow.location).includes(ifrs[1].src),
+        opener.ok(String(ifrs[1].contentWindow.location).includes(ifrs[1].src),
                   "Wrong document loaded (2)\n");
         if (opener && ++opener.testCount == 1) {
           window.location = "goback.html";
         } else {
           opener.nextTest();
           window.close();
         }
       }
--- a/docshell/test/navigation/file_scrollRestoration.html
+++ b/docshell/test/navigation/file_scrollRestoration.html
@@ -99,17 +99,17 @@
           }
           case 7: {
             oldHistoryObject = SpecialPowers.wrap(event.target).contentWindow.history;
             event.target.src = "about:blank";
             break;
           }
           case 8: {
             try {
-              var sr = oldHistoryObject.scrollRestoration;
+              oldHistoryObject.scrollRestoration;
               opener.ok(false, "Should have thrown an exception.");
             } catch (ex) {
               opener.isnot(ex, null, "Did get an exception");
             }
             try {
               oldHistoryObject.scrollRestoration = "auto";
               opener.ok(false, "Should have thrown an exception.");
             } catch (ex) {
--- a/docshell/test/navigation/file_static_and_dynamic_1.html
+++ b/docshell/test/navigation/file_static_and_dynamic_1.html
@@ -10,17 +10,17 @@
       staticFrame.contentWindow.location = "frame1.html";
     }
 
     function start() {
       if (++opener.testCount == 1) {
         test();
       } else {
         var staticFrame = document.getElementById("staticframe");
-        opener.ok(new String(staticFrame.contentWindow.location).includes(staticFrame.src),
+        opener.ok(String(staticFrame.contentWindow.location).includes(staticFrame.src),
                   "Wrong document loaded!");
         opener.nextTest();
         window.close();
       }
     }
     </script>
   </head>
   <body onload="setTimeout('start()', 0)">
--- a/docshell/test/navigation/file_triggeringprincipal_subframe_nav.html
+++ b/docshell/test/navigation/file_triggeringprincipal_subframe_nav.html
@@ -1,21 +1,21 @@
 <!DOCTYPE HTML>
 <html>
 <head><meta charset="utf-8"></head>
 <body onload="checkResults()">
 <b>Sub Frame 2 Navigated</b><br/>
 
 <script type='application/javascript'>
   function checkResults() {
-  	// query the uri of the loadingPrincipal and the TriggeringPrincipal and pass
-  	// that information on to the parent for verification.
+    // query the uri of the loadingPrincipal and the TriggeringPrincipal and pass
+    // that information on to the parent for verification.
     var channel = SpecialPowers.wrap(window).docShell.currentDocumentChannel;
     var triggeringPrincipalURI = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
     var loadingPrincipalURI = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
     var referrerURI = document.referrer;
     window.parent.parent.postMessage({triggeringPrincipalURI,
-    	                              loadingPrincipalURI,
-    	                              referrerURI}, "*");
+                                    loadingPrincipalURI,
+                                    referrerURI}, "*");
   }
 </script>
 </body>
 </html>
--- a/docshell/test/navigation/navigate.html
+++ b/docshell/test/navigation/navigate.html
@@ -1,20 +1,21 @@
 <html>
 <head>
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <script src="NavigationUtils.js"></script>
     <script>
     function navigate() {
-        var arguments = window.location.hash.substring(1).split(",");
-        var target = arguments[0];
-        var mechanism = arguments[1];
+        var args = window.location.hash.substring(1).split(",");
+        var target = args[0];
+        var mechanism = args[1];
 
         switch (mechanism) {
         case "location":
+          // eslint-disable-next-line no-eval
           navigateByLocation(eval(target));
           break;
         case "open":
           navigateByOpen(target);
           break;
         case "form":
           navigateByForm(target);
           break;
@@ -22,15 +23,15 @@
           navigateByHyperlink(target);
           break;
         }
     }
     </script>
 </head>
 <body onload="navigate();">
 <script>
-var arguments = window.location.hash.substring(1).split(",");
-var target = arguments[0];
-var mechanism = arguments[1];
+var args = window.location.hash.substring(1).split(",");
+var target = args[0];
+var mechanism = args[1];
 document.write("target=" + target + " mechanism=" + mechanism);
 </script>
 </body>
 </html>
--- a/docshell/test/navigation/test_bug270414.html
+++ b/docshell/test/navigation/test_bug270414.html
@@ -4,22 +4,28 @@
     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     <script type="text/javascript" src="NavigationUtils.js"></script>        
     <style type="text/css">
       iframe { width: 90%; height: 50px; }
     </style>
 <script>
+/* eslint-disable no-useless-concat */
 var headerHTML = "<html><head>" +
                  "<script src='/tests/SimpleTest/EventUtils.js'></scr" + "ipt>" +
                  "<script src='NavigationUtils.js'></scr" + "ipt>" +
                  "</head><body>";
 var footerHTML = "</body></html>";
 
+let window0 = null;
+let window1 = null;
+let window2 = null;
+let window3 = null;
+
 function testChild0() {
   if (!window.window0) {
     window0 = window.open("", "window0", "width=10,height=10");
     window0.document.open();
     window0.document.write(headerHTML);
     window0.document.write("<script>navigateByLocation(opener.frames[0])</scr" + "ipt>");
     window0.document.write(footerHTML);
     window0.document.close();
--- a/docshell/test/navigation/test_bug430624.html
+++ b/docshell/test/navigation/test_bug430624.html
@@ -20,16 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 430624 **/
 
 function onLoad() {
   window.frames[0].frameElement.onload = onReload;
+  // eslint-disable-next-line no-self-assign
   window.frames[0].frameElement.srcdoc = window.frames[0].frameElement.srcdoc;
 }
 
 function onReload() {
   var iframe = window.frames[0].frameElement;
   SimpleTest.waitForFocus(doTest, iframe.contentWindow);
   iframe.contentDocument.body.focus();
 }
--- a/docshell/test/navigation/test_bug430723.html
+++ b/docshell/test/navigation/test_bug430723.html
@@ -74,30 +74,32 @@ var step1 = function() {
 
 var step2 = function() {
   window.is(String(testWindow.location), gTallBlueBoxURI, "Ensure blue page loaded.");
 
   // Scroll around a bit.
   is(testWindow.document.body.scrollTop, 0,
      "Page2: Ensure the scrollpane is at the top before we start scrolling.");
 
-  var count = 0;
-  testWindow.addEventListener("scroll", function() {
+  var scrollTest = function() {
     if (++count < 2) {
       SimpleTest.executeSoon(function() { sendKey("DOWN", testWindow); });
     } else {
-      testWindow.removeEventListener("scroll", arguments.callee, true);
+      testWindow.removeEventListener("scroll", scrollTest, true);
 
       isnot(testWindow.document.body.scrollTop, 0,
             "Page2: Ensure we could scroll.");
 
       // Navigate backwards. This should fire step3.
       testWindow.history.back();
     }
-  }, true);
+  };
+
+  var count = 0;
+  testWindow.addEventListener("scroll", scrollTest, true);
   sendKey("DOWN", testWindow);
 };
 
 var step3 = function() {
   window.is(String(testWindow.location), gTallRedBoxURI,
             "Ensure red page restored from history.");
 
   // Check we can still scroll with the keys.
--- a/docshell/test/navigation/test_contentpolicy_block_window.html
+++ b/docshell/test/navigation/test_contentpolicy_block_window.html
@@ -19,30 +19,33 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 <script class="testbody" type="text/javascript">
 /*
  * Description of the test:
  * The test tries to open a new window and makes sure that a registered contentPolicy
  * gets called with the right (a non null) 'context' for the TYPE_DOCUMENT load.
  */
 
+// Services.jsm is disabled as ChromeUtils appears to be out of scope
+/* eslint-disable mozilla/use-services */
+
 const Cc = SpecialPowers.Cc;
 const Ci = SpecialPowers.Ci;
 
 var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
 var componentManager = SpecialPowers.wrap(SpecialPowers.Components).manager
                                     .QueryInterface(Ci.nsIComponentRegistrar);
 
 // Content policy / factory implementation for the test
 var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{b80e19d0-878f-d41b-2654-194714a4115c}");
 var policyName = "@mozilla.org/testpolicy;1";
 var policy = {
   // nsISupports implementation
-  // eslint-disable-next-line mozilla/use-chromeutils-generatedqi.js
-  QueryInterface: function(iid) {
+  // eslint-disable-next-line mozilla/use-chromeutils-generateqi
+  QueryInterface(iid) {
     iid = SpecialPowers.wrap(iid);
     if (iid.equals(Ci.nsISupports) ||
         iid.equals(Ci.nsIFactory) ||
         iid.equals(Ci.nsIContentPolicy))
       return this;
     throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
   },
 
--- a/docshell/test/navigation/test_not-opener.html
+++ b/docshell/test/navigation/test_not-opener.html
@@ -30,19 +30,19 @@ window.onload = function() {
     opener3.close();
 
     xpcCleanupWindows();
     SimpleTest.finish();
   }, 6);
 };
 
 // opener0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window0", "_blank", "width=10,height=10");
-opener1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window1", "_blank", "width=10,height=10");
-opener2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window2", "_blank", "width=10,height=10");
-opener3 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window3", "_blank", "width=10,height=10");
+let opener1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window1", "_blank", "width=10,height=10");
+let opener2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window2", "_blank", "width=10,height=10");
+let opener3 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window3", "_blank", "width=10,height=10");
 </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408052">Mozilla Bug 408052</a>
 <pre id="test">
 <script type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 </script>
--- a/docshell/test/navigation/test_popup-navigates-children.html
+++ b/docshell/test/navigation/test_popup-navigates-children.html
@@ -4,16 +4,22 @@
     <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     <script type="text/javascript" src="NavigationUtils.js"></script>        
     <style type="text/css">
       iframe { width: 90%; height: 50px; }
     </style>
 <script>
+
+let window0 = null;
+let window1 = null;
+let window2 = null;
+let window3 = null;
+
 function testChild0() {
   if (!window.window0)
     window0 = window.open("navigate.html#opener.frames[0],location", "window0", "width=10,height=10");
 }
 
 function testChild1() {
   if (!window.window1)
     window1 = window.open("navigate.html#child1,open", "window1", "width=10,height=10");
--- a/docshell/test/navigation/test_reserved.html
+++ b/docshell/test/navigation/test_reserved.html
@@ -9,38 +9,38 @@
       iframe { width: 90%; height: 200px; }
     </style>
 <script>
 if (navigator.platform.startsWith("Mac")) {
   SimpleTest.expectAssertions(0, 2);
 }
 
 function testTop() {
-  window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10");
+  let window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10");
 
   xpcWaitForFinishedFrames(function() {
     isInaccessible(window0, "Should be able to navigate off-domain top by setting location.");
     window0.close();
     xpcCleanupWindows();
 
-    window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10");
+    let window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10");
 
     xpcWaitForFinishedFrames(function() {
       isInaccessible(window1, "Should be able to navigate off-domain top by calling window.open.");
       window1.close();
       xpcCleanupWindows();
 
-      window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10");
+      let window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10");
 
       xpcWaitForFinishedFrames(function() {
         isInaccessible(window2, "Should be able to navigate off-domain top by submitting form.");
         window2.close();
         xpcCleanupWindows();
 
-        window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10");
+        let window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10");
 
         xpcWaitForFinishedFrames(function() {
           isInaccessible(window3, "Should be able to navigate off-domain top by targeted hyperlink.");
           window3.close();
           xpcCleanupWindows();
 
           testParent();
         }, 1);
--- a/docshell/test/navigation/test_triggeringprincipal_frame_nav.html
+++ b/docshell/test/navigation/test_triggeringprincipal_frame_nav.html
@@ -43,19 +43,19 @@ const TRIGGERINGPRINCIPALURI = BASEURL1 
 const LOADINGPRINCIPALURI = BASEURL2 + "file_triggeringprincipal_frame_2.html";
 
 SimpleTest.waitForExplicitFinish();
 
 window.addEventListener("message", receiveMessage);
 
 function receiveMessage(event) {
   is(event.data.triggeringPrincipalURI, TRIGGERINGPRINCIPALURI,
-  	 "TriggeringPrincipal should be the navigating iframe (Frame 1)");
+     "TriggeringPrincipal should be the navigating iframe (Frame 1)");
   is(event.data.loadingPrincipalURI, LOADINGPRINCIPALURI,
-  	 "LoadingPrincipal should be the enclosing iframe (Frame 2)");
+     "LoadingPrincipal should be the enclosing iframe (Frame 2)");
   is(event.data.referrerURI, TRIGGERINGPRINCIPALURI,
      "Referrer and TriggeringPrincipal should be identical (Frame 1)");
 
   window.removeEventListener("message", receiveMessage);
   SimpleTest.finish();
 }
 
 var frame1 = document.getElementById("testframe1");
--- a/docshell/test/navigation/test_triggeringprincipal_parent_iframe_window_open.html
+++ b/docshell/test/navigation/test_triggeringprincipal_parent_iframe_window_open.html
@@ -51,17 +51,17 @@ function checkResults() {
     "LoadingPrincipal for targeted window.open() should be the <iframe>.ownerDocument");
 
   SimpleTest.finish();
 }
 
 function performNavigation() {
   testframe.removeEventListener("load", performNavigation);
   testframe.addEventListener("load", checkResults);
-  win = window.open("file_triggeringprincipal_parent_iframe_window_open_nav.html", "testframe");
+  window.open("file_triggeringprincipal_parent_iframe_window_open_nav.html", "testframe");
 }
 
 // start the test
 SimpleTest.waitForExplicitFinish();
 
 testframe.addEventListener("load", performNavigation);
 
 </script>
--- a/docshell/test/unit/head_docshell.js
+++ b/docshell/test/unit/head_docshell.js
@@ -1,7 +1,7 @@
 /* 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/. */
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
-             getService(Ci.nsIProperties);
+var dirSvc = Services.dirSvc;
 var profileDir = do_get_profile();
--- a/docshell/test/unit/test_bug442584.js
+++ b/docshell/test/unit/test_bug442584.js
@@ -1,30 +1,28 @@
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 var prefetch = Cc["@mozilla.org/prefetch-service;1"].
                getService(Ci.nsIPrefetchService);
-var ios = Cc["@mozilla.org/network/io-service;1"].
-          getService(Ci.nsIIOService);
-var prefs = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
 
 function run_test() {
   // Fill up the queue
-  prefs.setBoolPref("network.prefetch-next", true);
+  Services.prefs.setBoolPref("network.prefetch-next", true);
   for (var i = 0; i < 5; i++) {
-    var uri = ios.newURI("http://localhost/" + i);
+    var uri = Services.io.newURI("http://localhost/" + i);
     prefetch.prefetchURI(uri, uri, null, true);
   }
 
   // Make sure the queue has items in it...
   Assert.ok(prefetch.hasMoreElements());
 
   // Now disable the pref to force the queue to empty...
-  prefs.setBoolPref("network.prefetch-next", false);
+  Services.prefs.setBoolPref("network.prefetch-next", false);
   Assert.ok(!prefetch.hasMoreElements());
 
   // Now reenable the pref, and add more items to the queue.
-  prefs.setBoolPref("network.prefetch-next", true);
-  for (var i = 0; i < 5; i++) {
-    var uri = ios.newURI("http://localhost/" + i);
-    prefetch.prefetchURI(uri, uri, null, true);
+  Services.prefs.setBoolPref("network.prefetch-next", true);
+  for (var k = 0; k < 5; k++) {
+    var uri2 = Services.io.newURI("http://localhost/" + k);
+    prefetch.prefetchURI(uri2, uri2, null, true);
   }
   Assert.ok(prefetch.hasMoreElements());
 }
--- a/docshell/test/unit/test_nsDefaultURIFixup.js
+++ b/docshell/test/unit/test_nsDefaultURIFixup.js
@@ -1,12 +1,9 @@
-var urifixup = Cc["@mozilla.org/docshell/urifixup;1"].
-               getService(Ci.nsIURIFixup);
-var prefs = Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch);
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var pref = "browser.fixup.typo.scheme";
 
 var data = [
   {
     // ttp -> http.
     wrong: "ttp://www.example.com/",
     fixed: "http://www.example.com/",
@@ -57,43 +54,43 @@ var data = [
     fixed: "whatever://this/is/a/test.html",
   },
 ];
 
 var len = data.length;
 
 // Make sure we fix what needs fixing when there is no pref set.
 add_task(function test_unset_pref_fixes_typos() {
-  prefs.clearUserPref(pref);
+  Services.prefs.clearUserPref(pref);
   for (let i = 0; i < len; ++i) {
     let item = data[i];
     let result =
-      urifixup.createFixupURI(item.wrong,
-                              urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
+      Services.uriFixup.createFixupURI(item.wrong,
+                              Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
     Assert.equal(result, item.fixed);
   }
 });
 
 // Make sure we don't do anything when the pref is explicitly
 // set to false.
 add_task(function test_false_pref_keeps_typos() {
-  prefs.setBoolPref(pref, false);
+  Services.prefs.setBoolPref(pref, false);
   for (let i = 0; i < len; ++i) {
     let item = data[i];
     let result =
-      urifixup.createFixupURI(item.wrong,
-                              urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
+      Services.uriFixup.createFixupURI(item.wrong,
+                              Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
     Assert.equal(result, item.wrong);
   }
 });
 
 // Finally, make sure we still fix what needs fixing if the pref is
 // explicitly set to true.
 add_task(function test_true_pref_fixes_typos() {
-  prefs.setBoolPref(pref, true);
+  Services.prefs.setBoolPref(pref, true);
   for (let i = 0; i < len; ++i) {
     let item = data[i];
     let result =
-        urifixup.createFixupURI(item.wrong,
-                                urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
+        Services.uriFixup.createFixupURI(item.wrong,
+                                Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
     Assert.equal(result, item.fixed);
   }
 });
--- a/docshell/test/unit/test_nsDefaultURIFixup_info.js
+++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js
@@ -1,11 +1,8 @@
-var urifixup = Cc["@mozilla.org/docshell/urifixup;1"].
-               getService(Ci.nsIURIFixup);
-
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var prefList = ["browser.fixup.typo.scheme", "keyword.enabled",
                 "browser.fixup.domainwhitelist.whitelisted"];
 for (let pref of prefList) {
   Services.prefs.setBoolPref(pref, true);
 }
 
@@ -35,19 +32,19 @@ registerCleanupFunction(function() {
     Services.search.removeEngine(engine);
   }
   Services.prefs.clearUserPref("keyword.enabled");
   Services.prefs.clearUserPref("browser.fixup.typo.scheme");
   Services.prefs.clearUserPref(kForceHostLookup);
 });
 
 var flagInputs = [
-  urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP,
-  urifixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI,
-  urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS,
+  Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP,
+  Services.uriFixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI,
+  Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS,
 ];
 
 flagInputs.concat([
   flagInputs[0] | flagInputs[1],
   flagInputs[1] | flagInputs[2],
   flagInputs[0] | flagInputs[2],
   flagInputs[0] | flagInputs[1] | flagInputs[2],
 ]);
@@ -573,24 +570,24 @@ function do_single_test_run() {
     affectedByDNSForSingleHosts = !!affectedByDNSForSingleHosts;
 
     expectKeywordLookup = expectKeywordLookup && (!affectedByDNSForSingleHosts || !gSingleWordHostLookup);
 
     for (let flags of flagInputs) {
       let URIInfo;
       let fixupURIOnly = null;
       try {
-        fixupURIOnly = urifixup.createFixupURI(testInput, flags);
+        fixupURIOnly = Services.uriFixup.createFixupURI(testInput, flags);
       } catch (ex) {
         info("Caught exception: " + ex);
         Assert.equal(expectedFixedURI, null);
       }
 
       try {
-        URIInfo = urifixup.getFixupURIInfo(testInput, flags);
+        URIInfo = Services.uriFixup.getFixupURIInfo(testInput, flags);
       } catch (ex) {
         // Both APIs should return an error in the same cases.
         info("Caught exception: " + ex);
         Assert.equal(expectedFixedURI, null);
         Assert.equal(fixupURIOnly, null);
         continue;
       }
 
@@ -598,28 +595,26 @@ function do_single_test_run() {
            " (host lookup for single words: " + (gSingleWordHostLookup ? "yes" : "no") + ")");
 
       // Both APIs should then also be using the same spec.
       Assert.equal(!!fixupURIOnly, !!URIInfo.preferredURI);
       if (fixupURIOnly) {
         Assert.equal(fixupURIOnly.spec, URIInfo.preferredURI.spec, "Fixed and preferred URI should match");
       }
 
-      let isFileURL = expectedFixedURI && expectedFixedURI.startsWith("file");
-
       // Check the fixedURI:
-      let makeAlternativeURI = flags & urifixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI;
+      let makeAlternativeURI = flags & Services.uriFixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI;
       if (makeAlternativeURI && alternativeURI != null) {
         Assert.equal(URIInfo.fixedURI.spec, alternativeURI, "should have gotten alternate URI");
       } else {
         Assert.equal(URIInfo.fixedURI && URIInfo.fixedURI.spec, expectedFixedURI, "should get correct fixed URI");
       }
 
       // Check booleans on input:
-      let couldDoKeywordLookup = flags & urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
+      let couldDoKeywordLookup = flags & Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
       Assert.equal(!!URIInfo.keywordProviderName, couldDoKeywordLookup && expectKeywordLookup, "keyword lookup as expected");
       Assert.equal(URIInfo.fixupChangedProtocol, expectProtocolChange, "protocol change as expected");
       Assert.equal(URIInfo.fixupCreatedAlternateURI, makeAlternativeURI && alternativeURI != null, "alternative URI as expected");
 
       // Check the preferred URI
       if (couldDoKeywordLookup) {
         if (expectKeywordLookup) {
           if (!inWhitelist) {
--- a/docshell/test/unit/test_nsDefaultURIFixup_search.js
+++ b/docshell/test/unit/test_nsDefaultURIFixup_search.js
@@ -1,10 +1,8 @@
-var urifixup = Cc["@mozilla.org/docshell/urifixup;1"].
-               getService(Ci.nsIURIFixup);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 Services.prefs.setBoolPref("keyword.enabled", true);
 
 const kSearchEngineID = "test_urifixup_search_engine";
 const kSearchEngineURL = "http://www.example.org/?search={searchTerms}";
 Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
@@ -106,13 +104,13 @@ if (extProtocolSvc && extProtocolSvc.ext
 }
 
 var len = data.length;
 // Make sure we fix what needs fixing
 add_task(function test_fix_unknown_schemes() {
   for (let i = 0; i < len; ++i) {
     let item = data[i];
     let result =
-      urifixup.createFixupURI(item.wrong,
-                              urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
+      Services.uriFixup.createFixupURI(item.wrong,
+                              Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS).spec;
     Assert.equal(result, item.fixed);
   }
 });
--- a/docshell/test/unit/test_pb_notification.js
+++ b/docshell/test/unit/test_pb_notification.js
@@ -1,19 +1,18 @@
 function destroy_transient_docshell() {
   let windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
-  windowlessBrowser.docshell.setOriginAttributes({privateBrowsingId: 1});
+  windowlessBrowser.docShell.setOriginAttributes({privateBrowsingId: 1});
   windowlessBrowser.close();
   do_test_pending();
   do_timeout(0, Cu.forceGC);
 }
 
 function run_test() {
   var obs = {
     observe(aSubject, aTopic, aData) {
       Assert.equal(aTopic, "last-pb-context-exited");
       do_test_finished();
     },
   };
-  var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-  os.addObserver(obs, "last-pb-context-exited");
+  Services.obs.addObserver(obs, "last-pb-context-exited");
   destroy_transient_docshell();
 }
--- a/docshell/test/unit_ipc/test_pb_notification_ipc.js
+++ b/docshell/test/unit_ipc/test_pb_notification_ipc.js
@@ -1,17 +1,18 @@
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 function run_test() {
   var notifications = 0;
   var obs = {
     observe(aSubject, aTopic, aData) {
       Assert.equal(aTopic, "last-pb-context-exited");
       notifications++;
     },
   };
-  var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-  os.addObserver(obs, "last-pb-context-exited");
+  Services.os.addObserver(obs, "last-pb-context-exited");
 
   run_test_in_child("../unit/test_pb_notification.js",
                     function() {
                       Assert.equal(notifications, 1);
                       do_test_finished();
                     });
 }