tor-browser

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

path.html (4995B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <meta charset=utf-8>
      5    <title>Test cookie path attribute parsing</title>
      6    <meta name=help href="https://tools.ietf.org/html/rfc6265#section-5.2.4">
      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    <script>
     16      const pathTests = [
     17        {
     18          cookie: "test=1; Path",
     19          expected: "test=1",
     20          name: "Set cookie for bare Path",
     21        },
     22        {
     23          cookie: "test=2; Path=",
     24          expected: "test=2",
     25          name: "Set cookie for Path=",
     26        },
     27        {
     28          cookie: "test=3; Path=/",
     29          expected: "test=3",
     30          name: "Set cookie for Path=/",
     31          defaultPath: false,
     32        },
     33        {
     34          cookie: "test=4; Path=/qux",
     35          expected: "",
     36          name: "No cookie returned for mismatched path",
     37          defaultPath: false,
     38        },
     39        {
     40          cookie: "test=5; Path    =/qux",
     41          expected: "",
     42          name: "No cookie returned for path space equals mismatched path",
     43          defaultPath: false,
     44        },
     45        {
     46          cookie: "test=6; Path=    /qux",
     47          expected: "",
     48          name: "No cookie returned for path equals space mismatched path",
     49          defaultPath: false,
     50        },
     51        {
     52          cookie: "test=7; Path=/qux      ; taz",
     53          expected: "",
     54          name: "No cookie returned for mismatched path and attribute",
     55          defaultPath: false,
     56        },
     57        {
     58          cookie: "test=8; Path=/qux; Path=/",
     59          expected: "test=8",
     60          name: "Set cookie for mismatched and root path",
     61        },
     62        {
     63          cookie: "test=9; Path=/; Path=/qux",
     64          expected: "",
     65          name: "No cookie returned for root and mismatched path",
     66          defaultPath: false,
     67        },
     68        {
     69          cookie: "test=10; Path=/lol; Path=/qux",
     70          expected: "",
     71          name: "No cookie returned for multiple mismatched paths",
     72          defaultPath: false,
     73        },
     74        {
     75          cookie: ["testA=11; path=/", "testB=11; path=/cookies/attributes"],
     76          expected: "testB=11; testA=11",
     77          name: "Return 2 cookies sorted by matching path length (earlier name with shorter path set first)",
     78          defaultPath: false,
     79        },
     80        {
     81          cookie: ["testB=12; path=/", "testA=12; path=/cookies/attributes"],
     82          expected: "testA=12; testB=12",
     83          name: "Return 2 cookies sorted by matching path length (later name with shorter path set first)",
     84          defaultPath: false,
     85        },
     86        {
     87          cookie: ["testA=13; path=/cookies/attributes", "testB=13; path=/"],
     88          expected: "testA=13; testB=13",
     89          name: "Return 2 cookies sorted by matching path length (earlier name with longer path set first)",
     90          defaultPath: false,
     91        },
     92        {
     93          cookie: ["testB=14; path=/cookies/attributes", "testA=14; path=/"],
     94          expected: "testB=14; testA=14",
     95          name: "Return 2 cookies sorted by matching path length (later name with longer path set first)",
     96          defaultPath: false,
     97        },
     98        {
     99          cookie: ["test=15; path=/cookies/attributes/foo"],
    100          expected: "",
    101          name: "No cookie returned for partial path match",
    102          defaultPath: false,
    103        },
    104        {
    105          cookie: ["test=16", "test=0; path=/cookies/attributes/foo"],
    106          expected: "test=16",
    107          name: "No cookie returned for partial path match, return cookie for default path",
    108        },
    109        {
    110          cookie: ["test=17; path= /"],
    111          expected: "test=17",
    112          name: "Return cookie for path= / (whitespace after equals)",
    113        },
    114        {
    115          cookie: ["test=18; path=/cookies/ATTRIBUTES"],
    116          expected: "",
    117          name: "No cookie returned for case mismatched path",
    118          defaultPath: false,
    119        },
    120        {
    121          cookie: ["testA=19; 	path	=	/cookies/attributes", "testB=19; 	path	=	/book"],
    122          expected: "testA=19",
    123          name: "Return cookie A on path match, no cookie returned for path mismatch (plus whitespace)",
    124          defaultPath: false,
    125        },
    126        {
    127          cookie: ["test=20; path=; path=/dog"],
    128          expected: "",
    129          name: "No cookie returned for mismatched path (after bare path=)",
    130          defaultPath: false,
    131        },
    132        {
    133          cookie: ["test=21; path=/dog; path="],
    134          expected: "test=21",
    135          name: "Return cookie for bare path= (after mismatched path)",
    136        },
    137      ];
    138 
    139      for (const test of pathTests) {
    140        httpCookieTest(test.cookie, test.expected, test.name, test.defaultPath);
    141      }
    142    </script>
    143  </body>
    144 </html>