|
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 run_test() { |
|
8 // Allow all cookies. |
|
9 Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); |
|
10 |
|
11 let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); |
|
12 |
|
13 let uri = NetUtil.newURI("http://example.org/"); |
|
14 |
|
15 let set = "foo=bar\nbaz=foo"; |
|
16 let expected = "foo=bar; baz=foo"; |
|
17 cs.setCookieStringFromHttp(uri, null, null, set, null, null); |
|
18 |
|
19 let actual = cs.getCookieStringFromHttp(uri, null, null); |
|
20 do_check_eq(actual, expected); |
|
21 |
|
22 uri = NetUtil.newURI("http://example.com/"); |
|
23 cs.setCookieString(uri, null, set, null); |
|
24 |
|
25 expected = "foo=bar"; |
|
26 actual = cs.getCookieString(uri, null, null); |
|
27 do_check_eq(actual, expected); |
|
28 } |
|
29 |