2010-04-29 13:11:23 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
2010-05-26 13:46:10 -07:00
|
|
|
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-08-20 10:54:41 -07:00
|
|
|
// The maximum allowable time since install. If an add-on claims to have been
|
|
|
|
// installed longer ago than this the the test will fail.
|
|
|
|
const MAX_INSTALL_TIME = 10000;
|
|
|
|
|
2010-05-26 13:46:10 -07:00
|
|
|
// This verifies that themes behave as expected
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
|
|
|
|
|
|
|
|
const profileDir = gProfD.clone();
|
|
|
|
profileDir.append("extensions");
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
// Observer to ensure a "lightweight-theme-styling-update" notification is sent
|
|
|
|
// when expected
|
|
|
|
var gLWThemeChanged = false;
|
|
|
|
var LightweightThemeObserver = {
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
|
|
if (aTopic != "lightweight-theme-styling-update")
|
|
|
|
return;
|
|
|
|
|
|
|
|
gLWThemeChanged = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
AM_Cc["@mozilla.org/observer-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIObserverService)
|
|
|
|
.addObserver(LightweightThemeObserver, "lightweight-theme-styling-update", false);
|
|
|
|
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
function run_test() {
|
|
|
|
do_test_pending();
|
|
|
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
|
|
|
|
|
|
|
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0");
|
|
|
|
var dest = profileDir.clone();
|
|
|
|
dest.append("theme1@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "theme1@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Test 1",
|
|
|
|
type: 4,
|
2010-07-02 07:48:26 -07:00
|
|
|
skinnable: true,
|
2010-04-29 13:11:23 -07:00
|
|
|
internalName: "theme1/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
}, dest);
|
2010-04-07 11:08:32 -07:00
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("theme2@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "theme2@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Test 1",
|
2010-07-02 07:48:26 -07:00
|
|
|
skinnable: false,
|
2010-04-29 13:11:23 -07:00
|
|
|
internalName: "theme2/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
}, dest);
|
|
|
|
|
2010-04-07 11:08:32 -07:00
|
|
|
// We need a default theme for some of these things to work but we have hidden
|
|
|
|
// the one in the application directory.
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("default@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "default@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Default",
|
|
|
|
internalName: "classic/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
}, dest);
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
startupManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
// Make sure we only register once despite multiple calls
|
|
|
|
AddonManager.addInstallListener(InstallListener);
|
|
|
|
AddonManager.addAddonListener(AddonListener);
|
|
|
|
AddonManager.addInstallListener(InstallListener);
|
|
|
|
AddonManager.addAddonListener(AddonListener);
|
2010-04-28 11:46:00 -07:00
|
|
|
AddonManager.addInstallListener(InstallListener);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-07-02 07:48:26 -07:00
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"],
|
|
|
|
function([d, t1, t2]) {
|
|
|
|
do_check_neq(d, null);
|
|
|
|
do_check_false(d.skinnable);
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_false(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_true(t1.isActive);
|
2010-07-02 07:48:26 -07:00
|
|
|
do_check_true(t1.skinnable);
|
2010-08-23 18:04:06 -07:00
|
|
|
do_check_eq(t1.screenshots, null);
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_true(isThemeInAddonsList(profileDir, t1.id));
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_eq(t1.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL |
|
|
|
|
AddonManager.OP_NEEDS_RESTART_DISABLE);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(t2, null);
|
|
|
|
do_check_true(t2.userDisabled);
|
|
|
|
do_check_false(t2.appDisabled);
|
|
|
|
do_check_false(t2.isActive);
|
2010-07-02 07:48:26 -07:00
|
|
|
do_check_false(t2.skinnable);
|
2010-08-23 18:04:06 -07:00
|
|
|
do_check_eq(t2.screenshots, null);
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_false(isThemeInAddonsList(profileDir, t2.id));
|
|
|
|
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_eq(t2.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_1();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function end_test() {
|
|
|
|
do_test_finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks enabling one theme disables the others
|
|
|
|
function run_test_1() {
|
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
"onDisabling"
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onEnabling"
|
|
|
|
]
|
|
|
|
});
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([t1, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
t2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
check_test_1();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_1() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme2/1.0");
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([t1, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_false(t1.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, t1.id));
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_eq(t1.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(t2, null);
|
|
|
|
do_check_false(t2.userDisabled);
|
|
|
|
do_check_false(t2.appDisabled);
|
|
|
|
do_check_true(t2.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, t2.id));
|
|
|
|
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_eq(t2.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL |
|
|
|
|
AddonManager.OP_NEEDS_RESTART_DISABLE);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_2();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Removing the active theme should fall back to the default (not ideal in this
|
|
|
|
// case since we don't have the default theme installed)
|
|
|
|
function run_test_2() {
|
|
|
|
var dest = profileDir.clone();
|
|
|
|
dest.append("theme2@tests.mozilla.org");
|
|
|
|
dest.remove(true);
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["theme1@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([t1, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_false(t1.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, t1.id));
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(t2, null);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, "theme2@tests.mozilla.org"));
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_3();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Installing a lightweight theme should happen instantly and disable the default theme
|
|
|
|
function run_test_3() {
|
|
|
|
var dest = profileDir.clone();
|
|
|
|
dest.append("theme2@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "theme2@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Test 1",
|
|
|
|
internalName: "theme2/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
}, dest);
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"1@personas.mozilla.org": [
|
|
|
|
["onInstalling", false],
|
|
|
|
"onInstalled",
|
|
|
|
["onEnabling", false],
|
|
|
|
"onEnabled"
|
|
|
|
],
|
2010-04-07 11:08:32 -07:00
|
|
|
"default@tests.mozilla.org": [
|
2010-04-29 13:11:23 -07:00
|
|
|
["onDisabling", false],
|
|
|
|
"onDisabled",
|
|
|
|
]
|
2010-04-28 11:46:00 -07:00
|
|
|
}, [
|
|
|
|
"onExternalInstall"
|
|
|
|
]);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
LightweightThemeManager.currentTheme = {
|
|
|
|
id: "1",
|
|
|
|
version: "1",
|
|
|
|
name: "Test LW Theme",
|
|
|
|
description: "A test theme",
|
|
|
|
author: "Mozilla",
|
|
|
|
homepageURL: "http://localhost:4444/data/index.html",
|
|
|
|
headerURL: "http://localhost:4444/data/header.png",
|
|
|
|
footerURL: "http://localhost:4444/data/footer.png",
|
|
|
|
previewURL: "http://localhost:4444/data/preview.png",
|
|
|
|
iconURL: "http://localhost:4444/data/icon.png"
|
|
|
|
};
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(null, p1);
|
|
|
|
do_check_eq(p1.name, "Test LW Theme");
|
|
|
|
do_check_eq(p1.version, "1");
|
2010-04-26 10:48:27 -07:00
|
|
|
do_check_eq(p1.type, "theme");
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_eq(p1.description, "A test theme");
|
|
|
|
do_check_eq(p1.creator, "Mozilla");
|
|
|
|
do_check_eq(p1.homepageURL, "http://localhost:4444/data/index.html");
|
|
|
|
do_check_eq(p1.iconURL, "http://localhost:4444/data/icon.png");
|
|
|
|
do_check_eq(p1.screenshots.length, 1);
|
|
|
|
do_check_eq(p1.screenshots[0], "http://localhost:4444/data/preview.png");
|
|
|
|
do_check_false(p1.appDisabled);
|
|
|
|
do_check_false(p1.userDisabled);
|
2010-04-06 14:39:30 -07:00
|
|
|
do_check_true(p1.isCompatible);
|
|
|
|
do_check_true(p1.providesUpdatesSecurely);
|
|
|
|
do_check_eq(p1.blocklistState, 0);
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_true(p1.isActive);
|
|
|
|
do_check_eq(p1.pendingOperations, 0);
|
|
|
|
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
2010-04-26 10:48:27 -07:00
|
|
|
do_check_eq(p1.scope, AddonManager.SCOPE_PROFILE);
|
|
|
|
do_check_true("isCompatibleWith" in p1);
|
|
|
|
do_check_true("findUpdates" in p1);
|
2010-07-01 21:33:34 -07:00
|
|
|
do_check_eq(p1.installDate.getTime(), p1.updateDate.getTime());
|
|
|
|
|
2010-08-20 10:54:41 -07:00
|
|
|
// Should have been installed sometime in the last few seconds.
|
|
|
|
let difference = Date.now() - p1.installDate.getTime();
|
|
|
|
if (difference > MAX_INSTALL_TIME)
|
|
|
|
do_throw("Add-on was installed " + difference + "ms ago");
|
|
|
|
else if (difference < 0)
|
|
|
|
do_throw("Add-on was installed " + difference + "ms in the future");
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
|
|
|
let seen = false;
|
|
|
|
addons.forEach(function(a) {
|
|
|
|
if (a.id == "1@personas.mozilla.org") {
|
|
|
|
seen = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dump("Checking theme " + a.id + "\n");
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
do_check_true(seen);
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_4();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Installing a second lightweight theme should disable the first with no restart
|
|
|
|
function run_test_4() {
|
|
|
|
prepare_test({
|
|
|
|
"1@personas.mozilla.org": [
|
|
|
|
["onDisabling", false],
|
|
|
|
"onDisabled",
|
|
|
|
],
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
["onInstalling", false],
|
|
|
|
"onInstalled",
|
|
|
|
["onEnabling", false],
|
|
|
|
"onEnabled"
|
|
|
|
]
|
2010-04-28 11:46:00 -07:00
|
|
|
}, [
|
|
|
|
"onExternalInstall"
|
|
|
|
]);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
LightweightThemeManager.currentTheme = {
|
|
|
|
id: "2",
|
|
|
|
version: "1",
|
|
|
|
name: "Test LW Theme",
|
|
|
|
description: "A second test theme",
|
|
|
|
author: "Mozilla",
|
|
|
|
homepageURL: "http://localhost:4444/data/index.html",
|
|
|
|
headerURL: "http://localhost:4444/data/header.png",
|
|
|
|
footerURL: "http://localhost:4444/data/footer.png",
|
|
|
|
previewURL: "http://localhost:4444/data/preview.png",
|
|
|
|
iconURL: "http://localhost:4444/data/icon.png"
|
|
|
|
};
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["1@personas.mozilla.org",
|
|
|
|
"2@personas.mozilla.org"], function([p1, p2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(null, p2);
|
|
|
|
do_check_false(p2.appDisabled);
|
|
|
|
do_check_false(p2.userDisabled);
|
|
|
|
do_check_true(p2.isActive);
|
|
|
|
do_check_eq(p2.pendingOperations, 0);
|
|
|
|
do_check_eq(p2.permissions, AddonManager.PERM_CAN_UNINSTALL);
|
2010-07-01 21:33:34 -07:00
|
|
|
do_check_eq(p2.installDate.getTime(), p2.updateDate.getTime());
|
|
|
|
|
2010-08-20 10:54:41 -07:00
|
|
|
// Should have been installed sometime in the last few seconds.
|
|
|
|
let difference = Date.now() - p2.installDate.getTime();
|
|
|
|
if (difference > MAX_INSTALL_TIME)
|
|
|
|
do_throw("Add-on was installed " + difference + "ms ago");
|
|
|
|
else if (difference < 0)
|
|
|
|
do_throw("Add-on was installed " + difference + "ms in the future");
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(null, p1);
|
|
|
|
do_check_false(p1.appDisabled);
|
|
|
|
do_check_true(p1.userDisabled);
|
|
|
|
do_check_false(p1.isActive);
|
|
|
|
do_check_eq(p1.pendingOperations, 0);
|
|
|
|
do_check_eq(p1.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE);
|
|
|
|
|
|
|
|
AddonManager.getAddonsByTypes(["theme"], function(addons) {
|
|
|
|
let seen = false;
|
|
|
|
addons.forEach(function(a) {
|
|
|
|
if (a.id == "2@personas.mozilla.org") {
|
|
|
|
seen = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dump("Checking theme " + a.id + "\n");
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
do_check_true(seen);
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_5();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Switching to a custom theme should disable the lightweight theme and require
|
|
|
|
// a restart. Cancelling that should also be possible.
|
|
|
|
function run_test_5() {
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onDisabling",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onEnabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["2@personas.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
t2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onOperationCancelled",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onOperationCancelled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
p2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onDisabling",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onEnabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
t2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_false(t2.isActive);
|
|
|
|
do_check_false(t2.userDisabled);
|
|
|
|
do_check_true(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations));
|
|
|
|
do_check_true(p2.isActive);
|
|
|
|
do_check_true(p2.userDisabled);
|
|
|
|
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations));
|
|
|
|
do_check_true(hasFlag(AddonManager.PERM_CAN_ENABLE, p2.permissions));
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
check_test_5();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_5() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["2@personas.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_true(t2.isActive);
|
|
|
|
do_check_false(t2.userDisabled);
|
|
|
|
do_check_false(hasFlag(AddonManager.PENDING_ENABLE, t2.pendingOperations));
|
|
|
|
do_check_false(p2.isActive);
|
|
|
|
do_check_true(p2.userDisabled);
|
|
|
|
do_check_false(hasFlag(AddonManager.PENDING_DISABLE, p2.pendingOperations));
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_6();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Switching from a custom theme to a lightweight theme should require a restart
|
|
|
|
function run_test_6() {
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onEnabling",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onDisabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["2@personas.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
p2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onOperationCancelled",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onOperationCancelled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
t2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
"onEnabling",
|
|
|
|
],
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onDisabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
p2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_false(p2.isActive);
|
|
|
|
do_check_false(p2.userDisabled);
|
|
|
|
do_check_true(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations));
|
|
|
|
do_check_true(t2.isActive);
|
|
|
|
do_check_true(t2.userDisabled);
|
|
|
|
do_check_true(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations));
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
check_test_6();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_6() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["2@personas.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([p2, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_true(p2.isActive);
|
|
|
|
do_check_false(p2.userDisabled);
|
|
|
|
do_check_false(hasFlag(AddonManager.PENDING_ENABLE, p2.pendingOperations));
|
|
|
|
do_check_false(t2.isActive);
|
|
|
|
do_check_true(t2.userDisabled);
|
|
|
|
do_check_false(hasFlag(AddonManager.PENDING_DISABLE, t2.pendingOperations));
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_7();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uninstalling a lightweight theme should not require a restart
|
|
|
|
function run_test_7() {
|
|
|
|
prepare_test({
|
|
|
|
"1@personas.mozilla.org": [
|
|
|
|
["onUninstalling", false],
|
|
|
|
"onUninstalled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
p1.uninstall();
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
do_check_eq(LightweightThemeManager.usedThemes.length, 1);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_8();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uninstalling a lightweight theme in use should not require a restart and it
|
|
|
|
// should reactivate the default theme
|
2010-06-08 09:45:30 -07:00
|
|
|
// Also, uninstalling a lightweight theme in use should send a
|
|
|
|
// "lightweight-theme-styling-update" notification through the observer service
|
2010-04-29 13:11:23 -07:00
|
|
|
function run_test_8() {
|
|
|
|
prepare_test({
|
|
|
|
"2@personas.mozilla.org": [
|
|
|
|
["onUninstalling", false],
|
|
|
|
"onUninstalled"
|
|
|
|
],
|
2010-04-07 11:08:32 -07:00
|
|
|
"default@tests.mozilla.org": [
|
2010-04-29 13:11:23 -07:00
|
|
|
["onEnabling", false],
|
|
|
|
"onEnabled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("2@personas.mozilla.org", function(p2) {
|
2010-04-29 13:11:23 -07:00
|
|
|
p2.uninstall();
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
do_check_eq(LightweightThemeManager.usedThemes.length, 0);
|
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_9();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uninstalling a theme not in use should not require a restart
|
|
|
|
function run_test_9() {
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
["onUninstalling", false],
|
|
|
|
"onUninstalled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
t1.uninstall();
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(newt1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_eq(newt1, null);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_10();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uninstalling a custom theme in use should require a restart
|
|
|
|
function run_test_10() {
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme2@tests.mozilla.org", function(oldt2) {
|
2010-04-29 13:11:23 -07:00
|
|
|
prepare_test({
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onEnabling",
|
|
|
|
],
|
2010-04-07 11:08:32 -07:00
|
|
|
"default@tests.mozilla.org": [
|
2010-04-29 13:11:23 -07:00
|
|
|
"onDisabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
oldt2.userDisabled = false;
|
|
|
|
|
|
|
|
ensure_test_completed();
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([d, t2]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_true(t2.isActive);
|
|
|
|
do_check_false(t2.userDisabled);
|
|
|
|
do_check_false(t2.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"theme2@tests.mozilla.org": [
|
|
|
|
"onUninstalling",
|
|
|
|
],
|
2010-04-07 11:08:32 -07:00
|
|
|
"default@tests.mozilla.org": [
|
2010-04-29 13:11:23 -07:00
|
|
|
"onEnabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
t2.uninstall();
|
|
|
|
|
|
|
|
ensure_test_completed();
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_11();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Installing a custom theme not in use should not require a restart
|
|
|
|
function run_test_11() {
|
|
|
|
prepare_test({ }, [
|
|
|
|
"onNewInstall"
|
|
|
|
]);
|
|
|
|
|
|
|
|
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_neq(install, null);
|
|
|
|
do_check_eq(install.type, "theme");
|
|
|
|
do_check_eq(install.version, "1.0");
|
|
|
|
do_check_eq(install.name, "Test Theme 1");
|
|
|
|
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
2010-07-02 07:48:26 -07:00
|
|
|
do_check_true(install.addon.skinnable, true);
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_false(hasFlag(install.addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_INSTALL));
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
["onInstalling", false],
|
|
|
|
"onInstalled"
|
|
|
|
]
|
|
|
|
}, [
|
|
|
|
"onInstallStarted",
|
|
|
|
"onInstallEnded",
|
|
|
|
], check_test_11);
|
|
|
|
install.install();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_11() {
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
2010-05-26 13:46:10 -07:00
|
|
|
var preview = profileDir.clone();
|
|
|
|
preview.append("theme1@tests.mozilla.org");
|
|
|
|
preview.append("preview.png");
|
|
|
|
do_check_eq(t1.screenshots.length, 1);
|
|
|
|
do_check_eq(t1.screenshots[0], NetUtil.newURI(preview).spec);
|
2010-07-02 07:48:26 -07:00
|
|
|
do_check_true(t1.skinnable);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_12();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Updating a custom theme not in use should not require a restart
|
|
|
|
function run_test_12() {
|
|
|
|
prepare_test({ }, [
|
|
|
|
"onNewInstall"
|
|
|
|
]);
|
|
|
|
|
|
|
|
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_neq(install, null);
|
|
|
|
do_check_eq(install.type, "theme");
|
|
|
|
do_check_eq(install.version, "1.0");
|
|
|
|
do_check_eq(install.name, "Test Theme 1");
|
|
|
|
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_false(hasFlag(install.addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_INSTALL));
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
["onInstalling", false],
|
|
|
|
"onInstalled"
|
|
|
|
]
|
|
|
|
}, [
|
|
|
|
"onInstallStarted",
|
|
|
|
"onInstallEnded",
|
|
|
|
], check_test_12);
|
|
|
|
install.install();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_12() {
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
run_test_13();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Updating a custom theme in use should require a restart
|
|
|
|
function run_test_13() {
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
"onEnabling",
|
|
|
|
],
|
2010-04-07 11:08:32 -07:00
|
|
|
"default@tests.mozilla.org": [
|
2010-04-29 13:11:23 -07:00
|
|
|
"onDisabling"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
t1.userDisabled = false;
|
|
|
|
ensure_test_completed();
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
prepare_test({ }, [
|
|
|
|
"onNewInstall"
|
|
|
|
]);
|
|
|
|
|
|
|
|
AddonManager.getInstallForFile(do_get_addon("test_theme"), function(install) {
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_neq(install, null);
|
|
|
|
do_check_eq(install.type, "theme");
|
|
|
|
do_check_eq(install.version, "1.0");
|
|
|
|
do_check_eq(install.name, "Test Theme 1");
|
|
|
|
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
|
2010-09-01 10:02:28 -07:00
|
|
|
do_check_true(hasFlag(install.addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_INSTALL));
|
2010-04-28 11:47:22 -07:00
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
"onInstalling",
|
|
|
|
]
|
|
|
|
}, [
|
|
|
|
"onInstallStarted",
|
|
|
|
"onInstallEnded",
|
|
|
|
], check_test_13);
|
|
|
|
install.install();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_13() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_true(t1.isActive);
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_false(gLWThemeChanged);
|
2010-04-27 13:45:20 -07:00
|
|
|
t1.uninstall();
|
|
|
|
restartManager();
|
|
|
|
|
|
|
|
run_test_14();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Switching from a lightweight theme to the default theme should not require
|
|
|
|
// a restart
|
|
|
|
function run_test_14() {
|
|
|
|
LightweightThemeManager.currentTheme = {
|
|
|
|
id: "1",
|
|
|
|
version: "1",
|
|
|
|
name: "Test LW Theme",
|
|
|
|
description: "A test theme",
|
|
|
|
author: "Mozilla",
|
|
|
|
homepageURL: "http://localhost:4444/data/index.html",
|
|
|
|
headerURL: "http://localhost:4444/data/header.png",
|
|
|
|
footerURL: "http://localhost:4444/data/footer.png",
|
|
|
|
previewURL: "http://localhost:4444/data/preview.png",
|
|
|
|
iconURL: "http://localhost:4444/data/icon.png"
|
|
|
|
};
|
|
|
|
|
|
|
|
AddonManager.getAddonByID("default@tests.mozilla.org", function(d) {
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"1@personas.mozilla.org": [
|
|
|
|
["onDisabling", false],
|
|
|
|
"onDisabled"
|
|
|
|
],
|
|
|
|
"default@tests.mozilla.org": [
|
|
|
|
["onEnabling", false],
|
|
|
|
"onEnabled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
d.userDisabled = false;
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_true(d.isActive);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-06-08 09:45:30 -07:00
|
|
|
do_check_true(gLWThemeChanged);
|
|
|
|
gLWThemeChanged = false;
|
|
|
|
|
2010-06-29 11:12:30 -07:00
|
|
|
run_test_15();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Upgrading the application with a custom theme in use should not disable it
|
|
|
|
function run_test_15() {
|
|
|
|
restartManager();
|
|
|
|
|
|
|
|
installAllFiles([do_get_addon("test_theme")], function() {
|
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
|
|
|
t1.userDisabled = false;
|
|
|
|
|
|
|
|
restartManager();
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme1/1.0");
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
do_check_false(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_true(t1.isActive);
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager("2");
|
2010-06-29 11:12:30 -07:00
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme1/1.0");
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
do_check_false(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_true(t1.isActive);
|
|
|
|
|
|
|
|
run_test_16();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Upgrading the application with a custom theme in use should disable it if it
|
|
|
|
// is no longer compatible
|
|
|
|
function run_test_16() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager("3");
|
2010-06-29 11:12:30 -07:00
|
|
|
|
2010-07-02 16:03:34 -07:00
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_true(t1.appDisabled);
|
|
|
|
do_check_false(t1.isActive);
|
|
|
|
|
|
|
|
run_test_17();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verifies that if the selected theme pref is changed by a different version
|
|
|
|
// of the application that we correctly reset it when it points to an
|
|
|
|
// incompatible theme
|
|
|
|
function run_test_17() {
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager("2");
|
2010-07-02 16:03:34 -07:00
|
|
|
shutdownManager();
|
|
|
|
|
|
|
|
Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0");
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager("3");
|
2010-07-02 16:03:34 -07:00
|
|
|
|
2010-06-29 11:12:30 -07:00
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_true(t1.appDisabled);
|
|
|
|
do_check_false(t1.isActive);
|
|
|
|
|
2010-07-26 10:20:35 -07:00
|
|
|
run_test_18();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disabling the active theme should switch back to the default theme
|
|
|
|
function run_test_18() {
|
|
|
|
restartManager(2);
|
|
|
|
|
|
|
|
AddonManager.getAddonByID("theme1@tests.mozilla.org", function(t1) {
|
|
|
|
t1.userDisabled = false;
|
|
|
|
|
|
|
|
restartManager();
|
|
|
|
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
do_check_false(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_true(t1.isActive);
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"theme1@tests.mozilla.org": [
|
|
|
|
"onDisabling",
|
|
|
|
],
|
|
|
|
"default@tests.mozilla.org": [
|
|
|
|
"onEnabling",
|
|
|
|
]
|
|
|
|
});
|
|
|
|
t1.userDisabled = true;
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_true(t1.isActive);
|
|
|
|
|
|
|
|
restartManager();
|
|
|
|
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"theme1@tests.mozilla.org"], function([d, t1]) {
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
|
|
|
|
do_check_true(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_false(t1.isActive);
|
|
|
|
|
|
|
|
run_test_19();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disabling the active persona should switch back to the default theme
|
|
|
|
function run_test_19() {
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"1@personas.mozilla.org"], function([d, p1]) {
|
|
|
|
p1.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
|
|
|
|
do_check_false(p1.userDisabled);
|
|
|
|
do_check_false(p1.appDisabled);
|
|
|
|
do_check_true(p1.isActive);
|
|
|
|
|
|
|
|
prepare_test({
|
|
|
|
"1@personas.mozilla.org": [
|
|
|
|
["onDisabling", false],
|
|
|
|
"onDisabled"
|
|
|
|
],
|
|
|
|
"default@tests.mozilla.org": [
|
|
|
|
["onEnabling", false],
|
|
|
|
"onEnabled"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
p1.userDisabled = true;
|
|
|
|
ensure_test_completed();
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
|
|
|
|
do_check_true(p1.userDisabled);
|
|
|
|
do_check_false(p1.appDisabled);
|
|
|
|
do_check_false(p1.isActive);
|
|
|
|
|
|
|
|
run_test_20();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that you cannot disable the default theme
|
|
|
|
function run_test_20() {
|
|
|
|
AddonManager.getAddonByID("default@tests.mozilla.org", function(d) {
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
|
|
|
|
try {
|
|
|
|
d.userDisabled = true;
|
|
|
|
do_throw("Disabling the default theme should throw an exception");
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
}
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
end_test();
|
|
|
|
});
|
|
|
|
}
|