tor-browser

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

partitioned-cookies-samesite-attribute.https.html (2626B)


      1 <!doctype html>
      2 <head>
      3  <meta charset="utf-8" />
      4  <meta name="timeout" content="long" />
      5  <meta
      6    name="help"
      7    href="https://github.com/WICG/CHIPS#chips-cookies-having-independent-partitioned-state"
      8  />
      9  <script src="/common/get-host-info.sub.js"></script>
     10  <script src="/resources/testharness.js"></script>
     11  <script src="/resources/testharnessreport.js"></script>
     12  <script src="/cookies/resources/testharness-helpers.js"></script>
     13  <script src="/resources/testdriver.js"></script>
     14  <script src="/resources/testdriver-vendor.js"></script>
     15  <title>Test SameSite attribute behavior for partitioned cookies</title>
     16 </head>
     17 <body>
     18  <script>
     19    document.body.onload = async () => {
     20      const iframe = document.createElement("iframe");
     21      iframe.src = new URL(
     22        "resources/partitioned-cookies-samesite-attributes-embed.html",
     23        get_host_info().HTTPS_NOTSAMESITE_ORIGIN + self.location.pathname,
     24      );
     25      document.body.appendChild(iframe);
     26      await new Promise(r => iframe.onload = r);
     27      await fetch_tests_from_window(iframe.contentWindow);
     28    };
     29 
     30    promise_test(async (t) => {
     31      t.add_cleanup(test_driver.delete_all_cookies);
     32 
     33      document.cookie = "testPartitioned=0; Secure; Partitioned;";
     34      document.cookie = "testUnpartitioned=1; Secure;";
     35      const partitionedCookie = await test_driver.get_named_cookie("testPartitioned");
     36      const unpartitionedCookie = await test_driver.get_named_cookie("testUnpartitioned");
     37 
     38      // Browsers have not aligned on a common SameSite attribute default yet.
     39      assert_any(assert_equals, partitionedCookie["sameSite"], ["Strict", "Lax", "None"]);
     40      assert_equals(partitionedCookie["sameSite"], unpartitionedCookie["sameSite"]);
     41    }, "In top-level contexts, partitioned cookies default to the same SameSite attribute as unpartitioned cookies.");
     42 
     43    promise_test(async (t) => {
     44      t.add_cleanup(test_driver.delete_all_cookies);
     45 
     46      document.cookie = "testStrict=0; Secure; Partitioned; SameSite=Strict;";
     47      let cookie = await test_driver.get_named_cookie("testStrict");
     48      assert_equals(cookie["sameSite"], "Strict");
     49 
     50      document.cookie = "testLax=0; Secure; Partitioned; SameSite=Lax;";
     51      cookie = await test_driver.get_named_cookie("testLax");
     52      assert_equals(cookie["sameSite"], "Lax");
     53 
     54      document.cookie = "testNone=0; Secure; Partitioned; SameSite=None;";
     55      cookie = await test_driver.get_named_cookie("testNone");
     56      assert_equals(cookie["sameSite"], "None");
     57    }, "In top-level contexts, partitioned cookies can be set with all SameSite attributes.");
     58  </script>
     59 </body>