2010-05-06 16:02:04 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This verifies that the themes switch as expected
|
|
|
|
|
|
|
|
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
|
|
|
|
|
|
|
const profileDir = gProfD.clone();
|
|
|
|
profileDir.append("extensions");
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
do_test_pending();
|
|
|
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
|
|
|
|
2010-09-10 15:54:37 -07:00
|
|
|
writeInstallRDFForExtension({
|
2010-05-06 16:02:04 -07:00
|
|
|
id: "default@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Default",
|
|
|
|
internalName: "classic/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
2010-09-10 15:54:37 -07:00
|
|
|
}, profileDir);
|
2010-05-06 16:02:04 -07:00
|
|
|
|
2010-09-10 15:54:37 -07:00
|
|
|
writeInstallRDFForExtension({
|
2010-05-06 16:02:04 -07:00
|
|
|
id: "alternate@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Test 1",
|
|
|
|
type: 4,
|
|
|
|
internalName: "alternate/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
2010-09-10 15:54:37 -07:00
|
|
|
}, profileDir);
|
2010-05-06 16:02:04 -07:00
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
startupManager();
|
|
|
|
|
2010-05-06 16:02:04 -07:00
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"alternate@tests.mozilla.org"], function([d, a]) {
|
|
|
|
do_check_neq(d, null);
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_neq(a, null);
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
run_test_1(d, a);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function end_test() {
|
|
|
|
do_test_finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checks switching to a different theme and back again leaves everything the
|
|
|
|
// same
|
|
|
|
function run_test_1(d, a) {
|
|
|
|
a.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_false(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
d.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-05-06 16:02:04 -07:00
|
|
|
run_test_2();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that after the restart themes can be changed as expected
|
|
|
|
function run_test_2() {
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"alternate@tests.mozilla.org"], function([d, a]) {
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
do_check_neq(d, null);
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_neq(a, null);
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
a.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_false(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
d.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
a.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_false(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-05-06 16:02:04 -07:00
|
|
|
check_test_2();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_test_2() {
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"alternate@tests.mozilla.org"], function([d, a]) {
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "alternate/1.0");
|
|
|
|
|
|
|
|
do_check_true(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_false(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_true(a.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
d.userDisabled = false;
|
|
|
|
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_false(d.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_true(a.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "alternate/1.0");
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager();
|
2010-05-06 16:02:04 -07:00
|
|
|
|
|
|
|
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
|
|
|
|
|
|
|
|
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
|
|
|
|
"alternate@tests.mozilla.org"], function([d, a]) {
|
|
|
|
do_check_neq(d, null);
|
|
|
|
do_check_false(d.userDisabled);
|
|
|
|
do_check_false(d.appDisabled);
|
|
|
|
do_check_true(d.isActive);
|
|
|
|
do_check_true(isThemeInAddonsList(profileDir, d.id));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
do_check_neq(a, null);
|
|
|
|
do_check_true(a.userDisabled);
|
|
|
|
do_check_false(a.appDisabled);
|
|
|
|
do_check_false(a.isActive);
|
|
|
|
do_check_false(isThemeInAddonsList(profileDir, a.id));
|
|
|
|
do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
|
|
|
|
do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
end_test();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|