mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 555486: Add a scope property to add-ons and allow disabling loading add-ons from certain scopes. r=robstrong
This commit is contained in:
parent
ddc0c3c62c
commit
09099ef21b
@ -312,6 +312,7 @@ user_pref("security.default_personal_cert", "Select Automatically"); // Need to
|
||||
user_pref("network.http.prompt-temp-redirect", false);
|
||||
user_pref("media.cache_size", 100);
|
||||
user_pref("security.warn_viewing_mixed", false);
|
||||
user_pref("extensions.enabledScopes", 3);
|
||||
|
||||
user_pref("geo.wifi.uri", "http://%(server)s/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
|
||||
user_pref("geo.wifi.testing", true);
|
||||
|
@ -827,6 +827,18 @@ var AddonManager = {
|
||||
// Indicates that the Addon can be upgraded.
|
||||
PERM_CAN_UPGRADE: 8,
|
||||
|
||||
// General descriptions of where items are installed.
|
||||
// Installed in this profile.
|
||||
SCOPE_PROFILE: 1,
|
||||
// Installed for all of this user's profiles.
|
||||
SCOPE_USER: 2,
|
||||
// Installed and owned by the application.
|
||||
SCOPE_APPLICATION: 4,
|
||||
// Installed for all users of the computer.
|
||||
SCOPE_SYSTEM: 8,
|
||||
// The combination of all scopes.
|
||||
SCOPE_ALL: 15,
|
||||
|
||||
getInstallForURL: function AM_getInstallForURL(url, callback, mimetype, hash,
|
||||
name, iconURL, version,
|
||||
loadGroup) {
|
||||
|
@ -63,6 +63,7 @@ const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
|
||||
const PREF_EM_UPDATE_URL = "extensions.update.url";
|
||||
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
|
||||
const PREF_EM_EXTENSION_FORMAT = "extensions.";
|
||||
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
|
||||
const PREF_XPI_ENABLED = "xpinstall.enabled";
|
||||
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
|
||||
|
||||
@ -782,7 +783,7 @@ var XPIProvider = {
|
||||
this.installLocations = [];
|
||||
this.installLocationsByName = {};
|
||||
|
||||
function addDirectoryInstallLocation(name, key, paths, locked) {
|
||||
function addDirectoryInstallLocation(name, key, paths, scope, locked) {
|
||||
try {
|
||||
var dir = FileUtils.getDir(key, paths);
|
||||
}
|
||||
@ -793,7 +794,7 @@ var XPIProvider = {
|
||||
}
|
||||
|
||||
try {
|
||||
var location = new DirectoryInstallLocation(name, dir, locked);
|
||||
var location = new DirectoryInstallLocation(name, dir, scope, locked);
|
||||
}
|
||||
catch (e) {
|
||||
WARN("Failed to add directory install location " + name + " " + e);
|
||||
@ -804,9 +805,9 @@ var XPIProvider = {
|
||||
XPIProvider.installLocationsByName[location.name] = location;
|
||||
}
|
||||
|
||||
function addRegistryInstallLocation(name, rootkey) {
|
||||
function addRegistryInstallLocation(name, rootkey, scope) {
|
||||
try {
|
||||
var location = new WinRegInstallLocation(name, rootkey);
|
||||
var location = new WinRegInstallLocation(name, rootkey, scope);
|
||||
}
|
||||
catch (e) {
|
||||
WARN("Failed to add registry install location " + name + " " + e);
|
||||
@ -819,16 +820,45 @@ var XPIProvider = {
|
||||
|
||||
let hasRegistry = ("nsIWindowsRegKey" in Ci);
|
||||
|
||||
let enabledScopes = Prefs.getIntPref(PREF_EM_ENABLED_SCOPES,
|
||||
AddonManager.SCOPE_ALL);
|
||||
|
||||
// These must be in order of priority for processFileChanges etc. to work
|
||||
if (hasRegistry)
|
||||
addRegistryInstallLocation("winreg-app-global", Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE);
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_LOCAL, "XRESysLExtPD", [Services.appinfo.ID], true);
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_SHARE, "XRESysSExtPD", [Services.appinfo.ID], true);
|
||||
addDirectoryInstallLocation(KEY_APP_GLOBAL, KEY_APPDIR, [DIR_EXTENSIONS], true);
|
||||
if (hasRegistry)
|
||||
addRegistryInstallLocation("winreg-app-user", Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER);
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_USER, "XREUSysExt", [Services.appinfo.ID], true);
|
||||
addDirectoryInstallLocation(KEY_APP_PROFILE, KEY_PROFILEDIR, [DIR_EXTENSIONS], false);
|
||||
if (enabledScopes & AddonManager.SCOPE_SYSTEM) {
|
||||
if (hasRegistry) {
|
||||
addRegistryInstallLocation("winreg-app-global",
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
|
||||
AddonManager.SCOPE_SYSTEM);
|
||||
}
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_LOCAL, "XRESysLExtPD",
|
||||
[Services.appinfo.ID],
|
||||
AddonManager.SCOPE_SYSTEM, true);
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_SHARE, "XRESysSExtPD",
|
||||
[Services.appinfo.ID],
|
||||
AddonManager.SCOPE_SYSTEM, true);
|
||||
}
|
||||
|
||||
if (enabledScopes & AddonManager.SCOPE_APPLICATION) {
|
||||
addDirectoryInstallLocation(KEY_APP_GLOBAL, KEY_APPDIR,
|
||||
[DIR_EXTENSIONS],
|
||||
AddonManager.SCOPE_APPLICATION, true);
|
||||
}
|
||||
|
||||
if (enabledScopes & AddonManager.SCOPE_USER) {
|
||||
if (hasRegistry) {
|
||||
addRegistryInstallLocation("winreg-app-user",
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
AddonManager.SCOPE_USER);
|
||||
}
|
||||
addDirectoryInstallLocation(KEY_APP_SYSTEM_USER, "XREUSysExt",
|
||||
[Services.appinfo.ID],
|
||||
AddonManager.SCOPE_USER, true);
|
||||
}
|
||||
|
||||
// The profile location is always enabled
|
||||
addDirectoryInstallLocation(KEY_APP_PROFILE, KEY_PROFILEDIR,
|
||||
[DIR_EXTENSIONS],
|
||||
AddonManager.SCOPE_PROFILE, false);
|
||||
|
||||
this.defaultSkin = Prefs.getDefaultCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN,
|
||||
"classic/1.0");
|
||||
@ -4247,6 +4277,13 @@ function AddonWrapper(addon) {
|
||||
return createWrapper(addon.pendingUpgrade);
|
||||
});
|
||||
|
||||
this.__defineGetter__("scope", function() {
|
||||
if (addon._installLocation)
|
||||
return addon._installLocation.scope;
|
||||
|
||||
return AddonManager.SCOPE_PROFILE;
|
||||
});
|
||||
|
||||
this.__defineGetter__("pendingOperations", function() {
|
||||
let pending = 0;
|
||||
if (!(addon instanceof DBAddonInternal))
|
||||
@ -4382,14 +4419,17 @@ AddonWrapper.prototype = {
|
||||
* The string identifier for the install location
|
||||
* @param directory
|
||||
* The nsIFile directory for the install location
|
||||
* @param scope
|
||||
* The scope of add-ons installed in this location
|
||||
* @param locked
|
||||
* true if add-ons cannot be installed, uninstalled or upgraded in the
|
||||
* install location
|
||||
*/
|
||||
function DirectoryInstallLocation(name, directory, locked) {
|
||||
function DirectoryInstallLocation(name, directory, scope, locked) {
|
||||
this._name = name;
|
||||
this.locked = locked;
|
||||
this._directory = directory;
|
||||
this._scope = scope
|
||||
this._IDToDirMap = {};
|
||||
this._DirToIDMap = {};
|
||||
|
||||
@ -4496,6 +4536,13 @@ DirectoryInstallLocation.prototype = {
|
||||
return this._name;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the scope of this install location.
|
||||
*/
|
||||
get scope() {
|
||||
return this._scope;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets an array of nsIFiles for add-ons installed in this location.
|
||||
*/
|
||||
@ -4602,12 +4649,14 @@ DirectoryInstallLocation.prototype = {
|
||||
* The string identifier of this Install Location.
|
||||
* @param rootKey
|
||||
* The root key (one of the ROOT_KEY_ values from nsIWindowsRegKey).
|
||||
* @constructor
|
||||
* @param scope
|
||||
* The scope of add-ons installed in this location
|
||||
*/
|
||||
function WinRegInstallLocation(name, rootKey) {
|
||||
function WinRegInstallLocation(name, rootKey, scope) {
|
||||
this.locked = true;
|
||||
this._name = name;
|
||||
this._rootKey = rootKey;
|
||||
this._scope = scope;
|
||||
this._IDToDirMap = {};
|
||||
this._DirToIDMap = {};
|
||||
|
||||
@ -4631,6 +4680,7 @@ function WinRegInstallLocation(name, rootKey) {
|
||||
WinRegInstallLocation.prototype = {
|
||||
_name : "",
|
||||
_rootKey : null,
|
||||
_scope : null,
|
||||
_IDToDirMap : null, // mapping from ID to directory object
|
||||
_DirToIDMap : null, // mapping from directory path to ID
|
||||
|
||||
@ -4687,6 +4737,13 @@ WinRegInstallLocation.prototype = {
|
||||
return this._name;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the scope of this install location.
|
||||
*/
|
||||
get scope() {
|
||||
return this._scope;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets an array of nsIFiles for add-ons installed in this location.
|
||||
*/
|
||||
|
@ -644,4 +644,7 @@ const gProfD = do_get_profile().QueryInterface(AM_Ci.nsILocalFile);
|
||||
// Enable more extensive EM logging
|
||||
Services.prefs.setBoolPref("extensions.logging.enabled", true);
|
||||
|
||||
// By default only load extensions from the profile install location
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_register_cleanup(shutdownManager);
|
||||
|
@ -5,8 +5,8 @@
|
||||
// This just verifies that the EM can actually startup and shutdown a few times
|
||||
// without any errors
|
||||
|
||||
// We have to look up how many add-ons are present in case apps like SeaMonkey
|
||||
// try to use this test with their built-in add-ons.
|
||||
// We have to look up how many add-ons are present since there will be plugins
|
||||
// etc. detected
|
||||
var gCount;
|
||||
|
||||
function run_test() {
|
||||
|
@ -5,6 +5,11 @@
|
||||
// Tests that extensions installed through the registry work as expected
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
// Enable loading extensions from the user and system scopes
|
||||
Services.prefs.setIntPref("extensions.enabledScopes",
|
||||
AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER +
|
||||
AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
@ -60,9 +65,12 @@ function run_test_1() {
|
||||
do_check_neq(a1, null);
|
||||
do_check_true(a1.isActive);
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_true(a2.isActive);
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
|
@ -5,9 +5,10 @@
|
||||
// This verifies startup detection of added/removed/changed items and install
|
||||
// location priorities
|
||||
|
||||
// We try to count the non-test extensions the add-on manager detects like the
|
||||
// built-in extensions in seamonkey.
|
||||
var additionalAddons, additionalExtensions;
|
||||
// Enable loading extensions from the user and system scopes
|
||||
Services.prefs.setIntPref("extensions.enabledScopes",
|
||||
AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER +
|
||||
AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
var addon1 = {
|
||||
id: "addon1@tests.mozilla.org",
|
||||
@ -82,29 +83,23 @@ function run_test() {
|
||||
do_test_pending();
|
||||
startupManager(1);
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(allAddons) {
|
||||
additionalAddons = allAddons.length;
|
||||
AddonManager.getAddonsByTypes(["extension"], function(allExtensions) {
|
||||
additionalExtensions = allExtensions.length;
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_eq(a1, null);
|
||||
do_check_not_in_crash_annotation(addon1.id, addon1.version);
|
||||
do_check_eq(a2, null);
|
||||
do_check_not_in_crash_annotation(addon2.id, addon2.version);
|
||||
do_check_eq(a3, null);
|
||||
do_check_not_in_crash_annotation(addon3.id, addon3.version);
|
||||
do_check_eq(a4, null);
|
||||
do_check_eq(a5, null);
|
||||
do_check_eq(a1, null);
|
||||
do_check_not_in_crash_annotation(addon1.id, addon1.version);
|
||||
do_check_eq(a2, null);
|
||||
do_check_not_in_crash_annotation(addon2.id, addon2.version);
|
||||
do_check_eq(a3, null);
|
||||
do_check_not_in_crash_annotation(addon3.id, addon3.version);
|
||||
do_check_eq(a4, null);
|
||||
do_check_eq(a5, null);
|
||||
|
||||
run_test_1();
|
||||
});
|
||||
});
|
||||
run_test_1();
|
||||
});
|
||||
}
|
||||
|
||||
@ -149,6 +144,7 @@ function run_test_1() {
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, addon1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -158,6 +154,7 @@ function run_test_1() {
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, addon2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_neq(a3, null);
|
||||
do_check_eq(a3.id, "addon3@tests.mozilla.org");
|
||||
@ -167,6 +164,7 @@ function run_test_1() {
|
||||
do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon3.id, addon3.version);
|
||||
do_check_eq(a3.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_eq(a4, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
|
||||
@ -180,12 +178,9 @@ function run_test_1() {
|
||||
dest.append("addon5@tests.mozilla.org");
|
||||
do_check_false(dest.exists());
|
||||
|
||||
AddonManager.getAddonsByTypes(null, function(addons) {
|
||||
do_check_eq(addons.length, 3 + additionalAddons);
|
||||
AddonManager.getAddonsByTypes(["extension"], function(extensionAddons) {
|
||||
do_check_eq(extensionAddons.length, 3 + additionalExtensions);
|
||||
run_test_2();
|
||||
});
|
||||
AddonManager.getAddonsByTypes(["extension"], function(extensionAddons) {
|
||||
do_check_eq(extensionAddons.length, 3);
|
||||
run_test_2();
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -230,6 +225,7 @@ function run_test_2() {
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -240,6 +236,7 @@ function run_test_2() {
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
@ -284,6 +281,7 @@ function run_test_3() {
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -294,6 +292,7 @@ function run_test_3() {
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
@ -312,8 +311,116 @@ function run_test_3() {
|
||||
});
|
||||
}
|
||||
|
||||
// Check that items in the profile hide the others again.
|
||||
// Test that disabling an install location works
|
||||
function run_test_4() {
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_eq(a1, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon1@tests.mozilla.org"));
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.2");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_true(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
run_test_5();
|
||||
});
|
||||
}
|
||||
|
||||
// Switching disabled locations works
|
||||
function run_test_5() {
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_USER);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.1");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.3");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
run_test_6();
|
||||
});
|
||||
}
|
||||
|
||||
// Resetting the pref makes everything visible again
|
||||
function run_test_6() {
|
||||
Services.prefs.clearUserPref("extensions.enabledScopes");
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.1");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
do_check_eq(a2.version, "2.3");
|
||||
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
|
||||
do_check_true(isExtensionInAddonsList(userDir, a2.id));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
run_test_7();
|
||||
});
|
||||
}
|
||||
|
||||
// Check that items in the profile hide the others again.
|
||||
function run_test_7() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
addon1.version = "1.2";
|
||||
@ -339,6 +446,7 @@ function run_test_4() {
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -349,6 +457,7 @@ function run_test_4() {
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon2.id, a2.version);
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
@ -359,12 +468,46 @@ function run_test_4() {
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_5();
|
||||
run_test_8();
|
||||
});
|
||||
}
|
||||
|
||||
// Disabling all locations still leaves the profile working
|
||||
function run_test_8() {
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", 0);
|
||||
|
||||
restartManager(1);
|
||||
|
||||
AddonManager.getAddons(["addon1@tests.mozilla.org",
|
||||
"addon2@tests.mozilla.org",
|
||||
"addon3@tests.mozilla.org",
|
||||
"addon4@tests.mozilla.org",
|
||||
"addon5@tests.mozilla.org"],
|
||||
function([a1, a2, a3, a4, a5]) {
|
||||
|
||||
do_check_neq(a1, null);
|
||||
do_check_eq(a1.id, "addon1@tests.mozilla.org");
|
||||
do_check_eq(a1.version, "1.2");
|
||||
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_in_crash_annotation(addon1.id, a1.version);
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_eq(a2, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon2@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(userDir, "addon2@tests.mozilla.org"));
|
||||
do_check_false(isExtensionInAddonsList(globalDir, "addon2@tests.mozilla.org"));
|
||||
|
||||
run_test_9();
|
||||
});
|
||||
}
|
||||
|
||||
// More hiding and revealing
|
||||
function run_test_5() {
|
||||
function run_test_9() {
|
||||
Services.prefs.clearUserPref("extensions.enabledScopes", 0);
|
||||
|
||||
var dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
@ -392,6 +535,7 @@ function run_test_5() {
|
||||
do_check_false(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -401,6 +545,7 @@ function run_test_5() {
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
@ -411,13 +556,13 @@ function run_test_5() {
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_6();
|
||||
run_test_10();
|
||||
});
|
||||
}
|
||||
|
||||
// Checks that a removal from one location and an addition in another location
|
||||
// for the same item is handled
|
||||
function run_test_6() {
|
||||
function run_test_10() {
|
||||
var dest = profileDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
@ -442,6 +587,7 @@ function run_test_6() {
|
||||
do_check_true(isExtensionInAddonsList(userDir, a1.id));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_eq(a1.scope, AddonManager.SCOPE_USER);
|
||||
|
||||
do_check_neq(a2, null);
|
||||
do_check_eq(a2.id, "addon2@tests.mozilla.org");
|
||||
@ -451,6 +597,7 @@ function run_test_6() {
|
||||
do_check_false(isExtensionInAddonsList(globalDir, a2.id));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
|
||||
do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
|
||||
do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
|
||||
|
||||
do_check_eq(a3, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
|
||||
@ -461,12 +608,12 @@ function run_test_6() {
|
||||
do_check_eq(a5, null);
|
||||
do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
|
||||
|
||||
run_test_7();
|
||||
run_test_11();
|
||||
});
|
||||
}
|
||||
|
||||
// This should remove any remaining items
|
||||
function run_test_7() {
|
||||
function run_test_11() {
|
||||
var dest = userDir.clone();
|
||||
dest.append("addon1@tests.mozilla.org");
|
||||
dest.remove(true);
|
||||
|
@ -32,6 +32,7 @@ function run_test() {
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, dest);
|
||||
|
||||
dest = profileDir.clone();
|
||||
dest.append("theme2@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
@ -46,6 +47,22 @@ function run_test() {
|
||||
}]
|
||||
}, dest);
|
||||
|
||||
// We need a default theme for some of these things to work but we have hidden
|
||||
// the one in the application directory.
|
||||
dest = profileDir.clone();
|
||||
dest.append("default@tests.mozilla.org");
|
||||
writeInstallRDFToDir({
|
||||
id: "default@tests.mozilla.org",
|
||||
version: "1.0",
|
||||
name: "Default",
|
||||
internalName: "classic/1.0",
|
||||
targetApplications: [{
|
||||
id: "xpcshell@tests.mozilla.org",
|
||||
minVersion: "1",
|
||||
maxVersion: "2"
|
||||
}]
|
||||
}, dest);
|
||||
|
||||
startupManager(1);
|
||||
// Make sure we only register once despite multiple calls
|
||||
AddonManager.addInstallListener(InstallListener);
|
||||
@ -179,7 +196,7 @@ function run_test_3() {
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"default@tests.mozilla.org": [
|
||||
["onDisabling", false],
|
||||
"onDisabled",
|
||||
]
|
||||
@ -471,13 +488,12 @@ function run_test_7() {
|
||||
// Uninstalling a lightweight theme in use should not require a restart and it
|
||||
// should reactivate the default theme
|
||||
function run_test_8() {
|
||||
// TODO stop this depending on the default theme being present
|
||||
prepare_test({
|
||||
"2@personas.mozilla.org": [
|
||||
["onUninstalling", false],
|
||||
"onUninstalled"
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"default@tests.mozilla.org": [
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
]
|
||||
@ -522,7 +538,7 @@ function run_test_10() {
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"default@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
@ -533,7 +549,7 @@ function run_test_10() {
|
||||
|
||||
restartManager(0);
|
||||
|
||||
AddonManager.getAddons(["{972ce4c6-7e08-4474-a285-3208198ce6fd}",
|
||||
AddonManager.getAddons(["default@tests.mozilla.org",
|
||||
"theme2@tests.mozilla.org"], function([d, t2]) {
|
||||
do_check_true(t2.isActive);
|
||||
do_check_false(t2.userDisabled);
|
||||
@ -546,7 +562,7 @@ function run_test_10() {
|
||||
"theme2@tests.mozilla.org": [
|
||||
"onUninstalling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"default@tests.mozilla.org": [
|
||||
"onEnabling"
|
||||
]
|
||||
});
|
||||
@ -641,7 +657,7 @@ function run_test_13() {
|
||||
"theme1@tests.mozilla.org": [
|
||||
"onEnabling",
|
||||
],
|
||||
"{972ce4c6-7e08-4474-a285-3208198ce6fd}": [
|
||||
"default@tests.mozilla.org": [
|
||||
"onDisabling"
|
||||
]
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user