Bug 1439061 - Stop tracking on engine finalization and clean up in history engine test. r=tcsc

MozReview-Commit-ID: JjgMdQwbnly

--HG--
extra : rebase_source : cc8d29a3170ea01df534c3b4de6fbec8a13c58e3
This commit is contained in:
Kit Cambridge 2018-02-16 19:21:06 -08:00
Родитель 0bd02a8387
Коммит da05a16e0a
2 изменённых файлов: 21 добавлений и 11 удалений

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

@ -246,6 +246,7 @@ Tracker.prototype = {
async finalize() { async finalize() {
// Persist all pending tracked changes to disk, and wait for the final write // Persist all pending tracked changes to disk, and wait for the final write
// to finish. // to finish.
await this.stop();
this._saveChangedIDs(); this._saveChangedIDs();
await this._storage.finalize(); await this._storage.finalize();
}, },

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

@ -128,7 +128,9 @@ add_task(async function test_history_download_limit() {
deepEqual(ping.engines[0].incoming, { applied: 5 }); deepEqual(ping.engines[0].incoming, { applied: 5 });
deepEqual(Array.from(engine.toFetch), []); deepEqual(Array.from(engine.toFetch), []);
await PlacesUtils.history.clear();
await engine.wipeClient();
await engine.finalize();
}); });
add_task(async function test_history_visit_roundtrip() { add_task(async function test_history_visit_roundtrip() {
@ -183,7 +185,9 @@ add_task(async function test_history_visit_roundtrip() {
// effectively `Math.round(microsecondTimestamp / 1000) * 1000`.) // effectively `Math.round(microsecondTimestamp / 1000) * 1000`.)
visits = await PlacesSyncUtils.history.fetchVisitsForURL("https://www.example.com"); visits = await PlacesSyncUtils.history.fetchVisitsForURL("https://www.example.com");
equal(visits.length, 2); equal(visits.length, 2);
await PlacesUtils.history.clear();
await engine.wipeClient();
await engine.finalize();
}); });
add_task(async function test_history_visit_dedupe_old() { add_task(async function test_history_visit_dedupe_old() {
@ -192,14 +196,17 @@ add_task(async function test_history_visit_dedupe_old() {
let server = await serverForFoo(engine); let server = await serverForFoo(engine);
await SyncTestingInfrastructure(server); await SyncTestingInfrastructure(server);
engine._tracker.start(); let initialVisits = Array.from({ length: 25 }, (_, index) => ({
transition: PlacesUtils.history.TRANSITION_LINK,
date: new Date(Date.UTC(2017, 10, 1 + index)),
}));
initialVisits.push({
transition: PlacesUtils.history.TRANSITION_LINK,
date: new Date(),
});
await PlacesUtils.history.insert({ await PlacesUtils.history.insert({
url: "https://www.example.com", url: "https://www.example.com",
visits: Array.from({ length: 25 }, (_, index) => ({ visits: initialVisits,
transition: PlacesUtils.history.TRANSITION_LINK,
date: new Date(Date.UTC(2017, 10, 1 + index)),
}))
}); });
let recentVisits = await PlacesSyncUtils.history.fetchVisitsForURL("https://www.example.com"); let recentVisits = await PlacesSyncUtils.history.fetchVisitsForURL("https://www.example.com");
@ -207,7 +214,7 @@ add_task(async function test_history_visit_dedupe_old() {
let {visits: allVisits, guid} = await PlacesUtils.history.fetch("https://www.example.com", { let {visits: allVisits, guid} = await PlacesUtils.history.fetch("https://www.example.com", {
includeVisits: true includeVisits: true
}); });
equal(allVisits.length, 25); equal(allVisits.length, 26);
let collection = server.user("foo").collection("history"); let collection = server.user("foo").collection("history");
@ -243,10 +250,12 @@ add_task(async function test_history_visit_dedupe_old() {
includeVisits: true includeVisits: true
})).visits; })).visits;
equal(allVisits.length, 27); equal(allVisits.length, 28);
ok(allVisits.find(x => x.date.getTime() === Date.UTC(2017, 11, 4)), ok(allVisits.find(x => x.date.getTime() === Date.UTC(2017, 11, 4)),
"Should contain the Dec. 4th visit"); "Should contain the Dec. 4th visit");
ok(allVisits.find(x => x.date.getTime() === Date.UTC(2017, 11, 5)), ok(allVisits.find(x => x.date.getTime() === Date.UTC(2017, 11, 5)),
"Should contain the Dec. 5th visit"); "Should contain the Dec. 5th visit");
await PlacesUtils.history.clear();
await engine.wipeClient();
await engine.finalize();
}); });