diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm
index 9e32b67644f..aacc36c0c1f 100644
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -1388,7 +1388,10 @@ var XPIProvider = {
// If there is migration data then apply it.
if (aMigrateData) {
- newAddon.userDisabled = aMigrateData.userDisabled;
+ // A theme's disabled state is determined by the selected theme
+ // preference which is read in loadManifestFromRDF
+ if (newAddon.type != "theme")
+ newAddon.userDisabled = aMigrateData.userDisabled;
if ("installDate" in aMigrateData)
newAddon.installDate = aMigrateData.installDate;
if ("targetApplications" in aMigrateData)
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf
index 52d9644894f..3f39d761f6b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_migrate.rdf
@@ -5,7 +5,8 @@
was pending user disable at the next restart and addon4 was pending user
enable at the next restart. Additionally addon1 and 2 have had
compatibility updates applies to make them compatible with the app and
- toolkit respectively, addon3 and 4 have not -->
+ toolkit respectively, addon3 and 4 have not.
+ It also contains two themes in the profile -->
+
+
+
2
+
+ 4
+
+
+
+ 4
+
+
+
+
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
index 01ec278afca..4ca3cea15cc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
@@ -48,6 +48,32 @@ var addon4 = {
}]
};
+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"
+ }]
+};
+
const profileDir = gProfD.clone();
profileDir.append("extensions");
@@ -67,15 +93,28 @@ function run_test() {
dest = profileDir.clone();
dest.append("addon4@tests.mozilla.org");
writeInstallRDFToDir(addon4, dest);
+ dest = profileDir.clone();
+ dest.append("theme1@tests.mozilla.org");
+ writeInstallRDFToDir(theme1, dest);
+ dest = profileDir.clone();
+ dest.append("theme2@tests.mozilla.org");
+ writeInstallRDFToDir(theme2, dest);
let old = do_get_file("data/test_migrate.rdf");
old.copyTo(gProfD, "extensions.rdf");
+ // Theme state is determined by the selected theme pref
+ Services.prefs.setCharPref("general.skins.selectedSkin", "theme1/1.0");
+
startupManager(1);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org"], function([a1, a2, a3, a4]) {
+ "addon4@tests.mozilla.org",
+ "theme1@tests.mozilla.org",
+ "theme2@tests.mozilla.org"], function([a1, a2,
+ a3, a4,
+ t1, t2]) {
// addon1 was user and app enabled in the old extensions.rdf
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
@@ -96,6 +135,18 @@ function run_test() {
do_check_false(a4.userDisabled);
do_check_true(a4.appDisabled);
+ // 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));
+
do_test_finished();
});
}