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 | // Checks that we migrate data from the old rdf style database |
michael@0 | 6 | |
michael@0 | 7 | var addon1 = { |
michael@0 | 8 | id: "addon1@tests.mozilla.org", |
michael@0 | 9 | version: "1.0", |
michael@0 | 10 | name: "Test 1", |
michael@0 | 11 | targetApplications: [{ |
michael@0 | 12 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 13 | minVersion: "1", |
michael@0 | 14 | maxVersion: "1" |
michael@0 | 15 | }] |
michael@0 | 16 | }; |
michael@0 | 17 | |
michael@0 | 18 | var addon2 = { |
michael@0 | 19 | id: "addon2@tests.mozilla.org", |
michael@0 | 20 | version: "2.0", |
michael@0 | 21 | name: "Test 2", |
michael@0 | 22 | targetApplications: [{ |
michael@0 | 23 | id: "toolkit@mozilla.org", |
michael@0 | 24 | minVersion: "1", |
michael@0 | 25 | maxVersion: "1" |
michael@0 | 26 | }] |
michael@0 | 27 | }; |
michael@0 | 28 | |
michael@0 | 29 | var addon3 = { |
michael@0 | 30 | id: "addon3@tests.mozilla.org", |
michael@0 | 31 | version: "2.0", |
michael@0 | 32 | name: "Test 3", |
michael@0 | 33 | targetApplications: [{ |
michael@0 | 34 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 35 | minVersion: "1", |
michael@0 | 36 | maxVersion: "1" |
michael@0 | 37 | }] |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | var addon4 = { |
michael@0 | 41 | id: "addon4@tests.mozilla.org", |
michael@0 | 42 | version: "2.0", |
michael@0 | 43 | name: "Test 4", |
michael@0 | 44 | targetApplications: [{ |
michael@0 | 45 | id: "toolkit@mozilla.org", |
michael@0 | 46 | minVersion: "1", |
michael@0 | 47 | maxVersion: "1" |
michael@0 | 48 | }] |
michael@0 | 49 | }; |
michael@0 | 50 | |
michael@0 | 51 | var addon5 = { |
michael@0 | 52 | id: "addon5@tests.mozilla.org", |
michael@0 | 53 | version: "2.0", |
michael@0 | 54 | name: "Test 5", |
michael@0 | 55 | targetApplications: [{ |
michael@0 | 56 | id: "toolkit@mozilla.org", |
michael@0 | 57 | minVersion: "1", |
michael@0 | 58 | maxVersion: "1" |
michael@0 | 59 | }] |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | var theme1 = { |
michael@0 | 63 | id: "theme1@tests.mozilla.org", |
michael@0 | 64 | version: "1.0", |
michael@0 | 65 | name: "Theme 1", |
michael@0 | 66 | type: 4, |
michael@0 | 67 | internalName: "theme1/1.0", |
michael@0 | 68 | targetApplications: [{ |
michael@0 | 69 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 70 | minVersion: "1", |
michael@0 | 71 | maxVersion: "2" |
michael@0 | 72 | }] |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | var theme2 = { |
michael@0 | 76 | id: "theme2@tests.mozilla.org", |
michael@0 | 77 | version: "1.0", |
michael@0 | 78 | name: "Theme 2", |
michael@0 | 79 | type: 4, |
michael@0 | 80 | internalName: "theme2/1.0", |
michael@0 | 81 | targetApplications: [{ |
michael@0 | 82 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 83 | minVersion: "1", |
michael@0 | 84 | maxVersion: "2" |
michael@0 | 85 | }] |
michael@0 | 86 | }; |
michael@0 | 87 | |
michael@0 | 88 | const profileDir = gProfD.clone(); |
michael@0 | 89 | profileDir.append("extensions"); |
michael@0 | 90 | |
michael@0 | 91 | function run_test() { |
michael@0 | 92 | do_test_pending(); |
michael@0 | 93 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2"); |
michael@0 | 94 | |
michael@0 | 95 | writeInstallRDFForExtension(addon1, profileDir); |
michael@0 | 96 | writeInstallRDFForExtension(addon2, profileDir); |
michael@0 | 97 | writeInstallRDFForExtension(addon3, profileDir); |
michael@0 | 98 | writeInstallRDFForExtension(addon4, profileDir); |
michael@0 | 99 | writeInstallRDFForExtension(addon5, profileDir); |
michael@0 | 100 | writeInstallRDFForExtension(theme1, profileDir); |
michael@0 | 101 | writeInstallRDFForExtension(theme2, profileDir); |
michael@0 | 102 | |
michael@0 | 103 | let stagedXPIs = profileDir.clone(); |
michael@0 | 104 | stagedXPIs.append("staged-xpis"); |
michael@0 | 105 | stagedXPIs.append("addon6@tests.mozilla.org"); |
michael@0 | 106 | stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755); |
michael@0 | 107 | |
michael@0 | 108 | let addon6 = do_get_addon("test_migrate6"); |
michael@0 | 109 | addon6.copyTo(stagedXPIs, "tmp.xpi"); |
michael@0 | 110 | stagedXPIs = stagedXPIs.parent; |
michael@0 | 111 | |
michael@0 | 112 | stagedXPIs.append("addon7@tests.mozilla.org"); |
michael@0 | 113 | stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755); |
michael@0 | 114 | |
michael@0 | 115 | let addon7 = do_get_addon("test_migrate7"); |
michael@0 | 116 | addon7.copyTo(stagedXPIs, "tmp.xpi"); |
michael@0 | 117 | stagedXPIs = stagedXPIs.parent; |
michael@0 | 118 | |
michael@0 | 119 | stagedXPIs.append("addon8@tests.mozilla.org"); |
michael@0 | 120 | stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755); |
michael@0 | 121 | |
michael@0 | 122 | let addon7 = do_get_addon("test_migrate8"); |
michael@0 | 123 | addon7.copyTo(stagedXPIs, "tmp.xpi"); |
michael@0 | 124 | stagedXPIs = stagedXPIs.parent; |
michael@0 | 125 | |
michael@0 | 126 | let old = do_get_file("data/test_migrate.rdf"); |
michael@0 | 127 | old.copyTo(gProfD, "extensions.rdf"); |
michael@0 | 128 | |
michael@0 | 129 | let oldCache = gProfD.clone(); |
michael@0 | 130 | oldCache.append("extensions.cache"); |
michael@0 | 131 | oldCache.create(AM_Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE); |
michael@0 | 132 | |
michael@0 | 133 | // Theme state is determined by the selected theme pref |
michael@0 | 134 | Services.prefs.setCharPref("general.skins.selectedSkin", "theme1/1.0"); |
michael@0 | 135 | |
michael@0 | 136 | Services.prefs.setCharPref("extensions.lastAppVersion", "1"); |
michael@0 | 137 | |
michael@0 | 138 | startupManager(); |
michael@0 | 139 | check_startup_changes("installed", []); |
michael@0 | 140 | check_startup_changes("updated", []); |
michael@0 | 141 | check_startup_changes("uninstalled", []); |
michael@0 | 142 | check_startup_changes("disabled", []); |
michael@0 | 143 | check_startup_changes("enabled", []); |
michael@0 | 144 | |
michael@0 | 145 | do_check_false(oldCache.exists()); |
michael@0 | 146 | |
michael@0 | 147 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 148 | "addon2@tests.mozilla.org", |
michael@0 | 149 | "addon3@tests.mozilla.org", |
michael@0 | 150 | "addon4@tests.mozilla.org", |
michael@0 | 151 | "addon5@tests.mozilla.org", |
michael@0 | 152 | "addon6@tests.mozilla.org", |
michael@0 | 153 | "addon7@tests.mozilla.org", |
michael@0 | 154 | "addon8@tests.mozilla.org", |
michael@0 | 155 | "theme1@tests.mozilla.org", |
michael@0 | 156 | "theme2@tests.mozilla.org"], function([a1, a2, a3, |
michael@0 | 157 | a4, a5, a6, |
michael@0 | 158 | a7, a8, t1, |
michael@0 | 159 | t2]) { |
michael@0 | 160 | // addon1 was user and app enabled in the old extensions.rdf |
michael@0 | 161 | do_check_neq(a1, null); |
michael@0 | 162 | do_check_false(a1.userDisabled); |
michael@0 | 163 | do_check_false(a1.appDisabled); |
michael@0 | 164 | do_check_true(a1.isActive); |
michael@0 | 165 | do_check_true(isExtensionInAddonsList(profileDir, a1.id)); |
michael@0 | 166 | do_check_false(a1.hasBinaryComponents); |
michael@0 | 167 | |
michael@0 | 168 | // addon2 was user disabled and app enabled in the old extensions.rdf |
michael@0 | 169 | do_check_neq(a2, null); |
michael@0 | 170 | do_check_true(a2.userDisabled); |
michael@0 | 171 | do_check_false(a2.appDisabled); |
michael@0 | 172 | do_check_false(a2.isActive); |
michael@0 | 173 | do_check_false(isExtensionInAddonsList(profileDir, a2.id)); |
michael@0 | 174 | do_check_false(a2.hasBinaryComponents); |
michael@0 | 175 | |
michael@0 | 176 | // addon3 was pending user disable and app disabled in the old extensions.rdf |
michael@0 | 177 | do_check_neq(a3, null); |
michael@0 | 178 | do_check_true(a3.userDisabled); |
michael@0 | 179 | do_check_true(a3.appDisabled); |
michael@0 | 180 | do_check_false(a3.isActive); |
michael@0 | 181 | do_check_false(isExtensionInAddonsList(profileDir, a3.id)); |
michael@0 | 182 | do_check_false(a3.hasBinaryComponents); |
michael@0 | 183 | |
michael@0 | 184 | // addon4 was pending user enable and app disabled in the old extensions.rdf |
michael@0 | 185 | do_check_neq(a4, null); |
michael@0 | 186 | do_check_false(a4.userDisabled); |
michael@0 | 187 | do_check_true(a4.appDisabled); |
michael@0 | 188 | do_check_false(a4.isActive); |
michael@0 | 189 | do_check_false(isExtensionInAddonsList(profileDir, a4.id)); |
michael@0 | 190 | do_check_false(a4.hasBinaryComponents); |
michael@0 | 191 | |
michael@0 | 192 | // addon5 was disabled and compatible but a new version has been installed |
michael@0 | 193 | // since, it should still be disabled but should be incompatible |
michael@0 | 194 | do_check_neq(a5, null); |
michael@0 | 195 | do_check_true(a5.userDisabled); |
michael@0 | 196 | do_check_true(a5.appDisabled); |
michael@0 | 197 | do_check_false(a5.isActive); |
michael@0 | 198 | do_check_false(isExtensionInAddonsList(profileDir, a5.id)); |
michael@0 | 199 | do_check_false(a5.hasBinaryComponents); |
michael@0 | 200 | |
michael@0 | 201 | // addon6 should be installed and compatible and packed unless unpacking is |
michael@0 | 202 | // forced |
michael@0 | 203 | do_check_neq(a6, null); |
michael@0 | 204 | do_check_false(a6.userDisabled); |
michael@0 | 205 | do_check_false(a6.appDisabled); |
michael@0 | 206 | do_check_true(a6.isActive); |
michael@0 | 207 | do_check_true(isExtensionInAddonsList(profileDir, a6.id)); |
michael@0 | 208 | if (Services.prefs.getBoolPref("extensions.alwaysUnpack")) |
michael@0 | 209 | do_check_eq(a6.getResourceURI("install.rdf").scheme, "file"); |
michael@0 | 210 | else |
michael@0 | 211 | do_check_eq(a6.getResourceURI("install.rdf").scheme, "jar"); |
michael@0 | 212 | do_check_false(a6.hasBinaryComponents); |
michael@0 | 213 | |
michael@0 | 214 | // addon7 should be installed and compatible and unpacked |
michael@0 | 215 | do_check_neq(a7, null); |
michael@0 | 216 | do_check_false(a7.userDisabled); |
michael@0 | 217 | do_check_false(a7.appDisabled); |
michael@0 | 218 | do_check_true(a7.isActive); |
michael@0 | 219 | do_check_true(isExtensionInAddonsList(profileDir, a7.id)); |
michael@0 | 220 | do_check_eq(a7.getResourceURI("install.rdf").scheme, "file"); |
michael@0 | 221 | do_check_false(a7.hasBinaryComponents); |
michael@0 | 222 | |
michael@0 | 223 | // addon8 should be installed and compatible and have binary components |
michael@0 | 224 | do_check_neq(a8, null); |
michael@0 | 225 | do_check_false(a8.userDisabled); |
michael@0 | 226 | do_check_false(a8.appDisabled); |
michael@0 | 227 | do_check_true(a8.isActive); |
michael@0 | 228 | do_check_true(isExtensionInAddonsList(profileDir, a8.id)); |
michael@0 | 229 | do_check_true(a8.hasBinaryComponents); |
michael@0 | 230 | |
michael@0 | 231 | // Theme 1 was previously enabled |
michael@0 | 232 | do_check_neq(t1, null); |
michael@0 | 233 | do_check_false(t1.userDisabled); |
michael@0 | 234 | do_check_false(t1.appDisabled); |
michael@0 | 235 | do_check_true(t1.isActive); |
michael@0 | 236 | do_check_true(isThemeInAddonsList(profileDir, t1.id)); |
michael@0 | 237 | do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 238 | |
michael@0 | 239 | // Theme 2 was previously disabled |
michael@0 | 240 | do_check_neq(t1, null); |
michael@0 | 241 | do_check_true(t2.userDisabled); |
michael@0 | 242 | do_check_false(t2.appDisabled); |
michael@0 | 243 | do_check_false(t2.isActive); |
michael@0 | 244 | do_check_false(isThemeInAddonsList(profileDir, t2.id)); |
michael@0 | 245 | do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 246 | |
michael@0 | 247 | do_check_false(stagedXPIs.exists()); |
michael@0 | 248 | |
michael@0 | 249 | do_execute_soon(do_test_finished); |
michael@0 | 250 | }); |
michael@0 | 251 | } |