Bug 1623173 - Preserve embedderDisabled when rebuilding addon DB. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D67226

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2020-03-17 22:50:04 +00:00
Родитель 53f946d1be
Коммит 3342f3308e
2 изменённых файлов: 45 добавлений и 2 удалений

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

@ -3011,6 +3011,7 @@ this.XPIDatabaseReconcile = {
"visible",
"active",
"userDisabled",
"embedderDisabled",
"applyBackgroundUpdates",
"sourceURI",
"releaseNotesURI",

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

@ -3,12 +3,23 @@
*/
const PREF_DB_SCHEMA = "extensions.databaseSchema";
const PREF_IS_EMBEDDED = "extensions.isembedded";
registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
Services.prefs.clearUserPref(PREF_IS_EMBEDDED);
});
const profileDir = gProfD.clone();
profileDir.append("extensions");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
add_task(async function test_setup() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
await promiseStartupManager();
});
add_task(async function run_tests() {
// Fake installTelemetryInfo used in the addon installation,
// to verify that they are preserved after the DB is updated
@ -78,8 +89,6 @@ add_task(async function run_tests() {
},
];
await promiseStartupManager();
for (let test of TESTS) {
info(test.what);
await promiseInstallFile(xpi1, false, fakeInstallTelemetryInfo);
@ -122,3 +131,36 @@ add_task(async function run_tests() {
await addon.uninstall();
}
});
add_task(async function embedder_disabled_stays_disabled() {
Services.prefs.setBoolPref(PREF_IS_EMBEDDED, true);
const ID = "embedder-disabled@tests.mozilla.org";
await promiseInstallWebExtension({
manifest: {
name: "Test Add-on",
version: "1.0",
applications: { gecko: { id: ID } },
},
});
let addon = await promiseAddonByID(ID);
equal(addon.embedderDisabled, false);
await addon.setEmbedderDisabled(true);
equal(addon.embedderDisabled, true);
await promiseShutdownManager();
// Change db schema to force reload
Services.prefs.setIntPref(PREF_DB_SCHEMA, 0);
await promiseStartupManager();
addon = await promiseAddonByID(ID);
equal(addon.embedderDisabled, true);
await addon.uninstall();
});