Bug 1847592 - Modify some Places tests to not rely on outdated versions of the database. r=places-reviewers,lina

Differential Revision: https://phabricator.services.mozilla.com/D185654
This commit is contained in:
Marco Bonardo 2023-08-08 17:12:12 +00:00
parent 2e1e0e2641
commit 7228304d66
7 changed files with 18 additions and 38 deletions

View File

@ -9,7 +9,6 @@ add_task(async function () {
// Ensure the database will go through a migration that depends on moz_places
// and break the schema by dropping that table.
let db = await Sqlite.openConnection({ path });
await db.setSchemaVersion(43);
await db.execute("DROP TABLE moz_places");
await db.close();

View File

@ -16,37 +16,24 @@ const ALL_ROOT_GUIDS = [
PlacesUtils.bookmarks.mobileGuid,
];
const INITIAL_ROOT_GUIDS = [
PlacesUtils.bookmarks.menuGuid,
PlacesUtils.bookmarks.tagsGuid,
PlacesUtils.bookmarks.unfiledGuid,
];
add_task(async function setup() {
// This file has the toolbar and mobile folders missing.
await setupPlacesDatabase("missingBuiltIn.sqlite");
await setupPlacesDatabase([
"migration",
`places_v${Ci.nsINavHistoryService.DATABASE_SCHEMA_VERSION}.sqlite`,
]);
// Check database contents to be migrated.
// Prepare database contents by removing the tolbar and mobile folders.
let path = PathUtils.join(PathUtils.profileDir, DB_FILENAME);
let db = await Sqlite.openConnection({ path });
let rows = await db.execute(
await db.execute(
`
SELECT guid FROM moz_bookmarks
WHERE parent = (SELECT id from moz_bookmarks WHERE guid = :guid)
`,
DELETE FROM moz_bookmarks WHERE guid IN(:toolbar, :mobile)
`,
{
guid: PlacesUtils.bookmarks.rootGuid,
toolbar: PlacesUtils.bookmarks.toolbarGuid,
mobile: PlacesUtils.bookmarks.mobileGuid,
}
);
let guids = rows.map(row => row.getResultByName("guid"));
Assert.deepEqual(
guids,
INITIAL_ROOT_GUIDS,
"Initial database should have only the expected GUIDs"
);
await db.close();
});

View File

@ -17,25 +17,22 @@ const ALL_ROOT_GUIDS = [
];
add_task(async function setup() {
// This file has no root folder.
await setupPlacesDatabase("noRoot.sqlite");
await setupPlacesDatabase([
"migration",
`places_v${Ci.nsINavHistoryService.DATABASE_SCHEMA_VERSION}.sqlite`,
]);
// Check database contents to be migrated.
// Prepare database contents by removing the root folder.
let path = PathUtils.join(PathUtils.profileDir, DB_FILENAME);
let db = await Sqlite.openConnection({ path });
let rows = await db.execute(
await db.execute(
`
SELECT guid FROM moz_bookmarks
WHERE guid = :guid
`,
DELETE FROM moz_bookmarks WHERE guid = :guid
`,
{
guid: PlacesUtils.bookmarks.rootGuid,
}
);
Assert.equal(rows.length, 0, "Root folder should not exist");
await db.close();
});

View File

@ -15,7 +15,6 @@ support-files =
mobile_bookmarks_multiple_folders.json
mobile_bookmarks_root_import.json
mobile_bookmarks_root_merge.json
places.sparse.sqlite
[test_331487.js]
[test_384370.js]
@ -85,9 +84,7 @@ prefs = places.frecency.pages.alternative.featureGate=true
[test_markpageas.js]
[test_metadata.js]
[test_missing_builtin_folders.js]
support-files = missingBuiltIn.sqlite
[test_missing_root_folder.js]
support-files = noRoot.sqlite
[test_multi_observation.js]
[test_multi_word_tags.js]
[test_nested_notifications.js]