diff --git a/cookiestore/cookieStore_set_path.https.window.js b/cookiestore/cookieStore_set_path.https.window.js new file mode 100644 index 00000000000000..4ccdda864b6a02 --- /dev/null +++ b/cookiestore/cookieStore_set_path.https.window.js @@ -0,0 +1,23 @@ +// META: title=Cookie Store API: set()'s path option +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js + +promise_test(async testCase => { + const currentUrl = new URL(self.location.href); + const currentPath = currentUrl.pathname; + const currentDirectory = currentPath.substr(0, currentPath.lastIndexOf('/')); + + await cookieStore.set({ name: 'cookie-name', value: 'cookie-value', path: '' }); + testCase.add_cleanup(async () => { + await cookieStore.delete({ name: 'cookie-name', path: currentDirectory }); + }); + + const internalCookie = await test_driver.get_named_cookie('cookie-name'); + assert_equals(internalCookie.path, currentDirectory); +}, 'CookieListItem - cookieStore.set with empty string path defaults to current URL'); + +promise_test(async testCase => { + const currentUrl = new URL(self.location.href); + const currentPath = currentUrl.pathname; + return promise_rejects_js(testCase, TypeError, cookieStore.set({ name: '__host-cookie-name', value: 'cookie-value', path: '' })); +}, 'CookieListItem - cookieStore.set with empty string path defaults to current URL with __host- prefix');