Bug 1394121 Let legacy extensions be installed temporarily r=kmag

MozReview-Commit-ID: 4fiA8vvCjmr

--HG--
extra : rebase_source : 41b7a47f9da4c8f7ca863168c118d2f934446d07
This commit is contained in:
Andrew Swan 2017-12-07 14:52:10 -08:00
Родитель 1e31306380
Коммит 0fb60e623e
2 изменённых файлов: 36 добавлений и 0 удалений

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

@ -784,7 +784,16 @@ function canRunInSafeMode(aAddon) {
function isDisabledLegacy(addon) {
return (!AddonSettings.ALLOW_LEGACY_EXTENSIONS &&
LEGACY_TYPES.has(addon.type) &&
// Legacy add-ons are allowed in the system location.
!addon._installLocation.isSystem &&
// Legacy extensions may be installed temporarily in
// non-release builds.
!(AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS &&
addon._installLocation.name == KEY_APP_TEMPORARY) &&
// Properly signed legacy extensions are allowed.
addon.signedState !== AddonManager.SIGNEDSTATE_PRIVILEGED);
}

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

@ -819,3 +819,30 @@ add_task(async function() {
await promiseRestartManager();
});
// Check that WebExtensions experiments can only be installed temporarily
// in builds that allow legacy extensions.
add_task(async function() {
const API_ID = "apiexperiment@tests.mozilla.org";
let xpi = createTempXPIFile({
id: API_ID,
name: "WebExtension Experiment",
version: "1.0",
type: 256,
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
});
await AddonManager.installTemporaryAddon(xpi);
let addon = await promiseAddonByID(API_ID);
if (AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS) {
notEqual(addon, null, "Temporary install of WebExtension experiment succeeded");
addon.uninstall();
} else {
equal(addon, null, "Temporary install of WebExtension experiment was not allowed");
}
});