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 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 Components.utils.import("resource://gre/modules/NetUtil.jsm");
5 Components.utils.import("resource://gre/modules/Services.jsm");
7 function inChildProcess() {
8 return Cc["@mozilla.org/xre/app-info;1"]
9 .getService(Ci.nsIXULRuntime)
10 .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
11 }
13 function run_test() {
14 // Allow all cookies if the pref service is available in this process.
15 if (!inChildProcess())
16 Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
18 let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
20 let uri = NetUtil.newURI("http://example.org/");
22 let set = "foo=bar";
23 cs.setCookieStringFromHttp(uri, null, null, set, null, null);
25 let expected = "foo=bar";
26 let actual = cs.getCookieStringFromHttp(uri, null, null);
27 do_check_eq(actual, expected);
28 }