Bug 1394121 Let legacy extensions be installed temporarily r=kmag

MozReview-Commit-ID: 4fiA8vvCjmr

--HG--
extra : rebase_source : 56e2e6a6637b9446b0d7d148598125a116ea376c
This commit is contained in:
Andrew Swan 2017-12-07 14:52:10 -08:00
parent 00626c42d9
commit 676c015ddb
2 changed files with 36 additions and 0 deletions

View File

@ -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);
}

View File

@ -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 ID = "apiexperiment@tests.mozilla.org";
let xpi = createTempXPIFile({
id: 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(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");
}
});