Bug 1696873 - Apply automatic fixes to enable more ESLint rules on remaining docshell xhtml files. r=smaug

This automatically fixes issues for these rules: dot-notation, object-shorthand and mozilla/no-useless-parameters
The other enabled rules had no issues associated with them, so are enabled without code changes.

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D107424
This commit is contained in:
Mark Banner 2021-03-08 13:41:52 +00:00
Родитель acb019156a
Коммит 5319c0f444
13 изменённых файлов: 47 добавлений и 57 удалений

Просмотреть файл

@ -378,23 +378,13 @@ module.exports = {
"docshell/test/chrome/test_viewsource_forbidden_in_iframe.xhtml",
],
rules: {
"dot-notation": "off",
"no-global-assign": "off",
"no-octal": "off",
"object-shorthand": "off",
"mozilla/consistent-if-bracing": "off",
"mozilla/no-compare-against-boolean-literals": "off",
"mozilla/no-useless-parameters": "off",
"mozilla/no-useless-removeEventListener": "off",
"mozilla/use-cc-etc": "off",
"mozilla/use-services": "off",
"mozilla/use-chromeutils-generateqi": "off",
"consistent-return": "off",
"no-delete-var": "off",
"no-redeclare": "off",
"no-sequences": "off",
"no-shadow": "off",
"no-useless-call": "off",
},
},
{

Просмотреть файл

@ -87,7 +87,7 @@
_afterFirst: false,
_removedDispatched: false,
_addedDispatched: false,
handleEvent: async function(aEvent) {
async handleEvent(aEvent) {
if (!this._afterFirst) {
is(aEvent.type, "DOMLinkAdded");
@ -97,10 +97,10 @@
if (strs[node.id]) strs[node.id] += " ";
strs[node.id] += node.id + ".page" + type;
}
node.addEventListener("page" + type, listener, false);
node.addEventListener("page" + type, listener);
listener.detach = function() {
node.removeEventListener("page" + type, listener, false);
node.removeEventListener("page" + type, listener);
}
return listener;
}
@ -125,8 +125,8 @@
var [same, first, second] = compareSnapshots(s1_new, s2, true);
ok(same, "Should reflow on swap. Expected " + second + " but got " + first);
is(strs["f1"], "f1.pagehide f1.pageshow");
is(strs["f3"], "f3.pagehide f3.pageshow");
is(strs.f1, "f1.pagehide f1.pageshow");
is(strs.f3, "f3.pagehide f3.pageshow");
this._afterFirst = true;
return;
}
@ -140,20 +140,20 @@
}
if (this._addedDispatched && this._removedDispatched) {
$("f1").removeEventListener("DOMLinkAdded", this, false);
$("f1").removeEventListener("DOMLinkRemoved", this, false);
$("f3").removeEventListener("DOMLinkAdded", this, false);
$("f3").removeEventListener("DOMLinkRemoved", this, false);
$("f1").removeEventListener("DOMLinkAdded", this);
$("f1").removeEventListener("DOMLinkRemoved", this);
$("f3").removeEventListener("DOMLinkAdded", this);
$("f3").removeEventListener("DOMLinkRemoved", this);
window.close();
SimpleTest.finish();
}
}
};
$("f1").addEventListener("DOMLinkAdded", DOMLinkListener, false);
$("f1").addEventListener("DOMLinkRemoved", DOMLinkListener, false);
$("f3").addEventListener("DOMLinkAdded", DOMLinkListener, false);
$("f3").addEventListener("DOMLinkRemoved", DOMLinkListener, false);
$("f1").addEventListener("DOMLinkAdded", DOMLinkListener);
$("f1").addEventListener("DOMLinkRemoved", DOMLinkListener);
$("f3").addEventListener("DOMLinkAdded", DOMLinkListener);
$("f3").addEventListener("DOMLinkRemoved", DOMLinkListener);
var linkElement = $("f1").contentDocument.createElement("link");
linkElement.setAttribute("rel", "alternate");

Просмотреть файл

@ -66,7 +66,7 @@
// Because adding visits is async, we will not be notified immediately.
let visitObserver = {
observe: function(aSubject, aTopic, aData)
observe(aSubject, aTopic, aData)
{
if (!testURI.equals(aSubject.QueryInterface(Ci.nsIURI))) {
return;
@ -80,7 +80,7 @@
// Load the page that the link on the previous page points to.
doPageNavigation({
uri: getHttpUrl("bug293235_p2.html"),
onNavComplete: function() {
onNavComplete() {
observedPageShow = true;
maybeResolve();
}

Просмотреть файл

@ -47,7 +47,7 @@ function WebProgressListener() {
}
WebProgressListener.prototype = {
QueryInterface: function(aIID) {
QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
@ -55,7 +55,7 @@ WebProgressListener.prototype = {
throw Components.Exception("", Cr.NS_NOINTERFACE);
},
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
setTimeout(this._callback, 0, aWebProgress, aRequest, aLocation, aFlags);
},

Просмотреть файл

@ -46,10 +46,10 @@
if (strs[node.id]) strs[node.id] += " ";
strs[node.id] += node.id + ".page" + type;
}
node.addEventListener("page" + type, listener, false);
node.addEventListener("page" + type, listener);
listener.detach = function() {
node.removeEventListener("page" + type, listener, false);
node.removeEventListener("page" + type, listener);
}
return listener;
}
@ -61,34 +61,34 @@
$("f1").swapDocShells($("f2"));
is(strs["f1"], "f1.pagehide f1.pageshow",
is(strs.f1, "f1.pagehide f1.pageshow",
"Expected hide then show on first loaded page");
is(strs["f2"], "f2.pagehide f2.pageshow",
is(strs.f2, "f2.pagehide f2.pageshow",
"Expected hide then show on second loaded page");
function listener2() {
$("f2").removeEventListener("testEvt", listener2, false);
$("f2").removeEventListener("testEvt", listener2);
strs = { "f1": "", "f2" : "" };
$("f1").swapDocShells($("f2"));
is(strs["f1"], "f1.pagehide",
is(strs.f1, "f1.pagehide",
"Expected hide on already-loaded page, then nothing");
is(strs["f2"], "f2.pageshow f2.pagehide f2.pageshow",
is(strs.f2, "f2.pageshow f2.pagehide f2.pageshow",
"Expected show on still-loading page, then hide on it, then show " +
"on already-loaded page");
strs = { "f1": "", "f2" : "" };
$("f1").addEventListener("pageshow", listener3, false);
$("f1").addEventListener("pageshow", listener3);
}
function listener3() {
$("f1").removeEventListener("pageshow", listener3, false);
$("f1").removeEventListener("pageshow", listener3);
is(strs["f1"], "f1.pageshow",
is(strs.f1, "f1.pageshow",
"Expected show as our page finishes loading");
is(strs["f2"], "", "Expected no more events here.");
is(strs.f2, "", "Expected no more events here.");
l1.detach();
l2.detach();

Просмотреть файл

@ -54,9 +54,9 @@
yield undefined;
// Ignore the notifications during swap
$("f1").removeEventListener("pageshow", testDriver, false);
$("f1").removeEventListener("pageshow", testDriver);
$("f1").swapDocShells($("f2"));
$("f2").addEventListener("pageshow", testDriver, false);
$("f2").addEventListener("pageshow", testDriver);
$("f2").goBack();
yield undefined;
@ -70,7 +70,7 @@
}
function doTheTest() {
$("f1").addEventListener("pageshow", testDriver, false);
$("f1").addEventListener("pageshow", testDriver);
$("f1").setAttribute("src", doc1);
}
]]></script>

Просмотреть файл

@ -34,7 +34,7 @@
var notificationCount = 0;
var observer = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
is(aSubject, browser.contentWindow,
"correct subject");
is(aTopic, "content-document-global-created",

Просмотреть файл

@ -60,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=453650
}
var observer = {
reflow: function (start, end) {
reflow (start, end) {
info("Entering observer.reflow");
if (interruptible) {
ok(false, "expected interruptible reflow");
@ -73,7 +73,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=453650
done();
},
reflowInterruptible: function (start, end) {
reflowInterruptible (start, end) {
info("Entering observer.reflowInterruptible");
if (!interruptible) {
ok(false, "expected uninterruptible reflow");

Просмотреть файл

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565388
function test() {
var progressListener = {
add: function(docShell, callback) {
add(docShell, callback) {
this.callback = callback;
this.docShell = docShell;
docShell.
@ -27,7 +27,7 @@ function test() {
addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
},
finish: function() {
finish() {
this.docShell.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebProgress).
@ -35,14 +35,14 @@ function test() {
this.callback();
},
onStateChange: function (webProgress, req, flags, status) {
onStateChange (webProgress, req, flags, status) {
if (req.name.startsWith("data:application/vnd.mozilla.xul")) {
if (flags & Ci.nsIWebProgressListener.STATE_STOP)
this.finish();
}
},
QueryInterface: function(iid) {
QueryInterface(iid) {
if (iid.equals(Ci.nsIWebProgressListener) ||
iid.equals(Ci.nsISupportsWeakReference))
return this;

Просмотреть файл

@ -33,7 +33,7 @@ let chromeWindow = window.browsingContext.topChromeWindow;
function* doTest() {
var notificationCount = 0;
var observer = {
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
is(aTopic, "chrome-document-global-created",
"correct topic");
is(aData, "null",

Просмотреть файл

@ -31,7 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=789773
var calledListenerForBrowserChromeURL = false;
var testProgressListener = {
START_DOC: Ci.nsIWebProgressListener.STATE_START | Ci.nsIWebProgressListener.STATE_IS_DOCUMENT,
onStateChange: function(wp, req, stateFlags, status) {
onStateChange(wp, req, stateFlags, status) {
let browserChromeFileName = AppConstants.BROWSER_CHROME_URL.split("/").reverse()[0];
if (req.name.includes(browserChromeFileName)) {
wp.DOMWindow; // Force the lazy creation of a DOM window.
@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=789773
if (req.name.includes("mozilla.html") && (stateFlags & Ci.nsIWebProgressListener.STATE_STOP))
finishTest();
},
QueryInterface: function(iid) {
QueryInterface(iid) {
if (iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsIWebProgressListener))
return this;

Просмотреть файл

@ -25,7 +25,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
}
var progressListener = {
add: function(docShell, callback) {
add(docShell, callback) {
this.callback = callback;
this.docShell = docShell;
docShell.
@ -34,7 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
},
finish: function(success) {
finish(success) {
this.docShell.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebProgress).
@ -42,7 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
this.callback(success);
},
onStateChange: function (webProgress, req, flags, status) {
onStateChange (webProgress, req, flags, status) {
if (!(flags & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT) &&
!(flags & Ci.nsIWebProgressListener.STATE_IS_REDIRECTED_DOCUMENT))
return;
@ -60,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
this.finish(false);
},
QueryInterface: function(iid) {
QueryInterface(iid) {
if (iid.equals(Ci.nsIWebProgressListener) ||
iid.equals(Ci.nsISupportsWeakReference))
return this;

Просмотреть файл

@ -30,14 +30,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=624883
// Error pages do not fire "load" events, so use a progressListener.
var originalDocumentURI = frame.contentDocument.documentURI;
var progressListener = {
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
// Make sure nothing other than an error page is loaded.
if (!(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE)) {
reject("location change was not to an error page");
}
},
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
// Wait until the documentURI changes (from about:blank) this should
// be the error page URI.
var documentURI = frame.contentDocument.documentURI;