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

"use strict";

add_task(async function setup() {
  const path = await setupPlacesDatabase("places_v68.sqlite");

  const db = await Sqlite.openConnection({ path });
  await db.execute("INSERT INTO moz_historyvisits (from_visit) VALUES (-1)");
  await db.close();
});

add_task(async function database_is_valid() {
  // Accessing the database for the first time triggers migration.
  Assert.equal(
    PlacesUtils.history.databaseStatus,
    PlacesUtils.history.DATABASE_STATUS_UPGRADED
  );

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

add_task(async function moz_historyvisits() {
  await PlacesUtils.withConnectionWrapper("test_sqlite_migration", async db => {
    const rows = await db.execute(
      "SELECT * FROM moz_historyvisits WHERE from_visit=-1"
    );

    Assert.equal(rows.length, 1);
    Assert.equal(rows[0].getResultByName("source"), 0);
    Assert.equal(rows[0].getResultByName("triggeringPlaceId"), null);
  });
});