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/cookie-store/cookieStore_get_set_across_origins.sub.https.html | |
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/cookie-store/cookieStore_get_set_across_origins.sub.https.html')
-rw-r--r-- | testing/web-platform/tests/cookie-store/cookieStore_get_set_across_origins.sub.https.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_origins.sub.https.html b/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_origins.sub.https.html new file mode 100644 index 0000000000..c67ef98bcc --- /dev/null +++ b/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_origins.sub.https.html @@ -0,0 +1,66 @@ +<!doctype html> +<meta charset='utf-8'> +<title>Async Cookies: cookieStore basic API across origins</title> +<link rel='help' href='https://github.com/WICG/cookie-store'> +<link rel='author' href='jarrydg@chromium.org' title='Jarryd Goodman'> +<script src='/resources/testharness.js'></script> +<script src='/resources/testharnessreport.js'></script> +<script src='resources/helpers.js'></script> +<style>iframe { display: none; }</style> + +<script> +'use strict'; + +const kPath = '/cookie-store/resources/helper_iframe.sub.html'; +const kCorsBase = `https://{{domains[www1]}}:{{ports[https][0]}}`; +const kCorsUrl = `${kCorsBase}${kPath}`; + +promise_test(async t => { + const iframe = await createIframe(kCorsUrl, t); + assert_true(iframe != null); + + iframe.contentWindow.postMessage({ + opname: 'set-cookie', + name: 'cookie-name', + value: 'cookie-value', + }, kCorsBase); + t.add_cleanup(async () => { + await cookieStore.delete({ name: 'cookie-name', domain: '{{host}}' }); + }); + await waitForMessage(); + + const cookies = await cookieStore.getAll(); + assert_equals(cookies.length, 1); + assert_equals(cookies[0].name, 'cookie-name'); + assert_equals(cookies[0].value, 'cookie-value'); +}, 'cookieStore.get() sees cookieStore.set() in cross-origin frame'); + +promise_test(async t => { + const iframe = await createIframe(kCorsUrl, t); + assert_true(iframe != null); + + await cookieStore.set({ + name: 'cookie-name', + value: 'cookie-value', + domain: '{{host}}', + }); + + const cookie = await cookieStore.get('cookie-name'); + assert_equals(cookie.value, 'cookie-value'); + + iframe.contentWindow.postMessage({ + opname: 'get-cookie', + name: 'cookie-name', + }, kCorsBase); + t.add_cleanup(async () => { + await cookieStore.delete({ name: 'cookie-name', domain: '{{host}}' }); + }); + + const message = await waitForMessage(); + + const { frameCookie } = message; + assert_not_equals(frameCookie, null); + assert_equals(frameCookie.name, 'cookie-name'); + assert_equals(frameCookie.value, 'cookie-value'); +}, 'cookieStore.get() in cross-origin frame sees cookieStore.set()'); +</script> |