summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/maintenance/test_corrupt_favicons_schema.js
blob: 299bbca65d1f32feae406fdeba8bea27f221a511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* 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", "favicons_v41.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(38);
  await db.execute("DROP TABLE moz_icons");
  await db.close();

  Assert.equal(
    PlacesUtils.history.databaseStatus,
    PlacesUtils.history.DATABASE_STATUS_CORRUPT
  );
  db = await PlacesUtils.promiseDBConnection();
  let rows = await db.execute("SELECT 1 FROM moz_icons");
  Assert.equal(rows.length, 0, "Found no icons");
});