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 download a complete on partial failure. Calling " + michael@0: "nsIUpdatePrompt::showUpdateError should call getNewPrompter " + michael@0: "and alert on the object returned by getNewPrompter when the " + michael@0: "update.state == " + STATE_FAILED + " and the update.errorCode " + michael@0: "== " + WRITE_ERROR + " (Bug 595059)."); 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: michael@0: standardInit(); michael@0: michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); michael@0: let url = URL_HOST + "/" + FILE_COMPLETE_MAR; michael@0: let patches = getLocalPatchString("complete", url, null, null, null, null, michael@0: STATE_FAILED); michael@0: let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0", michael@0: null, null, null, null, url); michael@0: writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); michael@0: writeStatusFile(STATE_FAILED); michael@0: michael@0: reloadUpdateManagerData(); michael@0: michael@0: let update = gUpdateManager.activeUpdate; michael@0: update.errorCode = WRITE_ERROR; michael@0: let prompter = AUS_Cc["@mozilla.org/updates/update-prompt;1"]. michael@0: createInstance(AUS_Ci.nsIUpdatePrompt); michael@0: prompter.showUpdateError(update); 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: } michael@0: michael@0: var WindowWatcher = { michael@0: getNewPrompter: function(aParent) { michael@0: do_check_eq(aParent, null); michael@0: return { michael@0: alert: function(aTitle, aText) { michael@0: let title = getString("updaterIOErrorTitle"); michael@0: do_check_eq(aTitle, title); michael@0: let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg", michael@0: [Services.appinfo.name, michael@0: Services.appinfo.name], 2); michael@0: do_check_eq(aText, text); michael@0: michael@0: doTestFinish(); michael@0: } michael@0: }; michael@0: }, michael@0: michael@0: QueryInterface: function(iid) { michael@0: if (iid.equals(AUS_Ci.nsIWindowWatcher) || michael@0: iid.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(outer, iid) { michael@0: if (outer != null) michael@0: throw AUS_Cr.NS_ERROR_NO_AGGREGATION; michael@0: return WindowWatcher.QueryInterface(iid); michael@0: } michael@0: };