diff --git a/toolkit/components/crashes/CrashManager.jsm b/toolkit/components/crashes/CrashManager.jsm index 473325939e2d..e5ef41308403 100644 --- a/toolkit/components/crashes/CrashManager.jsm +++ b/toolkit/components/crashes/CrashManager.jsm @@ -706,6 +706,18 @@ CrashStore.prototype = Object.freeze({ // ceiling on the per-type/per-day records that will be stored. HIGH_WATER_DAILY_THRESHOLD: 100, + /** + * Reset all data. + */ + reset() { + this._data = { + v: 1, + crashes: new Map(), + corruptDate: null, + }; + this._countsByDay = new Map(); + }, + /** * Load data from disk. * @@ -713,13 +725,8 @@ CrashStore.prototype = Object.freeze({ */ load: function () { return Task.spawn(function* () { - // Loading replaces data. So reset data structures. - this._data = { - v: 1, - crashes: new Map(), - corruptDate: null, - }; - this._countsByDay = new Map(); + // Loading replaces data. + this.reset(); try { let decoder = new TextDecoder(); diff --git a/toolkit/components/crashes/tests/xpcshell/test_crash_store.js b/toolkit/components/crashes/tests/xpcshell/test_crash_store.js index 9f86c2d45793..3ff06f60c3e7 100644 --- a/toolkit/components/crashes/tests/xpcshell/test_crash_store.js +++ b/toolkit/components/crashes/tests/xpcshell/test_crash_store.js @@ -79,6 +79,15 @@ add_task(function test_add_crash() { Assert.equal(s.crashesCount, 2); }); +add_task(function test_reset() { + let s = yield getStore(); + + Assert.ok(s.addCrash(PROCESS_TYPE_MAIN, CRASH_TYPE_CRASH, "id1", DUMMY_DATE)); + Assert.equal(s.crashes.length, 1); + s.reset(); + Assert.equal(s.crashes.length, 0); +}); + add_task(function test_save_load() { let s = yield getStore();