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: /** michael@0: * Test that nsIUpdatePrompt doesn't display UI for showUpdateInstalled and michael@0: * showUpdateAvailable when there is already an application update window open. michael@0: */ michael@0: michael@0: function run_test() { michael@0: setupTestCommon(); michael@0: michael@0: logTestInfo("testing nsIUpdatePrompt notifications should not be seen when " + michael@0: "there is already an application update window open"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false); 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: standardInit(); michael@0: michael@0: logTestInfo("testing showUpdateInstalled should not call openWindow"); michael@0: Services.prefs.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, true); michael@0: michael@0: gCheckFunc = check_showUpdateInstalled; michael@0: gUP.showUpdateInstalled(); michael@0: // Report a successful check after the call to showUpdateInstalled since it michael@0: // didn't throw and otherwise it would report no tests run. michael@0: do_check_true(true); michael@0: michael@0: logTestInfo("testing showUpdateAvailable should not call openWindow"); michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); michael@0: let patches = getLocalPatchString(null, null, null, null, null, null, michael@0: STATE_FAILED); michael@0: let updates = getLocalUpdateString(patches); michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); michael@0: writeStatusFile(STATE_FAILED); michael@0: reloadUpdateManagerData(); michael@0: michael@0: gCheckFunc = check_showUpdateAvailable; michael@0: let update = gUpdateManager.activeUpdate; michael@0: gUP.showUpdateAvailable(update); michael@0: // Report a successful check after the call to showUpdateAvailable since it michael@0: // didn't throw and otherwise it would report no tests run. michael@0: do_check_true(true); michael@0: 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: doTestFinish(); michael@0: } michael@0: michael@0: function check_showUpdateInstalled() { michael@0: do_throw("showUpdateInstalled should not have called openWindow!"); 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: gCheckFunc(); 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 { getInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDOMWindow]) }; 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: };