Bug 1765919 - Rename CrashManager.jsm.in to CrashManager.in.jsm to apply JSM eslint rules. r=gsvelto

CRASH_MANAGER_PROCESS_PINGS is modified to substitute only the properties of
the object, in order to let eslint use the `processPings` local variable while
linting CrashManager.in.jsm.

Also applied the eslint --fix.

Differential Revision: https://phabricator.services.mozilla.com/D144788
This commit is contained in:
Tooru Fujisawa 2022-04-28 11:17:57 +00:00
parent e6b256b16b
commit fec54a1fe4
4 changed files with 24 additions and 14 deletions

View File

@ -350,7 +350,7 @@ CrashManager.prototype = Object.freeze({
);
}
} catch (ex) {
if (ex instanceof DOMException) {
if (DOMException.isInstance(ex)) {
this._log.warn("I/O error reading " + entry.path, ex);
} else {
// We should never encounter an exception. This likely represents
@ -450,9 +450,11 @@ CrashManager.prototype = Object.freeze({
let promise = (async () => {
if (!this.isValidProcessType(processType)) {
Cu.reportError(
"Unhandled process type. Please file a bug: '" + processType +
"'. Ignore in the context of " +
"test_crash_manager.js:test_addCrashWrong().");
"Unhandled process type. Please file a bug: '" +
processType +
"'. Ignore in the context of " +
"test_crash_manager.js:test_addCrashWrong()."
);
return;
}
@ -486,7 +488,7 @@ CrashManager.prototype = Object.freeze({
* @return boolean True or false depending whether it is a legit one
*/
isValidProcessType(processType) {
if (typeof(processType) !== "string") {
if (typeof processType !== "string") {
return false;
}
@ -509,7 +511,9 @@ CrashManager.prototype = Object.freeze({
isPingAllowed(processType) {
// gen_CrashManager.py will input the proper process pings informations.
/* SUBST: CRASH_MANAGER_PROCESS_PINGS */
let processPings = {
/* SUBST: CRASH_MANAGER_PROCESS_PINGS */
};
// Should not even reach this because of isValidProcessType() but just in
// case we try to be cautious
@ -772,7 +776,12 @@ CrashManager.prototype = Object.freeze({
// If CrashPingUUID is not present then a ping was not generated
// by the crashreporter for this crash so we need to send one from
// here.
this._sendCrashPing(crashID, this.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT], date, metadata);
this._sendCrashPing(
crashID,
this.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT],
date,
metadata
);
}
break;
@ -1089,7 +1098,7 @@ CrashStore.prototype = Object.freeze({
}
} catch (ex) {
// Missing files (first use) are allowed.
if (!(ex instanceof DOMException) || ex.name != "NotFoundError") {
if (!DOMException.isInstance(ex) || ex.name != "NotFoundError") {
// If we can't load for any reason, mark a corrupt date in the instance
// and swallow the error.
//
@ -1320,7 +1329,10 @@ CrashStore.prototype = Object.freeze({
if (
count > this.HIGH_WATER_DAILY_THRESHOLD &&
processType != CrashManager.prototype.processTypes[Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT]
processType !=
CrashManager.prototype.processTypes[
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
]
) {
return null;
}

View File

@ -33,7 +33,7 @@ def gen_process_map():
def gen_process_pings():
kIdentifier = "/* SUBST: CRASH_MANAGER_PROCESS_PINGS */"
crashManagerPing = """let processPings = {"""
crashManagerPing = ""
for p in process_types:
crashManagerPing += """
@ -41,8 +41,6 @@ def gen_process_pings():
"proctype": process_name(p.string_name),
"crashping": "true" if p.crash_ping else "false",
}
crashManagerPing += """
};"""
return (kIdentifier, crashManagerPing)

View File

@ -22,7 +22,7 @@ if CONFIG["MOZ_CRASHREPORTER"]:
"CrashManager.jsm",
script="gen_CrashManager.py",
entry_point="main",
inputs=["CrashManager.jsm.in"],
inputs=["CrashManager.in.jsm"],
)
EXTRA_JS_MODULES += [

View File

@ -329,7 +329,7 @@ avoid-blacklist-and-whitelist:
- toolkit/components/antitracking/test/browser/browser_siteSpecificWorkArounds.js
- toolkit/components/antitracking/test/browser/browser_socialtracking_save_image.js
- toolkit/components/antitracking/test/xpcshell/test_rejectForeignAllowList.js
- toolkit/components/crashes/CrashManager.jsm.in
- toolkit/components/crashes/CrashManager.in.jsm
- toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
- toolkit/components/extensions/Extension.jsm
- toolkit/components/extensions/test/xpcshell/test_WebExtensionPolicy.js