|
1 const Cc = Components.classes; |
|
2 const Ci = Components.interfaces; |
|
3 |
|
4 Components.utils.import("resource://gre/modules/NetUtil.jsm"); |
|
5 Components.utils.import("resource://gre/modules/Services.jsm"); |
|
6 |
|
7 function inChildProcess() { |
|
8 return Cc["@mozilla.org/xre/app-info;1"] |
|
9 .getService(Ci.nsIXULRuntime) |
|
10 .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; |
|
11 } |
|
12 |
|
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); |
|
17 |
|
18 let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); |
|
19 |
|
20 let uri = NetUtil.newURI("http://example.org/"); |
|
21 |
|
22 let set = "foo=bar"; |
|
23 cs.setCookieStringFromHttp(uri, null, null, set, null, null); |
|
24 |
|
25 let expected = "foo=bar"; |
|
26 let actual = cs.getCookieStringFromHttp(uri, null, null); |
|
27 do_check_eq(actual, expected); |
|
28 } |
|
29 |