mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 709531 - Addons Manager tests should have AMO-related prefs reset after each test to disallow network access. r=dtownsend a=mbrubeck
This commit is contained in:
parent
6ce120ed7e
commit
10376be963
@ -132,6 +132,7 @@ _BROWSER_FILES = \
|
||||
browser_bug533232.js \
|
||||
browser_bug537474.js \
|
||||
browser_bug550565.js \
|
||||
browser_bug553455.js \
|
||||
browser_bug555224.js \
|
||||
browser_bug555767.js \
|
||||
browser_bug556061.js \
|
||||
@ -155,6 +156,7 @@ _BROWSER_FILES = \
|
||||
browser_bug585785.js \
|
||||
browser_bug585830.js \
|
||||
browser_bug590206.js \
|
||||
browser_bug592338.js \
|
||||
browser_bug594131.js \
|
||||
browser_bug595507.js \
|
||||
browser_bug596687.js \
|
||||
|
@ -398,6 +398,11 @@ user_pref("extensions.update.url", "http://%(server)s/extensions-dummy/updateURL
|
||||
user_pref("extensions.blocklist.url", "http://%(server)s/extensions-dummy/blocklistURL");
|
||||
// Make sure opening about:addons won't hit the network
|
||||
user_pref("extensions.webservice.discoverURL", "http://%(server)s/extensions-dummy/discoveryURL");
|
||||
// Make sure AddonRepository won't hit the network
|
||||
user_pref("extensions.getAddons.maxResults", 0);
|
||||
user_pref("extensions.getAddons.get.url", "http://%(server)s/extensions-dummy/repositoryGetURL");
|
||||
user_pref("extensions.getAddons.search.browseURL", "http://%(server)s/extensions-dummy/repositoryBrowseURL");
|
||||
user_pref("extensions.getAddons.search.url", "http://%(server)s/extensions-dummy/repositorySearchURL");
|
||||
""" % { "server" : self.webServer + ":" + str(self.httpPort) }
|
||||
prefs.append(part)
|
||||
|
||||
|
@ -51,6 +51,8 @@ MODULE = test_extensionmanager
|
||||
|
||||
ifneq (mobile,$(MOZ_BUILD_APP))
|
||||
DIRS += \
|
||||
xpinstall \
|
||||
browser \
|
||||
mochitest \
|
||||
$(NULL)
|
||||
endif
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
|
||||
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
|
||||
const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion";
|
||||
|
||||
@ -35,10 +34,6 @@ function test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_CACHE_ENABLED);
|
||||
});
|
||||
|
||||
function end_test() {
|
||||
// Test generates a lot of available installs so just cancel them all
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
|
@ -27,8 +27,6 @@ function test() {
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
|
||||
|
||||
// Test generates a lot of available installs so just cancel them all
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
|
@ -73,7 +73,6 @@ function test() {
|
||||
|
||||
|
||||
function end_test() {
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
|
||||
close_manager(gManagerWindow, finish);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
// Tests that the discovery view loads properly
|
||||
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
|
||||
|
||||
var gManagerWindow;
|
||||
@ -40,10 +39,6 @@ function test() {
|
||||
// Temporarily enable caching
|
||||
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
|
||||
});
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
@ -26,11 +26,7 @@ function test() {
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
Services.prefs.clearUserPref("extensions.getAddons.search.url");
|
||||
|
||||
finish();
|
||||
});
|
||||
close_manager(gManagerWindow, finish);
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
|
@ -29,7 +29,6 @@ function test() {
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
Services.prefs.clearUserPref("extensions.getAddons.search.url");
|
||||
Services.prefs.clearUserPref("extensions.checkUpdateSecurity");
|
||||
|
||||
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
|
||||
|
@ -5,7 +5,6 @@
|
||||
// Tests that compatibility overrides are refreshed when showing the addon
|
||||
// selection UI.
|
||||
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
|
||||
const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion";
|
||||
|
||||
@ -45,8 +44,6 @@ registerCleanupFunction(function() {
|
||||
if (gTestAddon)
|
||||
gTestAddon.uninstall();
|
||||
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_CACHE_ENABLED);
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_BYIDS);
|
||||
Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT);
|
||||
});
|
||||
|
||||
|
@ -21,6 +21,7 @@ const TESTROOT2 = "http://example.org/" + RELATIVE_DIR;
|
||||
const CHROMEROOT = pathParts.join("/") + "/";
|
||||
const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
|
||||
const PREF_UPDATEURL = "extensions.update.url";
|
||||
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
|
||||
|
||||
const MANAGER_URI = "about:addons";
|
||||
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
|
||||
@ -34,24 +35,45 @@ var gTestStart = null;
|
||||
|
||||
var gUseInContentUI = !gTestInWindow && ("switchToTabHavingURI" in window);
|
||||
|
||||
var gDiscoveryURL = Services.prefs.getCharPref(PREF_DISCOVERURL);
|
||||
var gUpdateURL = Services.prefs.getCharPref(PREF_UPDATEURL);
|
||||
var gRestorePrefs = [{name: PREF_LOGGING_ENABLED},
|
||||
{name: "extensions.webservice.discoverURL"},
|
||||
{name: "extensions.update.url"},
|
||||
{name: "extensions.getAddons.get.url"},
|
||||
{name: "extensions.getAddons.search.browseURL"},
|
||||
{name: "extensions.getAddons.search.url"},
|
||||
{name: "extensions.getAddons.cache.enabled"},
|
||||
{name: PREF_SEARCH_MAXRESULTS},
|
||||
{name: PREF_STRICT_COMPAT}];
|
||||
|
||||
gRestorePrefs.forEach(function(aPref) {
|
||||
if (!Services.prefs.prefHasUserValue(aPref.name)) {
|
||||
aPref.type = "clear";
|
||||
return;
|
||||
}
|
||||
aPref.type = Services.prefs.getPrefType(aPref.name);
|
||||
if (aPref.type == Services.prefs.PREF_BOOL)
|
||||
aPref.value = Services.prefs.getBoolPref(aPref.name);
|
||||
else if (aPref.type == Services.prefs.PREF_INT)
|
||||
aPref.value = Services.prefs.getIntPref(aPref.name);
|
||||
else if (aPref.type == Services.prefs.PREF_STRING)
|
||||
aPref.value = Services.prefs.getCharPref(aPref.name);
|
||||
});
|
||||
|
||||
// Turn logging on for all tests
|
||||
Services.prefs.setBoolPref(PREF_LOGGING_ENABLED, true);
|
||||
// Turn off remote results in searches
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 0);
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
|
||||
try {
|
||||
Services.prefs.clearUserPref(PREF_SEARCH_MAXRESULTS);
|
||||
} catch (e) {}
|
||||
try {
|
||||
Services.prefs.clearUserPref(PREF_STRICT_COMPAT);
|
||||
} catch (e) {}
|
||||
|
||||
Services.prefs.setCharPref(PREF_DISCOVERURL, gDiscoveryURL);
|
||||
Services.prefs.setCharPref(PREF_UPDATEURL, gUpdateURL);
|
||||
registerCleanupFunction(function() {
|
||||
// Restore prefs
|
||||
gRestorePrefs.forEach(function(aPref) {
|
||||
if (aPref.type == "clear")
|
||||
Services.prefs.clearUserPref(aPref.name);
|
||||
else if (aPref.type == Services.prefs.PREF_BOOL)
|
||||
Services.prefs.setBoolPref(aPref.name, aPref.value);
|
||||
else if (aPref.type == Services.prefs.PREF_INT)
|
||||
Services.prefs.setIntPref(aPref.name, aPref.value);
|
||||
else if (aPref.type == Services.prefs.PREF_STRING)
|
||||
Services.prefs.setCharPref(aPref.name, aPref.value);
|
||||
});
|
||||
|
||||
// Throw an error if the add-ons manager window is open anywhere
|
||||
var windows = Services.wm.getEnumerator("Addons:Manager");
|
||||
|
Loading…
Reference in New Issue
Block a user