michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: Components.utils.import("resource://gre/modules/NetUtil.jsm"); michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function inChildProcess() { michael@0: return Cc["@mozilla.org/xre/app-info;1"] michael@0: .getService(Ci.nsIXULRuntime) michael@0: .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; michael@0: } michael@0: michael@0: function run_test() { michael@0: // Allow all cookies if the pref service is available in this process. michael@0: if (!inChildProcess()) michael@0: Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); michael@0: michael@0: let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); michael@0: michael@0: let uri = NetUtil.newURI("http://example.org/"); michael@0: michael@0: let set = "foo=b;max-age=3600, c=d;path=/"; michael@0: cs.setCookieStringFromHttp(uri, null, null, set, null, null); michael@0: michael@0: let expected = "foo=b"; michael@0: let actual = cs.getCookieStringFromHttp(uri, null, null); michael@0: do_check_eq(actual, expected); michael@0: } michael@0: