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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 */
6 // Needs to be in sync w/ nsUpdateService.js
7 const NETWORK_ERROR_OFFLINE = 111;
9 function run_test() {
10 setupTestCommon();
12 logTestInfo("testing when an update check fails because the network is " +
13 "offline that we check again when the network comes online " +
14 "(Bug 794211).");
16 setUpdateURLOverride();
17 Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, false);
19 overrideXHR(null);
20 overrideUpdatePrompt(updatePrompt);
21 standardInit();
23 do_execute_soon(run_test_pt1);
24 }
26 function run_test_pt1() {
27 gResponseBody = null;
28 gCheckFunc = check_test_pt1;
29 gXHRCallback = xhr_pt1;
30 gUpdateChecker.checkForUpdates(updateCheckListener, true);
31 }
33 function xhr_pt1() {
34 gXHR.status = AUS_Cr.NS_ERROR_OFFLINE;
35 gXHR.onerror({ target: gXHR });
36 }
38 function check_test_pt1(request, update) {
39 do_check_eq(gStatusCode, AUS_Cr.NS_ERROR_OFFLINE);
40 do_check_eq(update.errorCode, NETWORK_ERROR_OFFLINE);
42 // Forward the error to AUS, which should register the online observer
43 gAUS.onError(request, update);
45 // Trigger another check by notifying the offline status observer
46 gXHRCallback = xhr_pt2;
47 Services.obs.notifyObservers(gAUS, "network:offline-status-changed", "online");
48 }
50 var updatePrompt = {
51 showUpdateAvailable: function(update) {
52 check_test_pt2(update);
53 }
54 };
56 function xhr_pt2() {
57 var patches = getLocalPatchString();
58 var updates = getLocalUpdateString(patches);
59 var responseBody = getLocalUpdatesXMLString(updates);
61 gXHR.status = 200;
62 gXHR.responseText = responseBody;
63 try {
64 var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
65 createInstance(AUS_Ci.nsIDOMParser);
66 gXHR.responseXML = parser.parseFromString(responseBody, "application/xml");
67 } catch (e) {
68 }
69 gXHR.onload({ target: gXHR });
70 }
72 function check_test_pt2(update) {
73 // We just verify that there are updates to know the check succeeded.
74 do_check_neq(update, null);
75 do_check_eq(update.name, "App Update Test");
77 doTestFinish();
78 }