tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cookieStore_set_path.https.window.js (1141B)


      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');