Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
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 inChildProcess() { |
michael@0 | 8 | return Cc["@mozilla.org/xre/app-info;1"] |
michael@0 | 9 | .getService(Ci.nsIXULRuntime) |
michael@0 | 10 | .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function run_test() { |
michael@0 | 14 | // Allow all cookies if the pref service is available in this process. |
michael@0 | 15 | if (!inChildProcess()) |
michael@0 | 16 | Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); |
michael@0 | 17 | |
michael@0 | 18 | let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); |
michael@0 | 19 | |
michael@0 | 20 | let uri = NetUtil.newURI("http://example.org/"); |
michael@0 | 21 | |
michael@0 | 22 | let set = "foo=b;max-age=3600, c=d;path=/"; |
michael@0 | 23 | cs.setCookieStringFromHttp(uri, null, null, set, null, null); |
michael@0 | 24 | |
michael@0 | 25 | let expected = "foo=b"; |
michael@0 | 26 | let actual = cs.getCookieStringFromHttp(uri, null, null); |
michael@0 | 27 | do_check_eq(actual, expected); |
michael@0 | 28 | } |
michael@0 | 29 |