Additional test patch - Bug 843497 - Update check says 'up to date' for out of date versions on unsupported OS versions. r=bbondy

This commit is contained in:
Robert Strong 2013-06-21 19:39:48 -07:00
parent 00a9ece28f
commit 36bf5da9d1
3 changed files with 134 additions and 2 deletions

View File

@ -243,13 +243,13 @@ function initMockIncrementalDownload() {
var registrar = AUS_Cm.QueryInterface(AUS_Ci.nsIComponentRegistrar);
gIncrementalDownloadClassID = registrar.contractIDToCID(INC_CONTRACT_ID);
gIncOldFactory = AUS_Cm.getClassObject(AUS_Cc[INC_CONTRACT_ID],
AUS_Ci.nsIFactory);
AUS_Ci.nsIFactory);
registrar.unregisterFactory(gIncrementalDownloadClassID, gIncOldFactory);
var components = [IncrementalDownload];
registrar.registerFactory(gIncrementalDownloadClassID, "",
INC_CONTRACT_ID, newFactory);
gIncOldFactory = AUS_Cm.getClassObject(AUS_Cc[INC_CONTRACT_ID],
AUS_Ci.nsIFactory);
AUS_Ci.nsIFactory);
}
function cleanupMockIncrementalDownload() {

View File

@ -0,0 +1,129 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test that nsIUpdatePrompt doesn't display UI for showUpdateAvailable for an
* unsupported system update when it has already been shown (bug 843497).
*/
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
removeUpdateDirsAndFiles();
setUpdateURLOverride();
// The mock XMLHttpRequest is MUCH faster
overrideXHR(callHandleEvent);
standardInit();
// The HTTP server is only used for the mar file downloads which is slow
start_httpserver(URL_PATH);
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
"Fake Window Watcher",
"@mozilla.org/embedcomp/window-watcher;1",
WindowWatcherFactory);
registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
"Fake Window Mediator",
"@mozilla.org/appshell/window-mediator;1",
WindowMediatorFactory);
logTestInfo("testing nsIUpdatePrompt notifications should not be seen for " +
"an unsupported system update when it has already been shown");
Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
Services.prefs.setBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, true);
// This preference is used to determine when the background update check has
// completed since a successful check will clear the preference.
Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, 1);
gResponseBody = getRemoteUpdatesXMLString(" <update type=\"major\" " +
"name=\"Unsupported Update\" " +
"unsupported=\"true\" " +
"detailsURL=\"" + URL_HOST +
"\"></update>\n");
gAUS.notify(null);
do_execute_soon(check_test);
}
function check_test() {
if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS)) {
do_execute_soon(check_test);
return;
}
do_check_true(true);
do_test_finished();
}
function end_test() {
let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
WindowWatcherFactory);
registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
WindowMediatorFactory);
cleanUp();
}
// Callback function used by the custom XMLHttpRequest implementation to
// call the nsIDOMEventListener's handleEvent method for onload.
function callHandleEvent() {
gXHR.status = 400;
gXHR.responseText = gResponseBody;
try {
var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
createInstance(AUS_Ci.nsIDOMParser);
gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
}
catch(e) {
}
var e = { target: gXHR };
gXHR.onload(e);
}
function check_showUpdateAvailable() {
do_throw("showUpdateAvailable should not have called openWindow!");
}
var WindowWatcher = {
openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) {
check_showUpdateAvailable();
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowWatcher) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowWatcherFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
return WindowWatcher.QueryInterface(aIID);
}
};
var WindowMediator = {
getMostRecentWindow: function(aWindowType) {
return null;
},
QueryInterface: function(aIID) {
if (aIID.equals(AUS_Ci.nsIWindowMediator) ||
aIID.equals(AUS_Ci.nsISupports))
return this;
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
}
var WindowMediatorFactory = {
createInstance: function createInstance(aOuter, aIID) {
if (aOuter != null)
throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
return WindowMediator.QueryInterface(aIID);
}
};

View File

@ -20,6 +20,9 @@ tail =
[test_0081_prompt_uiAlreadyOpen.js]
skip-if = toolkit == "gonk"
reason = custom nsIUpdatePrompt
[test_0082_prompt_unsupportAlreadyNotified.js]
skip-if = toolkit == "gonk"
reason = custom nsIUpdatePrompt
; Tests that require the updater binary
[include:xpcshell_updater.ini]
skip-if = os == 'android'