Bug 463154 - Form history should record creation/usage timestamps. r=mconnor, r=sdwilsh
[wine-gecko.git] / toolkit / components / satchel / test / unit / test_db_update_v999a.js
blob276f524cad8a73bd19cad2f049988df56c477bed
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is Satchel Test Code.
16 * The Initial Developer of the Original Code is
17 * Mozilla Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2008
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Justin Dolske <dolske@mozilla.com> (Original Author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * This test uses a formhistory.sqlite with schema version set to 999 (a
40 * future version). This exercies the code that allows using a future schema
41 * version as long as the expected columns are present.
43 * Part A tests this when the columns do match, so the DB is used.
44 * Part B tests this when the columns do *not* match, so the DB is reset.
47 function run_test()
49 try {
50 var testnum = 0;
52 // ===== test init =====
53 var testfile = do_get_file("toolkit/components/satchel/test/unit/formhistory_v999a.sqlite");
54 var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
56 // Cleanup from any previous tests or failures.
57 var destFile = profileDir.clone();
58 destFile.append("formhistory.sqlite");
59 if (destFile.exists())
60 destFile.remove(false);
62 testfile.copyTo(profileDir, "formhistory.sqlite");
64 var fh = Cc["@mozilla.org/satchel/form-history;1"].
65 getService(Ci.nsIFormHistory2);
68 // ===== 1 =====
69 testnum++;
70 // Check for expected contents.
71 do_check_true(fh.hasEntries);
72 do_check_true(fh.entryExists("name-A", "value-A"));
73 do_check_true(fh.entryExists("name-B", "value-B"));
74 do_check_true(fh.entryExists("name-C", "value-C1"));
75 do_check_true(fh.entryExists("name-C", "value-C2"));
76 do_check_true(fh.entryExists("name-E", "value-E"));
79 // ===== 2 =====
80 testnum++;
81 // Exercise adding and removing a name/value pair
82 do_check_false(fh.entryExists("name-D", "value-D"));
83 fh.addEntry("name-D", "value-D");
84 do_check_true(fh.entryExists("name-D", "value-D"));
85 fh.removeEntry("name-D", "value-D");
86 do_check_false(fh.entryExists("name-D", "value-D"));
88 } catch (e) {
89 throw "FAILED in test #" + testnum + " -- " + e;