summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/value/value.html
blob: 14292cece91eac18fc9f6685069e0c8fb51f19e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!doctype html>
<html>
  <head>
    <meta charset=utf-8>
    <title>Test cookie value parsing</title>
    <meta name=help href="https://tools.ietf.org/html/rfc6265#section-5.2">
    <meta name="timeout" content="long">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <script src="/resources/testdriver.js"></script>
    <script src="/resources/testdriver-vendor.js"></script>
    <script src="/cookies/resources/cookie-test.js"></script>
  </head>
  <body>
    <div id=log></div>
    <script>
      // TODO: there is more to test here, these tests capture the old
      // ported http-state tests. Feel free to delete this comment when more
      // are added, or these are split up into logical groups.
      const valueTests = [
        {
          cookie: "test=1, baz=qux",
          expected: "test=1, baz=qux",
          name: "Set value containing a comma",
        },
        {
          cookie: 'test="2, baz=qux"',
          expected: 'test="2, baz=qux"',
          name: "Set quoted value containing a comma",
        },
        {
          cookie: 'test="3zz;pp" ; ;',
          expected: 'test="3zz',
          name: "Ignore values after semicolon",
        },
        {
          cookie: 'test="4zz ;',
          expected: 'test="4zz',
          name: "Ignore whitespace at the end of value",
        },
        {
          cookie: 'test="5zzz "   "ppp"  ;',
          expected: 'test="5zzz "   "ppp"',
          name: "Set value including quotes and whitespace up until semicolon",
        },
        {
          cookie: 'test=6A"B ;',
          expected: 'test=6A"B',
          name: "Set value with a single quote excluding whitespace"
        },
        {
          cookie: "test7",
          expected: "test7",
          name: "Set nameless cookie to its value",
        },
        {
          cookie: '"test8\"HHH"',
          expected: '"test8\"HHH"',
          name: "Set nameless cookie to its value with an escaped quote",
        },
        {
          cookie: 'test="9',
          expected: 'test="9',
          name: "Set value with unbalanced leading quote",
        },
        {
          cookie: "=test10",
          expected: "test10",
          name: "Set nameless cookie followed by '=' to its value",
        },
        {
          // 4 + 2 + 4090 = 4096
          cookie: `test=11${"a".repeat(4090)}`,
          expected: `test=11${"a".repeat(4090)}`,
          name: "Set cookie with large name + value ( = 4kb)",
        },
        {
          // 4 + 2 + 4091 = 4097
          cookie: `test=12${"a".repeat(4091)}`,
          expected: "",
          name: "Ignore cookie with large name + value ( > 4kb)",
        },
        {
          cookie: `test=13\nZYX`,
          expected: "test=13",
          name: "Set cookie but ignore value after LF",
        },
        {
          cookie: 'test="14 "   ;',
          expected: 'test="14 "',
          name: "Set cookie ignoring whitespace after value endquote",
        },
        {
          cookie: "test=15    ;",
          expected: "test=15",
          name: "Ignore whitespace and ; after value",
        },
        {
          cookie: "test=  16",
          expected: "test=16",
          name: "Ignore whitespace preceding value",
        },
        {
          cookie: 'test="17"',
          expected: 'test="17"',
          name: "Set cookie with quotes in value",
        },
        {
          cookie: 'test="  18 "',
          expected: 'test="  18 "',
          name: "Set cookie keeping whitespace inside quoted value",
        },
        {
          cookie: 'test="19;wow"',
          expected: 'test="19',
          name: "Set cookie value ignoring characters after semicolon",
        },
        {
          cookie: 'test="20=20"',
          expected: 'test="20=20"',
          name: "Set cookie with another = inside quoted value",
        },
        {
          cookie: "test	=	21	 	;	ttt",
          expected: "test=21",
          name: "Set cookie ignoring whitespace surrounding value and characters after first semicolon",
        },
        {
          cookie: ["testA=22", "test22=", "testB=22"],
          expected: "testA=22; test22=; testB=22",
          name: "Set valueless cookie, given `Set-Cookie: test22=`",
        },
        {
          cookie: "test=%32%33",
          expected: "test=%32%33",
          name: "URL-encoded cookie value is not decoded",
        },
        {
          cookie: "test24==",
          expected: "test24==",
          name: "Set cookie with value set to =",
        },
        {
          cookie: 'test=25=25',
          expected: 'test=25=25',
          name: "Set cookie with one = inside an unquoted value",
        },
        {
          cookie: 'test=26=26=26',
          expected: 'test=26=26=26',
          name: "Set cookie with two = inside an unquoted value",
        },
        {
          cookie: 'test=27 test',
          expected: 'test=27 test',
          name: "Set cookie with a space character in the value",
        },
        {
          cookie: ' test test28 ;',
          expected: 'test test28',
          name: "Set a nameless cookie with a space character in the value",
        },
      ];

      for (const test of valueTests) {
        httpCookieTest(test.cookie, test.expected, test.name, test.defaultPath);
      }
    </script>
  </body>
</html>