michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests that we rebuild the database correctly if it contains michael@0: // JSON data that parses correctly but doesn't contain required fields michael@0: michael@0: var addon1 = { michael@0: id: "addon1@tests.mozilla.org", michael@0: version: "2.0", michael@0: name: "Test 1", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "1" michael@0: }] michael@0: }; michael@0: michael@0: const profileDir = gProfD.clone(); michael@0: profileDir.append("extensions"); michael@0: michael@0: function run_test() { michael@0: do_test_pending("Bad JSON"); michael@0: michael@0: createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); michael@0: michael@0: // This addon will be auto-installed at startup michael@0: writeInstallRDFForExtension(addon1, profileDir); michael@0: michael@0: startupManager(); michael@0: michael@0: shutdownManager(); michael@0: michael@0: // First startup/shutdown finished michael@0: // Replace the JSON store with something bogus michael@0: saveJSON({not: "what we expect to find"}, gExtensionsJSON); michael@0: michael@0: startupManager(false); michael@0: // Retrieve an addon to force the database to rebuild michael@0: AddonManager.getAddonsByIDs([addon1.id], callback_soon(after_db_rebuild)); michael@0: } michael@0: michael@0: function after_db_rebuild([a1]) { michael@0: do_check_eq(a1.id, addon1.id); michael@0: michael@0: shutdownManager(); michael@0: michael@0: // Make sure our JSON database has schemaVersion and our installed extension michael@0: let data = loadJSON(gExtensionsJSON); michael@0: do_check_true("schemaVersion" in data); michael@0: do_check_eq(data.addons[0].id, addon1.id); michael@0: michael@0: do_test_finished("Bad JSON"); michael@0: }