зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1059940 - Part 1: Expose CrashStore.reset() to clear all data. r=bsmedberg
This commit is contained in:
Родитель
f102d8b356
Коммит
d0c5512276
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче