Backout changeset ef21d6f2187d to correct bug number

This commit is contained in:
Ed Morley 2011-10-07 12:36:44 +01:00
parent c06a84abb0
commit 0abe4796c2
2 changed files with 5 additions and 41 deletions

View File

@ -1331,7 +1331,7 @@ var AddonDatabase = {
let dbfile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_DATABASE], true);
let dbMissing = !dbfile.exists();
var tryAgain = (function() {
function tryAgain() {
LOG("Deleting database, and attempting openConnection again");
this.initialized = false;
if (this.connection.connectionReady)
@ -1339,7 +1339,7 @@ var AddonDatabase = {
if (dbfile.exists())
dbfile.remove(false);
return this.openConnection(true);
}).bind(this);
}
try {
this.connection = Services.storage.openUnsharedDatabase(dbfile);

View File

@ -2,15 +2,13 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const EXPECTED_SCHEMA_VERSION = 2;
let dbfile;
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Write out a minimal database.
dbfile = gProfD.clone();
let dbfile = gProfD.clone();
dbfile.append("addons.sqlite");
let db = AM_Cc["@mozilla.org/storage/service;1"].
getService(AM_Ci.mozIStorageService).
@ -85,11 +83,11 @@ function run_test() {
db = AM_Cc["@mozilla.org/storage/service;1"].
getService(AM_Ci.mozIStorageService).
openDatabase(dbfile);
do_check_eq(db.schemaVersion, EXPECTED_SCHEMA_VERSION);
do_check_eq(db.schemaVersion, 2);
do_check_true(db.indexExists("developer_idx"));
do_check_true(db.indexExists("screenshot_idx"));
db.close();
run_test_2();
do_test_finished();
}
}, "addon-repository-shutdown", null);
@ -104,37 +102,3 @@ function run_test() {
AddonRepository.shutdown();
});
}
function run_test_2() {
// Write out a minimal database.
let db = AM_Cc["@mozilla.org/storage/service;1"].
getService(AM_Ci.mozIStorageService).
openDatabase(dbfile);
db.createTable("futuristicSchema",
"id INTEGER, " +
"sharks TEXT, " +
"lasers TEXT");
db.schemaVersion = 1000;
db.close();
Services.obs.addObserver({
observe: function () {
Services.obs.removeObserver(this, "addon-repository-shutdown");
// Check the DB schema has changed once AddonRepository has freed it.
db = AM_Cc["@mozilla.org/storage/service;1"].
getService(AM_Ci.mozIStorageService).
openDatabase(dbfile);
do_check_eq(db.schemaVersion, EXPECTED_SCHEMA_VERSION);
db.close();
do_test_finished();
}
}, "addon-repository-shutdown", null);
// Force a connection to the addon database to be opened.
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
AddonRepository.getCachedAddonByID("test1@tests.mozilla.org", function (aAddon) {
AddonRepository.shutdown();
});
}