diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 21:49:04 +0200 |
commit | 39dac57259cff8b61db0b22cb2ad0a8adb02692e (patch) | |
tree | 52a026cc8c22793eb17fd0f5e22adce1ae08a1dd /toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js | |
parent | a1cce3b2b00bbd9f4983013ddd8934a7bccb9e99 (diff) | |
parent | c2d9ab62f3d097c9e0e00184cab1f546554f5eaa (diff) | |
download | UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.gz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.lz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.tar.xz UXP-39dac57259cff8b61db0b22cb2ad0a8adb02692e.zip |
Merge branch 'redwood' into 28.9-platform
Diffstat (limited to 'toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js')
-rw-r--r-- | toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js b/toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js deleted file mode 100644 index 85d23e355..000000000 --- a/toolkit/components/contentprefs/tests/unit_cps2/test_migrationToSchema4.js +++ /dev/null @@ -1,82 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Dump of version we migrate from -var schema_version3 = ` -PRAGMA foreign_keys=OFF; -BEGIN TRANSACTION; - CREATE TABLE groups (id INTEGER PRIMARY KEY, name TEXT NOT NULL); - INSERT INTO "groups" VALUES(1,'foo.com'); - INSERT INTO "groups" VALUES(2,'bar.com'); - - CREATE TABLE settings (id INTEGER PRIMARY KEY, name TEXT NOT NULL); - INSERT INTO "settings" VALUES(1,'zoom-setting'); - INSERT INTO "settings" VALUES(2,'dir-setting'); - - CREATE TABLE prefs (id INTEGER PRIMARY KEY, groupID INTEGER REFERENCES groups(id), settingID INTEGER NOT NULL REFERENCES settings(id), value BLOB); - INSERT INTO "prefs" VALUES(1,1,1,0.5); - INSERT INTO "prefs" VALUES(2,1,2,'/download/dir'); - INSERT INTO "prefs" VALUES(3,2,1,0.3); - INSERT INTO "prefs" VALUES(4,NULL,1,0.1); - - CREATE INDEX groups_idx ON groups(name); - CREATE INDEX settings_idx ON settings(name); - CREATE INDEX prefs_idx ON prefs(groupID, settingID); -COMMIT;`; - -function prepareVersion3Schema(callback) { - var dirService = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties); - - var dbFile = dirService.get("ProfD", Ci.nsIFile); - dbFile.append("content-prefs.sqlite"); - - var dbService = Cc["@mozilla.org/storage/service;1"]. - getService(Ci.mozIStorageService); - ok(!dbFile.exists(), "Db should not exist yet."); - - var dbConnection = dbService.openDatabase(dbFile); - equal(dbConnection.schemaVersion, 0); - - dbConnection.executeSimpleSQL(schema_version3); - dbConnection.schemaVersion = 3; - - dbConnection.close(); -} - -function run_test() { - prepareVersion3Schema(); - runAsyncTests(tests, true); -} - - -// WARNING: Database will reset after every test. This limitation comes from -// the fact that we ContentPrefService constructor is run only once per test file -// and so migration will be run only once. -var tests = [ - function* testMigration() { - // Test migrated db content. - schemaVersionIs(4); - let dbExpectedState = [ - [null, "zoom-setting", 0.1], - ["bar.com", "zoom-setting", 0.3], - ["foo.com", "zoom-setting", 0.5], - ["foo.com", "dir-setting", "/download/dir"], - ]; - yield dbOK(dbExpectedState); - - // Migrated fields should have timestamp set to 0. - yield cps.removeAllDomainsSince(1000, null, makeCallback()); - yield dbOK(dbExpectedState); - - yield cps.removeAllDomainsSince(0, null, makeCallback()); - yield dbOK([[null, "zoom-setting", 0.1]]); - - // Test that dates are present after migration (column is added). - const timestamp = 1234; - yield setWithDate("a.com", "pref-name", "val", timestamp); - let actualTimestamp = yield getDate("a.com", "pref-name"); - equal(actualTimestamp, timestamp); - } -]; |