1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/satchel/test/unit/test_db_update_v4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +var testnum = 0; 1.9 + 1.10 +let iter; 1.11 + 1.12 +function run_test() 1.13 +{ 1.14 + do_test_pending(); 1.15 + iter = next_test(); 1.16 + iter.next(); 1.17 +} 1.18 + 1.19 +function next_test() 1.20 +{ 1.21 + try { 1.22 + 1.23 + // ===== test init ===== 1.24 + var testfile = do_get_file("formhistory_v3.sqlite"); 1.25 + var profileDir = dirSvc.get("ProfD", Ci.nsIFile); 1.26 + 1.27 + // Cleanup from any previous tests or failures. 1.28 + var destFile = profileDir.clone(); 1.29 + destFile.append("formhistory.sqlite"); 1.30 + if (destFile.exists()) 1.31 + destFile.remove(false); 1.32 + 1.33 + testfile.copyTo(profileDir, "formhistory.sqlite"); 1.34 + do_check_eq(3, getDBVersion(testfile)); 1.35 + 1.36 + // ===== 1 ===== 1.37 + testnum++; 1.38 + 1.39 + destFile = profileDir.clone(); 1.40 + destFile.append("formhistory.sqlite"); 1.41 + let dbConnection = Services.storage.openUnsharedDatabase(destFile); 1.42 + 1.43 + // check for upgraded schema. 1.44 + do_check_eq(CURRENT_SCHEMA, FormHistory.schemaVersion); 1.45 + 1.46 + // Check that the index was added 1.47 + do_check_true(dbConnection.tableExists("moz_deleted_formhistory")); 1.48 + dbConnection.close(); 1.49 + 1.50 + // check for upgraded schema. 1.51 + do_check_eq(CURRENT_SCHEMA, FormHistory.schemaVersion); 1.52 + // check that an entry still exists 1.53 + yield countEntries("name-A", "value-A", 1.54 + function (num) { 1.55 + do_check_true(num > 0); 1.56 + do_test_finished(); 1.57 + } 1.58 + ); 1.59 + 1.60 + } catch (e) { 1.61 + throw "FAILED in test #" + testnum + " -- " + e; 1.62 + } 1.63 +}