Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: browser/components/migration/tests/unit/xpcshell.toml
/* Any copyright is dedicated to the Public Domain.
"use strict";
const { sinon } = ChromeUtils.importESModule(
);
const { EdgeProfileMigrator } = ChromeUtils.importESModule(
"resource:///modules/EdgeProfileMigrator.sys.mjs"
);
const { MSMigrationUtils } = ChromeUtils.importESModule(
"resource:///modules/MSMigrationUtils.sys.mjs"
);
/**
* Tests that history visits loaded from the registry from Edge (EdgeHTML)
* that have a visit date older than maxAgeInDays days do not get imported.
*/
add_task(async function test_Edge_history_past_max_days() {
let sandbox = sinon.createSandbox();
registerCleanupFunction(() => {
sandbox.restore();
});
Assert.ok(
MigrationUtils.HISTORY_MAX_AGE_IN_DAYS < 300,
"This test expects the current pref to be less than the youngest expired visit."
);
Assert.ok(
MigrationUtils.HISTORY_MAX_AGE_IN_DAYS > 160,
"This test expects the current pref to be greater than the oldest unexpired visit."
);
const EXPIRED_VISITS = [
];
const UNEXPIRED_VISITS = [
];
const ALL_VISITS = [...EXPIRED_VISITS, ...UNEXPIRED_VISITS];
// Fake out the getResources method of the migrator so that we return
// a single fake MigratorResource per availableResourceType.
sandbox.stub(MSMigrationUtils, "getTypedURLs").callsFake(() => {
return new Map(ALL_VISITS);
});
// Manually create an EdgeProfileMigrator rather than going through
// MigrationUtils.getMigrator to avoid the user data availability check, since
// we're mocking out that stuff.
let migrator = new EdgeProfileMigrator();
let registryTypedHistoryMigrator =
migrator.getHistoryRegistryMigratorForTesting();
await new Promise(resolve => {
registryTypedHistoryMigrator.migrate(resolve);
});
Assert.ok(true, "History from registry migration done!");
for (let expiredEntry of EXPIRED_VISITS) {
let entry = await PlacesUtils.history.fetch(expiredEntry[0], {
includeVisits: true,
});
Assert.equal(entry, null, "Should not have found an entry.");
}
for (let unexpiredEntry of UNEXPIRED_VISITS) {
let entry = await PlacesUtils.history.fetch(unexpiredEntry[0], {
includeVisits: true,
});
Assert.equal(entry.url, unexpiredEntry[0], "Should have the correct URL");
Assert.ok(!!entry.visits.length, "Should have some visits");
}
});