|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 var testnum = 0; |
|
6 |
|
7 let iter; |
|
8 |
|
9 function run_test() |
|
10 { |
|
11 do_test_pending(); |
|
12 iter = next_test(); |
|
13 iter.next(); |
|
14 } |
|
15 |
|
16 function next_test() |
|
17 { |
|
18 try { |
|
19 |
|
20 // ===== test init ===== |
|
21 var testfile = do_get_file("formhistory_v3.sqlite"); |
|
22 var profileDir = dirSvc.get("ProfD", Ci.nsIFile); |
|
23 |
|
24 // Cleanup from any previous tests or failures. |
|
25 var destFile = profileDir.clone(); |
|
26 destFile.append("formhistory.sqlite"); |
|
27 if (destFile.exists()) |
|
28 destFile.remove(false); |
|
29 |
|
30 testfile.copyTo(profileDir, "formhistory.sqlite"); |
|
31 do_check_eq(3, getDBVersion(testfile)); |
|
32 |
|
33 // ===== 1 ===== |
|
34 testnum++; |
|
35 |
|
36 destFile = profileDir.clone(); |
|
37 destFile.append("formhistory.sqlite"); |
|
38 let dbConnection = Services.storage.openUnsharedDatabase(destFile); |
|
39 |
|
40 // check for upgraded schema. |
|
41 do_check_eq(CURRENT_SCHEMA, FormHistory.schemaVersion); |
|
42 |
|
43 // Check that the index was added |
|
44 do_check_true(dbConnection.tableExists("moz_deleted_formhistory")); |
|
45 dbConnection.close(); |
|
46 |
|
47 // check for upgraded schema. |
|
48 do_check_eq(CURRENT_SCHEMA, FormHistory.schemaVersion); |
|
49 // check that an entry still exists |
|
50 yield countEntries("name-A", "value-A", |
|
51 function (num) { |
|
52 do_check_true(num > 0); |
|
53 do_test_finished(); |
|
54 } |
|
55 ); |
|
56 |
|
57 } catch (e) { |
|
58 throw "FAILED in test #" + testnum + " -- " + e; |
|
59 } |
|
60 } |