2010-04-29 13:11:23 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This verifies that app upgrades produce the expected behaviours.
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
// Enable loading extensions from the application scope
|
|
|
|
Services.prefs.setIntPref("extensions.enabledScopes",
|
|
|
|
AddonManager.SCOPE_PROFILE +
|
|
|
|
AddonManager.SCOPE_APPLICATION);
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
const profileDir = gProfD.clone();
|
|
|
|
profileDir.append("extensions");
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsILocalFile);
|
|
|
|
globalDir.append("extensions");
|
|
|
|
|
|
|
|
var gGlobalExisted = globalDir.exists();
|
|
|
|
var gInstallTime = Date.now();
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
function run_test() {
|
|
|
|
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
|
|
|
|
|
|
|
// Will be enabled in the first version and disabled in subsequent versions
|
|
|
|
var dest = profileDir.clone();
|
|
|
|
dest.append("addon1@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon1@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 1",
|
2010-07-29 12:50:55 -07:00
|
|
|
targetPlatforms: [
|
|
|
|
"XPCShell",
|
|
|
|
"WINNT_x86",
|
|
|
|
]
|
2010-04-29 13:11:23 -07:00
|
|
|
}, dest);
|
|
|
|
|
|
|
|
// Works in all tested versions
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("addon2@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon2@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "2"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 2",
|
2010-07-29 12:50:55 -07:00
|
|
|
targetPlatforms: [
|
|
|
|
"XPCShell_noarch-spidermonkey"
|
|
|
|
]
|
2010-04-29 13:11:23 -07:00
|
|
|
}, dest);
|
|
|
|
|
|
|
|
// Will be disabled in the first version and enabled in the second.
|
|
|
|
dest = profileDir.clone();
|
|
|
|
dest.append("addon3@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon3@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "2",
|
|
|
|
maxVersion: "2"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 3",
|
|
|
|
}, dest);
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
// Will be enabled in both versions but will change version in between
|
|
|
|
dest = globalDir.clone();
|
|
|
|
dest.append("addon4@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon4@tests.mozilla.org",
|
|
|
|
version: "1.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "1",
|
|
|
|
maxVersion: "1"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 4",
|
|
|
|
}, dest);
|
|
|
|
dest.lastModifiedTime = gInstallTime;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
do_test_pending();
|
|
|
|
|
|
|
|
run_test_1();
|
|
|
|
}
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
function end_test() {
|
|
|
|
if (!gGlobalExisted) {
|
|
|
|
globalDir.remove(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
globalDir.append("addon4@tests.mozilla.org");
|
|
|
|
globalDir.remove(true);
|
|
|
|
}
|
|
|
|
do_test_finished();
|
|
|
|
}
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
// Test that the test extensions are all installed
|
|
|
|
function run_test_1() {
|
2010-07-14 10:13:26 -07:00
|
|
|
startupManager();
|
2010-04-29 13:11:23 -07:00
|
|
|
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
|
|
|
"addon2@tests.mozilla.org",
|
2010-07-19 16:05:04 -07:00
|
|
|
"addon3@tests.mozilla.org",
|
|
|
|
"addon4@tests.mozilla.org"],
|
|
|
|
function([a1, a2, a3, a4]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(a1, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
|
|
|
|
|
|
|
do_check_neq(a2, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
|
|
|
|
|
|
|
do_check_neq(a3, null);
|
|
|
|
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
do_check_neq(a4, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
|
|
|
|
do_check_eq(a4.version, "1.0");
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_2();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test that upgrading the application disables now incompatible add-ons
|
|
|
|
function run_test_2() {
|
2010-07-19 16:05:04 -07:00
|
|
|
// Upgrade the extension
|
|
|
|
dest = globalDir.clone();
|
|
|
|
dest.append("addon4@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon4@tests.mozilla.org",
|
|
|
|
version: "2.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "2",
|
|
|
|
maxVersion: "2"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 4",
|
|
|
|
}, dest);
|
|
|
|
dest.lastModifiedTime = gInstallTime;
|
|
|
|
|
2010-07-14 10:13:26 -07:00
|
|
|
restartManager("2");
|
2010-04-26 10:49:19 -07:00
|
|
|
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
|
|
|
|
"addon2@tests.mozilla.org",
|
2010-07-19 16:05:04 -07:00
|
|
|
"addon3@tests.mozilla.org",
|
|
|
|
"addon4@tests.mozilla.org"],
|
|
|
|
function([a1, a2, a3, a4]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(a1, null);
|
|
|
|
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
|
|
|
|
|
|
|
do_check_neq(a2, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
|
|
|
|
|
|
|
do_check_neq(a3, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
do_check_neq(a4, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
|
|
|
|
do_check_eq(a4.version, "2.0");
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
run_test_3();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test that nothing changes when only the build ID changes.
|
|
|
|
function run_test_3() {
|
2010-07-19 16:05:04 -07:00
|
|
|
// Upgrade the extension
|
|
|
|
dest = globalDir.clone();
|
|
|
|
dest.append("addon4@tests.mozilla.org");
|
|
|
|
writeInstallRDFToDir({
|
|
|
|
id: "addon4@tests.mozilla.org",
|
|
|
|
version: "3.0",
|
|
|
|
targetApplications: [{
|
|
|
|
id: "xpcshell@tests.mozilla.org",
|
|
|
|
minVersion: "3",
|
|
|
|
maxVersion: "3"
|
|
|
|
}],
|
|
|
|
name: "Test Addon 4",
|
|
|
|
}, dest);
|
|
|
|
dest.lastModifiedTime = gInstallTime;
|
|
|
|
|
2010-04-29 13:11:23 -07:00
|
|
|
// Simulates a simple Build ID change, the platform deletes extensions.ini
|
|
|
|
// whenever the application is changed.
|
|
|
|
var file = gProfD.clone();
|
|
|
|
file.append("extensions.ini");
|
|
|
|
file.remove(true);
|
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(["addon1@tests.mozilla.org",
|
|
|
|
"addon2@tests.mozilla.org",
|
2010-07-19 16:05:04 -07:00
|
|
|
"addon3@tests.mozilla.org",
|
|
|
|
"addon4@tests.mozilla.org"],
|
|
|
|
function([a1, a2, a3, a4]) {
|
2010-04-29 13:11:23 -07:00
|
|
|
|
|
|
|
do_check_neq(a1, null);
|
|
|
|
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
|
|
|
|
|
|
|
do_check_neq(a2, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a2.id));
|
|
|
|
|
|
|
|
do_check_neq(a3, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
|
|
|
|
|
2010-07-19 16:05:04 -07:00
|
|
|
do_check_neq(a4, null);
|
|
|
|
do_check_true(isExtensionInAddonsList(globalDir, a4.id));
|
|
|
|
do_check_eq(a4.version, "2.0");
|
|
|
|
|
|
|
|
end_test();
|
2010-04-29 13:11:23 -07:00
|
|
|
});
|
|
|
|
}
|