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