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 const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD"
8 let gActiveUpdate = null;
10 function FakeDirProvider() {}
11 FakeDirProvider.prototype = {
12 classID: Components.ID("{f30b43a7-2bfa-4e5f-8c4f-abc7dd4ac486}"),
13 QueryInterface: XPCOMUtils.generateQI([AUS_Ci.nsIDirectoryServiceProvider]),
15 getFile: function(prop, persistent) {
16 if (prop == KEY_UPDATE_ARCHIVE_DIR) {
17 if (gActiveUpdate) {
18 gActiveUpdate.errorCode = AUS_Cr.NS_ERROR_FILE_TOO_BIG;
19 }
20 }
21 return null;
22 }
23 };
25 function run_test() {
26 setupTestCommon();
28 setUpdateURLOverride();
29 overrideXHR(xhr_pt1);
30 standardInit();
32 logTestInfo("testing that error codes set from a directory provider propagate" +
33 "up to AUS.downloadUpdate() correctly (Bug 794211).");
35 gDirProvider = new FakeDirProvider();
36 gOldProvider = AUS_Cc["@mozilla.org/browser/directory-provider;1"]
37 .createInstance(AUS_Ci.nsIDirectoryServiceProvider);
39 gDirService = AUS_Cc["@mozilla.org/file/directory_service;1"]
40 .getService(AUS_Ci.nsIProperties);
42 gDirService.unregisterProvider(gOldProvider);
43 gDirService.registerProvider(gDirProvider);
45 Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
46 do_execute_soon(run_test_pt1);
47 }
49 function xhr_pt1() {
50 gXHR.status = 200;
51 gXHR.responseText = gResponseBody;
52 try {
53 var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"].
54 createInstance(AUS_Ci.nsIDOMParser);
55 gXHR.responseXML = parser.parseFromString(gResponseBody, "application/xml");
56 } catch (e) {
57 gXHR.responseXML = null;
58 }
59 var e = { target: gXHR };
60 gXHR.onload(e);
61 }
63 function run_test_pt1() {
64 gUpdates = null;
65 gUpdateCount = null;
66 gCheckFunc = check_test_pt1;
69 let patches = getRemotePatchString();
70 let updates = getRemoteUpdateString(patches);
71 gResponseBody = getRemoteUpdatesXMLString(updates);
72 gUpdateChecker.checkForUpdates(updateCheckListener, true);
73 }
75 function check_test_pt1() {
76 do_check_eq(gUpdateCount, 1);
78 gActiveUpdate = gUpdates[0];
79 do_check_neq(gActiveUpdate, null);
81 let state = gAUS.downloadUpdate(gActiveUpdate, true);
82 do_check_eq(state, "null");
83 do_check_eq(gActiveUpdate.errorCode >>> 0 , AUS_Cr.NS_ERROR_FILE_TOO_BIG);
85 doTestFinish();
86 }
88 function end_test() {
89 gDirService.unregisterProvider(gDirProvider);
90 gDirService.registerProvider(gOldProvider);
91 gActiveUpdate = null;
92 gDirService = null;
93 gDirProvider = null;
94 }