From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../first-party.all.tentative.https.window.js | 26 ++++++++---- .../first-party.default.tentative.https.window.js | 26 ++++++++---- .../first-party.none.tentative.https.window.js | 26 ++++++++---- .../same-site-cookies/resources/get_cookies.py | 13 ++++++ .../resources/get_cookies_redirect.py | 9 +++++ .../same-site-cookies/resources/iframe-iframe.html | 6 +-- .../same-site-cookies/resources/iframe.sub.html | 2 +- .../same-site-cookies/resources/set_cookies.py | 10 +++++ .../workers/same-site-cookies/resources/util.js | 46 ++++++++++++++++++++++ .../workers/same-site-cookies/resources/worker.js | 5 --- .../workers/same-site-cookies/resources/worker.py | 38 ++++++++++++++++++ .../same-site-cookies/resources/worker_redirect.py | 9 +++++ .../third-party.all.tentative.sub.https.window.js | 36 ++++++++++------- ...ird-party.default.tentative.sub.https.window.js | 38 +++++++++++------- .../third-party.none.tentative.sub.https.window.js | 38 +++++++++++------- 15 files changed, 253 insertions(+), 75 deletions(-) create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies.py create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies_redirect.py create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/set_cookies.py create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/util.js delete mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/worker.js create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/worker.py create mode 100644 testing/web-platform/tests/workers/same-site-cookies/resources/worker_redirect.py (limited to 'testing/web-platform/tests/workers/same-site-cookies') diff --git a/testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js index d7e5f2ee42..ac6030e654 100644 --- a/testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js @@ -1,19 +1,29 @@ // META: script=/resources/testdriver.js // META: script=/resources/testdriver-vendor.js +// META: script=/workers/same-site-cookies/resources/util.js 'use strict'; // Here's the set-up for this test: -// Step 1 (window) Set up listener for "DidStart" message and start worker. -// Step 2 (worker) Send "DidStart" message to window. -// Step 3 (window) Receive "DidStart" message and cleanup. +// Step 1 (window) Set cookies. +// Step 2 (window) Set up listener for cookie message and start worker. +// Step 3 (redirect) Redirect to worker script. +// Step 4 (worker) Send cookie message to window. +// Step 5 (window) Receive cookie message and cleanup. async_test(t => { // Step 1 - const worker = new SharedWorker("/workers/same-site-cookies/resources/worker.js", {sameSiteCookies: "all"}); - worker.port.onmessage = t.step_func(e => { - // Step 3 - assert_equals(e.data, "DidStart", "Worker should have started"); - t.done(); + const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py"); + cookie_set_window.onload = t.step_func(_ => { + // Step 2 + const worker = new SharedWorker("/workers/same-site-cookies/resources/worker_redirect.py", {sameSiteCookies: "all"}); + worker.port.onmessage = t.step_func(e => { + // Step 5 + getCookieNames().then(t.step_func((cookies) => { + assert_equals(e.data + cookies, "ReadOnLoad:StrictLaxNone,ReadOnFetch:StrictLaxNone,SetOnRedirectLoad:StrictLaxNone,SetOnLoad:StrictLaxNone,SetOnRedirectFetch:StrictLaxNone,SetOnFetch:StrictLaxNone", "Worker should get/set all cookies"); + cookie_set_window.close(); + t.done(); + })); + }); }); }, "Check SharedWorker sameSiteCookies option all for first-party"); diff --git a/testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js index b120014c1a..2c64ff628f 100644 --- a/testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js @@ -1,19 +1,29 @@ // META: script=/resources/testdriver.js // META: script=/resources/testdriver-vendor.js +// META: script=/workers/same-site-cookies/resources/util.js 'use strict'; // Here's the set-up for this test: -// Step 1 (window) Set up listener for "DidStart" message and start worker. -// Step 2 (worker) Send "DidStart" message to window. -// Step 3 (window) Receive "DidStart" message and cleanup. +// Step 1 (window) Set cookies. +// Step 2 (window) Set up listener for cookie message and start worker. +// Step 3 (redirect) Redirect to worker script. +// Step 4 (worker) Send cookie message to window. +// Step 5 (window) Receive cookie message and cleanup. async_test(t => { // Step 1 - const worker = new SharedWorker("/workers/same-site-cookies/resources/worker.js"); - worker.port.onmessage = t.step_func(e => { - // Step 3 - assert_equals(e.data, "DidStart", "Worker should have started"); - t.done(); + const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py"); + cookie_set_window.onload = t.step_func(_ => { + // Step 2 + const worker = new SharedWorker("/workers/same-site-cookies/resources/worker_redirect.py"); + worker.port.onmessage = t.step_func(e => { + // Step 5 + getCookieNames().then(t.step_func((cookies) => { + assert_equals(e.data + cookies, "ReadOnLoad:StrictLaxNone,ReadOnFetch:StrictLaxNone,SetOnRedirectLoad:StrictLaxNone,SetOnLoad:StrictLaxNone,SetOnRedirectFetch:StrictLaxNone,SetOnFetch:StrictLaxNone", "Worker should get/set all cookies"); + cookie_set_window.close(); + t.done(); + })); + }); }); }, "Check SharedWorker sameSiteCookies option default for first-party"); diff --git a/testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js index 762d924eb9..76a8b1d8bc 100644 --- a/testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js @@ -1,19 +1,29 @@ // META: script=/resources/testdriver.js // META: script=/resources/testdriver-vendor.js +// META: script=/workers/same-site-cookies/resources/util.js 'use strict'; // Here's the set-up for this test: -// Step 1 (window) Set up listener for "DidStart" message and start worker. -// Step 2 (worker) Send "DidStart" message to window. -// Step 3 (window) Receive "DidStart" message and cleanup. +// Step 1 (window) Set cookies. +// Step 2 (window) Set up listener for cookie message and start worker. +// Step 3 (redirect) Redirect to worker script. +// Step 4 (worker) Send cookie message to window. +// Step 5 (window) Receive cookie message and cleanup. async_test(t => { // Step 1 - const worker = new SharedWorker("/workers/same-site-cookies/resources/worker.js", {sameSiteCookies: "none"}); - worker.port.onmessage = t.step_func(e => { - // Step 3 - assert_equals(e.data, "DidStart", "Worker should have started"); - t.done(); + const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py"); + cookie_set_window.onload = t.step_func(_ => { + // Step 2 + const worker = new SharedWorker("/workers/same-site-cookies/resources/worker_redirect.py", {sameSiteCookies: "none"}); + worker.port.onmessage = t.step_func(e => { + // Step 5 + getCookieNames().then(t.step_func((cookies) => { + assert_equals(e.data + cookies, "ReadOnLoad:None,ReadOnFetch:None,SetOnRedirectLoad:None,SetOnLoad:None,SetOnRedirectFetch:None,SetOnFetch:None", "Worker should get/set SameSite=None cookies only"); + cookie_set_window.close(); + t.done(); + })); + }); }); }, "Check SharedWorker sameSiteCookies option none for first-party"); diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies.py b/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies.py new file mode 100644 index 0000000000..61b138321d --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies.py @@ -0,0 +1,13 @@ +import json +from cookies.resources.helpers import makeCookieHeader, readCookies, setNoCacheAndCORSHeaders + +from wptserve.utils import isomorphic_decode + +def main(request, response): + headers = setNoCacheAndCORSHeaders(request, response) + cookies = readCookies(request) + headers.append(makeCookieHeader(b"samesite_strict_set_on_fetch", b"test", {b"SameSite":b"Strict", b"path":b"/", b"Secure":b""})) + headers.append(makeCookieHeader(b"samesite_lax_set_on_fetch", b"test", {b"SameSite":b"Lax", b"path":b"/", b"Secure":b""})) + headers.append(makeCookieHeader(b"samesite_none_set_on_fetch", b"test", {b"SameSite":b"None", b"path":b"/", b"Secure":b""})) + decoded_cookies = {isomorphic_decode(key): isomorphic_decode(val) for key, val in cookies.items()} + return headers, json.dumps(decoded_cookies) diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies_redirect.py b/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies_redirect.py new file mode 100644 index 0000000000..0f3a647a2b --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies_redirect.py @@ -0,0 +1,9 @@ +from cookies.resources.helpers import makeCookieHeader + +# Step 3/5 (workers/same-site-cookies/{}) +def main(request, response): + headers = [(b"Location", b"/workers/same-site-cookies/resources/get_cookies.py")] + headers.append(makeCookieHeader(b"samesite_strict_set_on_redirect_fetch", b"test", {b"SameSite":b"Strict", b"path":b"/", b"Secure":b""})) + headers.append(makeCookieHeader(b"samesite_lax_set_on_redirect_fetch", b"test", {b"SameSite":b"Lax", b"path":b"/", b"Secure":b""})) + headers.append(makeCookieHeader(b"samesite_none_set_on_redirect_fetch", b"test", {b"SameSite":b"None", b"path":b"/", b"Secure":b""})) + return 302, headers, b"" diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html b/testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html index 0c5582176d..efd4f3a654 100644 --- a/testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html @@ -4,7 +4,7 @@