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 the themes switch as expected |
michael@0 | 6 | |
michael@0 | 7 | const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin"; |
michael@0 | 8 | |
michael@0 | 9 | const profileDir = gProfD.clone(); |
michael@0 | 10 | profileDir.append("extensions"); |
michael@0 | 11 | |
michael@0 | 12 | function run_test() { |
michael@0 | 13 | do_test_pending(); |
michael@0 | 14 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 15 | |
michael@0 | 16 | writeInstallRDFForExtension({ |
michael@0 | 17 | id: "default@tests.mozilla.org", |
michael@0 | 18 | version: "1.0", |
michael@0 | 19 | name: "Default", |
michael@0 | 20 | internalName: "classic/1.0", |
michael@0 | 21 | targetApplications: [{ |
michael@0 | 22 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 23 | minVersion: "1", |
michael@0 | 24 | maxVersion: "2" |
michael@0 | 25 | }] |
michael@0 | 26 | }, profileDir); |
michael@0 | 27 | |
michael@0 | 28 | writeInstallRDFForExtension({ |
michael@0 | 29 | id: "alternate@tests.mozilla.org", |
michael@0 | 30 | version: "1.0", |
michael@0 | 31 | name: "Test 1", |
michael@0 | 32 | type: 4, |
michael@0 | 33 | internalName: "alternate/1.0", |
michael@0 | 34 | targetApplications: [{ |
michael@0 | 35 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 36 | minVersion: "1", |
michael@0 | 37 | maxVersion: "2" |
michael@0 | 38 | }] |
michael@0 | 39 | }, profileDir); |
michael@0 | 40 | |
michael@0 | 41 | startupManager(); |
michael@0 | 42 | |
michael@0 | 43 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 44 | |
michael@0 | 45 | AddonManager.getAddonsByIDs(["default@tests.mozilla.org", |
michael@0 | 46 | "alternate@tests.mozilla.org"], function([d, a]) { |
michael@0 | 47 | do_check_neq(d, null); |
michael@0 | 48 | do_check_false(d.userDisabled); |
michael@0 | 49 | do_check_false(d.appDisabled); |
michael@0 | 50 | do_check_true(d.isActive); |
michael@0 | 51 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 52 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 53 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 54 | |
michael@0 | 55 | do_check_neq(a, null); |
michael@0 | 56 | do_check_true(a.userDisabled); |
michael@0 | 57 | do_check_false(a.appDisabled); |
michael@0 | 58 | do_check_false(a.isActive); |
michael@0 | 59 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 60 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 61 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 62 | |
michael@0 | 63 | run_test_1(d, a); |
michael@0 | 64 | }); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function end_test() { |
michael@0 | 68 | do_execute_soon(do_test_finished); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | // Checks switching to a different theme and back again leaves everything the |
michael@0 | 72 | // same |
michael@0 | 73 | function run_test_1(d, a) { |
michael@0 | 74 | a.userDisabled = false; |
michael@0 | 75 | |
michael@0 | 76 | do_check_true(d.userDisabled); |
michael@0 | 77 | do_check_false(d.appDisabled); |
michael@0 | 78 | do_check_true(d.isActive); |
michael@0 | 79 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 80 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 81 | do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 82 | |
michael@0 | 83 | do_check_false(a.userDisabled); |
michael@0 | 84 | do_check_false(a.appDisabled); |
michael@0 | 85 | do_check_false(a.isActive); |
michael@0 | 86 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 87 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 88 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 89 | |
michael@0 | 90 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 91 | |
michael@0 | 92 | d.userDisabled = false; |
michael@0 | 93 | |
michael@0 | 94 | do_check_false(d.userDisabled); |
michael@0 | 95 | do_check_false(d.appDisabled); |
michael@0 | 96 | do_check_true(d.isActive); |
michael@0 | 97 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 98 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 99 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 100 | |
michael@0 | 101 | do_check_true(a.userDisabled); |
michael@0 | 102 | do_check_false(a.appDisabled); |
michael@0 | 103 | do_check_false(a.isActive); |
michael@0 | 104 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 105 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 106 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 107 | |
michael@0 | 108 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 109 | |
michael@0 | 110 | do_execute_soon(run_test_2); |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | // Tests that after the restart themes can be changed as expected |
michael@0 | 114 | function run_test_2() { |
michael@0 | 115 | restartManager(); |
michael@0 | 116 | AddonManager.getAddonsByIDs(["default@tests.mozilla.org", |
michael@0 | 117 | "alternate@tests.mozilla.org"], function([d, a]) { |
michael@0 | 118 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 119 | |
michael@0 | 120 | do_check_neq(d, null); |
michael@0 | 121 | do_check_false(d.userDisabled); |
michael@0 | 122 | do_check_false(d.appDisabled); |
michael@0 | 123 | do_check_true(d.isActive); |
michael@0 | 124 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 125 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 126 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 127 | |
michael@0 | 128 | do_check_neq(a, null); |
michael@0 | 129 | do_check_true(a.userDisabled); |
michael@0 | 130 | do_check_false(a.appDisabled); |
michael@0 | 131 | do_check_false(a.isActive); |
michael@0 | 132 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 133 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 134 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 135 | |
michael@0 | 136 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 137 | |
michael@0 | 138 | a.userDisabled = false; |
michael@0 | 139 | |
michael@0 | 140 | do_check_true(d.userDisabled); |
michael@0 | 141 | do_check_false(d.appDisabled); |
michael@0 | 142 | do_check_true(d.isActive); |
michael@0 | 143 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 144 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 145 | do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 146 | |
michael@0 | 147 | do_check_false(a.userDisabled); |
michael@0 | 148 | do_check_false(a.appDisabled); |
michael@0 | 149 | do_check_false(a.isActive); |
michael@0 | 150 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 151 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 152 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 153 | |
michael@0 | 154 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 155 | |
michael@0 | 156 | d.userDisabled = false; |
michael@0 | 157 | |
michael@0 | 158 | do_check_false(d.userDisabled); |
michael@0 | 159 | do_check_false(d.appDisabled); |
michael@0 | 160 | do_check_true(d.isActive); |
michael@0 | 161 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 162 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 163 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 164 | |
michael@0 | 165 | do_check_true(a.userDisabled); |
michael@0 | 166 | do_check_false(a.appDisabled); |
michael@0 | 167 | do_check_false(a.isActive); |
michael@0 | 168 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 169 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 170 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 171 | |
michael@0 | 172 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 173 | |
michael@0 | 174 | a.userDisabled = false; |
michael@0 | 175 | |
michael@0 | 176 | do_check_true(d.userDisabled); |
michael@0 | 177 | do_check_false(d.appDisabled); |
michael@0 | 178 | do_check_true(d.isActive); |
michael@0 | 179 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 180 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 181 | do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 182 | |
michael@0 | 183 | do_check_false(a.userDisabled); |
michael@0 | 184 | do_check_false(a.appDisabled); |
michael@0 | 185 | do_check_false(a.isActive); |
michael@0 | 186 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 187 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 188 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 189 | |
michael@0 | 190 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 191 | |
michael@0 | 192 | do_execute_soon(check_test_2); |
michael@0 | 193 | }); |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | function check_test_2() { |
michael@0 | 197 | restartManager(); |
michael@0 | 198 | AddonManager.getAddonsByIDs(["default@tests.mozilla.org", |
michael@0 | 199 | "alternate@tests.mozilla.org"], callback_soon(function([d, a]) { |
michael@0 | 200 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "alternate/1.0"); |
michael@0 | 201 | |
michael@0 | 202 | do_check_true(d.userDisabled); |
michael@0 | 203 | do_check_false(d.appDisabled); |
michael@0 | 204 | do_check_false(d.isActive); |
michael@0 | 205 | do_check_false(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 206 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 207 | do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 208 | |
michael@0 | 209 | do_check_false(a.userDisabled); |
michael@0 | 210 | do_check_false(a.appDisabled); |
michael@0 | 211 | do_check_true(a.isActive); |
michael@0 | 212 | do_check_true(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 213 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 214 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 215 | |
michael@0 | 216 | d.userDisabled = false; |
michael@0 | 217 | |
michael@0 | 218 | do_check_false(d.userDisabled); |
michael@0 | 219 | do_check_false(d.appDisabled); |
michael@0 | 220 | do_check_false(d.isActive); |
michael@0 | 221 | do_check_false(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 222 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 223 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 224 | |
michael@0 | 225 | do_check_true(a.userDisabled); |
michael@0 | 226 | do_check_false(a.appDisabled); |
michael@0 | 227 | do_check_true(a.isActive); |
michael@0 | 228 | do_check_true(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 229 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 230 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 231 | |
michael@0 | 232 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "alternate/1.0"); |
michael@0 | 233 | |
michael@0 | 234 | restartManager(); |
michael@0 | 235 | |
michael@0 | 236 | do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0"); |
michael@0 | 237 | |
michael@0 | 238 | AddonManager.getAddonsByIDs(["default@tests.mozilla.org", |
michael@0 | 239 | "alternate@tests.mozilla.org"], function([d, a]) { |
michael@0 | 240 | do_check_neq(d, null); |
michael@0 | 241 | do_check_false(d.userDisabled); |
michael@0 | 242 | do_check_false(d.appDisabled); |
michael@0 | 243 | do_check_true(d.isActive); |
michael@0 | 244 | do_check_true(isThemeInAddonsList(profileDir, d.id)); |
michael@0 | 245 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 246 | do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 247 | |
michael@0 | 248 | do_check_neq(a, null); |
michael@0 | 249 | do_check_true(a.userDisabled); |
michael@0 | 250 | do_check_false(a.appDisabled); |
michael@0 | 251 | do_check_false(a.isActive); |
michael@0 | 252 | do_check_false(isThemeInAddonsList(profileDir, a.id)); |
michael@0 | 253 | do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 254 | do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 255 | |
michael@0 | 256 | end_test(); |
michael@0 | 257 | }); |
michael@0 | 258 | })); |
michael@0 | 259 | } |