Skip to content

Commit 5022366

Browse files
committed
Bug 1979264 [wpt PR 53973] - Cookie store - ensure whitespace prefix to __Http- and __HostHttp- is properly blocked, a=testonly
Automatic update from web-platform-tests Cookie store - ensure whitespace prefix to `__Http-` and `__HostHttp-` is properly blocked (#53973) * document_cookie prefix test - consistent output * Added whitespace tests and name tests for __Http and __HostHttp * Remove tests where these cookies are set -- wpt-commits: 79cb467f488d41ee0429b905eb43d68d21a64d0e wpt-pr: 53973 UltraBlame original commit: 73588302dc1e3d1f6ee44dc2652a12bb87628c09
1 parent 7fd5381 commit 5022366

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

testing/web-platform/tests/cookie-store/cookieStore_special_names.https.any.js

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
}, `cookieStore.set with ${prefix} prefix a path option`);
5757
});
5858

59-
['__HostHttp-', '__hosthttp-', '__Http-', '__http-'].forEach(prefix => {
59+
['__HostHttp-', '__hosthttp-', '__Http-', '__http-', ' __Http-', '\t__Http-',
60+
' __HostHttp-', '\t__HostHttp-'].forEach(prefix => {
6061
promise_test(async testCase => {
6162
await promise_rejects_js(testCase, TypeError,
6263
cookieStore.set({ name: `${prefix}cookie-name`, value: 'cookie-value'}));
@@ -74,32 +75,20 @@ promise_test(async testCase => {
7475
assert_true(exceptionThrown, "No exception thrown.");
7576
}, 'cookieStore.set with malformed name.');
7677

77-
promise_test(async testCase => {
78-
79-
await cookieStore.delete('');
80-
81-
const currentUrl = new URL(self.location.href);
82-
const currentDomain = currentUrl.hostname;
78+
['__Host-', '__Secure-', '__Http-', '__HostHttp-', ' __Host-', '\t__Host-', ' __Secure-',
79+
'\t__Secure-', ' __Http-', '\t__Http-', ' __HostHttp-', '\t__HostHttp-'].forEach(prefix => {
80+
promise_test(async testCase => {
81+
82+
await cookieStore.delete('');
8383

84-
await promise_rejects_js(testCase, TypeError, cookieStore.set(
85-
{ name: '',
86-
value: '__Host-nameless-cookie',
87-
domain: `.${currentDomain}` }));
88-
const cookie = await cookieStore.get('');
89-
assert_equals(cookie, null);
90-
}, 'cookieStore.set a nameless cookie cannot have __Host- prefix');
84+
const currentUrl = new URL(self.location.href);
85+
const currentDomain = currentUrl.hostname;
9186

92-
promise_test(async testCase => {
93-
94-
await cookieStore.delete('');
95-
96-
const currentUrl = new URL(self.location.href);
97-
const currentDomain = currentUrl.hostname;
98-
99-
await promise_rejects_js(testCase, TypeError, cookieStore.set(
100-
{ name: '',
101-
value: '__Secure-nameless-cookie',
102-
domain: `.${currentDomain}` }));
103-
const cookie = await cookieStore.get('');
104-
assert_equals(cookie, null);
105-
}, 'cookieStore.set a nameless cookie cannot have __Secure- prefix');
87+
await promise_rejects_js(testCase, TypeError, cookieStore.set(
88+
{ name: '',
89+
value: `${prefix}nameless-cookie`,
90+
domain: `.${currentDomain}` }));
91+
const cookie = await cookieStore.get('');
92+
assert_equals(cookie, null);
93+
}, `cookieStore.set a nameless cookie cannot have ${prefix} prefix`);
94+
});

0 commit comments

Comments
 (0)