diff options
Diffstat (limited to 'tests/wpt/tests/cookie-store')
5 files changed, 45 insertions, 26 deletions
diff --git a/tests/wpt/tests/cookie-store/META.yml b/tests/wpt/tests/cookie-store/META.yml index 68c30024552..4bbc6311bdc 100644 --- a/tests/wpt/tests/cookie-store/META.yml +++ b/tests/wpt/tests/cookie-store/META.yml @@ -1,4 +1,3 @@ spec: https://wicg.github.io/cookie-store/ suggested_reviewers: - - inexorabletash - - ayuishii + - dcthetall diff --git a/tests/wpt/tests/cookie-store/cookieStore_special_names.https.any.js b/tests/wpt/tests/cookie-store/cookieStore_special_names.https.any.js index e2a3df7fe33..1e12674a7f7 100644 --- a/tests/wpt/tests/cookie-store/cookieStore_special_names.https.any.js +++ b/tests/wpt/tests/cookie-store/cookieStore_special_names.https.any.js @@ -3,7 +3,7 @@ 'use strict'; -['__Secure-', '__Host-'].forEach(prefix => { +['__Secure-', '__secure-', '__Host-', '__host-'].forEach(prefix => { promise_test(async testCase => { await cookieStore.set(`${prefix}cookie-name`, `secure-cookie-value`); assert_equals( @@ -32,25 +32,27 @@ }, `cookieStore.delete with ${prefix} name on secure origin`); }); -promise_test(async testCase => { - const currentUrl = new URL(self.location.href); - const currentDomain = currentUrl.hostname; - await promise_rejects_js(testCase, TypeError, - cookieStore.set({ name: '__Host-cookie-name', value: 'cookie-value', - domain: currentDomain })); -}, 'cookieStore.set with __Host- prefix and a domain option'); +['__Host-', '__host-'].forEach(prefix => { + promise_test(async testCase => { + const currentUrl = new URL(self.location.href); + const currentDomain = currentUrl.hostname; + await promise_rejects_js(testCase, TypeError, + cookieStore.set({ name: `${prefix}cookie-name`, value: 'cookie-value', + domain: currentDomain })); + }, `cookieStore.set with ${prefix} prefix and a domain option`); -promise_test(async testCase => { - await cookieStore.set({ name: '__Host-cookie-name', value: 'cookie-value', - path: "/" }); + promise_test(async testCase => { + await cookieStore.set({ name: `${prefix}cookie-name`, value: 'cookie-value', + path: "/" }); - assert_equals( - (await cookieStore.get(`__Host-cookie-name`)).value, "cookie-value"); + assert_equals( + (await cookieStore.get(`${prefix}cookie-name`)).value, "cookie-value"); - await promise_rejects_js(testCase, TypeError, - cookieStore.set( { name: '__Host-cookie-name', value: 'cookie-value', - path: "/path" })); -}, 'cookieStore.set with __Host- prefix a path option'); + await promise_rejects_js(testCase, TypeError, + cookieStore.set( { name: `${prefix}cookie-name`, value: 'cookie-value', + path: "/path" })); + }, `cookieStore.set with ${prefix} prefix a path option`); +}); promise_test(async testCase => { let exceptionThrown = false; diff --git a/tests/wpt/tests/cookie-store/encoding.https.any.js b/tests/wpt/tests/cookie-store/encoding.https.any.js index 941639bdaec..f5d2ca15e71 100644 --- a/tests/wpt/tests/cookie-store/encoding.https.any.js +++ b/tests/wpt/tests/cookie-store/encoding.https.any.js @@ -4,15 +4,21 @@ 'use strict'; -cookie_test(async t => { +promise_test(async t => { await setCookieStringHttp('\uFEFFcookie=value; path=/'); + t.add_cleanup(async () => { + await setCookieStringHttp('\uFEFFcookie=value; path=/; Max-Age=0'); + }); const cookie = await cookieStore.get('\uFEFFcookie'); assert_equals(cookie.name, '\uFEFFcookie'); assert_equals(cookie.value, 'value'); }, 'BOM not stripped from name'); -cookie_test(async t => { +promise_test(async t => { await setCookieStringHttp('cookie=\uFEFFvalue; path=/'); + t.add_cleanup(async () => { + await setCookieStringHttp('cookie=\uFEFFvalue; path=/; Max-Age=0'); + }); const cookie = await cookieStore.get('cookie'); assert_equals(cookie.name, 'cookie'); assert_equals(cookie.value, '\uFEFFvalue'); diff --git a/tests/wpt/tests/cookie-store/httponly_cookies.https.window.js b/tests/wpt/tests/cookie-store/httponly_cookies.https.window.js index 605e94e6744..836f47da3f6 100644 --- a/tests/wpt/tests/cookie-store/httponly_cookies.https.window.js +++ b/tests/wpt/tests/cookie-store/httponly_cookies.https.window.js @@ -2,7 +2,7 @@ 'use strict'; -cookie_test(async t => { +promise_test(async t => { let eventPromise = observeNextCookieChangeEvent(); await setCookieStringHttp('HTTPONLY-cookie=value; path=/; httponly'); assert_equals( @@ -29,6 +29,9 @@ cookie_test(async t => { eventPromise = observeNextCookieChangeEvent(); await setCookieStringHttp( 'HTTPONLY-cookie=DELETED; path=/; max-age=0; httponly'); + t.add_cleanup(async () => { + await setCookieStringHttp(`HTTPONLY-cookie=DELETED; path=/; httponly; Max-Age=0`); + }); assert_equals( await getCookieString(), undefined, @@ -41,6 +44,9 @@ cookie_test(async t => { // HTTPONLY cookie changes should not have been observed; perform // a dummy change to verify that nothing else was queued up. await cookieStore.set('TEST', 'dummy'); + t.add_cleanup(async () => { + await cookieStore.delete('TEST'); + }); await verifyCookieChangeEvent( eventPromise, {changed: [{name: 'TEST', value: 'dummy'}]}, 'HttpOnly cookie deletion was not observed'); @@ -68,8 +74,11 @@ cookie_test(async t => { 'httpOnly is not an option for CookieStore.set()'); }, 'HttpOnly cookies can not be set by CookieStore'); -cookie_test(async t => { +promise_test(async t => { await setCookieStringHttp('HTTPONLY-cookie=value; path=/; httponly'); + t.add_cleanup(async () => { + await setCookieStringHttp(`HTTPONLY-cookie=DELETED; path=/; httponly; Max-Age=0`); + }); assert_equals( await getCookieString(), undefined, diff --git a/tests/wpt/tests/cookie-store/resources/cookie-test-helpers.js b/tests/wpt/tests/cookie-store/resources/cookie-test-helpers.js index 178947ad6ec..82ca135f88e 100644 --- a/tests/wpt/tests/cookie-store/resources/cookie-test-helpers.js +++ b/tests/wpt/tests/cookie-store/resources/cookie-test-helpers.js @@ -210,9 +210,12 @@ async function cookie_test(func, description) { // Wipe cookies used by tests before and after the test. async function deleteAllCookies() { - (await cookieStore.getAll()).forEach(({name, value}) => { - cookieStore.delete(name); - }); + const cookies = await cookieStore.getAll(); + await Promise.all(cookies.flatMap( + ({name}) => + [cookieStore.delete(name), + cookieStore.delete({name, partitioned: true}), + ])); } return promise_test(async t => { |