summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/xhr/cookies.http.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 20:56:19 +0000
commit0b6210cd37b68b94252cb798598b12974a20e1c1 (patch)
treee371686554a877842d95aa94f100bee552ff2a8e /test/wpt/tests/xhr/cookies.http.html
parentInitial commit. (diff)
downloadnode-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz
node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/wpt/tests/xhr/cookies.http.html')
-rw-r--r--test/wpt/tests/xhr/cookies.http.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/wpt/tests/xhr/cookies.http.html b/test/wpt/tests/xhr/cookies.http.html
new file mode 100644
index 0000000..0ab71dd
--- /dev/null
+++ b/test/wpt/tests/xhr/cookies.http.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<p>Derived from historical testcase for <a href="http://bugs.webkit.org/show_bug.cgi?id=3420">WebKit bug 3420</a>:
+XMLHttpRequest does not handle set-cookie headers.</p>
+
+<script>
+ function clearCookies()
+ {
+ return new Promise(resolve => {
+ var req = new XMLHttpRequest;
+ req.open("POST", "resources/get-set-cookie.py?clear=1");
+ req.onload = () => resolve();
+ req.send("");
+ });
+ }
+ function getAndSetCookies()
+ {
+ return new Promise(resolve => {
+ var req = new XMLHttpRequest;
+ req.open("POST", "resources/get-set-cookie.py");
+ req.onload = () => resolve(req.responseText);
+ req.send("");
+ });
+ }
+
+ promise_test(async function(t) {
+ await clearCookies();
+ var response = await getAndSetCookies();
+ assert_equals(response.match(/.*WK-test=1.*/), null,
+ "The cookie must not be present after clear. clearCookies() failed. Must be a bug in the test!");
+ var response = await getAndSetCookies();
+ assert_equals(response.match(/.*WK-test-secure=1.*/), null,
+ "a secure cookie was sent via HTTP");
+ assert_regexp_match(response, /.*WK-test=1.*/, "an insecure cookie was sent");
+ await clearCookies();
+ }, "Basic non-cross-site cookie handling in XHR");
+</script>
+</html>