From 26cd98a11ee3ca3a64e3f9d0ff11301cf0e30f8e Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 14 Oct 2021 06:29:59 -0700 Subject: [PATCH] Update some domain tests to follow latest 6265bis update. Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. https://github.com/httpwg/http-extensions/pull/1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See https://github.com/httpwg/http-extensions/issues/1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler Commit-Queue: Mike Taylor Cr-Commit-Position: refs/heads/main@{#931471} --- .../resources/domain-child.sub.html | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/cookies/attributes/resources/domain-child.sub.html b/cookies/attributes/resources/domain-child.sub.html index 9eab6d012acdbd..ae377c26941ffd 100644 --- a/cookies/attributes/resources/domain-child.sub.html +++ b/cookies/attributes/resources/domain-child.sub.html @@ -310,8 +310,8 @@ }, { cookie: `test=42; domain=${www1Host}; domain=`, - expected: "", - name: "No cookie returned for domain mismatch (with domain mismatch as first domain attribute and second a bare attribute)", + expected: "test=42", + name: "Cookie returned for bare domain attribute following mismatched domain attribute (after redirect to same-origin page).", location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, }, { @@ -332,6 +332,60 @@ name: "Cookies with same name, path, and domain (differing only in leading '.') overwrite each other ('.' first)", location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, }, + { + cookie: `test=46; domain=.`, + expected: "", + name: "No cookie returned for domain with single dot ('.') value.", + location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: `test=46b; domain=.`, + expected: "", + name: "No cookie returned with single dot ('.') domain value (aka host-cookie) on non-host subdomain redirect", + location: `http://${www2wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: `test=46c; domain=.; domain=${host}`, + expected: "test=46c", + name: "Return cookie with valid domain after domain with single dot ('.') value.", + location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=47", `test=47b; domain=${host}`,`test=47b; domain=${www1Host}; domain=`], + expected: "test=47b; test=47b", + name: "Empty domain treated as host cookie 1", + location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=48", `test=48b; domain=${host}`,`test=48b; domain=${host}; domain=`], + expected: "test=48b; test=48b", + name: "Empty domain treated as host cookie 2", + location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=49", `test=49b; domain=${host}`,`test=49b; domain=`], + expected: "test=49b; test=49b", + name: "Empty domain treated as host cookie 3", + location: `http://${wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=50", `test=50b; domain=${host}`,`test=50b; domain=${www1Host}; domain=`], + expected: "test=50b", + name: "No host cookies returned for host cookies after non-host redirect 1", + location: `http://${www2wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=51", `test=51b; domain=${host}`,`test=51b; domain=${host}; domain=`], + expected: "test=51b", + name: "No host cookies returned for host cookies after non-host redirect 2", + location: `http://${www2wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, + { + cookie: ["test=52", `test=52b; domain=${host}`,`test=52b; domain=`], + expected: "test=52b", + name: "No host cookies returned for host cookies after non-host redirect 3", + location: `http://${www2wwwHost}:${port}/cookies/attributes/resources/path.html`, + }, ]; for (const test of domainTests) {