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
This commit is contained in:
Mark Banner 2018-11-09 10:51:37 +00:00
parent ce1e7cce4b
commit 3a66c24aae
4 changed files with 20 additions and 24 deletions

View file

@ -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/**

View file

@ -8,13 +8,13 @@
<script>
var pageshowcount = 0;
function showpageshowcount() {
pageshowcount++;
var div1 = document.getElementById("div1");
while (div1.firstChild) {
div1.firstChild.remove();
}
div1.appendChild(document.createTextNode(
"pageshowcount: " + pageshowcount));
pageshowcount++;
var div1 = document.getElementById("div1");
while (div1.firstChild) {
div1.firstChild.remove();
}
div1.appendChild(document.createTextNode(
"pageshowcount: " + pageshowcount));
}
</script>
<div id="div1">

View file

@ -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);
}
}

View file

@ -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;