tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_parser_0001.js (927B)


      1 const { NetUtil } = ChromeUtils.importESModule(
      2  "resource://gre/modules/NetUtil.sys.mjs"
      3 );
      4 
      5 function inChildProcess() {
      6  return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
      7 }
      8 
      9 function run_test() {
     10  // Allow all cookies if the pref service is available in this process.
     11  if (!inChildProcess()) {
     12    Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
     13    Services.prefs.setBoolPref(
     14      "network.cookieJarSettings.unblocked_for_testing",
     15      true
     16    );
     17  }
     18 
     19  let uri = NetUtil.newURI("http://example.org/");
     20  let channel = NetUtil.newChannel({
     21    uri,
     22    loadUsingSystemPrincipal: true,
     23    contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
     24  });
     25 
     26  let set = "foo=bar";
     27  Services.cookies.setCookieStringFromHttp(uri, set, channel);
     28 
     29  let expected = "foo=bar";
     30  let actual = Services.cookies.getCookieStringFromHttp(uri, channel);
     31  Assert.equal(actual, expected);
     32 }