diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/unit/test_database_replaceOnStartup.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/unit/test_database_replaceOnStartup.js')
-rw-r--r-- | toolkit/components/places/tests/unit/test_database_replaceOnStartup.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js b/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js new file mode 100644 index 000000000..e83d0fdae --- /dev/null +++ b/toolkit/components/places/tests/unit/test_database_replaceOnStartup.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Tests that history initialization correctly handles a request to forcibly +// replace the current database. + +function run_test() { + // Ensure that our database doesn't already exist. + let dbFile = gProfD.clone(); + dbFile.append("places.sqlite"); + do_check_false(dbFile.exists()); + + dbFile = gProfD.clone(); + dbFile.append("places.sqlite.corrupt"); + do_check_false(dbFile.exists()); + + let file = do_get_file("default.sqlite"); + file.copyToFollowingLinks(gProfD, "places.sqlite"); + file = gProfD.clone(); + file.append("places.sqlite"); + + // Create some unique stuff to check later. + let db = Services.storage.openUnsharedDatabase(file); + db.executeSimpleSQL("CREATE TABLE test (id INTEGER PRIMARY KEY)"); + db.close(); + + Services.prefs.setBoolPref("places.database.replaceOnStartup", true); + do_check_eq(PlacesUtils.history.databaseStatus, + PlacesUtils.history.DATABASE_STATUS_CORRUPT); + + dbFile = gProfD.clone(); + dbFile.append("places.sqlite"); + do_check_true(dbFile.exists()); + + // Check the new database is really a new one. + db = Services.storage.openUnsharedDatabase(file); + try { + db.executeSimpleSQL("DELETE * FROM test"); + do_throw("The new database should not have our unique content"); + } catch (ex) {} + db.close(); + + dbFile = gProfD.clone(); + dbFile.append("places.sqlite.corrupt"); + do_check_true(dbFile.exists()); +} |