summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/migration/test_current_from_outdated.js
blob: e7fad5b3a4d383d16630b49acae9800354010dfd (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * This file tests migration from a preliminary schema version 6 that
 * lacks frecency column and moz_inputhistory table.
 */

add_task(async function setup() {
  await setupPlacesDatabase("places_outdated.sqlite");
});

add_task(async function corrupt_database_not_exists() {
  let corruptPath = PathUtils.join(
    PathUtils.profileDir,
    "places.sqlite.corrupt"
  );
  Assert.ok(
    !(await IOUtils.exists(corruptPath)),
    "Corrupt file should not exist"
  );
});

add_task(async function database_is_valid() {
  Assert.equal(
    PlacesUtils.history.databaseStatus,
    PlacesUtils.history.DATABASE_STATUS_CORRUPT
  );

  let db = await PlacesUtils.promiseDBConnection();
  Assert.equal(await db.getSchemaVersion(), CURRENT_SCHEMA_VERSION);
});

add_task(async function check_columns() {
  // Check the database has been replaced, these would throw otherwise.
  let db = await PlacesUtils.promiseDBConnection();
  await db.execute("SELECT frecency from moz_places");
  await db.execute("SELECT 1 from moz_inputhistory");
});

add_task(async function corrupt_database_exists() {
  let corruptPath = PathUtils.join(
    PathUtils.profileDir,
    "places.sqlite.corrupt"
  );
  Assert.ok(await IOUtils.exists(corruptPath), "Corrupt file should exist");
});