diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/workers/same-site-cookies | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/workers/same-site-cookies')
9 files changed, 179 insertions, 0 deletions
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 new file mode 100644 index 0000000000..d7e5f2ee42 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js @@ -0,0 +1,19 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.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. + +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(); + }); +}, "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 new file mode 100644 index 0000000000..b120014c1a --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js @@ -0,0 +1,19 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.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. + +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(); + }); +}, "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 new file mode 100644 index 0000000000..762d924eb9 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js @@ -0,0 +1,19 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.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. + +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(); + }); +}, "Check SharedWorker sameSiteCookies option none for first-party"); 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 new file mode 100644 index 0000000000..0c5582176d --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html @@ -0,0 +1,31 @@ +<!doctype html> +<meta charset="utf-8"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +// Step 3 (workers/same-site-cookies/third-party.{}) +test_driver.set_test_context(window.top); +const type = (new URLSearchParams(window.location.search)).get("type"); +let options = {}; +switch (type) { + case "default": + break; + case "all": + options.sameSiteCookies = "all"; + break; + case "none": + options.sameSiteCookies = "none"; + break; +} +// Step 5 (workers/same-site-cookies/third-party.{}) +try { + const worker = new SharedWorker("/workers/same-site-cookies/resources/worker.js", options); + worker.port.onmessage = (e) => { + window.top.postMessage(e.data, "*"); + }; +} catch (_) { + window.top.postMessage("DidNotStart", "*"); +} +</script> +</body> diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/iframe.sub.html b/testing/web-platform/tests/workers/same-site-cookies/resources/iframe.sub.html new file mode 100644 index 0000000000..2531f3d620 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/iframe.sub.html @@ -0,0 +1,14 @@ +<!doctype html> +<meta charset="utf-8"> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +// Step 2 (workers/same-site-cookies/third-party.{}) +test_driver.set_test_context(window.top); +const type = (new URLSearchParams(window.location.search)).get("type"); +let iframe = document.createElement("iframe"); +iframe.src = "https://{{hosts[][]}}:{{ports[https][0]}}/workers/same-site-cookies/resources/iframe-iframe.html?type=" + type; +document.body.appendChild(iframe); +</script> +</body> diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/worker.js b/testing/web-platform/tests/workers/same-site-cookies/resources/worker.js new file mode 100644 index 0000000000..658f499e92 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/resources/worker.js @@ -0,0 +1,5 @@ +// Step 2/4 (workers/same-site-cookies/{}) +self.onconnect = (e) => { + e.ports[0].postMessage("DidStart"); + self.close(); +} diff --git a/testing/web-platform/tests/workers/same-site-cookies/third-party.all.tentative.sub.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/third-party.all.tentative.sub.https.window.js new file mode 100644 index 0000000000..51ad1d3b02 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/third-party.all.tentative.sub.https.window.js @@ -0,0 +1,24 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Here's the set-up for this test: +// Step 1 (top-frame) Set up listener for "DidNotStart" message and open cross-site iframe. +// Step 2 (sub-frame) Open iframe same-site to top-frame. +// Step 3 (sub-sub-frame) Set up listener for message and start worker. +// Step 4 (worker) Skipped. +// Step 5 (sub-sub-frame) Worker failed to start and window messages "DidNotStart". +// Step 6 (top-frame) Receive "DidNotStart" message and cleanup. + +async_test(t => { + // Step 1 + window.addEventListener("message", t.step_func(e => { + // Step 6 + assert_equals(e.data, "DidNotStart", "Worker should not have started"); + t.done(); + })); + let iframe = document.createElement("iframe"); + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/workers/same-site-cookies/resources/iframe.sub.html?type=all"; + document.body.appendChild(iframe); +}, "Check SharedWorker sameSiteCookies option all for third-party"); diff --git a/testing/web-platform/tests/workers/same-site-cookies/third-party.default.tentative.sub.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/third-party.default.tentative.sub.https.window.js new file mode 100644 index 0000000000..194df38390 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/third-party.default.tentative.sub.https.window.js @@ -0,0 +1,24 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Here's the set-up for this test: +// Step 1 (top-frame) Set up listener for "DidStart" message and open cross-site iframe. +// Step 2 (sub-frame) Open iframe same-site to top-frame. +// Step 3 (sub-sub-frame) Set up listener for message and start worker. +// Step 4 (worker) Send "DidStart" message to iframe. +// Step 5 (sub-sub-frame) Receive message and pass on to window. +// Step 6 (top-frame) Receive "DidStart" message and cleanup. + +async_test(t => { + // Step 1 + window.addEventListener("message", t.step_func(e => { + // Step 6 + assert_equals(e.data, "DidStart", "Worker should have started"); + t.done(); + })); + let iframe = document.createElement("iframe"); + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/workers/same-site-cookies/resources/iframe.sub.html?type=default"; + document.body.appendChild(iframe); +}, "Check SharedWorker sameSiteCookies option default for third-party"); diff --git a/testing/web-platform/tests/workers/same-site-cookies/third-party.none.tentative.sub.https.window.js b/testing/web-platform/tests/workers/same-site-cookies/third-party.none.tentative.sub.https.window.js new file mode 100644 index 0000000000..b91b9d7ab2 --- /dev/null +++ b/testing/web-platform/tests/workers/same-site-cookies/third-party.none.tentative.sub.https.window.js @@ -0,0 +1,24 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +'use strict'; + +// Here's the set-up for this test: +// Step 1 (top-frame) Set up listener for "DidStart" message and open cross-site iframe. +// Step 2 (sub-frame) Open iframe same-site to top-frame. +// Step 3 (sub-sub-frame) Set up listener for message and start worker. +// Step 4 (worker) Send "DidStart" message to iframe. +// Step 5 (sub-sub-frame) Receive message and pass on to window. +// Step 6 (top-frame) Receive "DidStart" message and cleanup. + +async_test(t => { + // Step 1 + window.addEventListener("message", t.step_func(e => { + // Step 6 + assert_equals(e.data, "DidStart", "Worker should have started"); + t.done(); + })); + let iframe = document.createElement("iframe"); + iframe.src = "https://{{hosts[alt][]}}:{{ports[https][0]}}/workers/same-site-cookies/resources/iframe.sub.html?type=none"; + document.body.appendChild(iframe); +}, "Check SharedWorker sameSiteCookies option none for third-party"); |