Bug 557710 - add support for system add-ons to fake testing cert r=kmag

MozReview-Commit-ID: IMGlPXKaOYx

--HG--
extra : rebase_source : 1e7b314a0146ff4dd159b03b5605c19e5180ac88
This commit is contained in:
Robert Helmer 2016-08-29 21:27:04 -07:00
parent 125ee98fef
commit 141464cd20

View File

@ -233,6 +233,10 @@ var AddonTestUtils = {
appDirForAddons.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
this.registerDirectory("XREAddonAppDir", appDirForAddons);
// Create a directory for system add-on upgrades.
this.systemAddonDir = this.profileDir.clone();
this.systemAddonDir.append("features");
this.systemAddonDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
// Enable more extensive EM logging
Services.prefs.setBoolPref("extensions.logging.enabled", true);
@ -413,6 +417,16 @@ var AddonTestUtils = {
}
}),
/**
* Determine if this is a system add-on, based on install location.
*
* @param {nsIFile} file File pointer to the add-on.
* @returns {boolean} true if install location contains add-on file.
*/
isSystemAddon(file) {
return this.systemAddonDir.contains(file);
},
overrideCertDB() {
// Unregister the real database. This only works because the add-ons manager
// hasn't started up and grabbed the certificate database yet.
@ -436,6 +450,11 @@ var AddonTestUtils = {
let id = yield this.getIDFromManifest(manifestURI);
let fakeCert = {commonName: id};
if (this.isSystemAddon(file)) {
fakeCert["organizationalUnit"] = "Mozilla Components";
} else {
fakeCert["organizationalUnit"] = "Preliminary";
}
return [callback, Cr.NS_OK, fakeCert];
} catch (e) {