netwerk/cookie/test/unit/test_parser_0001.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 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=bar";
michael@0 23 cs.setCookieStringFromHttp(uri, null, null, set, null, null);
michael@0 24
michael@0 25 let expected = "foo=bar";
michael@0 26 let actual = cs.getCookieStringFromHttp(uri, null, null);
michael@0 27 do_check_eq(actual, expected);
michael@0 28 }
michael@0 29

mercurial