Bug 1773740 - Part 4: Reapply mach -l eslint --fix with use-isInstance changes r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D148939
This commit is contained in:
Kagami Sascha Rosylight 2022-06-27 20:31:34 +00:00
parent 39d7ee6f91
commit 764ef75de5
40 changed files with 65 additions and 66 deletions

View file

@ -643,7 +643,7 @@ var FullZoom = {
const XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
if (
target instanceof window.XULElement &&
window.XULElement.isInstance(target) &&
target.localName == "browser" &&
target.namespaceURI == XUL_NS
) {

View file

@ -1580,7 +1580,7 @@ var gBrowserInit = {
return this._tabToAdopt;
}
if (window.arguments && window.arguments[0] instanceof window.XULElement) {
if (window.arguments && window.XULElement.isInstance(window.arguments[0])) {
this._tabToAdopt = window.arguments[0];
// Clear the reference of the tab being adopted from the arguments.
@ -2432,7 +2432,7 @@ var gBrowserInit = {
// window (for this case, all other arguments are
// ignored).
let uri = window.arguments?.[0];
if (!uri || uri instanceof window.XULElement) {
if (!uri || window.XULElement.isInstance(uri)) {
return null;
}
@ -3257,7 +3257,7 @@ function BrowserPageInfo(
browsingContext,
browser
) {
if (documentURL instanceof HTMLDocument) {
if (HTMLDocument.isInstance(documentURL)) {
Deprecated.warning(
"Please pass the location URL instead of the document " +
"to BrowserPageInfo() as the first argument.",
@ -7015,9 +7015,9 @@ function hrefAndLinkNodeForClickEvent(event) {
function isHTMLLink(aNode) {
// Be consistent with what nsContextMenu.js does.
return (
(aNode instanceof HTMLAnchorElement && aNode.href) ||
(aNode instanceof HTMLAreaElement && aNode.href) ||
aNode instanceof HTMLLinkElement
(HTMLAnchorElement.isInstance(aNode) && aNode.href) ||
(HTMLAreaElement.isInstance(aNode) && aNode.href) ||
HTMLLinkElement.isInstance(aNode)
);
}
@ -7257,7 +7257,7 @@ function middleMousePaste(event) {
}
});
if (event instanceof Event) {
if (Event.isInstance(event)) {
event.stopPropagation();
}
}

View file

@ -753,7 +753,7 @@
.reduce((a, b) => a.concat(b))
.filter(
anim =>
anim instanceof CSSAnimation &&
CSSAnimation.isInstance(anim) &&
(anim.animationName === "tab-throbber-animation" ||
anim.animationName === "tab-throbber-animation-rtl") &&
anim.playState === "running"
@ -1433,7 +1433,7 @@
// last clicked when switching back to that tab
if (
newFocusedElement &&
(newFocusedElement instanceof HTMLAnchorElement ||
(HTMLAnchorElement.isInstance(newFocusedElement) ||
newFocusedElement.getAttributeNS(
"http://www.w3.org/1999/xlink",
"type"
@ -5861,7 +5861,7 @@
return;
}
let targetIsWindow = event.target instanceof Window;
let targetIsWindow = Window.isInstance(event.target);
// We're about to open a modal dialog, so figure out for which tab:
// If this is a same-process modal dialog, then we're given its DOM

View file

@ -573,9 +573,9 @@ function _browser_tabfocus_test_eventOccured(event) {
var id;
if (event.target instanceof Window) {
if (Window.isInstance(event.target)) {
id = getWindowDocId(event.originalTarget) + "-window";
} else if (event.target instanceof Document) {
} else if (Document.isInstance(event.target)) {
id = getWindowDocId(event.originalTarget) + "-document";
} else if (
event.target.id == "urlbar" &&

View file

@ -901,7 +901,7 @@ function gatherTextUnder(root) {
if (node.nodeType == Node.TEXT_NODE) {
// Add this text to our collection.
text += " " + node.data;
} else if (node instanceof HTMLImageElement) {
} else if (HTMLImageElement.isInstance(node)) {
// If it has an "alt" attribute, add that.
var altText = node.getAttribute("alt");
if (altText && altText != "") {

View file

@ -1619,7 +1619,7 @@ var PlacesControllerDragHelper = {
if (flavor != TAB_DROP_TYPE) {
nodes = [...nodes, ...PlacesUtils.unwrapNodes(data, flavor)];
} else if (
data instanceof XULElement &&
XULElement.isInstance(data) &&
data.localName == "tab" &&
data.ownerGlobal.isChromeWindow
) {

View file

@ -750,8 +750,8 @@ var PlacesOrganizer = {
if (gEditItemOverlay.itemId != -1) {
var focusedElement = document.commandDispatcher.focusedElement;
if (
(focusedElement instanceof HTMLInputElement ||
focusedElement instanceof HTMLTextAreaElement) &&
(HTMLInputElement.isInstance(focusedElement) ||
HTMLTextAreaElement.isInstance(focusedElement)) &&
/^editBMPanel.*/.test(focusedElement.parentNode.parentNode.id)
) {
focusedElement.blur();

View file

@ -321,7 +321,7 @@
}
} else {
if (
(aEvent instanceof KeyboardEvent &&
(KeyboardEvent.isInstance(aEvent) &&
(aEvent.altKey || aEvent.getModifierState("AltGraph"))) ^
newTabPref &&
!gBrowser.selectedTab.isEmpty
@ -329,7 +329,7 @@
where = "tab";
}
if (
aEvent instanceof MouseEvent &&
MouseEvent.isInstance(aEvent) &&
(aEvent.button == 1 || aEvent.getModifierState("Accel"))
) {
where = "tab";

View file

@ -323,7 +323,7 @@ var promiseForEachSessionRestoreFile = async function(cb) {
});
} catch (ex) {
// Ignore missing files
if (!(ex instanceof DOMException && ex.name == "NotFoundError")) {
if (!(DOMException.isInstance(ex) && ex.name == "NotFoundError")) {
throw ex;
}
}

View file

@ -371,7 +371,7 @@ function frecencyForUrl(aURI) {
let url = aURI;
if (aURI instanceof Ci.nsIURI) {
url = aURI.spec;
} else if (aURI instanceof URL) {
} else if (URL.isInstance(aURI)) {
url = aURI.href;
}
let stmt = DBConn().createStatement(

View file

@ -86,8 +86,8 @@ class AutofillEditDialog {
}
case "contextmenu": {
if (
!(event.target instanceof HTMLInputElement) &&
!(event.target instanceof HTMLTextAreaElement)
!HTMLInputElement.isInstance(event.target) &&
!HTMLTextAreaElement.isInstance(event.target)
) {
event.preventDefault();
}

View file

@ -41,10 +41,9 @@ CONTENT_WIN.addEventListener("DOMContentLoaded", function onDCL(evt) {
case "childList": {
// We really only care about elements appending inside pages.
let parent =
mutation.target instanceof HTMLDocument
? mutation.target.documentElement
: mutation.target;
let parent = HTMLDocument.isInstance(mutation.target)
? mutation.target.documentElement
: mutation.target;
if (!mutation.addedNodes || !parent.closest(".page")) {
break;
}

View file

@ -340,7 +340,7 @@ async function focusUpdateSubmitForm(target, args, submit = true) {
for (const [selector, value] of Object.entries(obj.newValues)) {
element = form.querySelector(selector);
if (element instanceof content.HTMLInputElement) {
if (content.HTMLInputElement.isInstance(element)) {
element.setUserInput(value);
} else {
element.value = value;
@ -420,7 +420,7 @@ async function focusAndWaitForFieldsIdentified(browserOrContext, selector) {
// If a browsing context was supplied, focus its parent frame as well.
if (
browserOrContext instanceof BrowsingContext &&
BrowsingContext.isInstance(browserOrContext) &&
browserOrContext.parent != browserOrContext
) {
await SpecialPowers.spawn(

View file

@ -28,7 +28,7 @@ this.test = makeMemoryTest(TEST_URL, async function({ tab, panel }) {
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"And we should be able to read a HeapSnapshot instance from the file"
);
});

View file

@ -41,7 +41,7 @@ add_task(async function() {
await helper.initialize();
ok(
helper.content instanceof content.AnonymousContent,
content.AnonymousContent.isInstance(helper.content),
"The helper owns the AnonymousContent object"
);
ok(

View file

@ -16,7 +16,7 @@ add_task(async () => {
);
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"And we should be able to read a HeapSnapshot instance from the file"
);
});

View file

@ -18,7 +18,7 @@ add_task(async () => {
);
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"And we should be able to read a HeapSnapshot instance from the file"
);
});

View file

@ -16,7 +16,7 @@ add_task(async () => {
);
const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"And we should be able to read a HeapSnapshot instance from the file"
);
});

View file

@ -22,7 +22,7 @@ window.onload = function() {
const dominatorTree = snapshot.computeDominatorTree();
ok(dominatorTree);
ok(dominatorTree instanceof DominatorTree);
ok(DominatorTree.isInstance(dominatorTree));
let threw = false;
try {

View file

@ -13,7 +13,7 @@ self.onmessage = e => {
const dominatorTree = snapshot.computeDominatorTree();
ok(dominatorTree);
ok(dominatorTree instanceof DominatorTree);
ok(DominatorTree.isInstance(dominatorTree));
let threw = false;
try {

View file

@ -143,7 +143,7 @@ function readHeapSnapshot(filePath) {
const snapshot = ChromeUtils.readHeapSnapshot(filePath);
ok(snapshot, "Should have read a heap snapshot back from " + filePath);
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"snapshot should be an instance of HeapSnapshot"
);
return snapshot;
@ -207,7 +207,7 @@ function saveHeapSnapshotAndComputeDominatorTree(dbg = null) {
ok(dominatorTree, "Should be able to compute a dominator tree");
ok(
dominatorTree instanceof DominatorTree,
DominatorTree.isInstance(dominatorTree),
"Should be an instance of DominatorTree"
);

View file

@ -17,7 +17,7 @@ self.onmessage = ex => {
const snapshot = ChromeUtils.readHeapSnapshot(filePath);
ok(snapshot, "Should be able to read a heap snapshot");
ok(
snapshot instanceof HeapSnapshot,
HeapSnapshot.isInstance(snapshot),
"Should be an instanceof HeapSnapshot"
);
} catch (e) {

View file

@ -10,7 +10,7 @@ function run_test() {
const dominatorTree = snapshot.computeDominatorTree();
ok(dominatorTree);
ok(dominatorTree instanceof DominatorTree);
ok(DominatorTree.isInstance(dominatorTree));
let threw = false;
try {

View file

@ -50,7 +50,7 @@ function run_test() {
const snapshot = ChromeUtils.readHeapSnapshot(filePath);
ok(snapshot, "Should be able to read a heap snapshot");
ok(snapshot instanceof HeapSnapshot, "Should be an instanceof HeapSnapshot");
ok(HeapSnapshot.isInstance(snapshot), "Should be an instanceof HeapSnapshot");
const report = snapshot.takeCensus({
breakdown: {

View file

@ -16,7 +16,7 @@ function run_test() {
const snapshot = ChromeUtils.readHeapSnapshot(filePath);
ok(snapshot, "Should be able to read a heap snapshot");
ok(snapshot instanceof HeapSnapshot, "Should be an instanceof HeapSnapshot");
ok(HeapSnapshot.isInstance(snapshot), "Should be an instanceof HeapSnapshot");
do_test_finished();
}

View file

@ -41,7 +41,7 @@ function run_test() {
const snapshot = ChromeUtils.readHeapSnapshot(filePath);
ok(snapshot, "Should be able to read a heap snapshot");
ok(snapshot instanceof HeapSnapshot, "Should be an instanceof HeapSnapshot");
ok(HeapSnapshot.isInstance(snapshot), "Should be an instanceof HeapSnapshot");
do_test_finished();
}

View file

@ -457,7 +457,7 @@ exports.isNativeAnonymous = isAnonymous;
*/
function isTemplateElement(node) {
return (
node.ownerGlobal && node instanceof node.ownerGlobal.HTMLTemplateElement
node.ownerGlobal && node.ownerGlobal.HTMLTemplateElement.isInstance(node)
);
}
exports.isTemplateElement = isTemplateElement;

View file

@ -432,7 +432,7 @@ function promisePageEvents(params) {
*/
function pageEventListener(
event,
originalTargetIsHTMLDocument = event.originalTarget instanceof HTMLDocument
originalTargetIsHTMLDocument = HTMLDocument.isInstance(event.originalTarget)
) {
try {
dump(

View file

@ -64,7 +64,7 @@ function checkInputEvent(aEvent, aCancelable, aIsComposing, aInputType, aData, a
if (aEvent.type !== "input" && aEvent.type !== "beforeinput") {
throw new Error(`${aDescription}"${aEvent.type}" is not InputEvent`);
}
ok(aEvent instanceof InputEvent, `${aDescription}"${aEvent.type}" event should be dispatched with InputEvent interface`);
ok(InputEvent.isInstance(aEvent), `${aDescription}"${aEvent.type}" event should be dispatched with InputEvent interface`);
is(aEvent.cancelable, aCancelable, `${aDescription}"${aEvent.type}" event should ${aCancelable ? "be" : "not be"} cancelable`);
is(aEvent.bubbles, true, `${aDescription}"${aEvent.type}" event should always bubble`);
is(aEvent.isComposing, aIsComposing, `${aDescription}isComposing of "${aEvent.type}" event should be ${aIsComposing}`);

View file

@ -379,7 +379,7 @@
info("== Test createRequest()");
ok(DOMRequest, "DOMRequest object exists");
var req = dummy.createRequest();
ok(req instanceof DOMRequest, "Returned a DOMRequest");
ok(DOMRequest.isInstance(req), "Returned a DOMRequest");
next();
},
function() {

View file

@ -433,10 +433,10 @@ function verifyBuffers(buffer1, buffer2) {
function verifyBlob(blob1, blob2) {
is(Blob.isInstance(blob1), true, "Instance of nsIDOMBlob");
is(blob1 instanceof File, blob2 instanceof File, "Instance of DOM File");
is(File.isInstance(blob1), File.isInstance(blob2), "Instance of DOM File");
is(blob1.size, blob2.size, "Correct size");
is(blob1.type, blob2.type, "Correct type");
if (blob2 instanceof File) {
if (File.isInstance(blob2)) {
is(blob1.name, blob2.name, "Correct name");
}
@ -476,7 +476,7 @@ function verifyBlob(blob1, blob2) {
function verifyMutableFile(mutableFile1, file2) {
is(
mutableFile1 instanceof IDBMutableFile,
IDBMutableFile.isInstance(mutableFile1),
true,
"Instance of IDBMutableFile"
);

View file

@ -530,7 +530,7 @@ function frecencyForUrl(aURI) {
let url = aURI;
if (aURI instanceof Ci.nsIURI) {
url = aURI.spec;
} else if (aURI instanceof URL) {
} else if (URL.isInstance(aURI)) {
url = aURI.href;
}
let stmt = DBConn().createStatement(

View file

@ -34,7 +34,7 @@ var Readerable = {
// Only care about 'real' HTML documents:
if (
doc.mozSyntheticDocument ||
!(doc instanceof doc.defaultView.HTMLDocument)
!doc.defaultView.HTMLDocument.isInstance(doc)
) {
return false;
}

View file

@ -638,7 +638,7 @@ add_task(async function test_telemetryCleanFHRDatabase() {
try {
await IOUtils.read(dbFilePath);
} catch (e) {
Assert.ok(e instanceof DOMException);
Assert.ok(DOMException.isInstance(e));
Assert.equal(
e.name,
"NotFoundError",
@ -670,7 +670,7 @@ add_task(async function test_telemetryCleanFHRDatabase() {
try {
await IOUtils.read(dbFilePath);
} catch (e) {
Assert.ok(e instanceof DOMException);
Assert.ok(DOMException.isInstance(e));
Assert.equal(
e.name,
"NotFoundError",

View file

@ -443,7 +443,7 @@ add_task(async function test_URL_values() {
parsedValue: new URL("https://www.example.com/foo#bar"),
},
});
Assert.ok(result.parsedValue instanceof URL, "parsedValue is a URL");
Assert.ok(URL.isInstance(result.parsedValue), "parsedValue is a URL");
Assert.equal(
result.parsedValue.origin,
"https://www.example.com",
@ -525,7 +525,7 @@ add_task(async function test_URLorEmpty_values() {
parsedValue: new URL("https://www.example.com/foo#bar"),
},
});
Assert.ok(result.parsedValue instanceof URL, "parsedValue is a URL");
Assert.ok(URL.isInstance(result.parsedValue), "parsedValue is a URL");
Assert.equal(
result.parsedValue.origin,
"https://www.example.com",
@ -621,7 +621,7 @@ add_task(async function test_origin_values() {
parsedValue: new URL("https://www.example.com/"),
},
});
Assert.ok(result.parsedValue instanceof URL, "parsedValue is a URL");
Assert.ok(URL.isInstance(result.parsedValue), "parsedValue is a URL");
Assert.equal(
result.parsedValue.origin,
"https://www.example.com",
@ -693,7 +693,7 @@ add_task(async function test_origin_file_values() {
parsedValue: new URL("file:///foo/bar"),
},
});
Assert.ok(result.parsedValue instanceof URL, "parsedValue is a URL");
Assert.ok(URL.isInstance(result.parsedValue), "parsedValue is a URL");
Assert.equal(
result.parsedValue.href,
"file:///foo/bar",
@ -715,7 +715,7 @@ add_task(async function test_origin_file_values() {
parsedValue: new URL("file:///foo/bar/foobar.html"),
},
});
Assert.ok(result.parsedValue instanceof URL, "parsedValue is a URL");
Assert.ok(URL.isInstance(result.parsedValue), "parsedValue is a URL");
Assert.equal(
result.parsedValue.href,
"file:///foo/bar/foobar.html",
@ -941,7 +941,7 @@ add_task(async function test_object_values() {
},
});
Assert.ok(
result.parsedValue.url instanceof URL,
URL.isInstance(result.parsedValue.url),
"types inside the object are also parsed"
);
Assert.equal(

View file

@ -689,7 +689,7 @@
get(target, prop, receiver) {
let propOrMethod = target[prop];
if (typeof propOrMethod == "function") {
if (propOrMethod instanceof MozQueryInterface) {
if (MozQueryInterface.isInstance(propOrMethod)) {
return Reflect.get(target, prop, receiver);
}
return function(...args) {

View file

@ -33,7 +33,7 @@
get control() {
var parent = this.parentNode;
// Return the parent if it is a menu or menulist.
if (parent && parent.parentNode instanceof XULMenuElement) {
if (parent && XULMenuElement.isInstance(parent.parentNode)) {
return parent.parentNode;
}
return null;
@ -42,7 +42,7 @@
// nsIDOMXULContainerItemElement
get parentContainer() {
for (var parent = this.parentNode; parent; parent = parent.parentNode) {
if (parent instanceof XULMenuElement) {
if (XULMenuElement.isInstance(parent)) {
return parent;
}
}

View file

@ -242,7 +242,7 @@
if (!element.isConnected) {
return;
}
if (element.previousSibling instanceof Text) {
if (Text.isInstance(element.previousSibling)) {
element.previousSibling.appendData(element.textContent);
} else {
element.parentNode.insertBefore(element.firstChild, element);

View file

@ -757,7 +757,7 @@ add_task(async function testMinimalExtension() {
checkLabel(row, "author");
let text = row.lastChild;
is(text.textContent, "I made it", "The author is set");
ok(text instanceof Text, "The author is a text node");
ok(Text.isInstance(text), "The author is a text node");
is(rows.length, 0, "There are no more rows");

View file

@ -754,7 +754,7 @@ function checkInputEvent(aEvent, aIsComposing, aInputType, aData, aTargetRanges,
if (aEvent.type !== "input" && aEvent.type !== "beforeinput") {
throw new Error(`${aDescription}: "${aEvent.type}" is not InputEvent`);
}
ok(aEvent instanceof InputEvent, `"${aEvent.type}" event should be dispatched with InputEvent interface: ${aDescription}`);
ok(InputEvent.isInstance(aEvent), `"${aEvent.type}" event should be dispatched with InputEvent interface: ${aDescription}`);
let cancelable = aEvent.type === "beforeinput" &&
aInputType !== "insertCompositionText" &&
aInputType !== "deleteCompositionText";