toolkit/mozapps/update/tests/unit_aus_update/downloadCompleteAfterPartialFailure.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 function run_test() {
michael@0 6 setupTestCommon();
michael@0 7
michael@0 8 logTestInfo("testing download a complete on partial failure. Calling " +
michael@0 9 "nsIUpdatePrompt::showUpdateError should call getNewPrompter " +
michael@0 10 "and alert on the object returned by getNewPrompter when the " +
michael@0 11 "update.state == " + STATE_FAILED + " and the update.errorCode " +
michael@0 12 "== " + WRITE_ERROR + " (Bug 595059).");
michael@0 13
michael@0 14 Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
michael@0 15
michael@0 16 let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
michael@0 17 registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
michael@0 18 "Fake Window Watcher",
michael@0 19 "@mozilla.org/embedcomp/window-watcher;1",
michael@0 20 WindowWatcherFactory);
michael@0 21
michael@0 22 standardInit();
michael@0 23
michael@0 24 writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
michael@0 25 let url = URL_HOST + "/" + FILE_COMPLETE_MAR;
michael@0 26 let patches = getLocalPatchString("complete", url, null, null, null, null,
michael@0 27 STATE_FAILED);
michael@0 28 let updates = getLocalUpdateString(patches, null, null, "version 1.0", "1.0",
michael@0 29 null, null, null, null, url);
michael@0 30 writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
michael@0 31 writeStatusFile(STATE_FAILED);
michael@0 32
michael@0 33 reloadUpdateManagerData();
michael@0 34
michael@0 35 let update = gUpdateManager.activeUpdate;
michael@0 36 update.errorCode = WRITE_ERROR;
michael@0 37 let prompter = AUS_Cc["@mozilla.org/updates/update-prompt;1"].
michael@0 38 createInstance(AUS_Ci.nsIUpdatePrompt);
michael@0 39 prompter.showUpdateError(update);
michael@0 40 }
michael@0 41
michael@0 42 function end_test() {
michael@0 43 let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
michael@0 44 registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
michael@0 45 WindowWatcherFactory);
michael@0 46 }
michael@0 47
michael@0 48 var WindowWatcher = {
michael@0 49 getNewPrompter: function(aParent) {
michael@0 50 do_check_eq(aParent, null);
michael@0 51 return {
michael@0 52 alert: function(aTitle, aText) {
michael@0 53 let title = getString("updaterIOErrorTitle");
michael@0 54 do_check_eq(aTitle, title);
michael@0 55 let text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg",
michael@0 56 [Services.appinfo.name,
michael@0 57 Services.appinfo.name], 2);
michael@0 58 do_check_eq(aText, text);
michael@0 59
michael@0 60 doTestFinish();
michael@0 61 }
michael@0 62 };
michael@0 63 },
michael@0 64
michael@0 65 QueryInterface: function(iid) {
michael@0 66 if (iid.equals(AUS_Ci.nsIWindowWatcher) ||
michael@0 67 iid.equals(AUS_Ci.nsISupports))
michael@0 68 return this;
michael@0 69
michael@0 70 throw AUS_Cr.NS_ERROR_NO_INTERFACE;
michael@0 71 }
michael@0 72 }
michael@0 73
michael@0 74 var WindowWatcherFactory = {
michael@0 75 createInstance: function createInstance(outer, iid) {
michael@0 76 if (outer != null)
michael@0 77 throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
michael@0 78 return WindowWatcher.QueryInterface(iid);
michael@0 79 }
michael@0 80 };

mercurial