tor-browser

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

max-age.html (2722B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <meta charset=utf-8>
      5    <title>Test max-age attribute parsing</title>
      6    <meta name=help href="https://tools.ietf.org/html/rfc6265#section-5.3.2">
      7    <meta name="timeout" content="long">
      8    <script src="/resources/testharness.js"></script>
      9    <script src="/resources/testharnessreport.js"></script>
     10    <script src="/resources/testdriver.js"></script>
     11    <script src="/resources/testdriver-vendor.js"></script>
     12    <script src="/cookies/resources/cookie-test.js"></script>
     13  </head>
     14  <body>
     15    <div id=log></div>
     16    <script>
     17      // TODO: there is more to test here, these tests capture the old
     18      // ported http-state tests. Feel free to delete this comment when more
     19      // are added.
     20      const maxAgeTests = [
     21        {
     22          cookie: "test=1; Max-Age=50,399",
     23          expected: "test=1",
     24          name: "Ignore max-age attribute with invalid non-zero-digit (containing a comma)",
     25        },
     26        {
     27          cookie: "test=2; max-age=10000",
     28          expected: "test=2",
     29          name: "Set cookie with age",
     30        },
     31        {
     32          cookie: "test=3; max-age=0",
     33          expected: "",
     34          name: "Set no cookie with max-age=0",
     35        },
     36        {
     37          cookie: "test=4; max-age=-1",
     38          expected: "",
     39          name: "Set no cookie with max-age=-1",
     40        },
     41        {
     42          cookie: "test=5; max-age=-20",
     43          expected: "",
     44          name: "Set no cookie with max-age=-20",
     45        },
     46        {
     47          cookie: ["testA=6; max-age=60", "testB=6; max-age=60"],
     48          expected: "testA=6; testB=6",
     49          name: "Set multiple cookies with max-age attribute",
     50        },
     51        {
     52          cookie: ["testA=7; max-age=60", "testB=7; max-age=60", "testA=differentvalue; max-age=0"],
     53          expected: "testB=7",
     54          name: "Expire later cookie with same name and max-age=0",
     55        },
     56        {
     57          cookie: ["testA=8; max-age=60", "testB=8; max-age=60", "testA=differentvalue; max-age=0", "testC=8; max-age=0"],
     58          expected: "testB=8",
     59          name: "Expire later cookie with same name and max-age=0, and don't set cookie with max-age=0",
     60        },
     61        {
     62          cookie: ['test="9! = foo;bar\";" parser; max-age=6', "test9; max-age=2.63,"],
     63          expected: 'test="9! = foo; test9',
     64          name: "Set multiple cookies with valid max-age values",
     65        },
     66        {
     67          cookie: ["test=10; max-age=0", "test10; max-age=0"],
     68          expected: "",
     69          name: "Don't set multiple cookies with max-age=0",
     70        },
     71      ];
     72 
     73      for (const test of maxAgeTests) {
     74        httpCookieTest(test.cookie, test.expected, test.name);
     75      }
     76    </script>
     77  </body>
     78 </html>