Bug 1462933 - Places Database Integrity in about:support doesn't produce log anymore. r=standard8 draft
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 21 May 2018 12:29:47 +0200
changeset 797714 34bec67c22cd60ab6da894bac68eed85a2c411ac
parent 797705 dc1868d255be744a7d2d462216be205086cc60af
push id110545
push usermak77@bonardo.net
push dateMon, 21 May 2018 13:15:26 +0000
reviewersstandard8
bugs1462933
milestone62.0a1
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
toolkit/components/places/PlacesDBUtils.jsm
toolkit/components/places/tests/maintenance/test_preventive_maintenance_checkAndFixDatabase.js
--- 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");