diff --git a/toolkit/mozapps/extensions/AddonRepository.jsm b/toolkit/mozapps/extensions/AddonRepository.jsm index 826ce24278b..54c739ea5c0 100644 --- a/toolkit/mozapps/extensions/AddonRepository.jsm +++ b/toolkit/mozapps/extensions/AddonRepository.jsm @@ -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); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js index d177ee02f5d..9132f15c983 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js @@ -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(); - }); -}