tor-browser

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

domain_parsing-child.sub.https.html (1723B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <script src="/resources/testharness.js"></script>
      5 </head>
      6 <body>
      7  <script>
      8    async function ValidateCookieStoreSet(testCase, cookieDomain, cookieName) {
      9      await cookieStore.set(
     10          { name: cookieName, value: "cookie-value", domain: cookieDomain });
     11 
     12      testCase.add_cleanup(async () => {
     13        await cookieStore.delete(cookieName);
     14      });
     15 
     16      const cookie = await cookieStore.get(cookieName);
     17      assert_equals(cookie.name, cookieName);
     18      assert_equals(cookie.value, "cookie-value");
     19    }
     20 
     21 
     22    const url = new URL(self.location.href);
     23    const test = url.searchParams.get("test");
     24    let cookieDomain;
     25 
     26    switch (test) {
     27      case "IDNA":
     28        cookieDomain = url.hostname;
     29        promise_test(async t => { await ValidateCookieStoreSet(t, cookieDomain, test) }, "cookieStore.set with domain on a IDNA host");
     30        break;
     31      case "IP":
     32        cookieDomain = url.hostname;
     33        promise_test(async t => { await ValidateCookieStoreSet(t, cookieDomain, test) }, "cookieStore.set with domain on an IP address host");
     34        break;
     35      case "uppercase":
     36        cookieDomain = url.hostname;
     37        // scramble the casing of the characters example.com ==> ExAmPlE.CoM
     38        cookieDomain = cookieDomain.split("")
     39          .map((char, index) =>
     40            index % 2 === 0 ? char.toUpperCase() : char.toLowerCase()
     41          )
     42          .join("");
     43        promise_test(async t => { await ValidateCookieStoreSet(t, cookieDomain, test) }, "cookieStore.set with domain set to the current hostname but differently cased");
     44        break;
     45      default:
     46        throw new Error(`Invalid test parameter: ${test}`);
     47    }
     48  </script>
     49 </body>
     50 </html>