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/. */
7 function getDBVersion(dbfile
) {
8 let dbConnection
= Services
.storage
.openDatabase(dbfile
);
9 let version
= dbConnection
.schemaVersion
;
15 function indexExists(dbfile
, indexname
) {
16 let dbConnection
= Services
.storage
.openDatabase(dbfile
);
17 let result
= dbConnection
.indexExists(indexname
);
23 add_task(async
function () {
25 let testfile
= do_get_file("data/cookies_v10.sqlite");
26 let profileDir
= do_get_profile();
28 // Cleanup from any previous tests or failures.
29 let destFile
= profileDir
.clone();
30 destFile
.append("cookies.sqlite");
31 if (destFile
.exists()) {
32 destFile
.remove(false);
35 testfile
.copyTo(profileDir
, "cookies.sqlite");
36 Assert
.equal(10, getDBVersion(destFile
));
38 Assert
.ok(destFile
.exists());
40 // Check that the index exists
41 Assert
.ok(indexExists(destFile
, "moz_basedomain"));
43 // Do something that will cause the cookie service access and upgrade the
45 Services
.cookies
.cookies
;
47 // Pretend that we're about to shut down, to tell the cookie manager
48 // to clean up its connection with its database.
49 Services
.startup
.advanceShutdownPhase(
50 Services
.startup
.SHUTDOWN_PHASE_APPSHUTDOWN
53 // check for upgraded schema.
54 Assert
.ok(getDBVersion(destFile
) >= 13);
56 // Check that the index was deleted
57 Assert
.ok(!indexExists(destFile
, "moz_basedomain"));
59 throw new Error(`FAILED: ${e}`);