tor-browser

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

name-and-value.html (3029B)


      1 <!doctype html>
      2 <html>
      3 
      4 <head>
      5  <meta charset=utf-8>
      6  <title>Test cookie name size restrictions</title>
      7  <meta name=help href="https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4">
      8  <meta name="timeout" content="long">
      9  <script src="/resources/testharness.js"></script>
     10  <script src="/resources/testharnessreport.js"></script>
     11  <script src="/resources/testdriver.js"></script>
     12  <script src="/resources/testdriver-vendor.js"></script>
     13  <script src="/cookies/resources/cookie-test.js"></script>
     14 </head>
     15 
     16 <body>
     17  <div id=log></div>
     18  <script>
     19    const nameAndValueSizeTests = [
     20      {
     21        cookie: cookieStringWithNameAndValueLengths(2048, 2048),
     22        expected: cookieStringWithNameAndValueLengths(2048, 2048),
     23        name: "Set max-size cookie with largest possible name and value (4096 bytes)",
     24      },
     25      {
     26        cookie: cookieStringWithNameAndValueLengths(4097, 1),
     27        expected: "",
     28        name: "Ignore cookie with name larger than 4096 and 1 byte value",
     29      },
     30      {
     31        cookie: cookieStringWithNameAndValueLengths(4096, 0),
     32        expected: cookieStringWithNameAndValueLengths(4096, 0),
     33        name: "Set max-size value-less cookie",
     34      },
     35      {
     36        cookie: cookieStringWithNameAndValueLengths(4097, 0),
     37        expected: "",
     38        name: "Ignore value-less cookie with name larger than 4096 bytes",
     39      },
     40      {
     41        cookie: cookieStringWithNameAndValueLengths(1, 4095),
     42        expected: cookieStringWithNameAndValueLengths(1, 4095),
     43        name: "Set max-size cookie with largest possible value (4095 bytes)",
     44      },
     45      {
     46        cookie: cookieStringWithNameAndValueLengths(1, 4096),
     47        expected: "",
     48        name: "Ignore named cookie (with non-zero length) and value larger than 4095 bytes",
     49      },
     50      {
     51        cookie: cookieStringWithNameAndValueLengths(4096, 1),
     52        expected: "",
     53        name: "Ignore named cookie with length larger than 4095 bytes, and a non-zero value",
     54      },
     55      {
     56        cookie: cookieStringWithNameAndValueLengths(0, 4096),
     57        expected: cookieStringWithNameAndValueLengths(0, 4096).slice(1), // it won't come back with leading =
     58        name: "Set max-size name-less cookie",
     59      },
     60      {
     61        cookie: cookieStringWithNameAndValueLengths(0, 4097),
     62        expected: "",
     63        name: "Ignore name-less cookie with value larger than 4096 bytes",
     64      },
     65      {
     66        cookie: cookieStringWithNameAndValueLengths(0, 4097).slice(1), // slice off leading =
     67        expected: "",
     68        name: "Ignore name-less cookie (without leading =) with value larger than 4096 bytes",
     69      },
     70      {
     71        cookie: cookieStringWithNameAndValueLengths(2048, 2048) + '; Max-Age:43110;',
     72        expected: cookieStringWithNameAndValueLengths(2048, 2048),
     73        name: "Set max-size cookie that also has an attribute",
     74      },
     75    ];
     76 
     77    for (const test of nameAndValueSizeTests) {
     78      httpCookieTest(test.cookie, test.expected, test.name);
     79    }
     80  </script>
     81 </body>
     82 
     83 </html>