From 9421690a89cdbde8ab443922242ecc1c70b61c0f Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Fri, 7 Oct 2011 12:36:44 +0100 Subject: [PATCH] Backout changeset ef21d6f2187d to correct bug number --- .../mozapps/extensions/AddonRepository.jsm | 4 +- .../xpcshell/test_migrateAddonRepository.js | 42 ++----------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/toolkit/mozapps/extensions/AddonRepository.jsm b/toolkit/mozapps/extensions/AddonRepository.jsm index 826ce24278b4..54c739ea5c0c 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 d177ee02f5db..9132f15c983b 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(); - }); -}