| <!doctype html> |
| <meta charset="utf-8"> |
| <title>Async Cookies: cookieStore.has()</title> |
| <link rel="help" href="https://github.com/WICG/async-cookies-api"> |
| <link rel="author" href="pwnall@chromium.org" title="Victor Costan"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script> |
| 'use strict'; |
| |
| // Workaround because add_cleanup doesn't support async functions yet. |
| // See https://github.com/w3c/web-platform-tests/issues/6075 |
| async function async_cleanup(cleanup_function) { |
| try { |
| await cleanup_function(); |
| } catch (e) { |
| // Errors in cleanup functions shouldn't result in test failures. |
| } |
| } |
| |
| promise_test(async testCase => { |
| await cookieStore.set('cookie-name', 'cookie-value'); |
| assert_equals(await cookieStore.has('cookie-name'), true); |
| |
| await async_cleanup(() => cookieStore.delete('cookie-name')); |
| }, 'cookieStore.has returns true for cookie set by cookieStore.set()'); |
| |
| promise_test(async testCase => { |
| await cookieStore.delete('cookie-name'); |
| assert_equals(await cookieStore.has('cookie-name'), false); |
| |
| await async_cleanup(() => cookieStore.delete('cookie-name')); |
| }, 'cookieStore.has returns false for cookie deleted by cookieStore.delete()'); |
| |
| </script> |