1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,514 @@ 1.4 +const Cc = Components.classes; 1.5 +const Ci = Components.interfaces; 1.6 + 1.7 +const MANDATORY = ["id", "name", "headerURL"]; 1.8 +const OPTIONAL = ["footerURL", "textcolor", "accentcolor", "iconURL", 1.9 + "previewURL", "author", "description", "homepageURL", 1.10 + "updateURL", "version"]; 1.11 + 1.12 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.13 + 1.14 +function dummy(id) { 1.15 + return { 1.16 + id: id || Math.random().toString(), 1.17 + name: Math.random().toString(), 1.18 + headerURL: "http://lwttest.invalid/a.png", 1.19 + footerURL: "http://lwttest.invalid/b.png", 1.20 + textcolor: Math.random().toString(), 1.21 + accentcolor: Math.random().toString() 1.22 + }; 1.23 +} 1.24 + 1.25 +function run_test() { 1.26 + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); 1.27 + startupManager(); 1.28 + 1.29 + Services.prefs.setIntPref("lightweightThemes.maxUsedThemes", 8); 1.30 + 1.31 + var temp = {}; 1.32 + Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", temp); 1.33 + do_check_eq(typeof temp.LightweightThemeManager, "object"); 1.34 + 1.35 + var ltm = temp.LightweightThemeManager; 1.36 + 1.37 + do_check_eq(typeof ltm.usedThemes, "object"); 1.38 + do_check_eq(ltm.usedThemes.length, 0); 1.39 + do_check_eq(ltm.currentTheme, null); 1.40 + 1.41 + ltm.previewTheme(dummy("preview0")); 1.42 + do_check_eq(ltm.usedThemes.length, 0); 1.43 + do_check_eq(ltm.currentTheme, null); 1.44 + 1.45 + ltm.previewTheme(dummy("preview1")); 1.46 + do_check_eq(ltm.usedThemes.length, 0); 1.47 + do_check_eq(ltm.currentTheme, null); 1.48 + ltm.resetPreview(); 1.49 + 1.50 + ltm.currentTheme = dummy("x0"); 1.51 + do_check_eq(ltm.usedThemes.length, 1); 1.52 + do_check_eq(ltm.currentTheme.id, "x0"); 1.53 + do_check_eq(ltm.usedThemes[0].id, "x0"); 1.54 + do_check_eq(ltm.getUsedTheme("x0").id, "x0"); 1.55 + 1.56 + ltm.previewTheme(dummy("preview0")); 1.57 + do_check_eq(ltm.usedThemes.length, 1); 1.58 + do_check_eq(ltm.currentTheme.id, "x0"); 1.59 + 1.60 + ltm.resetPreview(); 1.61 + do_check_eq(ltm.usedThemes.length, 1); 1.62 + do_check_eq(ltm.currentTheme.id, "x0"); 1.63 + 1.64 + ltm.currentTheme = dummy("x1"); 1.65 + do_check_eq(ltm.usedThemes.length, 2); 1.66 + do_check_eq(ltm.currentTheme.id, "x1"); 1.67 + do_check_eq(ltm.usedThemes[1].id, "x0"); 1.68 + 1.69 + ltm.currentTheme = dummy("x2"); 1.70 + do_check_eq(ltm.usedThemes.length, 3); 1.71 + do_check_eq(ltm.currentTheme.id, "x2"); 1.72 + do_check_eq(ltm.usedThemes[1].id, "x1"); 1.73 + do_check_eq(ltm.usedThemes[2].id, "x0"); 1.74 + 1.75 + ltm.currentTheme = dummy("x3"); 1.76 + ltm.currentTheme = dummy("x4"); 1.77 + ltm.currentTheme = dummy("x5"); 1.78 + ltm.currentTheme = dummy("x6"); 1.79 + ltm.currentTheme = dummy("x7"); 1.80 + do_check_eq(ltm.usedThemes.length, 8); 1.81 + do_check_eq(ltm.currentTheme.id, "x7"); 1.82 + do_check_eq(ltm.usedThemes[1].id, "x6"); 1.83 + do_check_eq(ltm.usedThemes[7].id, "x0"); 1.84 + 1.85 + ltm.currentTheme = dummy("x8"); 1.86 + do_check_eq(ltm.usedThemes.length, 8); 1.87 + do_check_eq(ltm.currentTheme.id, "x8"); 1.88 + do_check_eq(ltm.usedThemes[1].id, "x7"); 1.89 + do_check_eq(ltm.usedThemes[7].id, "x1"); 1.90 + do_check_eq(ltm.getUsedTheme("x0"), null); 1.91 + 1.92 + ltm.forgetUsedTheme("nonexistent"); 1.93 + do_check_eq(ltm.usedThemes.length, 8); 1.94 + do_check_neq(ltm.currentTheme, null); 1.95 + 1.96 + ltm.forgetUsedTheme("x8"); 1.97 + do_check_eq(ltm.usedThemes.length, 7); 1.98 + do_check_eq(ltm.currentTheme, null); 1.99 + do_check_eq(ltm.usedThemes[0].id, "x7"); 1.100 + do_check_eq(ltm.usedThemes[6].id, "x1"); 1.101 + 1.102 + ltm.forgetUsedTheme("x7"); 1.103 + ltm.forgetUsedTheme("x6"); 1.104 + ltm.forgetUsedTheme("x5"); 1.105 + ltm.forgetUsedTheme("x4"); 1.106 + ltm.forgetUsedTheme("x3"); 1.107 + do_check_eq(ltm.usedThemes.length, 2); 1.108 + do_check_eq(ltm.currentTheme, null); 1.109 + do_check_eq(ltm.usedThemes[0].id, "x2"); 1.110 + do_check_eq(ltm.usedThemes[1].id, "x1"); 1.111 + 1.112 + ltm.currentTheme = dummy("x1"); 1.113 + do_check_eq(ltm.usedThemes.length, 2); 1.114 + do_check_eq(ltm.currentTheme.id, "x1"); 1.115 + do_check_eq(ltm.usedThemes[0].id, "x1"); 1.116 + do_check_eq(ltm.usedThemes[1].id, "x2"); 1.117 + 1.118 + ltm.currentTheme = dummy("x2"); 1.119 + do_check_eq(ltm.usedThemes.length, 2); 1.120 + do_check_eq(ltm.currentTheme.id, "x2"); 1.121 + do_check_eq(ltm.usedThemes[0].id, "x2"); 1.122 + do_check_eq(ltm.usedThemes[1].id, "x1"); 1.123 + 1.124 + ltm.currentTheme = ltm.getUsedTheme("x1"); 1.125 + do_check_eq(ltm.usedThemes.length, 2); 1.126 + do_check_eq(ltm.currentTheme.id, "x1"); 1.127 + do_check_eq(ltm.usedThemes[0].id, "x1"); 1.128 + do_check_eq(ltm.usedThemes[1].id, "x2"); 1.129 + 1.130 + ltm.forgetUsedTheme("x1"); 1.131 + ltm.forgetUsedTheme("x2"); 1.132 + do_check_eq(ltm.usedThemes.length, 0); 1.133 + do_check_eq(ltm.currentTheme, null); 1.134 + 1.135 + // Use chinese name to test utf-8, for bug #541943 1.136 + var chineseTheme = dummy("chinese0"); 1.137 + chineseTheme.name = "笢恅0"; 1.138 + chineseTheme.description = "笢恅1"; 1.139 + ltm.currentTheme = chineseTheme; 1.140 + do_check_eq(ltm.usedThemes.length, 1); 1.141 + do_check_eq(ltm.currentTheme.name, "笢恅0"); 1.142 + do_check_eq(ltm.currentTheme.description, "笢恅1"); 1.143 + do_check_eq(ltm.usedThemes[0].name, "笢恅0"); 1.144 + do_check_eq(ltm.usedThemes[0].description, "笢恅1"); 1.145 + do_check_eq(ltm.getUsedTheme("chinese0").name, "笢恅0"); 1.146 + do_check_eq(ltm.getUsedTheme("chinese0").description, "笢恅1"); 1.147 + 1.148 + // This name used to break the usedTheme JSON causing all LWTs to be lost 1.149 + var chineseTheme1 = dummy("chinese1"); 1.150 + chineseTheme1.name = "眵昜湮桵蔗坌~郔乾"; 1.151 + chineseTheme1.description = "眵昜湮桵蔗坌~郔乾"; 1.152 + ltm.currentTheme = chineseTheme1; 1.153 + do_check_neq(ltm.currentTheme, null); 1.154 + do_check_eq(ltm.usedThemes.length, 2); 1.155 + do_check_eq(ltm.currentTheme.name, "眵昜湮桵蔗坌~郔乾"); 1.156 + do_check_eq(ltm.currentTheme.description, "眵昜湮桵蔗坌~郔乾"); 1.157 + do_check_eq(ltm.usedThemes[1].name, "笢恅0"); 1.158 + do_check_eq(ltm.usedThemes[1].description, "笢恅1"); 1.159 + do_check_eq(ltm.usedThemes[0].name, "眵昜湮桵蔗坌~郔乾"); 1.160 + do_check_eq(ltm.usedThemes[0].description, "眵昜湮桵蔗坌~郔乾"); 1.161 + 1.162 + ltm.forgetUsedTheme("chinese0"); 1.163 + do_check_eq(ltm.usedThemes.length, 1); 1.164 + do_check_neq(ltm.currentTheme, null); 1.165 + 1.166 + ltm.forgetUsedTheme("chinese1"); 1.167 + do_check_eq(ltm.usedThemes.length, 0); 1.168 + do_check_eq(ltm.currentTheme, null); 1.169 + 1.170 + do_check_eq(ltm.parseTheme("invalid json"), null); 1.171 + do_check_eq(ltm.parseTheme('"json string"'), null); 1.172 + 1.173 + function roundtrip(data, secure) { 1.174 + return ltm.parseTheme(JSON.stringify(data), 1.175 + "http" + (secure ? "s" : "") + "://lwttest.invalid/"); 1.176 + } 1.177 + 1.178 + var data = dummy(); 1.179 + do_check_neq(roundtrip(data), null); 1.180 + data.id = null; 1.181 + do_check_eq(roundtrip(data), null); 1.182 + data.id = 1; 1.183 + do_check_eq(roundtrip(data), null); 1.184 + data.id = 1.5; 1.185 + do_check_eq(roundtrip(data), null); 1.186 + data.id = true; 1.187 + do_check_eq(roundtrip(data), null); 1.188 + data.id = {}; 1.189 + do_check_eq(roundtrip(data), null); 1.190 + data.id = []; 1.191 + do_check_eq(roundtrip(data), null); 1.192 + 1.193 + // Check whether parseTheme handles international characters right 1.194 + var chineseTheme2 = dummy(); 1.195 + chineseTheme2.name = "眵昜湮桵蔗坌~郔乾"; 1.196 + chineseTheme2.description = "眵昜湮桵蔗坌~郔乾"; 1.197 + do_check_neq(roundtrip(chineseTheme2), null); 1.198 + do_check_eq(roundtrip(chineseTheme2).name, "眵昜湮桵蔗坌~郔乾"); 1.199 + do_check_eq(roundtrip(chineseTheme2).description, "眵昜湮桵蔗坌~郔乾"); 1.200 + 1.201 + data = dummy(); 1.202 + data.unknownProperty = "Foo"; 1.203 + do_check_eq(typeof roundtrip(data).unknownProperty, "undefined"); 1.204 + 1.205 + data = dummy(); 1.206 + data.unknownURL = "http://lwttest.invalid/"; 1.207 + do_check_eq(typeof roundtrip(data).unknownURL, "undefined"); 1.208 + 1.209 + function roundtripSet(props, modify, test, secure) { 1.210 + props.forEach(function (prop) { 1.211 + var data = dummy(); 1.212 + modify(data, prop); 1.213 + test(roundtrip(data, secure), prop, data); 1.214 + }); 1.215 + } 1.216 + 1.217 + roundtripSet(MANDATORY, function (data, prop) { 1.218 + delete data[prop]; 1.219 + }, function (after) { 1.220 + do_check_eq(after, null); 1.221 + }); 1.222 + 1.223 + roundtripSet(OPTIONAL, function (data, prop) { 1.224 + delete data[prop]; 1.225 + }, function (after) { 1.226 + do_check_neq(after, null); 1.227 + }); 1.228 + 1.229 + roundtripSet(MANDATORY, function (data, prop) { 1.230 + data[prop] = ""; 1.231 + }, function (after) { 1.232 + do_check_eq(after, null); 1.233 + }); 1.234 + 1.235 + roundtripSet(OPTIONAL, function (data, prop) { 1.236 + data[prop] = ""; 1.237 + }, function (after, prop) { 1.238 + do_check_eq(typeof after[prop], "undefined"); 1.239 + }); 1.240 + 1.241 + roundtripSet(MANDATORY, function (data, prop) { 1.242 + data[prop] = " "; 1.243 + }, function (after) { 1.244 + do_check_eq(after, null); 1.245 + }); 1.246 + 1.247 + roundtripSet(OPTIONAL, function (data, prop) { 1.248 + data[prop] = " "; 1.249 + }, function (after, prop) { 1.250 + do_check_neq(after, null); 1.251 + do_check_eq(typeof after[prop], "undefined"); 1.252 + }); 1.253 + 1.254 + function non_urls(props) { 1.255 + return props.filter(function (prop) !/URL$/.test(prop)); 1.256 + } 1.257 + 1.258 + function urls(props) { 1.259 + return props.filter(function (prop) /URL$/.test(prop)); 1.260 + } 1.261 + 1.262 + roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (data, prop) { 1.263 + data[prop] = prop; 1.264 + }, function (after, prop, before) { 1.265 + do_check_eq(after[prop], before[prop]); 1.266 + }); 1.267 + 1.268 + roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (data, prop) { 1.269 + data[prop] = " " + prop + " "; 1.270 + }, function (after, prop, before) { 1.271 + do_check_eq(after[prop], before[prop].trim()); 1.272 + }); 1.273 + 1.274 + roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) { 1.275 + data[prop] = Math.random().toString(); 1.276 + }, function (after, prop, before) { 1.277 + if (prop == "updateURL") 1.278 + do_check_eq(typeof after[prop], "undefined"); 1.279 + else 1.280 + do_check_eq(after[prop], "http://lwttest.invalid/" + before[prop]); 1.281 + }); 1.282 + 1.283 + roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) { 1.284 + data[prop] = Math.random().toString(); 1.285 + }, function (after, prop, before) { 1.286 + do_check_eq(after[prop], "https://lwttest.invalid/" + before[prop]); 1.287 + }, true); 1.288 + 1.289 + roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) { 1.290 + data[prop] = "https://sub.lwttest.invalid/" + Math.random().toString(); 1.291 + }, function (after, prop, before) { 1.292 + do_check_eq(after[prop], before[prop]); 1.293 + }); 1.294 + 1.295 + roundtripSet(urls(MANDATORY), function (data, prop) { 1.296 + data[prop] = "ftp://lwttest.invalid/" + Math.random().toString(); 1.297 + }, function (after) { 1.298 + do_check_eq(after, null); 1.299 + }); 1.300 + 1.301 + roundtripSet(urls(OPTIONAL), function (data, prop) { 1.302 + data[prop] = "ftp://lwttest.invalid/" + Math.random().toString(); 1.303 + }, function (after, prop) { 1.304 + do_check_eq(typeof after[prop], "undefined"); 1.305 + }); 1.306 + 1.307 + do_check_eq(ltm.usedThemes.length, 0); 1.308 + do_check_eq(ltm.currentTheme, null); 1.309 + 1.310 + data = dummy(); 1.311 + delete data.name; 1.312 + try { 1.313 + ltm.currentTheme = data; 1.314 + do_throw("Should have rejected a theme with no name"); 1.315 + } 1.316 + catch (e) { 1.317 + // Expected exception 1.318 + } 1.319 + 1.320 + data = dummy(); 1.321 + data.headerURL = "foo"; 1.322 + try { 1.323 + ltm.currentTheme = data; 1.324 + do_throw("Should have rejected a theme with a bad headerURL"); 1.325 + } 1.326 + catch (e) { 1.327 + // Expected exception 1.328 + } 1.329 + 1.330 + data = dummy(); 1.331 + data.headerURL = "ftp://lwtest.invalid/test.png"; 1.332 + try { 1.333 + ltm.currentTheme = data; 1.334 + do_throw("Should have rejected a theme with a non-http(s) headerURL"); 1.335 + } 1.336 + catch (e) { 1.337 + // Expected exception 1.338 + } 1.339 + 1.340 + data = dummy(); 1.341 + data.headerURL = "file:///test.png"; 1.342 + try { 1.343 + ltm.currentTheme = data; 1.344 + do_throw("Should have rejected a theme with a non-http(s) headerURL"); 1.345 + } 1.346 + catch (e) { 1.347 + // Expected exception 1.348 + } 1.349 + 1.350 + data = dummy(); 1.351 + data.updateURL = "file:///test.json"; 1.352 + ltm.setLocalTheme(data); 1.353 + do_check_eq(ltm.usedThemes.length, 1); 1.354 + do_check_eq(ltm.currentTheme.updateURL, undefined); 1.355 + ltm.forgetUsedTheme(ltm.currentTheme.id); 1.356 + do_check_eq(ltm.usedThemes.length, 0); 1.357 + 1.358 + data = dummy(); 1.359 + data.headerURL = "file:///test.png"; 1.360 + ltm.setLocalTheme(data); 1.361 + do_check_eq(ltm.usedThemes.length, 1); 1.362 + do_check_eq(ltm.currentTheme.headerURL, "file:///test.png"); 1.363 + ltm.forgetUsedTheme(ltm.currentTheme.id); 1.364 + do_check_eq(ltm.usedThemes.length, 0); 1.365 + 1.366 + data = dummy(); 1.367 + data.headerURL = "ftp://lwtest.invalid/test.png"; 1.368 + try { 1.369 + ltm.setLocalTheme(data); 1.370 + do_throw("Should have rejected a theme with a non-http(s), non-file headerURL"); 1.371 + } 1.372 + catch (e) { 1.373 + // Expected exception 1.374 + } 1.375 + 1.376 + data = dummy(); 1.377 + delete data.id; 1.378 + try { 1.379 + ltm.currentTheme = data; 1.380 + do_throw("Should have rejected a theme with no ID"); 1.381 + } 1.382 + catch (e) { 1.383 + // Expected exception 1.384 + } 1.385 + 1.386 + do_check_eq(ltm.usedThemes.length, 0); 1.387 + do_check_eq(ltm.currentTheme, null); 1.388 + 1.389 + // Force the theme into the prefs anyway 1.390 + let prefs = Cc["@mozilla.org/preferences-service;1"]. 1.391 + getService(Ci.nsIPrefBranch); 1.392 + let themes = [data]; 1.393 + prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes)); 1.394 + do_check_eq(ltm.usedThemes.length, 1); 1.395 + 1.396 + // This should silently drop the bad theme. 1.397 + ltm.currentTheme = dummy(); 1.398 + do_check_eq(ltm.usedThemes.length, 1); 1.399 + ltm.forgetUsedTheme(ltm.currentTheme.id); 1.400 + do_check_eq(ltm.usedThemes.length, 0); 1.401 + do_check_eq(ltm.currentTheme, null); 1.402 + 1.403 + // Add one broken and some working. 1.404 + themes = [data, dummy("x1"), dummy("x2")]; 1.405 + prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes)); 1.406 + do_check_eq(ltm.usedThemes.length, 3); 1.407 + 1.408 + // Switching to an existing theme should drop the bad theme. 1.409 + ltm.currentTheme = ltm.getUsedTheme("x1"); 1.410 + do_check_eq(ltm.usedThemes.length, 2); 1.411 + ltm.forgetUsedTheme("x1"); 1.412 + ltm.forgetUsedTheme("x2"); 1.413 + do_check_eq(ltm.usedThemes.length, 0); 1.414 + do_check_eq(ltm.currentTheme, null); 1.415 + 1.416 + prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(themes)); 1.417 + do_check_eq(ltm.usedThemes.length, 3); 1.418 + 1.419 + // Forgetting an existing theme should drop the bad theme. 1.420 + ltm.forgetUsedTheme("x1"); 1.421 + do_check_eq(ltm.usedThemes.length, 1); 1.422 + ltm.forgetUsedTheme("x2"); 1.423 + do_check_eq(ltm.usedThemes.length, 0); 1.424 + do_check_eq(ltm.currentTheme, null); 1.425 + 1.426 + // Test whether a JSON set with setCharPref can be retrieved with usedThemes 1.427 + ltm.currentTheme = dummy("x0"); 1.428 + ltm.currentTheme = dummy("x1"); 1.429 + prefs.setCharPref("lightweightThemes.usedThemes", JSON.stringify(ltm.usedThemes)); 1.430 + do_check_eq(ltm.usedThemes.length, 2); 1.431 + do_check_eq(ltm.currentTheme.id, "x1"); 1.432 + do_check_eq(ltm.usedThemes[1].id, "x0"); 1.433 + do_check_eq(ltm.usedThemes[0].id, "x1"); 1.434 + 1.435 + ltm.forgetUsedTheme("x0"); 1.436 + do_check_eq(ltm.usedThemes.length, 1); 1.437 + do_check_neq(ltm.currentTheme, null); 1.438 + 1.439 + ltm.forgetUsedTheme("x1"); 1.440 + do_check_eq(ltm.usedThemes.length, 0); 1.441 + do_check_eq(ltm.currentTheme, null); 1.442 + 1.443 + Services.prefs.clearUserPref("lightweightThemes.maxUsedThemes"); 1.444 + 1.445 + ltm.currentTheme = dummy("x1"); 1.446 + ltm.currentTheme = dummy("x2"); 1.447 + ltm.currentTheme = dummy("x3"); 1.448 + ltm.currentTheme = dummy("x4"); 1.449 + ltm.currentTheme = dummy("x5"); 1.450 + ltm.currentTheme = dummy("x6"); 1.451 + ltm.currentTheme = dummy("x7"); 1.452 + ltm.currentTheme = dummy("x8"); 1.453 + ltm.currentTheme = dummy("x9"); 1.454 + ltm.currentTheme = dummy("x10"); 1.455 + ltm.currentTheme = dummy("x11"); 1.456 + ltm.currentTheme = dummy("x12"); 1.457 + ltm.currentTheme = dummy("x13"); 1.458 + ltm.currentTheme = dummy("x14"); 1.459 + ltm.currentTheme = dummy("x15"); 1.460 + ltm.currentTheme = dummy("x16"); 1.461 + ltm.currentTheme = dummy("x17"); 1.462 + ltm.currentTheme = dummy("x18"); 1.463 + ltm.currentTheme = dummy("x19"); 1.464 + ltm.currentTheme = dummy("x20"); 1.465 + ltm.currentTheme = dummy("x21"); 1.466 + ltm.currentTheme = dummy("x22"); 1.467 + ltm.currentTheme = dummy("x23"); 1.468 + ltm.currentTheme = dummy("x24"); 1.469 + ltm.currentTheme = dummy("x25"); 1.470 + ltm.currentTheme = dummy("x26"); 1.471 + ltm.currentTheme = dummy("x27"); 1.472 + ltm.currentTheme = dummy("x28"); 1.473 + ltm.currentTheme = dummy("x29"); 1.474 + ltm.currentTheme = dummy("x30"); 1.475 + 1.476 + do_check_eq(ltm.usedThemes.length, 30); 1.477 + 1.478 + ltm.currentTheme = dummy("x31"); 1.479 + 1.480 + do_check_eq(ltm.usedThemes.length, 30); 1.481 + do_check_eq(ltm.getUsedTheme("x1"), null); 1.482 + 1.483 + Services.prefs.setIntPref("lightweightThemes.maxUsedThemes", 15); 1.484 + 1.485 + do_check_eq(ltm.usedThemes.length, 15); 1.486 + 1.487 + Services.prefs.setIntPref("lightweightThemes.maxUsedThemes", 32); 1.488 + 1.489 + ltm.currentTheme = dummy("x1"); 1.490 + ltm.currentTheme = dummy("x2"); 1.491 + ltm.currentTheme = dummy("x3"); 1.492 + ltm.currentTheme = dummy("x4"); 1.493 + ltm.currentTheme = dummy("x5"); 1.494 + ltm.currentTheme = dummy("x6"); 1.495 + ltm.currentTheme = dummy("x7"); 1.496 + ltm.currentTheme = dummy("x8"); 1.497 + ltm.currentTheme = dummy("x9"); 1.498 + ltm.currentTheme = dummy("x10"); 1.499 + ltm.currentTheme = dummy("x11"); 1.500 + ltm.currentTheme = dummy("x12"); 1.501 + ltm.currentTheme = dummy("x13"); 1.502 + ltm.currentTheme = dummy("x14"); 1.503 + ltm.currentTheme = dummy("x15"); 1.504 + ltm.currentTheme = dummy("x16"); 1.505 + 1.506 + ltm.currentTheme = dummy("x32"); 1.507 + 1.508 + do_check_eq(ltm.usedThemes.length, 32); 1.509 + 1.510 + ltm.currentTheme = dummy("x33"); 1.511 + 1.512 + do_check_eq(ltm.usedThemes.length, 32); 1.513 + 1.514 + Services.prefs.clearUserPref("lightweightThemes.maxUsedThemes"); 1.515 + 1.516 + do_check_eq(ltm.usedThemes.length, 30); 1.517 +}