2010-04-29 13:11:23 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Checks that we migrate data from previous versions of the database
|
|
|
|
|
|
|
|
var addon1 = {
|
|
|
|
id: "addon1@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Test 1",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
var addon2 = {
|
|
|
|
id: "addon2@tests.mozilla.org",
|
|
|
|
version: "2.0",
|
|
|
|
name: "Test 2",
|
|
|
|
targetApplications: [{
|
2010-04-20 15:41:56 -07:00
|
|
|
id: "toolkit@mozilla.org",
|
2010-04-29 13:11:23 -07:00
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
var addon3 = {
|
|
|
|
id: "addon3@tests.mozilla.org",
|
|
|
|
version: "2.0",
|
|
|
|
name: "Test 3",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
var addon4 = {
|
|
|
|
id: "addon4@tests.mozilla.org",
|
|
|
|
version: "2.0",
|
|
|
|
name: "Test 4",
|
|
|
|
targetApplications: [{
|
2010-04-20 15:41:56 -07:00
|
|
|
id: "toolkit@mozilla.org",
|
2010-04-29 13:11:23 -07:00
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2010-07-16 14:33:00 -07:00
|
|
|
var addon5 = {
|
|
|
|
id: "addon5@tests.mozilla.org",
|
|
|
|
version: "2.0",
|
|
|
|
name: "Test 5",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "toolkit@mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2010-05-10 11:10:10 -07:00
|
|
|
var theme1 = {
|
|
|
|
id: "theme1@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Theme 1",
|
|
|
|
type: 4,
|
|
|
|
internalName: "theme1/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
var theme2 = {
|
|
|
|
id: "theme2@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
name: "Theme 2",
|
|
|
|
type: 4,
|
|
|
|
internalName: "theme2/1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
const profileDir = gProfD.clone();
|
|
|
|
profileDir.append("extensions");
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
do_test_pending();
|
2010-04-20 15:41:56 -07:00
|
|
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
var dest = profileDir.clone();
|
|
|
|
dest.append("addon1@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(addon1, dest);
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("addon2@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(addon2, dest);
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("addon3@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(addon3, dest);
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("addon4@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(addon4, dest);
|
2010-05-10 11:10:10 -07:00
|
|
|
dest = profileDir.clone();
|
2010-07-16 14:33:00 -07:00
|
|
|
dest.append("addon5@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(addon5, dest);
|
|
|
|
dest = profileDir.clone();
|
2010-05-10 11:10:10 -07:00
|
|
|
dest.append("theme1@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(theme1, dest);
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("theme2@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir(theme2, dest);
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
let old = do_get_file("data/test_migrate.rdf");
|
|
|
|
old.copyTo(gProfD, "extensions.rdf");
|
|
|
|
|
2010-05-10 11:10:10 -07:00
|
|
|
// Theme state is determined by the selected theme pref
|
|
|
|
Services.prefs.setCharPref("general.skins.selectedSkin", "theme1/1.0");
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
startupManager();
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
|
|
|
"addon2@tests.mozilla.org",
|
|
|
|
"addon3@tests.mozilla.org",
|
2010-05-10 11:10:10 -07:00
|
|
|
"addon4@tests.mozilla.org",
|
2010-07-16 14:33:00 -07:00
|
|
|
"addon5@tests.mozilla.org",
|
2010-05-10 11:10:10 -07:00
|
|
|
"theme1@tests.mozilla.org",
|
|
|
|
"theme2@tests.mozilla.org"], function([a1, a2,
|
2010-07-16 14:33:00 -07:00
|
|
|
a3, a4, a5,
|
2010-05-10 11:10:10 -07:00
|
|
|
t1, t2]) {
|
2010-04-20 15:41:56 -07:00
|
|
|
// addon1 was user and app enabled in the old extensions.rdf
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(a1, null);
|
|
|
|
do_check_false(a1.userDisabled);
|
2010-04-20 15:41:56 -07:00
|
|
|
do_check_false(a1.appDisabled);
|
|
|
|
|
|
|
|
// addon2 was user disabled and app enabled in the old extensions.rdf
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(a2, null);
|
|
|
|
do_check_true(a2.userDisabled);
|
2010-04-20 15:41:56 -07:00
|
|
|
do_check_false(a2.appDisabled);
|
|
|
|
|
|
|
|
// addon3 was pending user disable and app disabled in the old extensions.rdf
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(a3, null);
|
|
|
|
do_check_true(a3.userDisabled);
|
2010-04-20 15:41:56 -07:00
|
|
|
do_check_true(a3.appDisabled);
|
|
|
|
|
|
|
|
// addon4 was pending user enable and app disabled in the old extensions.rdf
|
2010-04-29 13:11:23 -07:00
|
|
|
do_check_neq(a4, null);
|
|
|
|
do_check_false(a4.userDisabled);
|
2010-04-20 15:41:56 -07:00
|
|
|
do_check_true(a4.appDisabled);
|
|
|
|
|
2010-07-16 14:33:00 -07:00
|
|
|
// addon5 was disabled and compatible but a new version has been installed
|
|
|
|
// since, it should still be disabled but should be incompatible
|
|
|
|
do_check_neq(a5, null);
|
|
|
|
do_check_true(a5.userDisabled);
|
|
|
|
do_check_true(a5.appDisabled);
|
|
|
|
|
2010-05-10 11:10:10 -07:00
|
|
|
// Theme 1 was previously enabled
|
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_false(t1.userDisabled);
|
|
|
|
do_check_false(t1.appDisabled);
|
|
|
|
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
|
|
|
// Theme 2 was previously disabled
|
|
|
|
do_check_neq(t1, null);
|
|
|
|
do_check_true(t2.userDisabled);
|
|
|
|
do_check_false(t2.appDisabled);
|
|
|
|
do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
do_test_finished();
|
|
|
|
});
|
|
|
|
}
|