Skip to content

Commit 6575356

Browse files
authored
Cookie Store API: empty string path defaulting
For whatwg/cookiestore#283.
1 parent fe0d6c3 commit 6575356

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// META: title=Cookie Store API: set()'s path option
2+
// META: script=/resources/testdriver.js
3+
// META: script=/resources/testdriver-vendor.js
4+
5+
promise_test(async testCase => {
6+
const currentUrl = new URL(self.location.href);
7+
const currentPath = currentUrl.pathname;
8+
const currentDirectory = currentPath.substr(0, currentPath.lastIndexOf('/'));
9+
10+
await cookieStore.set({ name: 'cookie-name', value: 'cookie-value', path: '' });
11+
testCase.add_cleanup(async () => {
12+
await cookieStore.delete({ name: 'cookie-name', path: currentDirectory });
13+
});
14+
15+
const internalCookie = await test_driver.get_named_cookie('cookie-name');
16+
assert_equals(internalCookie.path, currentDirectory);
17+
}, 'CookieListItem - cookieStore.set with empty string path defaults to current URL');
18+
19+
promise_test(async testCase => {
20+
const currentUrl = new URL(self.location.href);
21+
const currentPath = currentUrl.pathname;
22+
return promise_rejects_js(testCase, TypeError, cookieStore.set({ name: '__host-cookie-name', value: 'cookie-value', path: '' }));
23+
}, 'CookieListItem - cookieStore.set with empty string path defaults to current URL with __host- prefix');

0 commit comments

Comments
 (0)