зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1036440 - Fix tests and consumers for rewritten `PlacesDBUtils`, r=mak
This includes 2 things: 1. Replacing the parts which test the logs for the presence of prefixes by testing the returned map for `suceeded`. 2. We don't need to wait to observe the topic anymore, we can simply await methods from `PlacesDBUtils` to know when they are done. MozReview-Commit-ID: Ct9l9pzUW5x --HG-- extra : rebase_source : 657e4ac53f8b3785740a5b732d483fad9600f73d
This commit is contained in:
Родитель
b03686f5f1
Коммит
fc8d285e3d
|
@ -230,10 +230,7 @@ add_task(async function test_filter_hidden() {
|
||||||
_(`Framed link visit GUID: ${embedGUID}`);
|
_(`Framed link visit GUID: ${embedGUID}`);
|
||||||
|
|
||||||
_("Run Places maintenance to mark redirect visit as hidden");
|
_("Run Places maintenance to mark redirect visit as hidden");
|
||||||
let maintenanceFinishedPromise =
|
await PlacesDBUtils.maintenanceOnIdle();
|
||||||
promiseOneObserver("places-maintenance-finished");
|
|
||||||
PlacesDBUtils.maintenanceOnIdle();
|
|
||||||
await maintenanceFinishedPromise;
|
|
||||||
|
|
||||||
await verifyTrackedItems([trackedGUID]);
|
await verifyTrackedItems([trackedGUID]);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
/* -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
@ -83,10 +83,7 @@ add_task(async function maintenance_foreign_count_test() {
|
||||||
|
|
||||||
// Run maintenance
|
// Run maintenance
|
||||||
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
||||||
let promiseMaintenanceFinished =
|
await PlacesDBUtils.maintenanceOnIdle();
|
||||||
promiseTopicObserved("places-maintenance-finished");
|
|
||||||
PlacesDBUtils.maintenanceOnIdle();
|
|
||||||
await promiseMaintenanceFinished;
|
|
||||||
|
|
||||||
// Check if the foreign_count has been adjusted to the correct value
|
// Check if the foreign_count has been adjusted to the correct value
|
||||||
Assert.equal((await getForeignCountForURL(conn, T_URI)), 0);
|
Assert.equal((await getForeignCountForURL(conn, T_URI)), 0);
|
||||||
|
|
|
@ -1312,13 +1312,8 @@ add_task(async function test_preventive_maintenance() {
|
||||||
dump("\nExecuting test: " + test.name + "\n*** " + test.desc + "\n");
|
dump("\nExecuting test: " + test.name + "\n*** " + test.desc + "\n");
|
||||||
await test.setup();
|
await test.setup();
|
||||||
|
|
||||||
let promiseMaintenanceFinished =
|
|
||||||
promiseTopicObserved(FINISHED_MAINTENANCE_NOTIFICATION_TOPIC);
|
|
||||||
Services.prefs.clearUserPref("places.database.lastMaintenance");
|
Services.prefs.clearUserPref("places.database.lastMaintenance");
|
||||||
let callbackInvoked = false;
|
await PlacesDBUtils.maintenanceOnIdle();
|
||||||
PlacesDBUtils.maintenanceOnIdle(() => callbackInvoked = true);
|
|
||||||
await 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);
|
||||||
|
|
|
@ -11,40 +11,19 @@
|
||||||
// Include PlacesDBUtils module.
|
// Include PlacesDBUtils module.
|
||||||
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
||||||
|
|
||||||
function run_test() {
|
add_task(async function() {
|
||||||
do_test_pending();
|
let tasksStatusMap = await PlacesDBUtils.checkAndFixDatabase();
|
||||||
PlacesDBUtils.checkAndFixDatabase(function(aLog) {
|
let numberOfTasksRun = tasksStatusMap.size;
|
||||||
let sections = [];
|
let successfulTasks = [];
|
||||||
let positives = [];
|
let failedTasks = [];
|
||||||
let negatives = [];
|
tasksStatusMap.forEach(val => {
|
||||||
let infos = [];
|
if (val.succeeded) {
|
||||||
|
successfulTasks.push(val);
|
||||||
aLog.forEach(function(aMsg) {
|
} else {
|
||||||
print(aMsg);
|
failedTasks.push(val);
|
||||||
switch (aMsg.substr(0, 1)) {
|
|
||||||
case "+":
|
|
||||||
positives.push(aMsg);
|
|
||||||
break;
|
|
||||||
case "-":
|
|
||||||
negatives.push(aMsg);
|
|
||||||
break;
|
|
||||||
case ">":
|
|
||||||
sections.push(aMsg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
infos.push(aMsg);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Assert.equal(numberOfTasksRun, 6, "Check that we have run all tasks.");
|
||||||
print("Check that we have run all sections.");
|
Assert.equal(successfulTasks.length, 6, "Check that we have run all tasks successfully");
|
||||||
do_check_eq(sections.length, 5);
|
Assert.equal(failedTasks.length, 0, "Check that no task is failing");
|
||||||
print("Check that we have no negatives.");
|
});
|
||||||
do_check_false(!!negatives.length);
|
|
||||||
print("Check that we have positives.");
|
|
||||||
do_check_true(!!positives.length);
|
|
||||||
print("Check that we have info.");
|
|
||||||
do_check_true(!!infos.length);
|
|
||||||
|
|
||||||
do_test_finished();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,38 +9,20 @@
|
||||||
// Include PlacesDBUtils module.
|
// Include PlacesDBUtils module.
|
||||||
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
|
||||||
|
|
||||||
function run_test() {
|
add_task(async function() {
|
||||||
do_test_pending();
|
let tasksStatusMap = await PlacesDBUtils.runTasks([PlacesDBUtils.reindex]);
|
||||||
PlacesDBUtils.runTasks([PlacesDBUtils.reindex], function(aLog) {
|
let numberOfTasksRun = tasksStatusMap.size;
|
||||||
let sections = [];
|
let successfulTasks = [];
|
||||||
let positives = [];
|
let failedTasks = [];
|
||||||
let negatives = [];
|
tasksStatusMap.forEach(val => {
|
||||||
let infos = [];
|
if (val.succeeded) {
|
||||||
|
successfulTasks.push(val);
|
||||||
aLog.forEach(function(aMsg) {
|
} else {
|
||||||
print(aMsg);
|
failedTasks.push(val);
|
||||||
switch (aMsg.substr(0, 1)) {
|
|
||||||
case "+":
|
|
||||||
positives.push(aMsg);
|
|
||||||
break;
|
|
||||||
case "-":
|
|
||||||
negatives.push(aMsg);
|
|
||||||
break;
|
|
||||||
case ">":
|
|
||||||
sections.push(aMsg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
infos.push(aMsg);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
print("Check that we have run all sections.");
|
Assert.equal(numberOfTasksRun, 1, "Check that we have run all tasks.");
|
||||||
do_check_eq(sections.length, 1);
|
Assert.equal(successfulTasks.length, 1, "Check that we have run all tasks successfully");
|
||||||
print("Check that we have no negatives.");
|
Assert.equal(failedTasks.length, 0, "Check that no task is failing");
|
||||||
do_check_false(!!negatives.length);
|
});
|
||||||
print("Check that we have positives.");
|
|
||||||
do_check_true(!!positives.length);
|
|
||||||
|
|
||||||
do_test_finished();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
@ -151,9 +151,7 @@ add_task(async function test_execute() {
|
||||||
// Test idle probes.
|
// Test idle probes.
|
||||||
PlacesUtils.history.QueryInterface(Ci.nsIObserver)
|
PlacesUtils.history.QueryInterface(Ci.nsIObserver)
|
||||||
.observe(null, "idle-daily", null);
|
.observe(null, "idle-daily", null);
|
||||||
PlacesDBUtils.maintenanceOnIdle();
|
await PlacesDBUtils.maintenanceOnIdle();
|
||||||
|
|
||||||
await promiseTopicObserved("places-maintenance-finished");
|
|
||||||
|
|
||||||
for (let histogramId in histograms) {
|
for (let histogramId in histograms) {
|
||||||
do_print("checking histogram " + histogramId);
|
do_print("checking histogram " + histogramId);
|
||||||
|
|
|
@ -1035,8 +1035,8 @@ function setupEventListeners() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("verify-place-integrity-button").addEventListener("click", function(event) {
|
$("verify-place-integrity-button").addEventListener("click", function(event) {
|
||||||
PlacesDBUtils.checkAndFixDatabase(function(aLog) {
|
PlacesDBUtils.checkAndFixDatabase().then((tasksStatusMap) => {
|
||||||
let msg = aLog.join("\n");
|
let msg = PlacesDBUtils.getLegacyLog(tasksStatusMap).join("\n");
|
||||||
$("verify-place-result").style.display = "block";
|
$("verify-place-result").style.display = "block";
|
||||||
$("verify-place-result").classList.remove("no-copy");
|
$("verify-place-result").classList.remove("no-copy");
|
||||||
$("verify-place-result").textContent = msg;
|
$("verify-place-result").textContent = msg;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче