diff --git a/testing/web-platform/tests/cookie-store/cookieStore_getAll_arguments.https.any.js b/testing/web-platform/tests/cookie-store/cookieStore_getAll_arguments.https.any.js index 5055a42e5d39..264b6b7a7f74 100644 --- a/testing/web-platform/tests/cookie-store/cookieStore_getAll_arguments.https.any.js +++ b/testing/web-platform/tests/cookie-store/cookieStore_getAll_arguments.https.any.js @@ -147,3 +147,39 @@ promise_test(async testCase => { await promise_rejects_js(testCase, TypeError, cookieStore.getAll( { url: invalid_url })); }, 'cookieStore.getAll with invalid url host in options'); + +promise_test(async testCase => { + await cookieStore.set('cookie-name', 'cookie-value'); + testCase.add_cleanup(async () => { + await cookieStore.delete('cookie-name'); + }); + + let target_url = self.location.href; + if (self.GLOBAL.isWorker()) { + target_url = target_url + '/path/within/scope'; + } + + target_url = target_url + "#foo"; + + const cookies = await cookieStore.getAll({ url: target_url }); + assert_equals(cookies.length, 1); + assert_equals(cookies[0].name, 'cookie-name'); + assert_equals(cookies[0].value, 'cookie-value'); +}, 'cookieStore.getAll with absolute url with fragment in options'); + +promise_test(async testCase => { + if (!self.GLOBAL.isWorker()) { + await cookieStore.set('cookie-name', 'cookie-value'); + testCase.add_cleanup(async () => { + await cookieStore.delete('cookie-name'); + }); + + self.location = "#foo"; + let target_url = self.location.href; + + const cookies = await cookieStore.getAll({ url: target_url }); + assert_equals(cookies.length, 1); + assert_equals(cookies[0].name, 'cookie-name'); + assert_equals(cookies[0].value, 'cookie-value'); + } +}, 'cookieStore.getAll with absolute different url in options'); diff --git a/testing/web-platform/tests/cookie-store/cookieStore_get_arguments.https.any.js b/testing/web-platform/tests/cookie-store/cookieStore_get_arguments.https.any.js index a56032f03e20..8507682f8ec6 100644 --- a/testing/web-platform/tests/cookie-store/cookieStore_get_arguments.https.any.js +++ b/testing/web-platform/tests/cookie-store/cookieStore_get_arguments.https.any.js @@ -100,3 +100,37 @@ promise_test(async testCase => { await promise_rejects_js(testCase, TypeError, cookieStore.get( { url: invalid_url })); }, 'cookieStore.get with invalid url host in options'); + +promise_test(async testCase => { + await cookieStore.set('cookie-name', 'cookie-value'); + testCase.add_cleanup(async () => { + await cookieStore.delete('cookie-name'); + }); + + let target_url = self.location.href; + if (self.GLOBAL.isWorker()) { + target_url = target_url + '/path/within/scope'; + } + + target_url = target_url + "#foo"; + + const cookie = await cookieStore.get({ url: target_url }); + assert_equals(cookie.name, 'cookie-name'); + assert_equals(cookie.value, 'cookie-value'); +}, 'cookieStore.get with absolute url with fragment in options'); + +promise_test(async testCase => { + if (!self.GLOBAL.isWorker()) { + await cookieStore.set('cookie-name', 'cookie-value'); + testCase.add_cleanup(async () => { + await cookieStore.delete('cookie-name'); + }); + + self.location = "#foo"; + let target_url = self.location.href; + + const cookie = await cookieStore.get({ url: target_url }); + assert_equals(cookie.name, 'cookie-name'); + assert_equals(cookie.value, 'cookie-value'); + } +}, 'cookieStore.get with absolute different url in options'); diff --git a/testing/web-platform/tests/cookie-store/cookieStore_get_set_creation_url.sub.https.html b/testing/web-platform/tests/cookie-store/cookieStore_get_set_creation_url.sub.https.html new file mode 100644 index 000000000000..216885298a58 --- /dev/null +++ b/testing/web-platform/tests/cookie-store/cookieStore_get_set_creation_url.sub.https.html @@ -0,0 +1,86 @@ + + +Async Cookies: cookieStore basic API on creation URL with fragments + + + + + + + + diff --git a/testing/web-platform/tests/cookie-store/resources/helper_iframe.sub.html b/testing/web-platform/tests/cookie-store/resources/helper_iframe.sub.html index 9017eace44d8..750f19b56d39 100644 --- a/testing/web-platform/tests/cookie-store/resources/helper_iframe.sub.html +++ b/testing/web-platform/tests/cookie-store/resources/helper_iframe.sub.html @@ -23,9 +23,12 @@ }); event.source.postMessage('Cookie has been set', event.origin); } else if (opname === 'get-cookie') { - const { name } = event.data - const frameCookie = await cookieStore.get(name); + const { name, options } = event.data + const frameCookie = await cookieStore.get(name, options); event.source.postMessage({frameCookie}, event.origin); + } else if (opname === 'push-state') { + history.pushState("foo", null, "some/path"); + event.source.postMessage('pushState called'); } });