diff options
Diffstat (limited to '')
-rw-r--r-- | testing/web-platform/tests/cookie-store/cookieStore_get_set_across_frames.https.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_frames.https.html b/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_frames.https.html new file mode 100644 index 0000000000..f7c737b422 --- /dev/null +++ b/testing/web-platform/tests/cookie-store/cookieStore_get_set_across_frames.https.html @@ -0,0 +1,46 @@ +<!doctype html> +<meta charset='utf-8'> +<title>Async Cookies: cookieStore basic API across frames</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> +<style>iframe { display: none; }</style> +<iframe id='iframe'></iframe> +<script> +'use strict'; + +promise_test(async t => { + const iframe = document.getElementById('iframe'); + const frameCookieStore = iframe.contentWindow.cookieStore; + + const oldCookie = await frameCookieStore.get('cookie-name'); + assert_equals(oldCookie, null, + 'Precondition not met: cookie store should be empty'); + + await cookieStore.set('cookie-name', 'cookie-value'); + t.add_cleanup(async () => { + await cookieStore.delete('cookie-name'); + }); + + const frameCookie = await frameCookieStore.get('cookie-name'); + assert_equals(frameCookie.value, 'cookie-value'); +}, 'cookieStore.get() sees cookieStore.set() in frame'); + +promise_test(async t => { + const iframe = document.getElementById('iframe'); + const frameCookieStore = iframe.contentWindow.cookieStore; + + const oldCookie = await frameCookieStore.get('cookie-name'); + assert_equals(oldCookie, null, + 'Precondition not met: cookie store should be empty'); + + await frameCookieStore.set('cookie-name', 'cookie-value'); + t.add_cleanup(async () => { + await frameCookieStore.delete('cookie-name'); + }); + + const cookie = await cookieStore.get('cookie-name'); + assert_equals(cookie.value, 'cookie-value'); +}, 'cookieStore.get() in frame sees cookieStore.set()') +</script> |