From 3a66c24aae1c9fb140c240ff073feb65af04168b Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Fri, 9 Nov 2018 10:51:37 +0000 Subject: [PATCH] Bug 1506042 - Enable ESLint for docshell/resources and docshell/test/chrome (manual fixes). r=smaug Depends on D11441 Differential Revision: https://phabricator.services.mozilla.com/D11442 --HG-- extra : moz-landing-system : lando --- .eslintignore | 2 -- docshell/test/chrome/bug303267.html | 14 ++++++------- docshell/test/chrome/docshell_helpers.js | 26 +++++++++++------------- docshell/test/chrome/test_bug909218.html | 2 +- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.eslintignore b/.eslintignore index 467562a1d8b5..68391e9e14af 100644 --- a/.eslintignore +++ b/.eslintignore @@ -14,9 +14,7 @@ obj*/** # We ignore all these directories by default, until we get them enabled. # If you are enabling a directory, please add directory specific exclusions # below. -docshell/resources/** docshell/test/browser/** -docshell/test/chrome/** docshell/test/iframesandbox/** docshell/test/mochitest/** extensions/cookie/** diff --git a/docshell/test/chrome/bug303267.html b/docshell/test/chrome/bug303267.html index ac423f56fa69..21b9f30311af 100644 --- a/docshell/test/chrome/bug303267.html +++ b/docshell/test/chrome/bug303267.html @@ -8,13 +8,13 @@
diff --git a/docshell/test/chrome/docshell_helpers.js b/docshell/test/chrome/docshell_helpers.js index dd51359cb2cd..2ff5596a15b4 100755 --- a/docshell/test/chrome/docshell_helpers.js +++ b/docshell/test/chrome/docshell_helpers.js @@ -7,6 +7,10 @@ for (var name of imports) { window[name] = window.opener.wrappedJSObject[name]; } ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm"); +ChromeUtils.import("resource://gre/modules/Services.jsm"); + +// Some functions assume chrome-harness.js has been loaded. +/* import-globals-from ../../../testing/mochitest/chrome-harness.js */ /** * Define global constants and variables. @@ -88,6 +92,7 @@ var gExtractedPath = null; // used to cache file path for extracting files from * must contain an object for each pagehide and pageshow event which occurs as * a result of this navigation. */ +// eslint-disable-next-line complexity function doPageNavigation(params) { // Parse the parameters. let back = params.back ? params.back : false; @@ -340,9 +345,7 @@ function finish() { // If the test changed the value of max_total_viewers via a call to // enableBFCache(), then restore it now. if (typeof(gOrigMaxTotalViewers) != "undefined") { - var prefs = Cc["@mozilla.org/preferences-service;1"] - .getService(Ci.nsIPrefBranch); - prefs.setIntPref("browser.sessionhistory.max_total_viewers", + Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", gOrigMaxTotalViewers); } @@ -351,11 +354,9 @@ function finish() { let SimpleTest = opener.wrappedJSObject.SimpleTest; // Wait for the window to be closed before finishing the test - let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"] - .getService(Ci.nsIWindowWatcher); - ww.registerNotification(function(subject, topic, data) { + Services.ww.registerNotification(function observer(subject, topic, data) { if (topic == "domwindowclosed") { - ww.unregisterNotification(arguments.callee); + Services.ww.unregisterNotification(observer); SimpleTest.waitForFocus(SimpleTest.finish, opener); } }); @@ -424,24 +425,21 @@ function waitForNextPaint(cb) { * to 0 (disabled), if a number, set it to that specific number */ function enableBFCache(enable) { - var prefs = Cc["@mozilla.org/preferences-service;1"] - .getService(Ci.nsIPrefBranch); - // If this is the first time the test called enableBFCache(), // store the original value of max_total_viewers, so it can // be restored at the end of the test. if (typeof(gOrigMaxTotalViewers) == "undefined") { gOrigMaxTotalViewers = - prefs.getIntPref("browser.sessionhistory.max_total_viewers"); + Services.prefs.getIntPref("browser.sessionhistory.max_total_viewers"); } if (typeof(enable) == "boolean") { if (enable) - prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1); + Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1); else - prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0); + Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0); } else if (typeof(enable) == "number") { - prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable); + Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable); } } diff --git a/docshell/test/chrome/test_bug909218.html b/docshell/test/chrome/test_bug909218.html index 68d875574163..836fb21a4843 100644 --- a/docshell/test/chrome/test_bug909218.html +++ b/docshell/test/chrome/test_bug909218.html @@ -41,7 +41,7 @@ function test() { // an nsIWebProgressListener that checks all requests made by the docShell // have the flags we expect. -RequestWatcher = { +var RequestWatcher = { init(docShell, callback) { this.callback = callback; this.docShell = docShell;