Bug 1569414 - Don't hardcode a too old history visit date in test_Chrome_history.js. r=mak, a=test-only
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Sat, 27 Jul 2019 15:57:53 +0000
changeset 544775 52440e49ce3b5da5ca765bfd9ac154ce5d92b453
parent 544774 52c27fa696582c056a1098b5677932f6e4eb8fc6
child 544776 ddfa84bcad9cc67afb25167c889c6ff28eea0d78
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, test-only
bugs1569414
milestone69.0
Bug 1569414 - Don't hardcode a too old history visit date in test_Chrome_history.js. r=mak, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D39606
browser/components/migration/tests/unit/test_Chrome_history.js
--- a/browser/components/migration/tests/unit/test_Chrome_history.js
+++ b/browser/components/migration/tests/unit/test_Chrome_history.js
@@ -73,16 +73,23 @@ async function setVisitTimes(time) {
   });
   await dbConn.execute(`UPDATE visits SET visit_time = :visit_time`, {
     visit_time: time,
   });
 
   await dbConn.close();
 }
 
+function setExpectedVisitTimes(time) {
+  for (let urlInfo of TEST_URLS) {
+    urlInfo.last_visit_time = time;
+    urlInfo.visits[0].visit_time = time;
+  }
+}
+
 function assertEntryMatches(entry, urlInfo, dateWasInFuture = false) {
   info(`Checking url: ${urlInfo.url}`);
   Assert.ok(entry, `Should have stored an entry`);
 
   Assert.equal(entry.url, urlInfo.url, "Should have the correct URL");
   Assert.equal(entry.title, urlInfo.title, "Should have the correct title");
   Assert.equal(
     entry.visits.length,
@@ -141,16 +148,21 @@ add_task(async function setup() {
     await PlacesUtils.history.clear();
     removeHistoryFile();
   });
 });
 
 add_task(async function test_import() {
   setupHistoryFile();
   await PlacesUtils.history.clear();
+  // Update to ~10 days ago since the date can't be too old or Places may expire it.
+  const pastDate = new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 10);
+  const pastChromeTime = ChromeMigrationUtils.dateToChromeTime(pastDate);
+  await setVisitTimes(pastChromeTime);
+  setExpectedVisitTimes(pastChromeTime);
 
   let migrator = await MigrationUtils.getMigrator("chrome");
   Assert.ok(
     await migrator.isSourceAvailable(),
     "Sanity check the source exists"
   );
 
   await promiseMigration(