Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | const Cc = Components.classes; |
michael@0 | 2 | const Ci = Components.interfaces; |
michael@0 | 3 | |
michael@0 | 4 | Components.utils.import("resource://gre/modules/NetUtil.jsm"); |
michael@0 | 5 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | function run_test() { |
michael@0 | 8 | // Allow all cookies. |
michael@0 | 9 | Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); |
michael@0 | 10 | |
michael@0 | 11 | let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); |
michael@0 | 12 | |
michael@0 | 13 | let uri = NetUtil.newURI("http://example.org/"); |
michael@0 | 14 | |
michael@0 | 15 | let set = "foo=bar\nbaz=foo"; |
michael@0 | 16 | let expected = "foo=bar; baz=foo"; |
michael@0 | 17 | cs.setCookieStringFromHttp(uri, null, null, set, null, null); |
michael@0 | 18 | |
michael@0 | 19 | let actual = cs.getCookieStringFromHttp(uri, null, null); |
michael@0 | 20 | do_check_eq(actual, expected); |
michael@0 | 21 | |
michael@0 | 22 | uri = NetUtil.newURI("http://example.com/"); |
michael@0 | 23 | cs.setCookieString(uri, null, set, null); |
michael@0 | 24 | |
michael@0 | 25 | expected = "foo=bar"; |
michael@0 | 26 | actual = cs.getCookieString(uri, null, null); |
michael@0 | 27 | do_check_eq(actual, expected); |
michael@0 | 28 | } |
michael@0 | 29 |