Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // Tests that we rebuild the database correctly if it contains |
michael@0 | 6 | // JSON data that parses correctly but doesn't contain required fields |
michael@0 | 7 | |
michael@0 | 8 | var addon1 = { |
michael@0 | 9 | id: "addon1@tests.mozilla.org", |
michael@0 | 10 | version: "2.0", |
michael@0 | 11 | name: "Test 1", |
michael@0 | 12 | targetApplications: [{ |
michael@0 | 13 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 14 | minVersion: "1", |
michael@0 | 15 | maxVersion: "1" |
michael@0 | 16 | }] |
michael@0 | 17 | }; |
michael@0 | 18 | |
michael@0 | 19 | const profileDir = gProfD.clone(); |
michael@0 | 20 | profileDir.append("extensions"); |
michael@0 | 21 | |
michael@0 | 22 | function run_test() { |
michael@0 | 23 | do_test_pending("Bad JSON"); |
michael@0 | 24 | |
michael@0 | 25 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 26 | |
michael@0 | 27 | // This addon will be auto-installed at startup |
michael@0 | 28 | writeInstallRDFForExtension(addon1, profileDir); |
michael@0 | 29 | |
michael@0 | 30 | startupManager(); |
michael@0 | 31 | |
michael@0 | 32 | shutdownManager(); |
michael@0 | 33 | |
michael@0 | 34 | // First startup/shutdown finished |
michael@0 | 35 | // Replace the JSON store with something bogus |
michael@0 | 36 | saveJSON({not: "what we expect to find"}, gExtensionsJSON); |
michael@0 | 37 | |
michael@0 | 38 | startupManager(false); |
michael@0 | 39 | // Retrieve an addon to force the database to rebuild |
michael@0 | 40 | AddonManager.getAddonsByIDs([addon1.id], callback_soon(after_db_rebuild)); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function after_db_rebuild([a1]) { |
michael@0 | 44 | do_check_eq(a1.id, addon1.id); |
michael@0 | 45 | |
michael@0 | 46 | shutdownManager(); |
michael@0 | 47 | |
michael@0 | 48 | // Make sure our JSON database has schemaVersion and our installed extension |
michael@0 | 49 | let data = loadJSON(gExtensionsJSON); |
michael@0 | 50 | do_check_true("schemaVersion" in data); |
michael@0 | 51 | do_check_eq(data.addons[0].id, addon1.id); |
michael@0 | 52 | |
michael@0 | 53 | do_test_finished("Bad JSON"); |
michael@0 | 54 | } |