tor-browser

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

test_bug667818.js (1284B)


      1 "use strict";
      2 
      3 function makeURI(str) {
      4  return Services.io.newURI(str);
      5 }
      6 
      7 add_task(async () => {
      8  // Allow all cookies.
      9  Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
     10  Services.prefs.setBoolPref(
     11    "network.cookieJarSettings.unblocked_for_testing",
     12    true
     13  );
     14  Services.prefs.setBoolPref("dom.security.https_first", false);
     15 
     16  var uri = makeURI("http://example.com/");
     17  var channel = NetUtil.newChannel({
     18    uri,
     19    loadUsingSystemPrincipal: true,
     20    contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
     21  });
     22  Services.scriptSecurityManager.createContentPrincipal(uri, {});
     23 
     24  CookieXPCShellUtils.createServer({ hosts: ["example.com"] });
     25 
     26  // Try an expiration time before the epoch
     27 
     28  await CookieXPCShellUtils.setCookieToDocument(
     29    uri.spec,
     30    "test=test; path=/; domain=example.com; expires=Sun, 31-Dec-1899 16:00:00 GMT;"
     31  );
     32  Assert.equal(
     33    await CookieXPCShellUtils.getCookieStringFromDocument(uri.spec),
     34    ""
     35  );
     36 
     37  // Now sanity check
     38  Services.cookies.setCookieStringFromHttp(
     39    uri,
     40    "test2=test2; path=/; domain=example.com;",
     41    channel
     42  );
     43 
     44  Assert.equal(
     45    await CookieXPCShellUtils.getCookieStringFromDocument(uri.spec),
     46    "test2=test2"
     47  );
     48  Services.prefs.clearUserPref("dom.security.https_first");
     49 });