Bug 1452618 - track force-disabling things so we don't accidentally re-enable them by using `isUsableAddon` later, r=kmag

MozReview-Commit-ID: B7ZAw04cVaZ

--HG--
extra : rebase_source : f5349905640c1c7403c11df9370f9a38c1d35584
This commit is contained in:
Gijs Kruitbosch 2018-04-13 15:01:05 +01:00
Родитель bd326a2a6b
Коммит a7f6ba42a1
3 изменённых файлов: 28 добавлений и 1 удалений

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

@ -811,6 +811,11 @@ function isUsableAddon(aAddon) {
return false;
}
// If we can't read it, it's not usable:
if (aAddon.brokenManifest) {
return false;
}
// Experiments are installed through an external mechanism that
// limits target audience to compatible clients. We trust it knows what
// it's doing and skip compatibility checks.

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

@ -1320,6 +1320,7 @@ this.XPIDatabaseReconcile = {
manifest = syncLoadManifestFromFile(file, aInstallLocation);
} catch (err) {
// If we can no longer read the manifest, it is no longer compatible.
aOldAddon.brokenManifest = true;
aOldAddon.appDisabled = true;
return aOldAddon;
}

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

@ -8,7 +8,7 @@ add_task(async function test_upgrade_incompatible() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await promiseStartupManager();
await promiseStartupManager(false);
let file = createTempWebExtensionFile({
manifest: {
@ -51,5 +51,26 @@ add_task(async function test_upgrade_incompatible() {
equal(addon.appDisabled, true);
await promiseShutdownManager();
file = createTempWebExtensionFile({
manifest: {
applications: {gecko: {id: ID}},
},
});
// swap the old extension back in and check that we don't persist the disabled state forever.
await OS.File.move(file.path, path);
await promiseSetExtensionModifiedTime(path, timestamp);
Services.obs.notifyObservers(new FileUtils.File(path), "flush-cache-entry");
// Restart. With the change to the DB schema we recompute compatibility.
Services.prefs.setIntPref("extensions.databaseSchema", 0);
await promiseStartupManager(true);
addon = await promiseAddonByID(ID);
notEqual(addon, null);
equal(addon.appDisabled, false);
await promiseShutdownManager();
});