1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cookie/test/unit/test_parser_0001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,29 @@ 1.4 +const Cc = Components.classes; 1.5 +const Ci = Components.interfaces; 1.6 + 1.7 +Components.utils.import("resource://gre/modules/NetUtil.jsm"); 1.8 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.9 + 1.10 +function inChildProcess() { 1.11 + return Cc["@mozilla.org/xre/app-info;1"] 1.12 + .getService(Ci.nsIXULRuntime) 1.13 + .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; 1.14 +} 1.15 + 1.16 +function run_test() { 1.17 + // Allow all cookies if the pref service is available in this process. 1.18 + if (!inChildProcess()) 1.19 + Services.prefs.setIntPref("network.cookie.cookieBehavior", 0); 1.20 + 1.21 + let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService); 1.22 + 1.23 + let uri = NetUtil.newURI("http://example.org/"); 1.24 + 1.25 + let set = "foo=bar"; 1.26 + cs.setCookieStringFromHttp(uri, null, null, set, null, null); 1.27 + 1.28 + let expected = "foo=bar"; 1.29 + let actual = cs.getCookieStringFromHttp(uri, null, null); 1.30 + do_check_eq(actual, expected); 1.31 +} 1.32 +