Commit bcc8d251 authored by Mike Taylor's avatar Mike Taylor Committed by Chromium LUCI CQ

Rewrite wpt/cookies/http-state/{general,mozilla}-tests.html

Note: after this CL lands, mozilla0011-test and mozilla0011-expected
will still be around. The intent is to port that with the rest of the
domain-test.html tests.

Here's a mapping from the legacy http-state/general-tests.html to their
new location (found in wpt/cookies/), which will have a cookie with
some variation of test=N in it.

0001 => Not ported. Already covered.
0002 => test=3 (attributes/expires.html)
0003 => test=4 (attributes/expires.html)
0004 => Not ported. Already covered.
0005 => test=2 (attributes/max-age.html)
0006 => test=3 (attributes/max-age.html)
0007 => test=14 (attributes/invalid.html)
0008 => test=15 (attributes/invalid.html)
0009 => Not ported. Basically the same as test=14 and 15 and otherwise
covered.
0010 => Not ported. Already covered.
0011 => test=16 (attributes/invalid.html)
0012 => test=17 (attributes/invalid.html)
0013 => test=12 (name/name.html)
0014 => testA=13 (name/name.html)
0015 => a=test14 (name/name.html)
0016 => z=test15 (name/name.html)
0017 => z=test16 (name/name.html)
0018 => test=18 (attributes/invalid.html)
0019 => test=19 (attributes/invalid.html)
0020 => test=20 (attributes/invalid.html)
0021 => test=16 (name/name.html)
0022 => test=22 (value/value.html)
0023 => test=21 (attributes/invalid.html)
0024 => test=22 (attributes/invalid.html)
0025 => test=23 (attributes/invalid.html)
0026 => test=24 (attributes/invalid.html)
0027 => test=17 (name/name.html)
0028 => test=25 (attributes/invalid.html)

Here's the mapping for  http-state/mozilla-tests.html:

mozilla0001 => test=4 (attributes/max-age.html)
mozilla0002 => Not ported. Dupe of test=3 in max-age.html.
mozilla0003 => test=5 (attributes/expires.html)
mozilla0004 => Not ported. Covered by test=2 in max-age.html.
mozilla0005 => test=5 (attributes/max-age.html)
mozilla0006 => Not ported. Covered by test=2 in max-age.html (and dupe
of mozilla0004?)
mozilla0007 => Not ported. Dupe of mozilla0003.
mozilla0008 => test=6 (attributes/max-age.html)
mozilla0009 => test=7 (attributes/max-age.html)
mozilla0010 => test=8 (attributes/max-age.html)
mozilla0011 => Not ported yet, will be ported as part of Bug 1159858
mozilla0012 => test=9 (attributes/max-age.html)
mozilla0013 => test=10 (attributes/max-age.html)
mozilla0014 => Not ported. Covered by test7 in value.html
mozilla0015 => test=11a (attributes/name.html)
mozilla0016 => test=11b (attributes/name.html)
mozilla0017 => test=11c (attributes/name.html)

Bug: 1159862
Change-Id: I662c4af50289fef313ddf0c509a30ab6b24c88b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628259Reviewed-by: default avatarSteven Bingler <bingler@chromium.org>
Commit-Queue: Mike Taylor <miketaylr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844801}
parent bdc683ae
......@@ -24,8 +24,23 @@
{
cookie: "test=2; Expires=Fri 01 Jan 2038 00:00:00 GMT, baz=qux",
expected: "test=2",
name: "Set cookie with expires value followed by comma"
}
name: "Set cookie with expires value followed by comma",
},
{
cookie: "test=3; Expires=Fri, 01 Jan 2038 00:00:00 GMT",
expected: "test=3",
name: "Set cookie with future expiration",
},
{
cookie: ["test=expired; Expires=Fri, 07 Aug 2007 08:04:19 GMT", "test=4; Expires=Fri, 07 Aug 2027 08:04:19 GMT"],
expected: "test=4",
name: "Set expired cookie along with valid cookie",
},
{
cookie: "test=5; expires=Thu, 10 Apr 1980 16:33:12 GMT",
expected: "",
name: "Don't set cookie with expires set to the past",
},
];
for (const test of expiresTests) {
......
......@@ -92,7 +92,68 @@
cookie: " test=== 13 ;foo;;; bar",
expected: "test=== 13",
name: "Set cookie with multiple '='s in its value, ignoring multiple invalid attributes, whitespace, and semicolons",
}
},
{
cookie: "test=14; version=1;",
expected: "test=14",
name: "Set cookie with (invalid) version=1 attribute",
},
{
cookie: "test=15; version=1000;",
expected: "test=15",
name: "Set cookie with (invalid) version=1000 attribute",
},
{
cookie: "test=16; customvalue='1000 or more';",
expected: "test=16",
name: "Set cookie ignoring anything after ; (which looks like an invalid attribute)",
},
{
cookie: "test=17; customvalue='1000 or more'",
expected: "test=17",
name: "Set cookie ignoring anything after ; (which looks like an invalid attribute, with no trailing semicolon)",
},
{
cookie: "test=18; foo=bar, a=b",
expected: "test=18",
name: "Ignore keys after semicolon",
},
{
cookie: "test=19;max-age=3600, c=d;path=/",
expected: "test=19",
name: "Ignore attributes after semicolon",
defaultPath: false,
},
{
cookie: ["testA=20", "=", "testb=20"],
expected: "testA=20; testb=20",
name: "Ignore `Set-Cookie: =`",
},
{
cookie: ["test=21", ""],
expected: "test=21",
name: "Ignore empty cookie string",
},
{
cookie: ["test22", "="],
expected: "test22",
name: "Ignore `Set-Cookie: =` with other `Set-Cookie` headers",
},
{
cookie: ["testA23", "; testB23"],
expected: "testA23",
name: "Ignore name- and value-less `Set-Cookie: ; bar`",
},
{
cookie: ["test24", " "],
expected: "test24",
name: "Ignore name- and value-less `Set-Cookie: `",
},
{
cookie: ["test25", "\t"],
expected: "test25",
name: "Ignore name- and value-less `Set-Cookie: \\t`",
},
];
for (const test of invalidAttributeTests) {
......
......@@ -21,6 +21,51 @@
expected: "test=1",
name: "Ignore max-age attribute with invalid non-zero-digit (containing a comma)",
},
{
cookie: "test=2; max-age=10000",
expected: "test=2",
name: "Set cookie with age",
},
{
cookie: "test=3; max-age=0",
expected: "",
name: "Set no cookie with max-age=0",
},
{
cookie: "test=4; max-age=-1",
expected: "",
name: "Set no cookie with max-age=-1",
},
{
cookie: "test=5; max-age=-20",
expected: "",
name: "Set no cookie with max-age=-20",
},
{
cookie: ["testA=6; max-age=60", "testB=6; max-age=60"],
expected: "testA=6; testB=6",
name: "Set multiple cookies with max-age attribute",
},
{
cookie: ["testA=7; max-age=60", "testB=7; max-age=60", "testA=differentvalue; max-age=0"],
expected: "testB=7",
name: "Expire later cookie with same name and max-age=0",
},
{
cookie: ["testA=8; max-age=60", "testB=8; max-age=60", "testA=differentvalue; max-age=0", "testC=8; max-age=0"],
expected: "testB=8",
name: "Expire later cookie with same name and max-age=0, and don't set cookie with max-age=0",
},
{
cookie: ['test="9! = foo;bar\";" parser; max-age=6', "test9; max-age=2.63,"],
expected: 'test="9! = foo; test9',
name: "Set mulitiple cookies with valid max-age values",
},
{
cookie: ["test=10; max-age=0", "test10; max-age=0"],
expected: "",
name: "Don't set multiple cookies with max-age=0",
},
];
for (const test of maxAgeTests) {
......
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Tests basic cookie setting functionality</title>
<meta name=help href="https://tools.ietf.org/html/rfc6265#page-8">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
const TEST_CASES = [
{file: "0001", name: "Set cookie."},
{file: "0002", name: "Set cookie with future expiration."},
{file: "0003", name: "Set expired cookie along with valid cookie."},
{file: "0004", name: "Set nameless cookie."},
{file: "0005", name: "Set cookie with age."},
{file: "0006", name: "Set no cookie with max-age=0."},
{file: "0007", name: "Set cookie with version=1."},
{file: "0008", name: "Set cookie with version=1000."},
{file: "0009", name: "Set cookie with custom value."},
// TODO(fhorschig): Could 0010 break when run on a HTTPS try server?
{file: "0010", name: "Dont accept 'secure' cookies over http."},
{file: "0011", name: "Ignore separators in cookie values."},
{file: "0012", name: "Ignore values with separators and without ';'."},
{file: "0013", name: "Use last value for cookies with identical keys."},
{file: "0014", name: "Keep alphabetic key order."},
{file: "0015", name: "Keep alphabetic single-char key order."},
{file: "0016", name: "Keep non-alphabetic key order."},
{file: "0017", name: "Keep order if comma-separated."},
{file: "0018", name: "Ignore keys after semicolon."},
{file: "0019", name: "Ignore attributes after semicolon."},
{file: "0020", name: "Ignore `Set-Cookie: =`."},
{file: "0021", name: "Set nameless cookie, given `Set-Cookie: =x`"},
{file: "0022", name: "Set valueless cookie, given `Set-Cookie: x=`"},
{file: "0023", name: "Ignore empty cookie string."},
{file: "0024", name: "Ignore `Set-Cookie: =` with other `Set-Cookie` headers."},
{file: "0025", name: "Ignore name- and value-less `Set-Cookie: ; bar`."},
{file: "0026", name: "Ignore name- and value-less `Set-Cookie: `."},
{file: "0027", name: "Overwrite nameless cookie."},
{file: "0028", name: "Ignore name- and value-less `Set-Cookie: \t"},
];
for (const i in TEST_CASES) {
const t = TEST_CASES[i];
promise_test(createCookieTest(t.file),
t.file + " - " + t.name);
}
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>Tests basic cookie setting functionality</title>
<meta name=help href="https://tools.ietf.org/html/rfc6265#page-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/cookie-http-state-template.js"></script>
</head>
<body>
<div id="log"></div>
<div id="iframes"></div>
<script>
setup({ explicit_timeout: true });
const TEST_CASES = [
{file: "mozilla0001", name: "mozilla0001"},
{file: "mozilla0002", name: "mozilla0002"},
{file: "mozilla0003", name: "mozilla0003"},
{file: "mozilla0004", name: "mozilla0004"},
{file: "mozilla0005", name: "mozilla0005"},
{file: "mozilla0006", name: "mozilla0006"},
{file: "mozilla0007", name: "mozilla0007"},
{file: "mozilla0008", name: "mozilla0008"},
{file: "mozilla0009", name: "mozilla0009"},
{file: "mozilla0010", name: "mozilla0010"},
{file: "mozilla0011", name: "mozilla0011"},
{file: "mozilla0012", name: "mozilla0012"},
{file: "mozilla0013", name: "mozilla0013"},
{file: "mozilla0014", name: "mozilla0014"},
{file: "mozilla0015", name: "mozilla0015"},
{file: "mozilla0016", name: "mozilla0016"},
{file: "mozilla0017", name: "mozilla0017"},
];
for (const i in TEST_CASES) {
const t = TEST_CASES[i];
promise_test(createCookieTest(t.file),
t.file + " - " + t.name);
}
</script>
</body>
</html>
Set-Cookie: foo=bar; Expires=Fri, 07 Aug 2007 08:04:19 GMT
Set-Cookie: foo2=bar2; Expires=Fri, 07 Aug 2027 08:04:19 GMT
Set-Cookie: foo=bar; max-age=60
Set-Cookie: foo1=bar; max-age=60
Set-Cookie: foo=differentvalue; max-age=0
Set-Cookie: foo=bar; max-age=60
Set-Cookie: foo1=bar; max-age=60
Set-Cookie: foo=differentvalue; max-age=0
Set-Cookie: foo2=evendifferentvalue; max-age=0
Set-Cookie: test="fubar! = foo;bar\";" parser; max-age=6
Set-Cookie: five; max-age=2.63,
Set-Cookie: six
Set-Cookie: seven
Set-Cookie: =eight
Set-Cookie: test=six
......@@ -79,6 +79,56 @@
expected: "test11",
name: "Return the most recent nameless cookie",
},
{
cookie: ["test11", "test11a"],
expected: "test11a",
name: "Return the most recent nameless cookie, without leading =",
},
{
cookie: ["test11", "test11a", "=test11b"],
expected: "test11b",
name: "Return the most recent nameless cookie, even if preceded by =",
},
{
cookie: ["test11", "test11a", "=test11b", "test=11c"],
expected: "test11b; test=11c",
name: "Return the most recent nameless cookie, even if preceded by =, in addition to other valid cookie",
},
{
cookie: ["test12=11", "test12=12"],
expected: "test12=12",
name: "Use last value for cookies with identical names",
},
{
cookie: ["testA=13", "testB=13"],
expected: "testA=13; testB=13",
name: "Keep first-in, first-out name order",
},
{
cookie: ["a=test14", "z=test14"],
expected: "a=test14; z=test14",
name: "Keep first-in, first-out single-char name order",
},
{
cookie: ["z=test15", "a=test15"],
expected: "z=test15; a=test15",
name: "Keep non-alphabetic first-in, first-out name order",
},
{
cookie: "z=test16, a=test16",
expected: "z=test16, a=test16",
name: "Keep first-in, first-out order if comma-separated",
},
{
cookie: ["testA=16", "=test16", "testB=16"],
expected: "testA=16; test16; testB=16",
name: "Set nameless cookie, given `Set-Cookie: =test16`",
},
{
cookie: ["test17a", "test17b"],
expected: "test17b",
name: "Overwrite nameless cookie",
},
{
cookie: "=",
expected: "",
......
......@@ -126,6 +126,11 @@
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=`",
},
];
for (const test of valueTests) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment