toolkit/components/satchel/test/unit/test_db_update_v4.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial