summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /browser/components/migration/tests/unit
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/migration/tests/unit')
-rw-r--r--browser/components/migration/tests/unit/head_migration.js28
-rw-r--r--browser/components/migration/tests/unit/test_Chrome_bookmarks.js20
-rw-r--r--browser/components/migration/tests/unit/test_Safari_history_strange_entries.js7
3 files changed, 46 insertions, 9 deletions
diff --git a/browser/components/migration/tests/unit/head_migration.js b/browser/components/migration/tests/unit/head_migration.js
index 9900f34232..9b056e6670 100644
--- a/browser/components/migration/tests/unit/head_migration.js
+++ b/browser/components/migration/tests/unit/head_migration.js
@@ -118,6 +118,34 @@ async function assertFavicons(pageURIs) {
}
/**
+ * Check the image data for favicon of given page uri.
+ *
+ * @param {string} pageURI
+ * The page URI to which the favicon belongs.
+ * @param {Array} expectedImageData
+ * Expected image data of the favicon.
+ * @param {string} expectedMimeType
+ * Expected mime type of the favicon.
+ */
+async function assertFavicon(pageURI, expectedImageData, expectedMimeType) {
+ let result = await new Promise(resolve => {
+ PlacesUtils.favicons.getFaviconDataForPage(
+ Services.io.newURI(pageURI),
+ (faviconURI, dataLen, imageData, mimeType) => {
+ resolve({ faviconURI, dataLen, imageData, mimeType });
+ }
+ );
+ });
+ Assert.ok(!!result, `Got favicon for ${pageURI}`);
+ Assert.equal(
+ result.imageData.join(","),
+ expectedImageData.join(","),
+ "Image data is correct"
+ );
+ Assert.equal(result.mimeType, expectedMimeType, "Mime type is correct");
+}
+
+/**
* Replaces a directory service entry with a given nsIFile.
*
* @param {string} key
diff --git a/browser/components/migration/tests/unit/test_Chrome_bookmarks.js b/browser/components/migration/tests/unit/test_Chrome_bookmarks.js
index d115cda412..3c09869800 100644
--- a/browser/components/migration/tests/unit/test_Chrome_bookmarks.js
+++ b/browser/components/migration/tests/unit/test_Chrome_bookmarks.js
@@ -71,11 +71,13 @@ async function testBookmarks(migratorKey, subDirs) {
).path;
await IOUtils.copy(sourcePath, target.path);
- // Get page url for each favicon
- let faviconURIs = await MigrationUtils.getRowsFromDBWithoutLocks(
+ // Get page url and the image data for each favicon
+ let favicons = await MigrationUtils.getRowsFromDBWithoutLocks(
sourcePath,
"Chrome Bookmark Favicons",
- `select page_url from icon_mapping`
+ `SELECT page_url, image_data FROM icon_mapping
+ INNER JOIN favicon_bitmaps ON (favicon_bitmaps.icon_id = icon_mapping.icon_id)
+ `
);
target.append("Bookmarks");
@@ -171,10 +173,14 @@ async function testBookmarks(migratorKey, subDirs) {
"Telemetry reporting correct."
);
Assert.ok(observerNotified, "The observer should be notified upon migration");
- let pageUrls = Array.from(faviconURIs, f =>
- Services.io.newURI(f.getResultByName("page_url"))
- );
- await assertFavicons(pageUrls);
+
+ for (const favicon of favicons) {
+ await assertFavicon(
+ favicon.getResultByName("page_url"),
+ favicon.getResultByName("image_data"),
+ "image/png"
+ );
+ }
}
add_task(async function test_Chrome() {
diff --git a/browser/components/migration/tests/unit/test_Safari_history_strange_entries.js b/browser/components/migration/tests/unit/test_Safari_history_strange_entries.js
index 2578353e35..a22e6e1655 100644
--- a/browser/components/migration/tests/unit/test_Safari_history_strange_entries.js
+++ b/browser/components/migration/tests/unit/test_Safari_history_strange_entries.js
@@ -74,7 +74,7 @@ add_task(async function testHistoryImportStrangeEntries() {
await PlacesUtils.history.clear();
let placesQuery = new PlacesQuery();
- let emptyHistory = await placesQuery.getHistory();
+ let emptyHistory = await placesQuery.getHistory({ daysOld: Infinity });
Assert.equal(emptyHistory.size, 0, "Empty history should indeed be empty.");
const EXPECTED_MIGRATED_SITES = 10;
@@ -94,7 +94,10 @@ add_task(async function testHistoryImportStrangeEntries() {
let migrator = await MigrationUtils.getMigrator("safari");
await promiseMigration(migrator, MigrationUtils.resourceTypes.HISTORY);
- let migratedHistory = await placesQuery.getHistory({ sortBy: "site" });
+ let migratedHistory = await placesQuery.getHistory({
+ daysOld: Infinity,
+ sortBy: "site",
+ });
let siteCount = migratedHistory.size;
let visitCount = 0;
for (let [, visits] of migratedHistory) {