From c500f4b4ac250ffa441c13cb670b548f7b50fa1b Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 7 Jan 2021 09:53:52 +0000 Subject: [PATCH] Bug 1684082 [wpt PR 27002] - Re-write wpt/cookies/http-state/ path tests, a=testonly Automatic update from web-platform-tests Re-write wpt/cookies/http-state/ path tests This also adds support for sending multiple Set-Cookie strings to the test infrastructure. Notes for history books (and reviewers) legacy test => ported test cookie name map (ignoring Path) path0001 => (path.html) testA=11; testB=11 path0002 => (path.html) testB=12; testA=12 path0003 => (path.html) testA=13; testB=13 path0004 => (path.html) testB=14; testA=14 path0005 => (path.html) test=15 path0006 => (path.html) test=16 path0007 => (path-redirect.html) test=1 path0008 => (path-redirect.html) test=9 path0009 => (path-redirect.html) test=10 (can be improved) path0010 => (path-redirect.html) test=2 path0011 => (path-redirect.html) test=11 path0012 => (path-redirect.html) test=12 path0013 => (path-redirect.html) test=13 path0014 => (path-redirect.html) test=17 path0015 => not ported, see note below. path0016 => (path-redirect.html) test=3 path0017 => (path-redirect.html) test=4 path0018 => (path-redirect.html) test=14 (can be improved) path0019, dupe of (path.html) test1, not ported path0020, dupe of (path.html) test2, not ported path0021, dupe of (path.html) test3, not ported path0022 => (path.html) test=17 path0023 => (path.html) test=18 path0024 => (path-redirect.html) test=15 path0025 => (path-redirect.html) test=16 path0026 => (path-redirect.html) test=5 path0027 => (path-redirect.html) test=6 path0028 => (path-redirect.html) test=7a disabled-path0029 (path-redirect.html) test=7b path0029 => (path.html) test=19 path0030 => (path.html) test=21 path0031 => path.html test=20 path0032 => (path-redirect.html) test=8a; test=8b Notes: For path0027 and path0028, I'm swapping the assertions (to expected a cookie) because Firefox, Safari and Chrome do this. path0015 isn't possible to port with current WPT infra (as there are no dynamic handlers, and '/' is treated as a directory "mount"). https://bugs.chromium.org/p/chromium/issues/detail?id=1161544 is filed to track that work, and a few improvements to better capture the intents of path0009 and path0018. Bug: 1159925 Change-Id: I37da066e60d79e3f99e01a7d6ccbc408f447e01b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598139 Commit-Queue: Mike Taylor Reviewed-by: Lily Chen Cr-Commit-Position: refs/heads/master@{#839497} -- wpt-commits: 821a1ef63f08a7329175513b6c2eb00bb8b0152e wpt-pr: 27002 --- .../cookies/attributes/path-redirect.html | 126 ++++++++++++++++++ .../tests/cookies/attributes/path.html | 79 +++++++++-- .../resources/path-redirect-shared.js | 7 + .../cookies/attributes/resources/path.html | 11 ++ .../attributes/resources/path/one.html | 11 ++ .../attributes/resources/path/three.html | 11 ++ .../attributes/resources/path/two.html | 11 ++ .../attributes/resources/pathfakeout.html | 11 ++ .../attributes/resources/pathfakeout/one.html | 11 ++ .../tests/cookies/http-state/path-tests.html | 63 --------- .../test-files/disabled-path0029-expected | 1 - .../test-files/disabled-path0029-test | 2 - .../resources/test-files/path0001-expected | 1 - .../resources/test-files/path0001-test | 2 - .../resources/test-files/path0002-expected | 1 - .../resources/test-files/path0002-test | 2 - .../resources/test-files/path0003-expected | 1 - .../resources/test-files/path0003-test | 2 - .../resources/test-files/path0004-expected | 1 - .../resources/test-files/path0004-test | 2 - .../resources/test-files/path0005-expected | 0 .../resources/test-files/path0005-test | 1 - .../resources/test-files/path0006-expected | 1 - .../resources/test-files/path0006-test | 2 - .../resources/test-files/path0007-expected | 1 - .../resources/test-files/path0007-test | 2 - .../resources/test-files/path0008-expected | 0 .../resources/test-files/path0008-test | 2 - .../resources/test-files/path0009-expected | 0 .../resources/test-files/path0009-test | 2 - .../resources/test-files/path0010-expected | 1 - .../resources/test-files/path0010-test | 2 - .../resources/test-files/path0011-expected | 0 .../resources/test-files/path0011-test | 2 - .../resources/test-files/path0012-expected | 0 .../resources/test-files/path0012-test | 2 - .../resources/test-files/path0013-expected | 0 .../resources/test-files/path0013-test | 2 - .../resources/test-files/path0014-expected | 0 .../resources/test-files/path0014-test | 2 - .../resources/test-files/path0015-expected | 1 - .../resources/test-files/path0015-test | 2 - .../resources/test-files/path0016-expected | 1 - .../resources/test-files/path0016-test | 2 - .../resources/test-files/path0017-expected | 1 - .../resources/test-files/path0017-test | 2 - .../resources/test-files/path0018-expected | 0 .../resources/test-files/path0018-test | 2 - .../resources/test-files/path0019-expected | 1 - .../resources/test-files/path0019-test | 1 - .../resources/test-files/path0020-expected | 1 - .../resources/test-files/path0020-test | 1 - .../resources/test-files/path0021-expected | 1 - .../resources/test-files/path0021-test | 1 - .../resources/test-files/path0022-expected | 1 - .../resources/test-files/path0022-test | 1 - .../resources/test-files/path0023-expected | 0 .../resources/test-files/path0023-test | 1 - .../resources/test-files/path0024-expected | 0 .../resources/test-files/path0024-test | 2 - .../resources/test-files/path0025-expected | 0 .../resources/test-files/path0025-test | 2 - .../resources/test-files/path0026-expected | 1 - .../resources/test-files/path0026-test | 2 - .../resources/test-files/path0027-expected | 1 - .../resources/test-files/path0027-test | 2 - .../resources/test-files/path0028-expected | 0 .../resources/test-files/path0028-test | 2 - .../resources/test-files/path0029-expected | 1 - .../resources/test-files/path0029-test | 2 - .../resources/test-files/path0030-expected | 1 - .../resources/test-files/path0030-test | 1 - .../resources/test-files/path0031-expected | 0 .../resources/test-files/path0031-test | 1 - .../resources/test-files/path0032-expected | 1 - .../resources/test-files/path0032-test | 3 - .../tests/cookies/resources/cookie-test.js | 56 +++++++- .../tests/cookies/resources/cookie.py | 35 ++++- 78 files changed, 353 insertions(+), 158 deletions(-) create mode 100644 testing/web-platform/tests/cookies/attributes/path-redirect.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/path-redirect-shared.js create mode 100644 testing/web-platform/tests/cookies/attributes/resources/path.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/path/one.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/path/three.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/path/two.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/pathfakeout.html create mode 100644 testing/web-platform/tests/cookies/attributes/resources/pathfakeout/one.html delete mode 100644 testing/web-platform/tests/cookies/http-state/path-tests.html delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-test delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-expected delete mode 100644 testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-test diff --git a/testing/web-platform/tests/cookies/attributes/path-redirect.html b/testing/web-platform/tests/cookies/attributes/path-redirect.html new file mode 100644 index 000000000000..8c4d587cd46b --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/path-redirect.html @@ -0,0 +1,126 @@ + + + + + Test cookie path attribute parsing + + + + + + + + + + diff --git a/testing/web-platform/tests/cookies/attributes/path.html b/testing/web-platform/tests/cookies/attributes/path.html index c201aa170b83..2d5cfe74f174 100644 --- a/testing/web-platform/tests/cookies/attributes/path.html +++ b/testing/web-platform/tests/cookies/attributes/path.html @@ -26,48 +26,111 @@ cookie: "test=3; Path=/", expected: "test=3", name: "Set cookie for Path=/", - defaultPath: false + defaultPath: false, }, { cookie: "test=4; Path=/qux", expected: "", name: "No cookie returned for mismatched path", - defaultPath: false + defaultPath: false, }, { cookie: "test=5; Path =/qux", expected: "", name: "No cookie returned for path space equals mismatched path", - defaultPath: false + defaultPath: false, }, { cookie: "test=6; Path= /qux", expected: "", name: "No cookie returned for path equals space mismatched path", - defaultPath: false + defaultPath: false, }, { cookie: "test=7; Path=/qux ; taz", expected: "", name: "No cookie returned for mismatched path and attribute", - defaultPath: false + defaultPath: false, }, { cookie: "test=8; Path=/qux; Path=/", expected: "test=8", - name: "Set cookie for mismatched and root path" + name: "Set cookie for mismatched and root path", }, { cookie: "test=9; Path=/; Path=/qux", expected: "", name: "No cookie returned for root and mismatched path", - defaultPath: false + defaultPath: false, }, { cookie: "test=10; Path=/lol; Path=/qux", expected: "", name: "No cookie returned for multiple mismatched paths", - defaultPath: false + defaultPath: false, + }, + { + cookie: ["testA=11; path=/", "testB=11; path=/cookies/attributes"], + expected: "testB=11; testA=11", + name: "Return 2 cookies sorted by matching path length (earlier name with shorter path set first)", + defaultPath: false, + }, + { + cookie: ["testB=12; path=/", "testA=12; path=/cookies/attributes"], + expected: "testA=12; testB=12", + name: "Return 2 cookies sorted by matching path length (later name with shorter path set first)", + defaultPath: false, + }, + { + cookie: ["testA=13; path=/cookies/attributes", "testB=13; path=/"], + expected: "testA=13; testB=13", + name: "Return 2 cookies sorted by matching path length (earlier name with longer path set first)", + defaultPath: false, + }, + { + cookie: ["testB=14; path=/cookies/attributes", "testA=14; path=/"], + expected: "testB=14; testA=14", + name: "Return 2 cookies sorted by matching path length (later name with longer path set first)", + defaultPath: false, + }, + { + cookie: ["test=15; path=/cookies/attributes/foo"], + expected: "", + name: "No cookie returned for partial path match", + defaultPath: false, + }, + { + cookie: ["test=16", "test=0; path=/cookies/attributes/foo"], + expected: "test=16", + name: "No cookie returned for partial path match, return cookie for default path", + }, + { + cookie: ["test=17; path= /"], + expected: "test=17", + name: "Return cookie for path= / (whitespace after equals)", + }, + { + cookie: ["test=18; path=/cookies/ATTRIBUTES"], + expected: "", + name: "No cookie returned for case mismatched path", + defaultPath: false, + }, + { + cookie: ["testA=19; path = /cookies/attributes", "testB=19; path = /book"], + expected: "testA=19", + name: "Return cookie A on path match, no cookie returned for path mismatch (plus whitespace)", + defaultPath: false, + }, + { + cookie: ["test=20; path=; path=/dog"], + expected: "", + name: "No cookie returned for mismatched path (after bare path=)", + defaultPath: false, + }, + { + cookie: ["test=21; path=/dog; path="], + expected: "test=21", + name: "Return cookie for bare path= (after mismatched path)", }, ]; diff --git a/testing/web-platform/tests/cookies/attributes/resources/path-redirect-shared.js b/testing/web-platform/tests/cookies/attributes/resources/path-redirect-shared.js new file mode 100644 index 000000000000..83a614117cd5 --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/path-redirect-shared.js @@ -0,0 +1,7 @@ +window.expireCookie = (cookie) => { + const cookies = Array.isArray(cookie) ? cookie : [cookie]; + for (let c of cookies) { + document.cookie = c += "; max-age=0"; + } +} +window.getCookies = () => document.cookie; \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/path.html b/testing/web-platform/tests/cookies/attributes/resources/path.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/path.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/path/one.html b/testing/web-platform/tests/cookies/attributes/resources/path/one.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/path/one.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/path/three.html b/testing/web-platform/tests/cookies/attributes/resources/path/three.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/path/three.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/path/two.html b/testing/web-platform/tests/cookies/attributes/resources/path/two.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/path/two.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/pathfakeout.html b/testing/web-platform/tests/cookies/attributes/resources/pathfakeout.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/pathfakeout.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/attributes/resources/pathfakeout/one.html b/testing/web-platform/tests/cookies/attributes/resources/pathfakeout/one.html new file mode 100644 index 000000000000..3c5af1cb205d --- /dev/null +++ b/testing/web-platform/tests/cookies/attributes/resources/pathfakeout/one.html @@ -0,0 +1,11 @@ + + + + + helper iframe for matching cookie path redirect tests + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/cookies/http-state/path-tests.html b/testing/web-platform/tests/cookies/http-state/path-tests.html deleted file mode 100644 index b76360e249c4..000000000000 --- a/testing/web-platform/tests/cookies/http-state/path-tests.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - Tests basic cookie setting functionality - - - - - - - - -
-
- - - diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-test deleted file mode 100644 index d7219d590c6f..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/disabled-path0029-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/bar -Location: /cookie-parser-result/f%6Fo/bar?disabled-path0029 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-expected deleted file mode 100644 index 785d0a2f5f78..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: x=y; a=b diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-test deleted file mode 100644 index ed81cb955f79..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0001-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: a=b; path=/ -Set-Cookie: x=y; path=/cookie-parser-result diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-expected deleted file mode 100644 index 2314ba0d4959..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: a=b; x=y diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-test deleted file mode 100644 index 224932851853..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0002-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: a=b; path=/cookie-parser-result -Set-Cookie: x=y; path=/ diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-expected deleted file mode 100644 index 2314ba0d4959..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: a=b; x=y diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-test deleted file mode 100644 index e4b5a4b25650..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0003-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: x=y; path=/ -Set-Cookie: a=b; path=/cookie-parser-result diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-expected deleted file mode 100644 index 785d0a2f5f78..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: x=y; a=b diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-test deleted file mode 100644 index a80ea6ec0158..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0004-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: x=y; path=/cookie-parser-result -Set-Cookie: a=b; path=/ diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-test deleted file mode 100644 index 6447c9164f9c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0005-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-test deleted file mode 100644 index 07ecf27b82b0..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0006-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar -Set-Cookie: foo=qux; path=/cookie-parser-result/foo diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-test deleted file mode 100644 index 66a54de7420a..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0007-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo -Location: /cookie-parser-result/foo?path0007 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-test deleted file mode 100644 index b10012d30960..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0008-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo -Location: /cookie-parser-result/bar?path0008 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-test deleted file mode 100644 index 874f21bad97d..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0009-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux -Location: /cookie-parser-result/foo?path0009 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-test deleted file mode 100644 index 0ea62fd5ec53..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0010-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux -Location: /cookie-parser-result/foo/qux?path0010 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-test deleted file mode 100644 index 35ea0620495b..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0011-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux -Location: /cookie-parser-result/bar/qux?path0011 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-test deleted file mode 100644 index 4c0577897bd9..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0012-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux -Location: /cookie-parser-result/foo/baz?path0012 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-test deleted file mode 100644 index d17b99b6b436..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0013-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux/ -Location: /cookie-parser-result/foo/baz?path0013 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-test deleted file mode 100644 index a953e707b3b2..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0014-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux/ -Location: /cookie-parser-result/foo/qux?path0014 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-test deleted file mode 100644 index 253a9bb2fcdd..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0015-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux/ -Location: /cookie-parser-result/foo/qux/?path0015 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-test deleted file mode 100644 index 433faeb91204..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0016-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/ -Location: /cookie-parser-result/foo/qux?path0016 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-test deleted file mode 100644 index a602d7ca6fe9..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0017-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/ -Location: /cookie-parser-result/foo//qux?path0017 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-test deleted file mode 100644 index 37040dac5d32..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0018-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/ -Location: /cookie-parser-result/fooqux?path0018 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-test deleted file mode 100644 index 6d498600a2f4..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0019-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-test deleted file mode 100644 index 603eded7ebd2..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0020-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path= diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-test deleted file mode 100644 index 4577c510a42d..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0021-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path=/ diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-test deleted file mode 100644 index 4aade9e0145d..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0022-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path= / diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-test deleted file mode 100644 index f14d683df977..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0023-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; Path=/cookie-PARSER-result diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-test deleted file mode 100644 index 18a71c875b4a..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0024-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux? -Location: /cookie-parser-result/foo/qux?path0024 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-test deleted file mode 100644 index b6c497b97158..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0025-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux# -Location: /cookie-parser-result/foo/qux?path0025 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-test deleted file mode 100644 index ffc3b7a54fa3..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0026-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/foo/qux; -Location: /cookie-parser-result/foo/qux?path0026 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-test deleted file mode 100644 index bd021f33e2c0..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0027-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path="/cookie-parser-result/foo/qux;" -Location: /cookie-parser-result/foo/qux?path0027 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-test deleted file mode 100644 index 3bcd6a5c657b..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0028-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result/f%6Fo/bar -Location: /cookie-parser-result/foo/bar?path0028 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-expected deleted file mode 100644 index 1022f64a2906..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: a=b diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-test deleted file mode 100644 index 17bd42f42125..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0029-test +++ /dev/null @@ -1,2 +0,0 @@ -Set-Cookie: a=b; path = /cookie-parser-result -Set-Cookie: x=y; path = /book diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-expected deleted file mode 100644 index b14d4f69b58c..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-test deleted file mode 100644 index e17a2d490b78..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0030-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path=/dog; path= diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-test deleted file mode 100644 index 3b24090b3384..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0031-test +++ /dev/null @@ -1 +0,0 @@ -Set-Cookie: foo=bar; path=; path=/dog diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-expected b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-expected deleted file mode 100644 index e7403c4aadce..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-expected +++ /dev/null @@ -1 +0,0 @@ -Cookie: foo=qux; foo=bar diff --git a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-test b/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-test deleted file mode 100644 index db6ceb2ea067..000000000000 --- a/testing/web-platform/tests/cookies/http-state/resources/test-files/path0032-test +++ /dev/null @@ -1,3 +0,0 @@ -Set-Cookie: foo=bar; path=/cookie-parser-result -Set-Cookie: foo=qux; path=/cookie-parser-result/ -Location: /cookie-parser-result/dog?path0032 diff --git a/testing/web-platform/tests/cookies/resources/cookie-test.js b/testing/web-platform/tests/cookies/resources/cookie-test.js index c0a03d78355a..56e958263d97 100644 --- a/testing/web-platform/tests/cookies/resources/cookie-test.js +++ b/testing/web-platform/tests/cookies/resources/cookie-test.js @@ -22,11 +22,38 @@ async function getDefaultPathCookies(path = '/cookies/resources') { }); } +// getRedirectedCookies is a helper method to get and delete cookies that +// were set from a Location header redirect. +async function getRedirectedCookies(location, cookie) { + return new Promise((resolve, reject) => { + try { + const iframe = document.createElement('iframe'); + iframe.style = 'display: none'; + iframe.src = `${location}`; + + iframe.addEventListener('load', (e) => { + const win = e.target.contentWindow; + const iframeCookies = win.getCookies(); + win.expireCookie(cookie); + resolve(iframeCookies); + }, {once: true}); + + document.documentElement.appendChild(iframe); + } catch (e) { + reject(e); + } + }); +} + // httpCookieTest sets a |cookie| (via HTTP), then asserts it was or was not set // via |expectedValue| (via the DOM). Then cleans it up (via HTTP). Most tests // do not set a Path attribute, so |defaultPath| defaults to true. +// +// |cookie| may be a single cookie string, or an array of cookie strings, where +// the order of the array items represents the order of the Set-Cookie headers +// sent by the server. function httpCookieTest(cookie, expectedValue, name, defaultPath = true) { - let encodedCookie = encodeURIComponent(cookie); + let encodedCookie = encodeURIComponent(JSON.stringify(cookie)); return promise_test( async t => { return fetch(`/cookies/resources/cookie.py?set=${encodedCookie}`) @@ -53,3 +80,30 @@ function httpCookieTest(cookie, expectedValue, name, defaultPath = true) { })}, name); } + +// This is a variation on httpCookieTest, where a redirect happens via +// the Location header and we check to see if cookies are sent via +// getRedirectedCookies +function httpRedirectCookieTest(cookie, expectedValue, name, location) { + const encodedCookie = encodeURIComponent(JSON.stringify(cookie)); + const encodedLocation = encodeURIComponent(location); + const setParams = `?set=${encodedCookie}&location=${encodedLocation}`; + return promise_test( + async t => { + return fetch(`/cookies/resources/cookie.py${setParams}`) + .then(async () => { + // for the tests where a redirect happens, we need to head + // to that URI to get the cookies (and then delete them there) + const cookies = await getRedirectedCookies(location, cookie); + if (Boolean(expectedValue)) { + assert_equals(cookies, expectedValue, + 'The cookie was set as expected.'); + } else { + assert_equals(cookies, expectedValue, 'The cookie was rejected.'); + } + }).then(() => { + return fetch(`/cookies/resources/cookie.py?drop=${encodedCookie}`); + }) + }, + name); +} diff --git a/testing/web-platform/tests/cookies/resources/cookie.py b/testing/web-platform/tests/cookies/resources/cookie.py index 63eedf0b01ef..16efcc04aeb9 100644 --- a/testing/web-platform/tests/cookies/resources/cookie.py +++ b/testing/web-platform/tests/cookies/resources/cookie.py @@ -1,14 +1,26 @@ +import json + from cookies.resources.helpers import setNoCacheAndCORSHeaders +from wptserve.utils import isomorphic_decode from wptserve.utils import isomorphic_encode +def set_cookie(headers, cookie_string, drop=False): + """Helper method to add a Set-Cookie header""" + if drop: + cookie_string = cookie_string.encode('utf-8') + b'; max-age=0' + headers.append((b'Set-Cookie', isomorphic_encode(cookie_string))) + def main(request, response): """Set or drop a cookie via GET params. Usage: `/cookie.py?set={cookie}` or `/cookie.py?drop={cookie}` - The passed-in cookie string should be encoded via encodeURIComponent, - otherwise `parse_qsl` will split on any semicolons (used by the Request.GET - property getter). + The passed-in cookie string should be stringified via JSON.stringify() (in + the case of multiple cookie headers sent in an array) and encoded via + encodeURIComponent, otherwise `parse_qsl` will split on any semicolons + (used by the Request.GET property getter). Note that values returned by + Request.GET will decode any percent-encoded sequences sent in a GET param + (which may or may not be surprising depending on what you're doing). Note: here we don't use Response.delete_cookie() or similar other methods in this resources directory because there are edge cases that are impossible @@ -21,13 +33,22 @@ def main(request, response): try: if b'drop' in request.GET: cookie = request.GET[b'drop'] - cookie += b'; max-age=0' + cookie = json.loads(cookie) + cookies = cookie if isinstance(cookie, list) else [cookie] + for c in cookies: + set_cookie(headers, c, drop=True) if b'set' in request.GET: - cookie = request.GET[b'set'] + cookie = isomorphic_decode(request.GET[b'set']) + cookie = json.loads(cookie) + cookies = cookie if isinstance(cookie, list) else [cookie] + for c in cookies: + set_cookie(headers, c) + + if b'location' in request.GET: + headers.append((b'Location', request.GET[b'location'])) + return 302, headers, b'{"redirect": true}' - headers.append((b'Set-Cookie', isomorphic_encode(cookie))) return headers, b'{"success": true}' except Exception as e: return 500, headers, bytes({'error': '{}'.format(e)}) -