зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1229519: Fix crash manager to pass eslint checks. r=mak
--HG-- extra : commitid : 2Lm9e2zVu5g extra : rebase_source : 3e1e564bfed49a13548af0f3bd0aa2cb72be64ed extra : amend_source : dc45a48fe9f498f3c5476f45071eb6494018016e
This commit is contained in:
Родитель
90346debbf
Коммит
265caf229e
|
@ -270,19 +270,21 @@ this.CrashManager.prototype = Object.freeze({
|
|||
Cu.reportError("Unhandled crash event file return code. Please " +
|
||||
"file a bug: " + result);
|
||||
}
|
||||
} catch (ex if ex instanceof OS.File.Error) {
|
||||
this._log.warn("I/O error reading " + entry.path + ": " +
|
||||
CommonUtils.exceptionStr(ex));
|
||||
} catch (ex) {
|
||||
// We should never encounter an exception. This likely represents
|
||||
// a coding error because all errors should be detected and
|
||||
// converted to return codes.
|
||||
//
|
||||
// If we get here, report the error and delete the source file
|
||||
// so we don't see it again.
|
||||
Cu.reportError("Exception when processing crash event file: " +
|
||||
CommonUtils.exceptionStr(ex));
|
||||
deletePaths.push(entry.path);
|
||||
if (ex instanceof OS.File.Error) {
|
||||
this._log.warn("I/O error reading " + entry.path + ": " +
|
||||
CommonUtils.exceptionStr(ex));
|
||||
} else {
|
||||
// We should never encounter an exception. This likely represents
|
||||
// a coding error because all errors should be detected and
|
||||
// converted to return codes.
|
||||
//
|
||||
// If we get here, report the error and delete the source file
|
||||
// so we don't see it again.
|
||||
Cu.reportError("Exception when processing crash event file: " +
|
||||
CommonUtils.exceptionStr(ex));
|
||||
deletePaths.push(entry.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,8 +596,11 @@ this.CrashManager.prototype = Object.freeze({
|
|||
return Task.spawn(function* () {
|
||||
try {
|
||||
yield OS.File.stat(path);
|
||||
} catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
|
||||
return [];
|
||||
} catch (ex) {
|
||||
if (!(ex instanceof OS.File.Error) || !ex.becauseNoSuchFile) {
|
||||
throw ex;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
let it = new OS.File.DirectoryIterator(path);
|
||||
|
@ -855,16 +860,17 @@ CrashStore.prototype = Object.freeze({
|
|||
this._countsByDay.get(day).set(type, count);
|
||||
}
|
||||
}
|
||||
} catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
|
||||
// Missing files (first use) are allowed.
|
||||
} catch (ex) {
|
||||
// If we can't load for any reason, mark a corrupt date in the instance
|
||||
// and swallow the error.
|
||||
//
|
||||
// The marking of a corrupted file is intentionally not persisted to
|
||||
// disk yet. Instead, we wait until the next save(). This is to give
|
||||
// non-permanent failures the opportunity to recover on their own.
|
||||
this._data.corruptDate = new Date();
|
||||
// Missing files (first use) are allowed.
|
||||
if (!(ex instanceof OS.File.Error) || !ex.becauseNoSuchFile) {
|
||||
// If we can't load for any reason, mark a corrupt date in the instance
|
||||
// and swallow the error.
|
||||
//
|
||||
// The marking of a corrupted file is intentionally not persisted to
|
||||
// disk yet. Instead, we wait until the next save(). This is to give
|
||||
// non-permanent failures the opportunity to recover on their own.
|
||||
this._data.corruptDate = new Date();
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
|
@ -96,7 +96,7 @@ add_task(function* test_submitted_dumps() {
|
|||
entries = yield m.submittedDumps();
|
||||
Assert.equal(entries.length, COUNT + 1, "hr- in filename detected.");
|
||||
|
||||
let gotIDs = new Set([e.id for (e of entries)]);
|
||||
let gotIDs = new Set(entries.map(e => e.id));
|
||||
Assert.ok(gotIDs.has(hrID));
|
||||
});
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ add_task(function* test_constructor() {
|
|||
Assert.ok(s instanceof CrashStore);
|
||||
});
|
||||
|
||||
add_task(function test_add_crash() {
|
||||
add_task(function* test_add_crash() {
|
||||
let s = yield getStore();
|
||||
|
||||
Assert.equal(s.crashesCount, 0);
|
||||
|
@ -79,7 +79,7 @@ add_task(function test_add_crash() {
|
|||
Assert.equal(s.crashesCount, 2);
|
||||
});
|
||||
|
||||
add_task(function test_reset() {
|
||||
add_task(function* test_reset() {
|
||||
let s = yield getStore();
|
||||
|
||||
Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", DUMMY_DATE));
|
||||
|
@ -88,7 +88,7 @@ add_task(function test_reset() {
|
|||
Assert.equal(s.crashes.length, 0);
|
||||
});
|
||||
|
||||
add_task(function test_save_load() {
|
||||
add_task(function* test_save_load() {
|
||||
let s = yield getStore();
|
||||
|
||||
yield s.save();
|
||||
|
@ -120,7 +120,7 @@ add_task(function test_save_load() {
|
|||
Assert.equal(submission.result, SUBMISSION_RESULT_OK);
|
||||
});
|
||||
|
||||
add_task(function test_corrupt_json() {
|
||||
add_task(function* test_corrupt_json() {
|
||||
let s = yield getStore();
|
||||
|
||||
let buffer = new TextEncoder().encode("{bad: json-file");
|
||||
|
|
|
@ -98,7 +98,10 @@ var CrashMonitorInternal = {
|
|||
let data;
|
||||
try {
|
||||
data = yield OS.File.read(CrashMonitorInternal.path, { encoding: "utf-8" });
|
||||
} catch (ex if ex instanceof OS.File.Error) {
|
||||
} catch (ex) {
|
||||
if (!(ex instanceof OS.File.Error)) {
|
||||
throw ex;
|
||||
}
|
||||
if (!ex.becauseNoSuchFile) {
|
||||
Cu.reportError("Error while loading crash monitor data: " + ex.toString());
|
||||
}
|
||||
|
@ -187,7 +190,7 @@ this.CrashMonitor = {
|
|||
// If this is the first time this notification is received,
|
||||
// remember it and write it to file
|
||||
CrashMonitorInternal.checkpoints[aTopic] = true;
|
||||
Task.spawn(function() {
|
||||
Task.spawn(function* () {
|
||||
try {
|
||||
let data = JSON.stringify(CrashMonitorInternal.checkpoints);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/**
|
||||
* Test with sessionCheckpoints.json containing invalid data
|
||||
*/
|
||||
add_task(function test_invalid_file() {
|
||||
add_task(function* test_invalid_file() {
|
||||
// Write bogus data to checkpoint file
|
||||
let data = "1234";
|
||||
yield OS.File.writeAtomic(sessionCheckpointsPath, data,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/**
|
||||
* Test with sessionCheckpoints.json containing invalid JSON data
|
||||
*/
|
||||
add_task(function test_invalid_file() {
|
||||
add_task(function* test_invalid_file() {
|
||||
// Write bogus data to checkpoint file
|
||||
let data = "[}";
|
||||
yield OS.File.writeAtomic(sessionCheckpointsPath, data,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/**
|
||||
* Test with non-existing sessionCheckpoints.json
|
||||
*/
|
||||
add_task(function test_missing_file() {
|
||||
add_task(function* test_missing_file() {
|
||||
CrashMonitor.init();
|
||||
let checkpoints = yield CrashMonitor.previousCheckpoints;
|
||||
do_check_eq(checkpoints, null);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/**
|
||||
* Test with sessionCheckpoints.json containing valid data
|
||||
*/
|
||||
add_task(function test_valid_file() {
|
||||
add_task(function* test_valid_file() {
|
||||
// Write valid data to checkpoint file
|
||||
let data = JSON.stringify({"final-ui-startup": true});
|
||||
yield OS.File.writeAtomic(sessionCheckpointsPath, data,
|
||||
|
|
Загрузка…
Ссылка в новой задаче