summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js')
-rw-r--r--toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js b/toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js
new file mode 100644
index 0000000000..9af7863ca2
--- /dev/null
+++ b/toolkit/components/places/tests/maintenance/test_corrupt_places_schema.js
@@ -0,0 +1,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.
+});