diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/migration/tests | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/migration/tests')
8 files changed, 54 insertions, 17 deletions
diff --git a/browser/components/migration/tests/browser/browser_disabled_migrator.js b/browser/components/migration/tests/browser/browser_disabled_migrator.js index 782666f6a6..a9a6b3083c 100644 --- a/browser/components/migration/tests/browser/browser_disabled_migrator.js +++ b/browser/components/migration/tests/browser/browser_disabled_migrator.js @@ -17,7 +17,7 @@ add_task(async function test_enabled_migrator() { let wizard = dialog.querySelector("migration-wizard"); let shadow = wizard.openOrClosedShadowRoot; let selector = shadow.querySelector("#browser-profile-selector"); - selector.click(); + EventUtils.synthesizeMouseAtCenter(selector, {}, prefsWin); await new Promise(resolve => { shadow @@ -78,7 +78,7 @@ add_task(async function test_disabling_migrator() { let wizard = dialog.querySelector("migration-wizard"); let shadow = wizard.openOrClosedShadowRoot; let selector = shadow.querySelector("#browser-profile-selector"); - selector.click(); + EventUtils.synthesizeMouseAtCenter(selector, {}, prefsWin); await new Promise(resolve => { shadow diff --git a/browser/components/migration/tests/browser/browser_do_migration.js b/browser/components/migration/tests/browser/browser_do_migration.js index fab9641960..74454c0ab1 100644 --- a/browser/components/migration/tests/browser/browser_do_migration.js +++ b/browser/components/migration/tests/browser/browser_do_migration.js @@ -106,7 +106,7 @@ add_task(async function test_successful_migrations() { ); let dialogClosed = BrowserTestUtils.waitForEvent(dialog, "close"); - doneButton.click(); + EventUtils.synthesizeMouseAtCenter(doneButton, {}, prefsWin); await dialogClosed; assertQuantitiesShown(wizard, [ MigrationWizardConstants.DISPLAYED_RESOURCE_TYPES.PASSWORDS, diff --git a/browser/components/migration/tests/browser/browser_file_migration.js b/browser/components/migration/tests/browser/browser_file_migration.js index c73dfc4456..94f4ff2908 100644 --- a/browser/components/migration/tests/browser/browser_file_migration.js +++ b/browser/components/migration/tests/browser/browser_file_migration.js @@ -132,7 +132,7 @@ add_task(async function test_file_migration() { // Now select our DummyFileMigrator from the list. let selector = shadow.querySelector("#browser-profile-selector"); - selector.click(); + EventUtils.synthesizeMouseAtCenter(selector, {}, prefsWin); info("Waiting for panel-list shown"); await new Promise(resolve => { @@ -246,7 +246,7 @@ add_task(async function test_file_migration_error() { // Now select our DummyFileMigrator from the list. let selector = shadow.querySelector("#browser-profile-selector"); - selector.click(); + EventUtils.synthesizeMouseAtCenter(selector, {}, prefsWin); info("Waiting for panel-list shown"); await new Promise(resolve => { diff --git a/browser/components/migration/tests/browser/head.js b/browser/components/migration/tests/browser/head.js index d3d188a7e1..8824a50ee9 100644 --- a/browser/components/migration/tests/browser/head.js +++ b/browser/components/migration/tests/browser/head.js @@ -332,7 +332,7 @@ async function selectResourceTypesAndStartMigration( // First, select the InternalTestingProfileMigrator browser. let selector = shadow.querySelector("#browser-profile-selector"); - selector.click(); + EventUtils.synthesizeMouseAtCenter(selector, {}, wizard.ownerGlobal); await new Promise(resolve => { shadow diff --git a/browser/components/migration/tests/chrome/test_migration_wizard.html b/browser/components/migration/tests/chrome/test_migration_wizard.html index cc2d8a0363..43fd3ab931 100644 --- a/browser/components/migration/tests/chrome/test_migration_wizard.html +++ b/browser/components/migration/tests/chrome/test_migration_wizard.html @@ -147,7 +147,7 @@ // Test that the resource type checkboxes are shown or hidden depending on // which resourceTypes are included with the MigratorProfileInstance. for (let migratorInstance of MIGRATOR_PROFILE_INSTANCES) { - selector.click(); + synthesizeMouseAtCenter(selector, {}, gWiz.ownerGlobal); await new Promise(resolve => { gShadowRoot .querySelector("panel-list") @@ -248,7 +248,7 @@ ok(isHidden(preamble), "preamble should be hidden."); let selector = gShadowRoot.querySelector("#browser-profile-selector"); - selector.click(); + synthesizeMouseAtCenter(selector, {}, gWiz.ownerGlobal); await new Promise(resolve => { let panelList = gShadowRoot.querySelector("panel-list"); if (panelList) { 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) { |