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.

     1 const Cc = Components.classes;
     2 const Ci = Components.interfaces;
     4 Components.utils.import("resource://gre/modules/NetUtil.jsm");
     5 Components.utils.import("resource://gre/modules/Services.jsm");
     7 function inChildProcess() {
     8   return Cc["@mozilla.org/xre/app-info;1"]
     9            .getService(Ci.nsIXULRuntime)
    10            .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
    11 }
    13 function run_test() {
    14   // Allow all cookies if the pref service is available in this process.
    15   if (!inChildProcess())
    16     Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
    18   let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
    20   let uri = NetUtil.newURI("http://example.org/");
    22   let set = "foo=bar";
    23   cs.setCookieStringFromHttp(uri, null, null, set, null, null);
    25   let expected = "foo=bar";
    26   let actual = cs.getCookieStringFromHttp(uri, null, null);
    27   do_check_eq(actual, expected);
    28 }

mercurial