Bug 956990 - Temporarily make extensions.checkCompatibility=false not work for Australis-incompatible themes. r=Mossop

This commit is contained in:
Blair McBride 2014-01-31 01:00:47 +13:00
parent 2f49c3b34b
commit 9b7a1cc28b
5 changed files with 115 additions and 2 deletions

View File

@ -33,6 +33,9 @@ pref("extensions.strictCompatibility", false);
// Specifies a minimum maxVersion an addon needs to say it's compatible with
// for it to be compatible by default.
pref("extensions.minCompatibleAppVersion", "4.0");
// Temporary preference to forcibly make themes more safe with Australis even if
// extensions.checkCompatibility=false has been set.
pref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "29.0a1");
// Preferences for AMO integration
pref("extensions.getAddons.cache.enabled", true);

View File

@ -75,6 +75,8 @@ const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
const PREF_EM_MIN_COMPAT_APP_VERSION = "extensions.minCompatibleAppVersion";
const PREF_EM_MIN_COMPAT_PLATFORM_VERSION = "extensions.minCompatiblePlatformVersion";
const PREF_CHECKCOMAT_THEMEOVERRIDE = "extensions.checkCompatibility.temporaryThemeOverride_minAppVersion";
const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul";
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
@ -603,8 +605,22 @@ function isUsableAddon(aAddon) {
return false;
}
else {
if (!aAddon.matchingTargetApplication)
let app = aAddon.matchingTargetApplication;
if (!app)
return false;
// XXX Temporary solution to let applications opt-in to make themes safer
// following significant UI changes even if checkCompatibility=false has
// been set, until we get bug 962001.
if (aAddon.type == "theme" && app.id == Services.appinfo.ID) {
try {
let minCompatVersion = Services.prefs.getCharPref(PREF_CHECKCOMAT_THEMEOVERRIDE);
if (minCompatVersion &&
Services.vc.compare(minCompatVersion, app.maxVersion) > 0) {
return false;
}
} catch (e) {}
}
}
return true;

View File

@ -50,7 +50,7 @@ if CONFIG['MOZ_UPDATE_CHANNEL'] not in ('aurora', 'beta', 'release', 'esr'):
# This is used in multiple places, so is defined here to avoid it getting
# out of sync.
DEFINES['MOZ_EXTENSIONS_DB_SCHEMA'] = 15
DEFINES['MOZ_EXTENSIONS_DB_SCHEMA'] = 16
# Additional debugging info is exposed in debug builds
if CONFIG['MOZ_DEBUG']:

View File

@ -0,0 +1,93 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that the (temporary)
// extensions.checkCompatibility.temporaryThemeOverride_minAppVersion
// preference works.
var ADDONS = [{
id: "addon1@tests.mozilla.org",
type: 4,
internalName: "theme1/1.0",
version: "1.0",
name: "Test 1",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1.0",
maxVersion: "1.0"
}]
}, {
id: "addon2@tests.mozilla.org",
type: 4,
internalName: "theme2/1.0",
version: "1.0",
name: "Test 2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "2.0",
maxVersion: "2.0"
}]
}];
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3.0", "1");
for (let a of ADDONS) {
writeInstallRDFForExtension(a, profileDir);
}
startupManager();
run_test_1();
}
function run_test_1() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org"],
function([a1, a2]) {
do_check_neq(a1, null);
do_check_false(a1.isActive);
do_check_false(a1.isCompatible);
do_check_true(a1.appDisabled);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_false(a2.isCompatible);
do_check_true(a1.appDisabled);
do_execute_soon(run_test_2);
});
}
function run_test_2() {
Services.prefs.setCharPref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "2.0");
if (isNightlyChannel())
Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
else
Services.prefs.setBoolPref("extensions.checkCompatibility.3.0", false);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org"],
function([a1, a2]) {
do_check_neq(a1, null);
do_check_false(a1.isActive);
do_check_false(a1.isCompatible);
do_check_true(a1.appDisabled);
do_check_neq(a2, null);
do_check_false(a2.isActive);
do_check_false(a2.isCompatible);
do_check_false(a2.appDisabled);
do_execute_soon(do_test_finished);
});
}

View File

@ -144,6 +144,7 @@ fail-if = os == "android"
[test_bug953156.js]
[test_cacheflush.js]
[test_checkcompatibility.js]
[test_checkCompatibility_themeOverride.js]
[test_childprocess.js]
[test_ChromeManifestParser.js]
[test_compatoverrides.js]