summaryrefslogtreecommitdiffstats
path: root/browser/components/migration/tests/unit/test_IE_history.js
blob: fd803f4607737f96db41a41bae7fb3df6d8de496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"use strict";

// These match what we add to IE via InsertIEHistory.exe.
const TEST_ENTRIES = [
  {
    url: "http://www.mozilla.org/1",
    title: "Mozilla HTTP Test",
  },
  {
    url: "https://www.mozilla.org/2",
    // Test character encoding with a fox emoji:
    title: "Mozilla HTTPS Test 🦊",
  },
];

function insertIEHistory() {
  let file = do_get_file("InsertIEHistory.exe", false);
  let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
  process.init(file);

  let args = [];
  process.run(true, args, args.length);

  Assert.ok(!process.isRunning, "Should be done running");
  Assert.equal(process.exitValue, 0, "Check exit code");
}

add_task(async function setup() {
  await PlacesUtils.history.clear();

  insertIEHistory();

  registerCleanupFunction(async () => {
    await PlacesUtils.history.clear();
  });
});

add_task(async function test_IE_history() {
  let migrator = await MigrationUtils.getMigrator("ie");
  Assert.ok(await migrator.isSourceAvailable(), "Source is available");

  await promiseMigration(migrator, MigrationUtils.resourceTypes.HISTORY);

  for (let { url, title } of TEST_ENTRIES) {
    let entry = await PlacesUtils.history.fetch(url, { includeVisits: true });
    Assert.equal(entry.url, url, "Should have the correct URL");
    Assert.equal(entry.title, title, "Should have the correct title");
    Assert.ok(!!entry.visits.length, "Should have some visits");
  }
});