bug 663372: some addon manager tests fail when network access is shut off. r=bmcbride, a=asa
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -1,17 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Tests that history navigation works for the add-ons manager.
*/
-const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
const SECOND_URL = "https://example.com/" + RELATIVE_DIR + "releaseNotes.xhtml";
var gLoadCompleteCallback = null;
var gProgressListener = {
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
// Only care about the network stop status events
@@ -53,19 +52,16 @@ function clickLink(aManager, aId, aCallb
}
function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
- registerCleanupFunction(function() {
- Services.prefs.clearUserPref(PREF_DISCOVERURL);
- });
var gProvider = new MockProvider();
gProvider.createAddons([{
id: "test1@tests.mozilla.org",
name: "Test add-on 1",
description: "foo"
},
{
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -1,16 +1,15 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that the discovery view loads properly
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
-const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
const MAIN_URL = "https://example.com/" + RELATIVE_DIR + "discovery.html";
var gManagerWindow;
var gCategoryUtilities;
var gProvider;
var gLoadCompleteCallback = null;
@@ -31,25 +30,22 @@ var gProgressListener = {
onProgressChange: function() { },
onStatusChange: function() { },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
};
function test() {
- var currentURL = Services.prefs.getCharPref(PREF_DISCOVERURL);
-
// Switch to a known url
Services.prefs.setCharPref(PREF_DISCOVERURL, MAIN_URL);
// Temporarily enable caching
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
registerCleanupFunction(function() {
- Services.prefs.setCharPref(PREF_DISCOVERURL, currentURL);
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
});
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -16,40 +16,45 @@ var gTestInWindow = /-window$/.test(path
pathParts.splice(pathParts.length - 1);
pathParts.push("browser");
const RELATIVE_DIR = pathParts.slice(4).join("/") + "/";
const TESTROOT = "http://example.com/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/" + RELATIVE_DIR;
const CHROMEROOT = pathParts.join("/") + "/";
+const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
const MANAGER_URI = "about:addons";
const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const PREF_SEARCH_MAXRESULTS = "extensions.getAddons.maxResults";
var gPendingTests = [];
var gTestsRun = 0;
var gTestStart = null;
var gUseInContentUI = !gTestInWindow && ("switchToTabHavingURI" in window);
+var gDiscoveryURL = Services.prefs.getCharPref(PREF_DISCOVERURL);
+
// 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) {
}
+ Services.prefs.setCharPref(PREF_DISCOVERURL, gDiscoveryURL);
+
// Throw an error if the add-ons manager window is open anywhere
var windows = Services.wm.getEnumerator("Addons:Manager");
if (windows.hasMoreElements())
ok(false, "Found unexpected add-ons manager window still open");
while (windows.hasMoreElements())
windows.getNext().QueryInterface(Ci.nsIDOMWindow).close();
windows = Services.wm.getEnumerator("Addons:Compatibility");