tor-browser

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

create-session.https.html (1518B)


      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 } from "./helper.js";
      9 
     10  promise_test(async t => {
     11    await setupShardedServerState();
     12    const expectedCookieAndValue = "auth_cookie=abcdef0123";
     13    const expectedCookieAndAttributes = `${expectedCookieAndValue};Domain=${location.hostname};Path=/device-bound-session-credentials`;
     14    addCookieAndSessionCleanup(t);
     15 
     16    // Prompt starting a session, and wait until registration completes.
     17    const loginResponse = await fetch('login.py');
     18    assert_equals(loginResponse.status, 200);
     19    await waitForCookie(expectedCookieAndValue, /*expectCookie=*/true);
     20 
     21    // Confirm that a request has the cookie set.
     22    const authResponse = await fetch('verify_authenticated.py');
     23    assert_equals(authResponse.status, 200);
     24 
     25    // Confirm that expiring the cookie still leads to a request with the cookie set (refresh occurs).
     26    expireCookie(expectedCookieAndAttributes);
     27    assert_false(documentHasCookie(expectedCookieAndValue));
     28    const authResponseAfterExpiry = await fetch('verify_authenticated.py');
     29    assert_equals(authResponseAfterExpiry.status, 200);
     30    assert_true(documentHasCookie(expectedCookieAndValue));
     31  }, "An established session can refresh a cookie");
     32 </script>