Bug 1508985 - Enable ESLint for dom/tests/browser (manual changes) r=Standard8,qdot
authorVincent W <VinceDaDev@hotmail.com>
Tue, 22 Jan 2019 21:26:02 +0000
changeset 514876 62947b5b105bb61f1875b98671ddfda082980356
parent 514875 efd90c73657e20a9f80f9f2e7fbfa9f631a2c441
child 514877 c0900754337e0568fd2d9896e950ecf9a77e4351
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, qdot
bugs1508985
milestone66.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 1508985 - Enable ESLint for dom/tests/browser (manual changes) r=Standard8,qdot Differential Revision: https://phabricator.services.mozilla.com/D14018
.eslintignore
dom/tests/browser/browser_ConsoleAPITests.js
dom/tests/browser/browser_allocateGigabyte.js
dom/tests/browser/browser_beforeunload_between_chrome_content.js
dom/tests/browser/browser_bug396843.js
dom/tests/browser/browser_focus_steal_from_chrome.js
dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
dom/tests/browser/browser_keypressTelemetry.js
dom/tests/browser/browser_largeAllocation_non_win32.js
dom/tests/browser/browser_largeAllocation_win32.js
dom/tests/browser/browser_localStorage_e10s.js
dom/tests/browser/browser_localStorage_snapshotting_e10s.js
dom/tests/browser/browser_test_focus_after_modal_state.js
dom/tests/browser/browser_test_new_window_from_content.js
dom/tests/browser/browser_test_performance_metrics_off.js
dom/tests/browser/browser_xhr_sandbox.js
dom/tests/browser/helper_largeAllocation.js
dom/tests/browser/helper_localStorage_e10s.js
dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
dom/tests/browser/position.html
dom/tests/browser/prevent_return_key.html
dom/tests/browser/shared_worker.js
dom/tests/browser/test-console-api.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -203,17 +203,17 @@ dom/quota/**
 dom/security/test/cors/**
 dom/security/test/csp/**
 dom/security/test/general/**
 dom/security/test/mixedcontentblocker/**
 dom/security/test/sri/**
 dom/serviceworkers/**
 dom/smil/**
 dom/svg/**
-dom/tests/browser/**
+
 dom/tests/html/**
 dom/tests/mochitest/**
 dom/u2f/**
 dom/url/**
 dom/vr/**
 dom/webauthn/**
 dom/webgpu/**
 dom/websocket/**
--- a/dom/tests/browser/browser_ConsoleAPITests.js
+++ b/dom/tests/browser/browser_ConsoleAPITests.js
@@ -96,16 +96,18 @@ async function consoleAPISanityTest(brow
     ok(win.console.time, "console.time is here");
     ok(win.console.timeEnd, "console.timeEnd is here");
     ok(win.console.timeStamp, "console.timeStamp is here");
     ok(win.console.assert, "console.assert is here");
     ok(win.console.count, "console.count is here");
   });
 }
 
+// These globals are all defined in spawnWithObserver in a sub-process.
+/* global gWindow, gArgs:true, gLevel:true, gStyle:true, expect, resolve */
 function testConsoleData(aMessageObject) {
   let messageWindow = Services.wm.getOuterWindowWithId(aMessageObject.ID);
   is(messageWindow, gWindow, "found correct window by window ID");
 
   is(aMessageObject.level, gLevel, "expected level received");
   ok(aMessageObject.arguments, "we have arguments");
 
   switch (gLevel) {
--- a/dom/tests/browser/browser_allocateGigabyte.js
+++ b/dom/tests/browser/browser_allocateGigabyte.js
@@ -1,16 +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/. */
 
 const TEST_URI = "http://example.com/browser/dom/tests/browser/test_largeAllocation.html";
 
 function expectProcessCreated() {
-  let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+  let os = Services.obs;
   return new Promise(resolve => {
     let topic = "ipc:content-created";
     function observer() {
       os.removeObserver(observer, topic);
       ok(true, "Expect process created");
       resolve();
     }
     os.addObserver(observer, topic);
--- a/dom/tests/browser/browser_beforeunload_between_chrome_content.js
+++ b/dom/tests/browser/browser_beforeunload_between_chrome_content.js
@@ -36,16 +36,17 @@ function awaitAndCloseBeforeUnloadDialog
 
 SpecialPowers.pushPrefEnv(
   {"set": [["dom.require_user_interaction_for_beforeunload", false]]});
 
 /**
  * Test navigation from a content page to a chrome page. Also check that only
  * one beforeunload event is fired.
  */
+/* global messageManager */
 add_task(async function() {
   let beforeUnloadCount = 0;
   messageManager.addMessageListener("Test:OnBeforeUnloadReceived", function() {
     beforeUnloadCount++;
   });
 
   // Open a content page.
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
--- a/dom/tests/browser/browser_bug396843.js
+++ b/dom/tests/browser/browser_bug396843.js
@@ -268,16 +268,17 @@ add_task(async function test1() {
     testInDocument(document, "browser window");
 });
 
 async function newTabTest(location) {
     await BrowserTestUtils.withNewTab({ gBrowser, url: location },
         async function(browser) {
           await ContentTask.spawn(browser, { location, testInDocument_: testInDocument.toSource() },
             async function({ location, testInDocument_ }) {
+              // eslint-disable-next-line no-eval
               let testInDocument = eval(`(() => (${testInDocument_}))()`);
               testInDocument(content.document, location);
             });
         });
 }
 
 add_task(async function test2() {
     await newTabTest("about:blank");
--- a/dom/tests/browser/browser_focus_steal_from_chrome.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome.js
@@ -45,16 +45,17 @@ add_task(async function() {
         ok(true, "Test1: Both of the tabs are loaded");
 
         // Confirm that the contents should be able to steal focus from content.
         await ContentTask.spawn(fg, test, test => {
           return new Promise(res => {
             function f() {
               let e = content.document.activeElement;
               if (e.tagName != test.tagName) {
+                // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
                 setTimeout(f, 10);
               } else {
                 is(Services.focus.focusedElement, e,
                    "the foreground tab's " + test.tagName +
                    " element isn't focused by the " + test.methodName +
                    " (Test1: content can steal focus)");
                 res();
               }
@@ -63,16 +64,17 @@ add_task(async function() {
           });
         });
 
         await ContentTask.spawn(bg, test, test => {
           return new Promise(res => {
             function f() {
               let e = content.document.activeElement;
               if (e.tagName != test.tagName) {
+                // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
                 setTimeout(f, 10);
               } else {
                 isnot(Services.focus.focusedElement, e,
                       "the background tab's " + test.tagName +
                       " element is focused by the " + test.methodName +
                       " (Test1: content can steal focus)");
                 res();
               }
@@ -105,16 +107,17 @@ add_task(async function() {
         ok(true, "Test2: Both of the tabs are loaded");
 
         // Confirm that the contents should be able to steal focus from content.
         await ContentTask.spawn(fg, test, test => {
           return new Promise(res => {
             function f() {
               let e = content.document.activeElement;
               if (e.tagName != test.tagName) {
+                // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
                 setTimeout(f, 10);
               } else {
                 isnot(Services.focus.focusedElement, e,
                       "the foreground tab's " + test.tagName +
                       " element is focused by the " + test.methodName +
                       " (Test2: content can NOT steal focus)");
                 res();
               }
@@ -123,16 +126,17 @@ add_task(async function() {
           });
         });
 
         await ContentTask.spawn(bg, test, test => {
           return new Promise(res => {
             function f() {
               let e = content.document.activeElement;
               if (e.tagName != test.tagName) {
+                // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
                 setTimeout(f, 10);
               } else {
                 isnot(Services.focus.focusedElement, e,
                       "the background tab's " + test.tagName +
                       " element is focused by the " + test.methodName +
                       " (Test2: content can NOT steal focus)");
                 res();
               }
--- a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
@@ -8,36 +8,34 @@ add_task(async function test() {
     "  }" +
     "</script>" +
     "<body id=\"body\">" +
     "<button onmousedown=\"onMouseDown(event);\" style=\"width: 100px; height: 100px;\">click here</button>" +
     "<input id=\"willBeFocused\"></body>";
 
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, kTestURI);
 
-  let fm = Cc["@mozilla.org/focus-manager;1"].
-        getService(Ci.nsIFocusManager);
+  let fm = Services.focus;
 
   for (var button = 0; button < 3; button++) {
     // Set focus to a chrome element before synthesizing a mouse down event.
     document.getElementById("urlbar").focus();
 
     is(fm.focusedElement, document.getElementById("urlbar").inputField,
        "Failed to move focus to search bar: button=" + button);
 
     // Synthesize mouse down event on browser object over the button, such that
     // the event propagates through both processes.
     EventUtils.synthesizeMouse(tab.linkedBrowser, 20, 20, { "button": button });
 
     isnot(fm.focusedElement, document.getElementById("urlbar").inputField,
        "Failed to move focus away from search bar: button=" + button);
 
     await ContentTask.spawn(tab.linkedBrowser, button, async function(button) {
-      let fm = Cc["@mozilla.org/focus-manager;1"].
-          getService(Ci.nsIFocusManager);
+      let fm = Services.focus;
 
       let attempts = 10;
       await new Promise(resolve => {
         function check() {
           if (attempts > 0 && content.document.activeElement.id != "willBeFocused") {
             attempts--;
             content.window.setTimeout(check, 100);
             return;
--- a/dom/tests/browser/browser_keypressTelemetry.js
+++ b/dom/tests/browser/browser_keypressTelemetry.js
@@ -3,47 +3,45 @@
  * 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 EventUtils = {};
 var PaintListener = {};
 Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
 const { ContentTaskUtils } = ChromeUtils.import("resource://testing-common/ContentTaskUtils.jsm", {});
 
-function getRecordedKeypressCount()
-{
+function getRecordedKeypressCount() {
     let snapshot = Services.telemetry.getSnapshotForHistograms("main", false);
 
     var totalCount = 0;
     for (var prop in snapshot) {
-        if (snapshot[prop]["KEYPRESS_PRESENT_LATENCY"]) {
+        if (snapshot[prop].KEYPRESS_PRESENT_LATENCY) {
             dump("found snapshot");
-            totalCount += Object.values(snapshot[prop]["KEYPRESS_PRESENT_LATENCY"].values).reduce((a, b) => a + b, 0);
+            totalCount += Object.values(snapshot[prop].KEYPRESS_PRESENT_LATENCY.values).reduce((a, b) => a + b, 0);
         }
     }
 
     return totalCount;
 }
 
-add_task(async function()
-{
+add_task(async function() {
     await SpecialPowers.pushPrefEnv({set: [["toolkit.telemetry.ipcBatchTimeout", 10]]});
     let histogram = Services.telemetry.getHistogramById("KEYPRESS_PRESENT_LATENCY");
     histogram.clear();
 
     waitForExplicitFinish();
 
     gURLBar.focus();
     await SimpleTest.promiseFocus(window);
-    EventUtils.sendChar('x');
+    EventUtils.sendChar("x");
 
-    await ContentTaskUtils.waitForCondition(() => { return getRecordedKeypressCount() > 0; }, "waiting for telemetry", 200, 600)
+    await ContentTaskUtils.waitForCondition(() => { return getRecordedKeypressCount() > 0; }, "waiting for telemetry", 200, 600);
     let result = getRecordedKeypressCount();
     ok(result == 1, "One keypress recorded");
 
     gURLBar.focus();
     await SimpleTest.promiseFocus(window);
-    EventUtils.sendChar('x');
+    EventUtils.sendChar("x");
 
-    await ContentTaskUtils.waitForCondition(() => { return getRecordedKeypressCount() > 1; }, "waiting for telemetry", 200, 600)
+    await ContentTaskUtils.waitForCondition(() => { return getRecordedKeypressCount() > 1; }, "waiting for telemetry", 200, 600);
     result = getRecordedKeypressCount();
     ok(result == 2, "Two keypresses recorded");
 });
--- a/dom/tests/browser/browser_largeAllocation_non_win32.js
+++ b/dom/tests/browser/browser_largeAllocation_non_win32.js
@@ -1,9 +1,10 @@
 let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
+/* import-globals-from helper_largeAllocation.js */
 Services.scriptloader.loadSubScript(testDir + "/helper_largeAllocation.js", this);
 
 // Force-enabling the Large-Allocation header
 add_task(async function() {
   info("Test 1 - force enabling the Large-Allocation header");
   await SpecialPowers.pushPrefEnv({
     set: [
       // Enable the header if it is disabled
--- a/dom/tests/browser/browser_largeAllocation_win32.js
+++ b/dom/tests/browser/browser_largeAllocation_win32.js
@@ -7,12 +7,12 @@ add_task(async function() {
     set: [
       // Enable the header if it is disabled
       ["dom.largeAllocationHeader.enabled", true],
       // Increase processCount.webLargeAllocation to avoid any races where
       // processes aren't being cleaned up quickly enough.
       ["dom.ipc.processCount.webLargeAllocation", 20],
     ],
   });
-
+  /* global largeAllocSuccessTests */
   await largeAllocSuccessTests();
 });
 
--- a/dom/tests/browser/browser_localStorage_e10s.js
+++ b/dom/tests/browser/browser_localStorage_e10s.js
@@ -1,91 +1,26 @@
 const HELPER_PAGE_URL =
   "http://example.com/browser/dom/tests/browser/page_localstorage_e10s.html";
 const HELPER_PAGE_ORIGIN = "http://example.com/";
 
 let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
 Services.scriptloader.loadSubScript(testDir + "/helper_localStorage_e10s.js",
                                     this);
-// Simple tab wrapper abstracting our messaging mechanism;
-class KnownTab {
-  constructor(name, tab) {
-    this.name = name;
-    this.tab = tab;
-  }
-
-  cleanup() {
-    this.tab = null;
-  }
-}
-
-// Simple data structure class to help us track opened tabs and their pids.
-class KnownTabs {
-  constructor() {
-    this.byPid = new Map();
-    this.byName = new Map();
-  }
-
-  cleanup() {
-    this.byPid = null;
-    this.byName = null;
-  }
-}
-
-/**
- * Open our helper page in a tab in its own content process, asserting that it
- * really is in its own process.  We initially load and wait for about:blank to
- * load, and only then loadURI to our actual page.  This is to ensure that
- * LocalStorageManager has had an opportunity to be created and populate
- * mOriginsHavingData.
- *
- * (nsGlobalWindow will reliably create LocalStorageManager as a side-effect of
- * the unconditional call to nsGlobalWindow::PreloadLocalStorage.  This will
- * reliably create the StorageDBChild instance, and its corresponding
- * StorageDBParent will send the set of origins when it is constructed.)
- */
-async function openTestTabInOwnProcess(name, knownTabs) {
-  let realUrl = HELPER_PAGE_URL + "?" + encodeURIComponent(name);
-  // Load and wait for about:blank.
-  let tab = await BrowserTestUtils.openNewForegroundTab({
-    gBrowser, opening: "about:blank", forceNewProcess: true,
-  });
-  let pid = tab.linkedBrowser.frameLoader.tabParent.osPid;
-  ok(!knownTabs.byName.has(name), "tab needs its own name: " + name);
-  ok(!knownTabs.byPid.has(pid), "tab needs to be in its own process: " + pid);
-
-  let knownTab = new KnownTab(name, tab);
-  knownTabs.byPid.set(pid, knownTab);
-  knownTabs.byName.set(name, knownTab);
-
-  // Now trigger the actual load of our page.
-  BrowserTestUtils.loadURI(tab.linkedBrowser, realUrl);
-  await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
-  is(tab.linkedBrowser.frameLoader.tabParent.osPid, pid, "still same pid");
-  return knownTab;
-}
-
-/**
- * Close all the tabs we opened.
- */
-async function cleanupTabs(knownTabs) {
-  for (let knownTab of knownTabs.byName.values()) {
-    BrowserTestUtils.removeTab(knownTab.tab);
-    knownTab.cleanup();
-  }
-  knownTabs.cleanup();
-}
 
 /**
  * Wait for a LocalStorage flush to occur.  This notification can occur as a
  * result of any of:
  * - The normal, hardcoded 5-second flush timer.
  * - InsertDBOp seeing a preload op for an origin with outstanding changes.
  * - Us generating a "domstorage-test-flush-force" observer notification.
  */
+
+ /* import-globals-from helper_localStorage_e10s.js */
+
 function waitForLocalStorageFlush() {
   if (Services.lsm.nextGenLocalStorageEnabled) {
     return new Promise(resolve => executeSoon(resolve));
   }
 
   return new Promise(function(resolve) {
     let observer = {
       observe() {
--- a/dom/tests/browser/browser_localStorage_snapshotting_e10s.js
+++ b/dom/tests/browser/browser_localStorage_snapshotting_e10s.js
@@ -1,12 +1,14 @@
 const HELPER_PAGE_URL =
   "http://example.com/browser/dom/tests/browser/page_localstorage_snapshotting_e10s.html";
 const HELPER_PAGE_ORIGIN = "http://example.com/";
 
+/* import-globals-from helper_localStorage_e10s.js */
+
 let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
 Services.scriptloader.loadSubScript(testDir + "/helper_localStorage_e10s.js",
                                     this);
 
 function clearOrigin() {
   let principal =
     Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(
       HELPER_PAGE_ORIGIN);
@@ -89,17 +91,17 @@ add_task(async function() {
     return;
   }
 
   await SpecialPowers.pushPrefEnv({
     set: [
       // Enable LocalStorage's testing API so we can explicitly create
       // snapshots when needed.
       ["dom.storage.testing", true],
-    ]
+    ],
   });
 
   // Ensure that there is no localstorage data by forcing the origin to be
   // cleared prior to the start of our test..
   await clearOrigin();
 
   // - Open tabs.  Don't configure any of them yet.
   const knownTabs = new KnownTabs();
@@ -115,103 +117,102 @@ add_task(async function() {
   const initialMutations = [
     [null, null],
     ["key1", "initial1"],
     ["key2", "initial2"],
     ["key3", "initial3"],
     ["key5", "initial5"],
     ["key6", "initial6"],
     ["key7", "initial7"],
-    ["key8", "initial8"]
+    ["key8", "initial8"],
   ];
 
   const initialState = {
     key1: "initial1",
     key2: "initial2",
     key3: "initial3",
     key5: "initial5",
     key6: "initial6",
     key7: "initial7",
-    key8: "initial8"
+    key8: "initial8",
   };
 
-  function getPartialPrefill()
-  {
+  function getPartialPrefill() {
     let size = 0;
     let entries = Object.entries(initialState);
     for (let i = 0; i < entries.length / 2; i++) {
       let entry = entries[i];
       size += entry[0].length + entry[1].length;
     }
     return size;
   }
 
   const prefillValues = [
     0,                   // no prefill
     getPartialPrefill(), // partial prefill
-    -1                   // full prefill
+    -1,                  // full prefill
   ];
 
   for (let prefillValue of prefillValues) {
     info("Setting prefill value");
 
     await SpecialPowers.pushPrefEnv({
       set: [
-        ["dom.storage.snapshot_prefill", prefillValue]
-      ]
+        ["dom.storage.snapshot_prefill", prefillValue],
+      ],
     });
 
     info("Stage 1");
 
     const setRemoveMutations1 = [
       ["key0", "setRemove10"],
       ["key1", "setRemove11"],
       ["key2", null],
       ["key3", "setRemove13"],
       ["key4", "setRemove14"],
       ["key5", "setRemove15"],
       ["key6", "setRemove16"],
       ["key7", "setRemove17"],
       ["key8", null],
-      ["key9", "setRemove19"]
+      ["key9", "setRemove19"],
     ];
 
     const setRemoveState1 = {
       key0: "setRemove10",
       key1: "setRemove11",
       key3: "setRemove13",
       key4: "setRemove14",
       key5: "setRemove15",
       key6: "setRemove16",
       key7: "setRemove17",
-      key9: "setRemove19"
+      key9: "setRemove19",
     };
 
     const setRemoveMutations2 = [
       ["key0", "setRemove20"],
       ["key1", null],
       ["key2", "setRemove22"],
       ["key3", "setRemove23"],
       ["key4", "setRemove24"],
       ["key5", "setRemove25"],
       ["key6", "setRemove26"],
       ["key7", null],
       ["key8", "setRemove28"],
-      ["key9", "setRemove29"]
+      ["key9", "setRemove29"],
     ];
 
     const setRemoveState2 = {
       key0: "setRemove20",
       key2: "setRemove22",
       key3: "setRemove23",
       key4: "setRemove24",
       key5: "setRemove25",
       key6: "setRemove26",
       key8: "setRemove28",
-      key9: "setRemove29"
+      key9: "setRemove29",
     };
 
     // Apply initial mutations using an explicit snapshot. The explicit
     // snapshot here ensures that the parent process have received the changes.
     await beginExplicitSnapshot(writerTab1);
     await applyMutations(writerTab1, initialMutations);
     await endExplicitSnapshot(writerTab1);
 
@@ -254,26 +255,26 @@ add_task(async function() {
     await verifyState(readerTab1, setRemoveState2);
     await endExplicitSnapshot(readerTab1);
 
     info("Stage 2");
 
     const setRemoveClearMutations1 = [
       ["key0", "setRemoveClear10"],
       ["key1", null],
-      [null, null]
+      [null, null],
     ];
 
     const setRemoveClearState1 = {
     };
 
     const setRemoveClearMutations2 = [
       ["key8", null],
       ["key9", "setRemoveClear29"],
-      [null, null]
+      [null, null],
     ];
 
     const setRemoveClearState2 = {
     };
 
     // This is very similar to previous stage except that in addition to
     // set/remove, the clear operation is involved too.
     await beginExplicitSnapshot(writerTab1);
@@ -313,17 +314,17 @@ add_task(async function() {
       ["key7", null],
       ["key8", null],
       ["key8", "initial8"],
       ["key7", "initial7"],
       ["key6", "initial6"],
       ["key5", "initial5"],
       ["key3", "initial3"],
       ["key2", "initial2"],
-      ["key1", "initial1"]
+      ["key1", "initial1"],
     ];
 
     // Apply initial mutations using an explicit snapshot. The explicit
     // snapshot here ensures that the parent process have received the changes.
     await beginExplicitSnapshot(writerTab1);
     await applyMutations(writerTab1, initialMutations);
     await endExplicitSnapshot(writerTab1);
 
--- a/dom/tests/browser/browser_test_focus_after_modal_state.js
+++ b/dom/tests/browser/browser_test_focus_after_modal_state.js
@@ -7,17 +7,17 @@ function awaitAndClosePrompt() {
       Services.obs.removeObserver(onDialogShown, "tabmodal-dialog-loaded");
       let button = node.querySelector(".tabmodalprompt-button0");
       button.click();
       resolve();
     }
     Services.obs.addObserver(onDialogShown, "tabmodal-dialog-loaded");
   });
 }
-
+/* global messageManager */
 let lastMessageReceived = "";
 function waitForMessage(message) {
   return new Promise((resolve, reject) => {
     messageManager.addMessageListener(message, function() {
       ok(true, "Received message: " + message);
       lastMessageReceived = message;
       resolve();
     });
--- a/dom/tests/browser/browser_test_new_window_from_content.js
+++ b/dom/tests/browser/browser_test_new_window_from_content.js
@@ -110,39 +110,34 @@ function prepareForResult(aBrowser, aExp
     case kSameTab:
       return (async function() {
         await BrowserTestUtils.browserLoaded(aBrowser);
         is(aBrowser.currentURI.spec, expectedSpec, "Should be at dummy.html");
         // Now put the browser back where it came from
         await BrowserTestUtils.loadURI(aBrowser, kContentDoc);
         await BrowserTestUtils.browserLoaded(aBrowser);
       })();
-      break;
     case kNewWin:
       return (async function() {
         let newWin = await BrowserTestUtils.waitForNewWindow({url: expectedSpec});
         let newBrowser = newWin.gBrowser.selectedBrowser;
         is(newBrowser.currentURI.spec, expectedSpec, "Should be at dummy.html");
         await BrowserTestUtils.closeWindow(newWin);
       })();
-      break;
     case kNewTab:
       return (async function() {
         let newTab = await BrowserTestUtils.waitForNewTab(gBrowser);
         is(newTab.linkedBrowser.currentURI.spec, expectedSpec,
            "Should be at dummy.html");
         BrowserTestUtils.removeTab(newTab);
       })();
-      break;
     default:
       ok(false, "prepareForResult can't handle an expectation of " + aExpectation);
-      return;
+      return Promise.resolve();
   }
-
-  return deferred.promise;
 }
 
 /**
  * Ensure that clicks on a link with ID aLinkID cause us to
  * perform as specified in the supplied aMatrix (kWinOpenDefault,
  * for example).
  *
  * @param aLinkSelector a selector for the link within the testing page to click.
--- a/dom/tests/browser/browser_test_performance_metrics_off.js
+++ b/dom/tests/browser/browser_test_performance_metrics_off.js
@@ -6,14 +6,14 @@
 
 add_task(async function testNotActivated() {
   // dom.performance.enable_scheduler_timing is set to false in browser.ini
   waitForExplicitFinish();
   // make sure we throw a JS exception in case the pref is off and
   // we call requestPerformanceMetrics()
   let failed = false;
   try {
-    let promise = await ChromeUtils.requestPerformanceMetrics();
+    await ChromeUtils.requestPerformanceMetrics();
   } catch (e) {
     failed = true;
   }
   Assert.ok(failed, "We should get an exception if preffed off");
 });
--- a/dom/tests/browser/browser_xhr_sandbox.js
+++ b/dom/tests/browser/browser_xhr_sandbox.js
@@ -18,18 +18,17 @@ var sandboxCode = (function() {
       postMessage({result}, "*");
     }
   };
   req.send(null);
 }).toSource() + "();";
 
 function test() {
   waitForExplicitFinish();
-  let appShell = Cc["@mozilla.org/appshell/appShellService;1"]
-                  .getService(Ci.nsIAppShellService);
+  let appShell = Services.appShell;
   let doc = appShell.hiddenDOMWindow.document;
   let frame = doc.createElement("iframe");
   frame.setAttribute("type", "content");
   frame.setAttribute("src", "http://mochi.test:8888/browser/dom/tests/browser/browser_xhr_sandbox.js");
 
   frame.addEventListener("load", function() {
     let workerWindow = frame.contentWindow;
     workerWindow.addEventListener("message", function(evt) {
--- a/dom/tests/browser/helper_largeAllocation.js
+++ b/dom/tests/browser/helper_largeAllocation.js
@@ -1,17 +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/. */
 
 const TEST_URI = "http://example.com/browser/dom/tests/browser/test_largeAllocation.html";
 const TEST_URI_2 = "http://example.com/browser/dom/tests/browser/test_largeAllocation2.html";
 
 function expectProcessCreated() {
-  let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+  let os = Services.obs;
   let kill; // A kill function which will disable the promise.
   let promise = new Promise((resolve, reject) => {
     let topic = "ipc:content-created";
     function observer() {
       os.removeObserver(observer, topic);
       ok(true, "Expect process created");
       resolve();
     }
@@ -22,32 +22,30 @@ function expectProcessCreated() {
       reject();
     };
   });
   promise.kill = kill;
   return promise;
 }
 
 function expectNoProcess() {
-  let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+  let os = Services.obs;
   let topic = "ipc:content-created";
   function observer() {
     ok(false, "A process was created!");
     os.removeObserver(observer, topic);
   }
   os.addObserver(observer, topic);
 
   return () => os.removeObserver(observer, topic);
 }
 
 function getPID(aBrowser) {
   return ContentTask.spawn(aBrowser, null, () => {
-    const appinfo = Cc["@mozilla.org/xre/app-info;1"]
-            .getService(Ci.nsIXULRuntime);
-    return appinfo.processID;
+    return Services.appinfo.processID;
   });
 }
 
 function getInLAProc(aBrowser) {
   return ContentTask.spawn(aBrowser, null, () => {
     return Services.appinfo.remoteType == "webLargeAllocation";
   });
 }
@@ -98,16 +96,17 @@ async function largeAllocSuccessTests() 
     info("Starting test 1");
     let pid1 = await getPID(aBrowser);
     is(false, await getInLAProc(aBrowser));
 
     // Fail the test if we create a process
     let stopExpectNoProcess = expectNoProcess();
 
     await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
+      // eslint-disable-next-line no-unsanitized/property
       content.document.body.innerHTML = `<iframe src='${TEST_URI}'></iframe>`;
 
       return new Promise(resolve => {
         content.document.body.querySelector("iframe").onload = () => {
           ok(true, "Iframe finished loading");
           resolve();
         };
       });
@@ -177,17 +176,16 @@ async function largeAllocSuccessTests() 
     is(true, await getInLAProc(aBrowser));
 
     await BrowserTestUtils.browserLoaded(aBrowser);
 
     await ContentTask.spawn(aBrowser, null, () => content.document.location = "about:blank");
 
     await BrowserTestUtils.browserLoaded(aBrowser);
 
-    let pid3 = await getPID(aBrowser);
 
     // We should have been kicked out of the large-allocation process by the
     // load, meaning we're back in a non-fresh process
     is(false, await getInLAProc(aBrowser));
 
     epc = expectProcessCreated();
 
     await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
--- a/dom/tests/browser/helper_localStorage_e10s.js
+++ b/dom/tests/browser/helper_localStorage_e10s.js
@@ -35,20 +35,20 @@ class KnownTabs {
  * mOriginsHavingData.
  *
  * (nsGlobalWindow will reliably create LocalStorageManager as a side-effect of
  * the unconditional call to nsGlobalWindow::PreloadLocalStorage.  This will
  * reliably create the StorageDBChild instance, and its corresponding
  * StorageDBParent will send the set of origins when it is constructed.)
  */
 async function openTestTabInOwnProcess(helperPageUrl, name, knownTabs) {
-  let realUrl = helperPageUrl + '?' + encodeURIComponent(name);
+  let realUrl = helperPageUrl + "?" + encodeURIComponent(name);
   // Load and wait for about:blank.
   let tab = await BrowserTestUtils.openNewForegroundTab({
-    gBrowser, opening: 'about:blank', forceNewProcess: true
+    gBrowser, opening: "about:blank", forceNewProcess: true,
   });
   let pid = tab.linkedBrowser.frameLoader.tabParent.osPid;
   ok(!knownTabs.byName.has(name), "tab needs its own name: " + name);
   ok(!knownTabs.byPid.has(pid), "tab needs to be in its own process: " + pid);
 
   let knownTab = new KnownTab(name, tab);
   knownTabs.byPid.set(pid, knownTab);
   knownTabs.byName.set(name, knownTab);
--- a/dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
+++ b/dom/tests/browser/perfmetrics/browser_test_performance_metrics.js
@@ -65,17 +65,16 @@ add_task(async function test() {
     // grab events..
     let workerDuration = 0;
     let workerTotal = 0;
     let duration = 0;
     let total = 0;
     let isTopLevel = false;
     let aboutMemoryFound = false;
     let parentProcessEvent = false;
-    let workerEvent = false;
     let subFrameIds = [];
     let topLevelIds = [];
     let sharedWorker = false;
     let counterIds = [];
     let timerCalls = 0;
     let heapUsage = 0;
     let mediaMemory = 0;
 
@@ -103,17 +102,16 @@ add_task(async function test() {
         }
         if (entry.host == "about:memory") {
           aboutMemoryFound = true;
         }
         if (entry.pid == Services.appinfo.processID) {
           parentProcessEvent = true;
         }
         if (entry.isWorker) {
-          workerEvent = true;
           workerDuration += entry.duration;
         } else {
           duration += entry.duration;
         }
         // let's look at the data we got back
         for (let item of entry.items) {
           Assert.ok(item.count > 0, "Categories with an empty count are dropped");
           if (entry.isWorker) {
--- a/dom/tests/browser/position.html
+++ b/dom/tests/browser/position.html
@@ -1,19 +1,21 @@
 <!DOCTYPE html>
 <html lang="en" dir="ltr">
 <head>
   <script type="text/javascript">
     var result = null;
 
     function handlePosition(position) {
+      // eslint-disable-next-line no-unsanitized/property
       result.innerHTML = position.coords.latitude + " " + position.coords.longitude;
     }
 
     function handleError(error) {
+      // eslint-disable-next-line no-unsanitized/property
       result.innerHTML = error.message;
     }
 
     function init() {
       result = document.getElementById("result");
 
       if (navigator.geolocation)
         navigator.geolocation.getCurrentPosition(handlePosition, handleError);
--- a/dom/tests/browser/prevent_return_key.html
+++ b/dom/tests/browser/prevent_return_key.html
@@ -7,16 +7,17 @@
   function init() {
     let input = document.getElementById("input");
     input.addEventListener("keydown", function(aEvent) {
       if (aEvent.keyCode == 13) { // return key
         alert("Hello!");
         aEvent.preventDefault();
         return false;
       }
+      return true;
     }, {once: true});
 
     let form = document.getElementById("form");
     form.addEventListener("submit", function() {
       let result = document.getElementById("result");
       result.innerHTML = "submitted";
     }, {once: true});
   }
--- a/dom/tests/browser/shared_worker.js
+++ b/dom/tests/browser/shared_worker.js
@@ -1,9 +1,7 @@
-
-onconnect = function(e) {
+let onconnect = function(e) {
   var port = e.ports[0];
 
   port.onmessage = function(e) {
-    var workerResult = "Result: " + (e.data[0] * e.data[1]);
     port.postMessage(e.data[0]);
   };
 };
--- a/dom/tests/browser/test-console-api.html
+++ b/dom/tests/browser/test-console-api.html
@@ -2,16 +2,17 @@
 <html dir="ltr" xml:lang="en-US" lang="en-US"><head>
     <title>Console API test page</title>
     <script type="text/javascript">
       window.foobar585956c = function(a) {
         console.trace();
         return a + "c";
       };
 
+      /* global foobar585956c */
       function foobar585956b(a) {
         return foobar585956c(a + "b");
       }
 
       function foobar585956a(omg) {
         return foobar585956b(omg + "a");
       }