Bug 562919: When migrating with multiple themes all will be marked as enabled in the database. r=robstrong

This commit is contained in:
Dave Townsend 2010-05-10 11:10:10 -07:00
parent 114f4e2b22
commit 9e981f86a5
3 changed files with 88 additions and 3 deletions

View File

@ -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)

View File

@ -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 -->
<RDF:RDF xmlns:NS1="http://www.mozilla.org/2004/em-rdf#"
xmlns:NC="http://home.netscape.com/NC-rdf#"
@ -14,6 +15,18 @@
NS1:id="xpcshell@tests.mozilla.org"
NS1:minVersion="1"
NS1:maxVersion="1" />
<RDF:Description RDF:about="rdf:#$w8dNC4"
NS1:id="xpcshell@tests.mozilla.org"
NS1:minVersion="1"
NS1:maxVersion="2" />
<RDF:Description RDF:about="rdf:#$w8dNC5"
NS1:id="xpcshell@tests.mozilla.org"
NS1:minVersion="1"
NS1:maxVersion="2" />
<RDF:Description RDF:about="rdf:#$w8dNC6"
NS1:id="xpcshell@tests.mozilla.org"
NS1:minVersion="1"
NS1:maxVersion="2" />
<RDF:Description RDF:about="rdf:#$w8dNC2"
NS1:id="toolkit@mozilla.org"
NS1:minVersion="1"
@ -57,10 +70,28 @@
<NS1:type NC:parseType="Integer">2</NS1:type>
<NS1:targetApplication RDF:resource="rdf:#$w8dNC2"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mozilla:item:theme1@tests.mozilla.org"
NS1:installLocation="app-profile"
NS1:version="1.0"
NS1:name="Theme 2"
NS1:internalName="theme1/1.0">
<NS1:type NC:parseType="Integer">4</NS1:type>
<NS1:targetApplication RDF:resource="rdf:#$w8dNC5"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mozilla:item:theme2@tests.mozilla.org"
NS1:installLocation="app-profile"
NS1:version="2.0"
NS1:name="Theme 2"
NS1:internalName="theme2/1.0">
<NS1:type NC:parseType="Integer">4</NS1:type>
<NS1:targetApplication RDF:resource="rdf:#$w8dNC6"/>
</RDF:Description>
<RDF:Seq RDF:about="urn:mozilla:item:root">
<RDF:li RDF:resource="urn:mozilla:item:addon1@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:addon2@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:addon3@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:addon4@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:theme1@tests.mozilla.org"/>
<RDF:li RDF:resource="urn:mozilla:item:theme2@tests.mozilla.org"/>
</RDF:Seq>
</RDF:RDF>

View File

@ -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();
});
}