Bug 1160450 - Places Maintenance never runs. r=ttaubert

This commit is contained in:
Marco Bonardo 2015-05-01 10:42:48 +02:00
Родитель 66deded1e3
Коммит 792db8bcbf
3 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -126,6 +126,7 @@ add_task(function test_execute()
}); });
add_test(function test_healthreport_callback() { add_test(function test_healthreport_callback() {
Services.prefs.clearUserPref("places.database.lastMaintenance");
PlacesDBUtils.telemetry(null, function onResult(data) { PlacesDBUtils.telemetry(null, function onResult(data) {
do_check_neq(data, null); 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_PAGES_COUNT, 1);
do_check_eq(data.PLACES_BOOKMARKS_COUNT, 1); do_check_eq(data.PLACES_BOOKMARKS_COUNT, 1);
do_check_true(!Services.prefs.prefHasUserValue("places.database.lastMaintenance"));
run_next_test(); run_next_test();
}); });
}); });