Sat, 03 Jan 2015 20:18:00 +0100
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 | /** |
michael@0 | 6 | * Test that nsIUpdatePrompt doesn't display UI for showUpdateInstalled, |
michael@0 | 7 | * showUpdateAvailable, and showUpdateError when the app.update.silent |
michael@0 | 8 | * preference is true. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | function run_test() { |
michael@0 | 12 | setupTestCommon(); |
michael@0 | 13 | |
michael@0 | 14 | logTestInfo("testing nsIUpdatePrompt notifications should not be seen " + |
michael@0 | 15 | "when the " + PREF_APP_UPDATE_SILENT + " preference is true"); |
michael@0 | 16 | |
michael@0 | 17 | Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true); |
michael@0 | 18 | |
michael@0 | 19 | let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); |
michael@0 | 20 | registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), |
michael@0 | 21 | "Fake Window Watcher", |
michael@0 | 22 | "@mozilla.org/embedcomp/window-watcher;1", |
michael@0 | 23 | WindowWatcherFactory); |
michael@0 | 24 | |
michael@0 | 25 | standardInit(); |
michael@0 | 26 | |
michael@0 | 27 | logTestInfo("testing showUpdateInstalled should not call openWindow"); |
michael@0 | 28 | Services.prefs.setBoolPref(PREF_APP_UPDATE_SHOW_INSTALLED_UI, true); |
michael@0 | 29 | |
michael@0 | 30 | gCheckFunc = check_showUpdateInstalled; |
michael@0 | 31 | gUP.showUpdateInstalled(); |
michael@0 | 32 | // Report a successful check after the call to showUpdateInstalled since it |
michael@0 | 33 | // didn't throw and otherwise it would report no tests run. |
michael@0 | 34 | do_check_true(true); |
michael@0 | 35 | |
michael@0 | 36 | logTestInfo("testing showUpdateAvailable should not call openWindow"); |
michael@0 | 37 | writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); |
michael@0 | 38 | let patches = getLocalPatchString(null, null, null, null, null, null, |
michael@0 | 39 | STATE_FAILED); |
michael@0 | 40 | let updates = getLocalUpdateString(patches); |
michael@0 | 41 | writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true); |
michael@0 | 42 | writeStatusFile(STATE_FAILED); |
michael@0 | 43 | reloadUpdateManagerData(); |
michael@0 | 44 | |
michael@0 | 45 | gCheckFunc = check_showUpdateAvailable; |
michael@0 | 46 | let update = gUpdateManager.activeUpdate; |
michael@0 | 47 | gUP.showUpdateAvailable(update); |
michael@0 | 48 | // Report a successful check after the call to showUpdateAvailable since it |
michael@0 | 49 | // didn't throw and otherwise it would report no tests run. |
michael@0 | 50 | do_check_true(true); |
michael@0 | 51 | |
michael@0 | 52 | logTestInfo("testing showUpdateError should not call getNewPrompter"); |
michael@0 | 53 | gCheckFunc = check_showUpdateError; |
michael@0 | 54 | update.errorCode = WRITE_ERROR; |
michael@0 | 55 | gUP.showUpdateError(update); |
michael@0 | 56 | // Report a successful check after the call to showUpdateError since it |
michael@0 | 57 | // didn't throw and otherwise it would report no tests run. |
michael@0 | 58 | do_check_true(true); |
michael@0 | 59 | |
michael@0 | 60 | let registrar = Components.manager.QueryInterface(AUS_Ci.nsIComponentRegistrar); |
michael@0 | 61 | registrar.unregisterFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), |
michael@0 | 62 | WindowWatcherFactory); |
michael@0 | 63 | |
michael@0 | 64 | doTestFinish(); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function check_showUpdateInstalled() { |
michael@0 | 68 | do_throw("showUpdateInstalled should not have called openWindow!"); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function check_showUpdateAvailable() { |
michael@0 | 72 | do_throw("showUpdateAvailable should not have called openWindow!"); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function check_showUpdateError() { |
michael@0 | 76 | do_throw("showUpdateError should not have seen getNewPrompter!"); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | var WindowWatcher = { |
michael@0 | 80 | openWindow: function(aParent, aUrl, aName, aFeatures, aArgs) { |
michael@0 | 81 | gCheckFunc(); |
michael@0 | 82 | }, |
michael@0 | 83 | |
michael@0 | 84 | getNewPrompter: function(aParent) { |
michael@0 | 85 | gCheckFunc(); |
michael@0 | 86 | }, |
michael@0 | 87 | |
michael@0 | 88 | QueryInterface: function(aIID) { |
michael@0 | 89 | if (aIID.equals(AUS_Ci.nsIWindowWatcher) || |
michael@0 | 90 | aIID.equals(AUS_Ci.nsISupports)) |
michael@0 | 91 | return this; |
michael@0 | 92 | |
michael@0 | 93 | throw AUS_Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 94 | } |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | var WindowWatcherFactory = { |
michael@0 | 98 | createInstance: function createInstance(aOuter, aIID) { |
michael@0 | 99 | if (aOuter != null) |
michael@0 | 100 | throw AUS_Cr.NS_ERROR_NO_AGGREGATION; |
michael@0 | 101 | return WindowWatcher.QueryInterface(aIID); |
michael@0 | 102 | } |
michael@0 | 103 | }; |