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 | // This verifies that add-ons with invalid target application entries show |
michael@0 | 6 | // up in the API but are correctly appDisabled |
michael@0 | 7 | |
michael@0 | 8 | // A working add-on |
michael@0 | 9 | var addon1 = { |
michael@0 | 10 | id: "addon1@tests.mozilla.org", |
michael@0 | 11 | version: "1.0", |
michael@0 | 12 | name: "Test 1", |
michael@0 | 13 | targetApplications: [{ |
michael@0 | 14 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 15 | minVersion: "1", |
michael@0 | 16 | maxVersion: "1" |
michael@0 | 17 | }] |
michael@0 | 18 | }; |
michael@0 | 19 | |
michael@0 | 20 | // Missing id |
michael@0 | 21 | var addon2 = { |
michael@0 | 22 | id: "addon2@tests.mozilla.org", |
michael@0 | 23 | version: "1.0", |
michael@0 | 24 | name: "Test 2", |
michael@0 | 25 | targetApplications: [{ |
michael@0 | 26 | minVersion: "1", |
michael@0 | 27 | maxVersion: "2" |
michael@0 | 28 | }] |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | // Missing minVersion |
michael@0 | 32 | var addon3 = { |
michael@0 | 33 | id: "addon3@tests.mozilla.org", |
michael@0 | 34 | version: "1.0", |
michael@0 | 35 | name: "Test 3", |
michael@0 | 36 | targetApplications: [{ |
michael@0 | 37 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 38 | maxVersion: "1" |
michael@0 | 39 | }] |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | // Missing maxVersion |
michael@0 | 43 | var addon4 = { |
michael@0 | 44 | id: "addon4@tests.mozilla.org", |
michael@0 | 45 | version: "1.0", |
michael@0 | 46 | name: "Test 4", |
michael@0 | 47 | targetApplications: [{ |
michael@0 | 48 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 49 | minVersion: "1" |
michael@0 | 50 | }] |
michael@0 | 51 | }; |
michael@0 | 52 | |
michael@0 | 53 | // Blank id |
michael@0 | 54 | var addon5 = { |
michael@0 | 55 | id: "addon5@tests.mozilla.org", |
michael@0 | 56 | version: "1.0", |
michael@0 | 57 | name: "Test 5", |
michael@0 | 58 | targetApplications: [{ |
michael@0 | 59 | id: "", |
michael@0 | 60 | minVersion: "1", |
michael@0 | 61 | maxVersion: "2" |
michael@0 | 62 | }] |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | // Blank minVersion |
michael@0 | 66 | var addon6 = { |
michael@0 | 67 | id: "addon6@tests.mozilla.org", |
michael@0 | 68 | version: "1.0", |
michael@0 | 69 | name: "Test 6", |
michael@0 | 70 | targetApplications: [{ |
michael@0 | 71 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 72 | minVersion: "", |
michael@0 | 73 | maxVersion: "1" |
michael@0 | 74 | }] |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | // Blank maxVersion |
michael@0 | 78 | var addon7 = { |
michael@0 | 79 | id: "addon7@tests.mozilla.org", |
michael@0 | 80 | version: "1.0", |
michael@0 | 81 | name: "Test 7", |
michael@0 | 82 | targetApplications: [{ |
michael@0 | 83 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 84 | minVersion: "1", |
michael@0 | 85 | maxVersion: "" |
michael@0 | 86 | }] |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 90 | |
michael@0 | 91 | const profileDir = gProfD.clone(); |
michael@0 | 92 | profileDir.append("extensions"); |
michael@0 | 93 | |
michael@0 | 94 | // Set up the profile |
michael@0 | 95 | function run_test() { |
michael@0 | 96 | do_test_pending(); |
michael@0 | 97 | |
michael@0 | 98 | writeInstallRDFForExtension(addon1, profileDir); |
michael@0 | 99 | writeInstallRDFForExtension(addon2, profileDir); |
michael@0 | 100 | writeInstallRDFForExtension(addon3, profileDir); |
michael@0 | 101 | writeInstallRDFForExtension(addon4, profileDir); |
michael@0 | 102 | writeInstallRDFForExtension(addon5, profileDir); |
michael@0 | 103 | writeInstallRDFForExtension(addon6, profileDir); |
michael@0 | 104 | writeInstallRDFForExtension(addon7, profileDir); |
michael@0 | 105 | |
michael@0 | 106 | startupManager(); |
michael@0 | 107 | |
michael@0 | 108 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 109 | "addon2@tests.mozilla.org", |
michael@0 | 110 | "addon3@tests.mozilla.org", |
michael@0 | 111 | "addon4@tests.mozilla.org", |
michael@0 | 112 | "addon5@tests.mozilla.org", |
michael@0 | 113 | "addon6@tests.mozilla.org", |
michael@0 | 114 | "addon7@tests.mozilla.org"], |
michael@0 | 115 | function([a1, a2, a3, a4, a5, a6, a7]) { |
michael@0 | 116 | do_check_neq(a1, null); |
michael@0 | 117 | do_check_false(a1.appDisabled); |
michael@0 | 118 | do_check_true(a1.isActive); |
michael@0 | 119 | |
michael@0 | 120 | do_check_neq(a2, null); |
michael@0 | 121 | do_check_true(a2.appDisabled); |
michael@0 | 122 | do_check_false(a2.isActive); |
michael@0 | 123 | |
michael@0 | 124 | do_check_neq(a3, null); |
michael@0 | 125 | do_check_true(a3.appDisabled); |
michael@0 | 126 | do_check_false(a3.isActive); |
michael@0 | 127 | |
michael@0 | 128 | do_check_neq(a4, null); |
michael@0 | 129 | do_check_true(a4.appDisabled); |
michael@0 | 130 | do_check_false(a4.isActive); |
michael@0 | 131 | |
michael@0 | 132 | do_check_neq(a5, null); |
michael@0 | 133 | do_check_true(a5.appDisabled); |
michael@0 | 134 | do_check_false(a5.isActive); |
michael@0 | 135 | |
michael@0 | 136 | do_check_neq(a6, null); |
michael@0 | 137 | do_check_true(a6.appDisabled); |
michael@0 | 138 | do_check_false(a6.isActive); |
michael@0 | 139 | |
michael@0 | 140 | do_check_neq(a6, null); |
michael@0 | 141 | do_check_true(a6.appDisabled); |
michael@0 | 142 | do_check_false(a6.isActive); |
michael@0 | 143 | |
michael@0 | 144 | do_execute_soon(do_test_finished); |
michael@0 | 145 | |
michael@0 | 146 | }); |
michael@0 | 147 | } |