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

Rewrite wpt/cookies/http-state/{name,value}-tests.html

For the history books, here's a mapping between the old ported tests
and the new tests, where test=N roughly corresponds to a string name or value:

in wpt/cookies/name/name.html
name0001 through name0016, name0019, name0020 => the for of block with the description "`Name is set as expected for ${name}=test`"
name0017 => test=2
name0018 => test=3
name0021 => test=5
name0022 => test=4
name0023 => test=6
name0024 => test=7
name0025 => test=2b
name0026. Not ported. This is covered already. A lot.
name0028 => test2c
name0029 => test with name "Ignore cookie with empty name and empty value"
name0030 => test=8
name0031 => test=9
name0032 => "test\"10
name0033 => test=11

in wpt/cookies/value/value.html
name0027 => test=15
value0001 => test=16
value0002 => test=17
value0003 => test=18
value0004 => test=19
value0005 => test="20=20"
value0006 => test=21

Bug: 1159861
Change-Id: Ica8879a906f13b1464661af8bf1c5f5271a8f54f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615668
Commit-Queue: Mike Taylor <miketaylr@chromium.org>
Auto-Submit: Mike Taylor <miketaylr@chromium.org>
Reviewed-by: default avatarLily Chen <chlily@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841251}
parent c758efa2
<!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: "name0001", name: "name0001"},
{file: "name0002", name: "name0002"},
{file: "name0003", name: "name0003"},
{file: "name0004", name: "name0004"},
{file: "name0005", name: "name0005"},
{file: "name0006", name: "name0006"},
{file: "name0007", name: "name0007"},
{file: "name0008", name: "name0008"},
{file: "name0009", name: "name0009"},
{file: "name0010", name: "name0010"},
{file: "name0011", name: "name0011"},
{file: "name0012", name: "name0012"},
{file: "name0013", name: "name0013"},
{file: "name0014", name: "name0014"},
{file: "name0015", name: "name0015"},
{file: "name0016", name: "name0016"},
{file: "name0017", name: "name0017"},
{file: "name0018", name: "name0018"},
{file: "name0019", name: "name0019"},
{file: "name0020", name: "name0020"},
{file: "name0021", name: "name0021"},
{file: "name0022", name: "name0022"},
{file: "name0023", name: "name0023"},
{file: "name0024", name: "name0024"},
{file: "name0025", name: "name0025"},
{file: "name0026", name: "name0026"},
{file: "name0027", name: "name0027"},
{file: "name0028", name: "name0028"},
{file: "name0029", name: "name0029"},
{file: "name0030", name: "name0030"},
{file: "name0031", name: "name0031"},
{file: "name0032", name: "name0032"},
{file: "name0033", name: "name0033"},
];
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: "value0001", name: "value0001"},
{file: "value0002", name: "value0002"},
{file: "value0003", name: "value0003"},
{file: "value0004", name: "value0004"},
{file: "value0005", name: "value0005"},
{file: "value0006", name: "value0006"},
];
for (const i in TEST_CASES) {
const t = TEST_CASES[i];
promise_test(createCookieTest(t.file),
t.file + " - " + t.name);
}
</script>
</body>
</html>
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
<body> <body>
<div id=log></div> <div id=log></div>
<script> <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.
const nameTests = [ const nameTests = [
{ {
cookie: "test1=; path = /", cookie: "test1=; path = /",
...@@ -22,17 +19,89 @@ ...@@ -22,17 +19,89 @@
name: "Set valueless cookie to its name with empty value", name: "Set valueless cookie to its name with empty value",
defaultValue: false, defaultValue: false,
}, },
{
cookie: "=test=2",
expected: "test=2",
name: "Set a nameless cookie (that has an = in its value)",
},
{
cookie: "===test=2b",
expected: "==test=2b",
name: "Set a nameless cookie (that has multiple ='s in its value)",
},
{
cookie: "=test2c",
expected: "test2c",
name: "Set a nameless cookie",
},
{
cookie: "test =3",
expected: "test=3",
name: "Remove trailing WSP characters from the name string",
},
{
cookie: " test=4",
expected: "test=4",
name: "Remove leading WSP characters from the name string",
},
{
cookie: ['"test=5"=test', '"test=5'],
expected: '"test=5',
name: "Only return the new cookie (with the same name)",
},
{
cookie: "test6;cool=dude",
expected: "test6",
name: "Ignore invalid attributes after nameless cookie",
},
{
cookie: "$Version=1; test=7",
expected: "$Version=1",
name: "Ignore invalid attributes after valid name (that looks like Cookie2 Version attribute)",
},
{
cookie: "test test=8",
expected: "test test=8",
name: "Set a cookie that has whitespace in its name",
},
{
cookie: '"test9;test"=9',
expected: '"test9',
name: "Set a nameless cookie ignoring characters after first ;",
},
{
cookie: '"test\"10;baz"=qux',
expected: '"test\"10',
name: "Set a nameless cookie ignoring characters after first ; (2)",
},
{
cookie: ["=test=11", "test11"],
expected: "test11",
name: "Return the most recent nameless cookie",
},
{
cookie: "=",
expected: "",
name: "Ignore cookie with empty name and empty value",
},
{ {
cookie: "", cookie: "",
expected: "", expected: "",
name: "Ignore cookie with no name or value", name: "Ignore cookie with no name or value",
}, },
]; ];
for (const test of nameTests) { for (const test of nameTests) {
httpCookieTest(test.cookie, test.expected, test.name); httpCookieTest(test.cookie, test.expected, test.name);
} }
for (const name of ["a", "1", "$", "!a", "@a", "#a", "$a", "%a",
"^a", "&a", "*a", "(a", ")a", "-a", "_a", "+",
'"a', '"a=b"'
]) {
const cookie = `${name}=test`;
httpCookieTest(cookie, cookie, `Name is set as expected for ${name}=test`);
}
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -91,6 +91,41 @@ ...@@ -91,6 +91,41 @@
expected: 'test="14 "', expected: 'test="14 "',
name: "Set cookie ignoring whitespace after value endquote", 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",
},
]; ];
for (const test of valueTests) { 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