summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/same-site-cookies
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /testing/web-platform/tests/workers/same-site-cookies
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/workers/same-site-cookies')
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/first-party.all.tentative.https.window.js26
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/first-party.default.tentative.https.window.js26
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/first-party.none.tentative.https.window.js26
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies.py13
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/get_cookies_redirect.py9
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/iframe-iframe.html6
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/iframe.sub.html2
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/set_cookies.py10
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/util.js46
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/worker.js5
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/worker.py38
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/resources/worker_redirect.py9
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/third-party.all.tentative.sub.https.window.js36
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/third-party.default.tentative.sub.https.window.js38
-rw-r--r--testing/web-platform/tests/workers/same-site-cookies/third-party.none.tentative.sub.https.window.js38
15 files changed, 253 insertions, 75 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
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 @@
<script src="/resources/testdriver-vendor.js"></script>
<body>
<script>
-// Step 3 (workers/same-site-cookies/third-party.{})
+// Step 4 (workers/same-site-cookies/third-party.{})
test_driver.set_test_context(window.top);
const type = (new URLSearchParams(window.location.search)).get("type");
let options = {};
@@ -18,9 +18,9 @@ switch (type) {
options.sameSiteCookies = "none";
break;
}
-// Step 5 (workers/same-site-cookies/third-party.{})
+// Step 7 (workers/same-site-cookies/third-party.{})
try {
- const worker = new SharedWorker("/workers/same-site-cookies/resources/worker.js", options);
+ const worker = new SharedWorker("/workers/same-site-cookies/resources/worker_redirect.py", options);
worker.port.onmessage = (e) => {
window.top.postMessage(e.data, "*");
};
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
index 2531f3d620..c4724d01d2 100644
--- 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
@@ -4,7 +4,7 @@
<script src="/resources/testdriver-vendor.js"></script>
<body>
<script>
-// Step 2 (workers/same-site-cookies/third-party.{})
+// 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 iframe = document.createElement("iframe");
diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/set_cookies.py b/testing/web-platform/tests/workers/same-site-cookies/resources/set_cookies.py
new file mode 100644
index 0000000000..c721cc51f7
--- /dev/null
+++ b/testing/web-platform/tests/workers/same-site-cookies/resources/set_cookies.py
@@ -0,0 +1,10 @@
+from cookies.resources.helpers import makeCookieHeader, setNoCacheAndCORSHeaders
+
+def main(request, response):
+ headers = setNoCacheAndCORSHeaders(request, response)
+ headers[0] = (b"Content-Type", b"text/html; charset=utf-8")
+ headers.append(makeCookieHeader(b"samesite_strict_set_before_load", b"test", {b"SameSite":b"Strict", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_lax_set_before_load", b"test", {b"SameSite":b"Lax", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_none_set_before_load", b"test", {b"SameSite":b"None", b"path":b"/", b"Secure":b""}))
+ document = b"<!DOCTYPE html>"
+ return headers, document \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/util.js b/testing/web-platform/tests/workers/same-site-cookies/resources/util.js
new file mode 100644
index 0000000000..67d9ee5c06
--- /dev/null
+++ b/testing/web-platform/tests/workers/same-site-cookies/resources/util.js
@@ -0,0 +1,46 @@
+async function getCookieNames() {
+ const cookies = await test_driver.get_all_cookies();
+ const cookie_names = {};
+ cookies.forEach((element) => cookie_names[element["name"]] = true);
+ let message = ",SetOnRedirectLoad:";
+ if (cookie_names.hasOwnProperty("samesite_strict_set_on_redirect_load")) {
+ message += "Strict";
+ }
+ if (cookie_names.hasOwnProperty("samesite_lax_set_on_redirect_load")) {
+ message += "Lax";
+ }
+ if (cookie_names.hasOwnProperty("samesite_none_set_on_redirect_load")) {
+ message += "None";
+ }
+ message += ",SetOnLoad:";
+ if (cookie_names.hasOwnProperty("samesite_strict_set_on_load")) {
+ message += "Strict";
+ }
+ if (cookie_names.hasOwnProperty("samesite_lax_set_on_load")) {
+ message += "Lax";
+ }
+ if (cookie_names.hasOwnProperty("samesite_none_set_on_load")) {
+ message += "None";
+ }
+ message += ",SetOnRedirectFetch:";
+ if (cookie_names.hasOwnProperty("samesite_strict_set_on_redirect_fetch")) {
+ message += "Strict";
+ }
+ if (cookie_names.hasOwnProperty("samesite_lax_set_on_redirect_fetch")) {
+ message += "Lax";
+ }
+ if (cookie_names.hasOwnProperty("samesite_none_set_on_redirect_fetch")) {
+ message += "None";
+ }
+ message += ",SetOnFetch:";
+ if (cookie_names.hasOwnProperty("samesite_strict_set_on_fetch")) {
+ message += "Strict";
+ }
+ if (cookie_names.hasOwnProperty("samesite_lax_set_on_fetch")) {
+ message += "Lax";
+ }
+ if (cookie_names.hasOwnProperty("samesite_none_set_on_fetch")) {
+ message += "None";
+ }
+ return message;
+}
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
deleted file mode 100644
index 658f499e92..0000000000
--- a/testing/web-platform/tests/workers/same-site-cookies/resources/worker.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// 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/resources/worker.py b/testing/web-platform/tests/workers/same-site-cookies/resources/worker.py
new file mode 100644
index 0000000000..8440c2d70e
--- /dev/null
+++ b/testing/web-platform/tests/workers/same-site-cookies/resources/worker.py
@@ -0,0 +1,38 @@
+from cookies.resources.helpers import makeCookieHeader, readCookies, setNoCacheAndCORSHeaders
+
+# Step 4/6 (workers/same-site-cookies/{})
+def main(request, response):
+ headers = setNoCacheAndCORSHeaders(request, response)
+ headers[0] = (b"Content-Type", b"text/javascript")
+ headers.append(makeCookieHeader(b"samesite_strict_set_on_load", b"test", {b"SameSite":b"Strict", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_lax_set_on_load", b"test", {b"SameSite":b"Lax", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_none_set_on_load", b"test", {b"SameSite":b"None", b"path":b"/", b"Secure":b""}))
+ cookies = readCookies(request)
+ message = b"ReadOnLoad:"
+ if b"samesite_strict_set_before_load" in cookies:
+ message += b"Strict"
+ if b"samesite_lax_set_before_load" in cookies:
+ message += b"Lax"
+ if b"samesite_none_set_before_load" in cookies:
+ message += b"None"
+ document = b"""
+self.onconnect = (e) => {
+ fetch("/workers/same-site-cookies/resources/get_cookies_redirect.py", {credentials: 'include'}).then((resp) => {
+ resp.json().then((cookies) => {
+ let message = \"""" + message + b""",ReadOnFetch:";
+ if (cookies.hasOwnProperty("samesite_strict_set_before_load")) {
+ message += "Strict";
+ }
+ if (cookies.hasOwnProperty("samesite_lax_set_before_load")) {
+ message += "Lax";
+ }
+ if (cookies.hasOwnProperty("samesite_none_set_before_load")) {
+ message += "None";
+ }
+ e.ports[0].postMessage(message);
+ self.close();
+ });
+ });
+}
+"""
+ return headers, document
diff --git a/testing/web-platform/tests/workers/same-site-cookies/resources/worker_redirect.py b/testing/web-platform/tests/workers/same-site-cookies/resources/worker_redirect.py
new file mode 100644
index 0000000000..633a3ae67e
--- /dev/null
+++ b/testing/web-platform/tests/workers/same-site-cookies/resources/worker_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/worker.py")]
+ headers.append(makeCookieHeader(b"samesite_strict_set_on_redirect_load", b"test", {b"SameSite":b"Strict", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_lax_set_on_redirect_load", b"test", {b"SameSite":b"Lax", b"path":b"/", b"Secure":b""}))
+ headers.append(makeCookieHeader(b"samesite_none_set_on_redirect_load", 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/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
index 51ad1d3b02..21b53819d9 100644
--- 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
@@ -1,24 +1,32 @@
// 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 (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.
+// Step 1 (window) Set cookies.
+// Step 2 (top-frame) Set up listener for "DidNotStart" message and open cross-site iframe.
+// Step 3 (sub-frame) Open iframe same-site to top-frame.
+// Step 4 (sub-sub-frame) Set up listener for message and start worker.
+// Step 5 (redirect) Skipped.
+// Step 6 (worker) Skipped.
+// Step 7 (sub-sub-frame) Worker failed to start and window messages "DidNotStart".
+// Step 8 (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);
+ const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py");
+ cookie_set_window.onload = t.step_func(_ => {
+ // Step 2
+ window.addEventListener("message", t.step_func(e => {
+ // Step 8
+ assert_equals(e.data, "DidNotStart", "Worker should not have started");
+ cookie_set_window.close();
+ 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
index 194df38390..bf499c1992 100644
--- 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
@@ -1,24 +1,34 @@
// 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 (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.
+// Step 1 (window) Set cookies.
+// Step 2 (top-frame) Set up listener for cookie message and open cross-site iframe.
+// Step 3 (sub-frame) Open iframe same-site to top-frame.
+// Step 4 (sub-sub-frame) Set up listener for message and start worker.
+// Step 5 (redirect) Redirect to worker script.
+// Step 6 (worker) Send cookie message to iframe.
+// Step 7 (sub-sub-frame) Receive message and pass on to window.
+// Step 8 (top-frame) Receive cookie 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);
+ const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py");
+ cookie_set_window.onload = t.step_func(_ => {
+ // Step 2
+ window.addEventListener("message", t.step_func(e => {
+ // Step 8
+ 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();
+ }));
+ }));
+ 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
index b91b9d7ab2..f00e585f77 100644
--- 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
@@ -1,24 +1,34 @@
// 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 (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.
+// Step 1 (window) Set cookies.
+// Step 2 (top-frame) Set up listener for cookie message and open cross-site iframe.
+// Step 3 (sub-frame) Open iframe same-site to top-frame.
+// Step 4 (sub-sub-frame) Set up listener for message and start worker.
+// Step 5 (redirect) Redirect to worker script.
+// Step 6 (worker) Send cookie message to iframe.
+// Step 7 (sub-sub-frame) Receive message and pass on to window.
+// Step 8 (top-frame) Receive cookie 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);
+ const cookie_set_window = window.open("/workers/same-site-cookies/resources/set_cookies.py");
+ cookie_set_window.onload = t.step_func(_ => {
+ // Step 2
+ window.addEventListener("message", t.step_func(e => {
+ // Step 8
+ 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();
+ }));
+ }));
+ 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");