Bug 740289 - Check install.rdf has a valid combination of optionsType, optionsURL and/or options.xul in the add-on. r=Unfocused

This commit is contained in:
Geoff Lankow 2012-08-18 19:48:53 +12:00
Родитель 1ce209ace1
Коммит 409cf6bf73
2 изменённых файлов: 84 добавлений и 6 удалений

Просмотреть файл

@ -5834,13 +5834,24 @@ function AddonWrapper(aAddon) {
if (!this.isActive)
return null;
if (aAddon.optionsType)
return aAddon.optionsType;
let hasOptionsXUL = this.hasResource("options.xul");
let hasOptionsURL = !!this.optionsURL;
if (this.hasResource("options.xul"))
if (aAddon.optionsType) {
switch (parseInt(aAddon.optionsType, 10)) {
case AddonManager.OPTIONS_TYPE_DIALOG:
case AddonManager.OPTIONS_TYPE_TAB:
return hasOptionsURL ? aAddon.optionsType : null;
case AddonManager.OPTIONS_TYPE_INLINE:
return (hasOptionsXUL || hasOptionsURL) ? aAddon.optionsType : null;
}
return null;
}
if (hasOptionsXUL)
return AddonManager.OPTIONS_TYPE_INLINE;
if (this.optionsURL)
if (hasOptionsURL)
return AddonManager.OPTIONS_TYPE_DIALOG;
return null;

Просмотреть файл

@ -283,6 +283,53 @@ function run_test() {
name: "Test Addon 21"
}, profileDir);
writeInstallRDFForExtension({
id: "addon22@tests.mozilla.org",
version: "1.0",
optionsType: "2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 22"
}, profileDir);
writeInstallRDFForExtension({
id: "addon23@tests.mozilla.org",
version: "1.0",
optionsType: "2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 23"
}, profileDir, null, "options.xul");
writeInstallRDFForExtension({
id: "addon24@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 24"
}, profileDir, null, "options.xul");
writeInstallRDFForExtension({
id: "addon25@tests.mozilla.org",
version: "1.0",
optionsType: "3",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 25"
}, profileDir);
do_test_pending();
startupManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
@ -305,10 +352,14 @@ function run_test() {
"addon18@tests.mozilla.org",
"addon19@tests.mozilla.org",
"addon20@tests.mozilla.org",
"addon21@tests.mozilla.org"],
"addon21@tests.mozilla.org",
"addon22@tests.mozilla.org",
"addon23@tests.mozilla.org",
"addon24@tests.mozilla.org",
"addon25@tests.mozilla.org"],
function([a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20,
a21]) {
a21, a22, a23, a24, a25]) {
do_check_neq(a1, null);
do_check_eq(a1.id, "addon1@tests.mozilla.org");
@ -473,6 +524,22 @@ function run_test() {
do_check_eq(a21.optionsURL, "chrome://test/content/options.xul");
do_check_eq(a21.optionsType, AddonManager.OPTIONS_TYPE_TAB);
do_check_neq(a22, null);
do_check_eq(a22.optionsType, null);
do_check_eq(a22.optionsURL, null);
do_check_neq(a23, null);
do_check_eq(a23.optionsType, AddonManager.OPTIONS_TYPE_INLINE);
do_check_neq(a23.optionsURL, null);
do_check_neq(a24, null);
do_check_eq(a24.optionsType, AddonManager.OPTIONS_TYPE_INLINE);
do_check_neq(a24.optionsURL, null);
do_check_neq(a25, null);
do_check_eq(a25.optionsType, null);
do_check_eq(a25.optionsURL, null);
do_test_finished();
});
}