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