Bug 1462933 - Places Database Integrity in about:support doesn't produce log anymore. r=standard8
Ensure that maintenance tasks always produce some log.
MozReview-Commit-ID: JY0YE7eEhaN
--- a/toolkit/components/places/PlacesDBUtils.jsm
+++ b/toolkit/components/places/PlacesDBUtils.jsm
@@ -865,17 +865,19 @@ var PlacesDBUtils = {
/**
* Recalculates statistical data on the frecencies in the database.
*
* @return {Promise} resolves when statistics are collected.
*/
frecencyStats() {
return new Promise(resolve => {
- PlacesUtils.history.recalculateFrecencyStats(() => resolve());
+ PlacesUtils.history.recalculateFrecencyStats(() => resolve([
+ "Recalculated frecency stats"
+ ]));
});
},
/**
* Collects telemetry data and reports it to Telemetry.
*
* Note: although this function isn't actually async, we keep it async to
* allow us to maintain a simple, consistent API for the tasks within this object.
@@ -1067,19 +1069,19 @@ var PlacesDBUtils = {
if (PlacesDBUtils._clearTaskQueue) {
tasksMap.set(
task.name,
{ succeeded: false, logs: ["The task queue was cleared by an error in another task."] });
continue;
}
- let result =
- await task().then(logs => { return { succeeded: true, logs }; })
- .catch(err => { return { succeeded: false, logs: [err.message] }; });
+ let result = await task()
+ .then((logs = [`${task.name} complete`]) => ({ succeeded: true, logs }))
+ .catch(err => ({ succeeded: false, logs: [err.message] }));
tasksMap.set(task.name, result);
}
return tasksMap;
}
};
async function integrity(dbName) {
async function check(db) {
--- a/toolkit/components/places/tests/maintenance/test_preventive_maintenance_checkAndFixDatabase.js
+++ b/toolkit/components/places/tests/maintenance/test_preventive_maintenance_checkAndFixDatabase.js
@@ -13,17 +13,17 @@ add_task(async function() {
Assert.equal(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CREATE);
let tasksStatusMap = await PlacesDBUtils.checkAndFixDatabase();
let numberOfTasksRun = tasksStatusMap.size;
let successfulTasks = [];
let failedTasks = [];
tasksStatusMap.forEach(val => {
- if (val.succeeded) {
+ if (val.succeeded && val.logs) {
successfulTasks.push(val);
} else {
failedTasks.push(val);
}
});
Assert.equal(numberOfTasksRun, 8, "Check that we have run all tasks.");
Assert.equal(successfulTasks.length, 8, "Check that we have run all tasks successfully");
Assert.equal(failedTasks.length, 0, "Check that no task is failing");