Bug 1160450 - Places Maintenance never runs. r=ttaubert

This commit is contained in:
Marco Bonardo 2015-05-01 10:42:48 +02:00
parent 9ea8d35d4f
commit e7d4046987
3 changed files with 13 additions and 4 deletions

View File

@ -67,7 +67,6 @@ this.PlacesDBUtils = {
}
// Notify observers that maintenance finished.
Services.prefs.setIntPref("places.database.lastMaintenance", parseInt(Date.now() / 1000));
Services.obs.notifyObservers(null, FINISHED_MAINTENANCE_TOPIC, null);
}
},
@ -94,7 +93,12 @@ this.PlacesDBUtils = {
, this._refreshUI
]);
tasks._telemetryStart = Date.now();
tasks.callback = aCallback;
tasks.callback = function() {
Services.prefs.setIntPref("places.database.lastMaintenance",
parseInt(Date.now() / 1000));
if (aCallback)
aCallback();
}
tasks.scope = aScope;
this._executeTasks(tasks);
},

View File

@ -1279,14 +1279,17 @@ add_task(function test_preventive_maintenance()
stmt.finalize();
do_check_true(defaultBookmarksMaxId > 0);
for ([, test] in Iterator(tests)) {
for (let [, test] in Iterator(tests)) {
dump("\nExecuting test: " + test.name + "\n" + "*** " + test.desc + "\n");
yield test.setup();
let promiseMaintenanceFinished =
promiseTopicObserved(FINISHED_MAINTENANCE_NOTIFICATION_TOPIC);
PlacesDBUtils.maintenanceOnIdle();
Services.prefs.clearUserPref("places.database.lastMaintenance");
let callbackInvoked = false;
PlacesDBUtils.maintenanceOnIdle(() => callbackInvoked = true);
yield promiseMaintenanceFinished;
do_check_true(callbackInvoked);
// Check the lastMaintenance time has been saved.
do_check_neq(Services.prefs.getIntPref("places.database.lastMaintenance"), null);

View File

@ -126,6 +126,7 @@ add_task(function test_execute()
});
add_test(function test_healthreport_callback() {
Services.prefs.clearUserPref("places.database.lastMaintenance");
PlacesDBUtils.telemetry(null, function onResult(data) {
do_check_neq(data, null);
@ -133,6 +134,7 @@ add_test(function test_healthreport_callback() {
do_check_eq(data.PLACES_PAGES_COUNT, 1);
do_check_eq(data.PLACES_BOOKMARKS_COUNT, 1);
do_check_true(!Services.prefs.prefHasUserValue("places.database.lastMaintenance"));
run_next_test();
});
});