summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js
blob: 9af7863ca208ffb4ebeb32d63c82ab2574a0d1e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that history initialization correctly handles a corrupt places schema.

add_task(async function () {
  let path = await setupPlacesDatabase(["migration", "places_v43.sqlite"]);

  // Ensure the database will go through a migration that depends on moz_places
  // and break the schema by dropping that table.
  let db = await Sqlite.openConnection({ path });
  await db.setSchemaVersion(43);
  await db.execute("DROP TABLE moz_places");
  await db.close();

  Assert.equal(
    PlacesUtils.history.databaseStatus,
    PlacesUtils.history.DATABASE_STATUS_CORRUPT
  );
  db = await PlacesUtils.promiseDBConnection();
  await db.execute("SELECT * FROM moz_places LIMIT 1"); // Should not fail.
});