toolkit/mozapps/update/tests/unit_aus_update/uiUnsupportedAlreadyNotified.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 nsIUpdatePrompt notifications should not be displayed " +
michael@0 9 "when showUpdateAvailable is called for an unsupported system " +
michael@0 10 "update when the unsupported notification has already been " +
michael@0 11 "shown (bug 843497)");
michael@0 12
michael@0 13 setUpdateURLOverride();
michael@0 14 // The mock XMLHttpRequest is MUCH faster
michael@0 15 overrideXHR(callHandleEvent);
michael@0 16 standardInit();
michael@0 17 // The HTTP server is only used for the mar file downloads which is slow
michael@0 18 start_httpserver();
michael@0 19
michael@0 20 let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
michael@0 21 registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
michael@0 22 "Fake Window Watcher",
michael@0 23 "@mozilla.org/embedcomp/window-watcher;1",
michael@0 24 WindowWatcherFactory);
michael@0 25 registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
michael@0 26 "Fake Window Mediator",
michael@0 27 "@mozilla.org/appshell/window-mediator;1",
michael@0 28 WindowMediatorFactory);
michael@0 29
michael@0 30 Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, false);
michael@0 31 Services.prefs.setBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, true);
michael@0 32 // This preference is used to determine when the background update check has
michael@0 33 // completed since a successful check will clear the preference.
michael@0 34 Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, 1);
michael@0 35
michael@0 36 gResponseBody = getRemoteUpdatesXMLString(" <update type=\"major\" " +
michael@0 37 "name=\"Unsupported Update\" " +
michael@0 38 "unsupported=\"true\" " +
michael@0 39 "detailsURL=\"" + URL_HOST +
michael@0 40 "\"></update>\n");
michael@0 41 gAUS.notify(null);
michael@0 42 do_execute_soon(check_test);
michael@0 43 }
michael@0 44
michael@0 45 function check_test() {
michael@0 46 if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS)) {
michael@0 47 do_execute_soon(check_test);
michael@0 48 return;
michael@0 49 }
michael@0 50 do_check_true(true);
michael@0 51
michael@0 52 doTestFinish();
michael@0 53 }
michael@0 54
michael@0 55 function end_test() {
michael@0 56 let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar);
michael@0 57 registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
michael@0 58 WindowWatcherFactory);
michael@0 59 registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af56}"),
michael@0 60 WindowMediatorFactory);
michael@0 61 }
michael@0 62
michael@0 63 // Callback function used by the custom XMLHttpRequest implementation to
michael@0 64 // call the nsIDOMEventListener's handleEvent method for onload.
michael@0 65 function callHandleEvent() {
michael@0 66 gXHR.status = 400;
michael@0 67 gXHR.responseText = gResponseBody;
michael@0 68 try {
michael@0 69 var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
michael@0 70 createInstance(AUS_Ci.nsIDOMParser);
michael@0 71 gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
michael@0 72 } catch (e) {
michael@0 73 }
michael@0 74 var e = { target: gXHR };
michael@0 75 gXHR.onload(e);
michael@0 76 }
michael@0 77
michael@0 78 function check_showUpdateAvailable() {
michael@0 79 do_throw("showUpdateAvailable should not have called openWindow!");
michael@0 80 }
michael@0 81
michael@0 82 var WindowWatcher = {
michael@0 83 openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) {
michael@0 84 check_showUpdateAvailable();
michael@0 85 },
michael@0 86
michael@0 87 QueryInterface: function(aIID) {
michael@0 88 if (aIID.equals(AUS_Ci.nsIWindowWatcher) ||
michael@0 89 aIID.equals(AUS_Ci.nsISupports))
michael@0 90 return this;
michael@0 91
michael@0 92 throw AUS_Cr.NS_ERROR_NO_INTERFACE;
michael@0 93 }
michael@0 94 }
michael@0 95
michael@0 96 var WindowWatcherFactory = {
michael@0 97 createInstance: function createInstance(aOuter, aIID) {
michael@0 98 if (aOuter != null)
michael@0 99 throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
michael@0 100 return WindowWatcher.QueryInterface(aIID);
michael@0 101 }
michael@0 102 };
michael@0 103
michael@0 104 var WindowMediator = {
michael@0 105 getMostRecentWindow: function(aWindowType) {
michael@0 106 return null;
michael@0 107 },
michael@0 108
michael@0 109 QueryInterface: function(aIID) {
michael@0 110 if (aIID.equals(AUS_Ci.nsIWindowMediator) ||
michael@0 111 aIID.equals(AUS_Ci.nsISupports))
michael@0 112 return this;
michael@0 113
michael@0 114 throw AUS_Cr.NS_ERROR_NO_INTERFACE;
michael@0 115 }
michael@0 116 }
michael@0 117
michael@0 118 var WindowMediatorFactory = {
michael@0 119 createInstance: function createInstance(aOuter, aIID) {
michael@0 120 if (aOuter != null)
michael@0 121 throw AUS_Cr.NS_ERROR_NO_AGGREGATION;
michael@0 122 return WindowMediator.QueryInterface(aIID);
michael@0 123 }
michael@0 124 };

mercurial