tor-browser

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

session-cookie-has-no-attributes.https.html (1577B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="helper.js" type="module"></script>
      6 
      7 <script type="module">
      8  import { expireCookie, documentHasCookie, waitForCookie, addCookieAndSessionCleanup, setupShardedServerState, configureServer } from "./helper.js";
      9 
     10  promise_test(async t => {
     11    await setupShardedServerState();
     12    const expectedCookieAndValue = "auth_cookie=abcdef0123";
     13    addCookieAndSessionCleanup(t);
     14 
     15    // Configure server to set up a session with a cookie that has no attributes.
     16    await configureServer({ cookieDetails: [{ attributes: "" }] });
     17 
     18    // Prompt starting a session, and wait until registration completes.
     19    const loginResponse = await fetch('login.py');
     20    assert_equals(loginResponse.status, 200);
     21    await waitForCookie(expectedCookieAndValue, /*expectCookie=*/true);
     22 
     23    // Confirm that a request has the cookie set.
     24    const authResponse = await fetch('verify_authenticated.py');
     25    assert_equals(authResponse.status, 200);
     26 
     27    // Confirm that expiring the cookie still leads to a request with the cookie set (refresh occurs).
     28    expireCookie(expectedCookieAndValue);
     29    assert_false(documentHasCookie(expectedCookieAndValue));
     30    const authResponseAfterExpiry = await fetch('verify_authenticated.py');
     31    assert_equals(authResponseAfterExpiry.status, 200);
     32    assert_true(documentHasCookie(expectedCookieAndValue));
     33  }, "An established session can refresh a cookie that has all default attributes");
     34 </script>