From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../web-platform/tests/websockets/cookies/001.html | 28 +++++++++++ .../web-platform/tests/websockets/cookies/002.html | 26 ++++++++++ .../web-platform/tests/websockets/cookies/003.html | 34 +++++++++++++ .../web-platform/tests/websockets/cookies/004.html | 31 ++++++++++++ .../web-platform/tests/websockets/cookies/005.html | 35 +++++++++++++ .../web-platform/tests/websockets/cookies/006.html | 35 +++++++++++++ .../web-platform/tests/websockets/cookies/007.html | 36 ++++++++++++++ .../tests/websockets/cookies/support/set-cookie.py | 7 +++ .../support/websocket-cookies-helper.sub.js | 57 ++++++++++++++++++++++ .../cookies/third-party-cookie-accepted.https.html | 25 ++++++++++ 10 files changed, 314 insertions(+) create mode 100644 testing/web-platform/tests/websockets/cookies/001.html create mode 100644 testing/web-platform/tests/websockets/cookies/002.html create mode 100644 testing/web-platform/tests/websockets/cookies/003.html create mode 100644 testing/web-platform/tests/websockets/cookies/004.html create mode 100644 testing/web-platform/tests/websockets/cookies/005.html create mode 100644 testing/web-platform/tests/websockets/cookies/006.html create mode 100644 testing/web-platform/tests/websockets/cookies/007.html create mode 100644 testing/web-platform/tests/websockets/cookies/support/set-cookie.py create mode 100644 testing/web-platform/tests/websockets/cookies/support/websocket-cookies-helper.sub.js create mode 100644 testing/web-platform/tests/websockets/cookies/third-party-cookie-accepted.https.html (limited to 'testing/web-platform/tests/websockets/cookies') diff --git a/testing/web-platform/tests/websockets/cookies/001.html b/testing/web-platform/tests/websockets/cookies/001.html new file mode 100644 index 0000000000..c43947fa87 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/001.html @@ -0,0 +1,28 @@ + +WebSockets: Cookie in request + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/002.html b/testing/web-platform/tests/websockets/cookies/002.html new file mode 100644 index 0000000000..1a5e03e335 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/002.html @@ -0,0 +1,26 @@ + +WebSockets: Set-Cookie in response + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/003.html b/testing/web-platform/tests/websockets/cookies/003.html new file mode 100644 index 0000000000..2af4735402 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/003.html @@ -0,0 +1,34 @@ + +WebSockets: sending HttpOnly cookies in ws request + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/004.html b/testing/web-platform/tests/websockets/cookies/004.html new file mode 100644 index 0000000000..efc3a9f84d --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/004.html @@ -0,0 +1,31 @@ + +WebSockets: setting HttpOnly cookies in ws response, checking document.cookie + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/005.html b/testing/web-platform/tests/websockets/cookies/005.html new file mode 100644 index 0000000000..8940d95127 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/005.html @@ -0,0 +1,35 @@ + +WebSockets: setting HttpOnly cookies in ws response, checking ws request + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/006.html b/testing/web-platform/tests/websockets/cookies/006.html new file mode 100644 index 0000000000..3c74363a43 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/006.html @@ -0,0 +1,35 @@ + +WebSockets: setting Secure cookie with document.cookie, checking ws request + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/007.html b/testing/web-platform/tests/websockets/cookies/007.html new file mode 100644 index 0000000000..2c214a1dbb --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/007.html @@ -0,0 +1,36 @@ + +WebSockets: when to process set-cookie fields in ws response + + + + + + + +
+ diff --git a/testing/web-platform/tests/websockets/cookies/support/set-cookie.py b/testing/web-platform/tests/websockets/cookies/support/set-cookie.py new file mode 100644 index 0000000000..71cd8bca60 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/support/set-cookie.py @@ -0,0 +1,7 @@ +from urllib.parse import unquote + +from wptserve.utils import isomorphic_encode + +def main(request, response): + response.headers.set(b'Set-Cookie', isomorphic_encode(unquote(request.url_parts.query))) + return [(b"Content-Type", b"text/plain")], b"" diff --git a/testing/web-platform/tests/websockets/cookies/support/websocket-cookies-helper.sub.js b/testing/web-platform/tests/websockets/cookies/support/websocket-cookies-helper.sub.js new file mode 100644 index 0000000000..a7fae2551e --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/support/websocket-cookies-helper.sub.js @@ -0,0 +1,57 @@ +// Set up global variables. +(_ => { + var HOST = '{{host}}'; + var CROSS_ORIGIN_HOST = '{{hosts[alt][]}}'; + var WSS_PORT = ':{{ports[wss][0]}}'; + var HTTPS_PORT = ':{{ports[https][0]}}'; + + window.WSS_ORIGIN = 'wss://' + HOST + WSS_PORT; + window.WSS_CROSS_SITE_ORIGIN = 'wss://' + CROSS_ORIGIN_HOST + WSS_PORT; + window.HTTPS_ORIGIN = 'https://' + HOST + HTTPS_PORT; + window.HTTPS_CROSS_SITE_ORIGIN = 'https://' + CROSS_ORIGIN_HOST + HTTPS_PORT; +})(); + +// Sets a cookie with each SameSite option. +function setSameSiteCookies(origin, value) { + return new Promise(resolve => { + const ws = new WebSocket(origin + '/set-cookies-samesite?value=' + value); + ws.onopen = () => { + ws.close(); + }; + ws.onclose = resolve; + }); +} + +// Clears cookies set by setSameSiteCookies(). +function clearSameSiteCookies(origin) { + return new Promise(resolve => { + const ws = new WebSocket(origin + '/set-cookies-samesite?clear'); + ws.onopen = () => ws.close(); + ws.onclose = resolve; + }); +} + +// Gets value of Cookie header sent in request. +function connectAndGetRequestCookiesFrom(origin) { + return new Promise((resolve, reject) => { + var ws = new WebSocket(origin + '/echo-cookie'); + ws.onmessage = evt => { + var cookies = evt.data + resolve(cookies); + ws.onerror = undefined; + ws.onclose = undefined; + }; + ws.onerror = () => reject('Unexpected error event'); + ws.onclose = evt => reject('Unexpected close event: ' + JSON.stringify(evt)); + }); +} + +// Assert that a given cookie is or is not present in the string |cookies|. +function assertCookie(cookies, name, value, present) { + var assertion = present ? assert_true : assert_false; + var description = name + '=' + value + ' cookie is' + + (present ? ' ' : ' not ') + 'present.'; + var re = new RegExp('(?:^|; )' + name + '=' + value + '(?:$|;)'); + assertion(re.test(cookies), description); +} + diff --git a/testing/web-platform/tests/websockets/cookies/third-party-cookie-accepted.https.html b/testing/web-platform/tests/websockets/cookies/third-party-cookie-accepted.https.html new file mode 100644 index 0000000000..208d297016 --- /dev/null +++ b/testing/web-platform/tests/websockets/cookies/third-party-cookie-accepted.https.html @@ -0,0 +1,25 @@ + + + + + + -- cgit v1.2.3