File: partitioned-cookies-samesite-attribute.https.html

package info (click to toggle)
firefox 145.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,653,344 kB
  • sloc: cpp: 7,594,932; javascript: 6,459,612; ansic: 3,752,905; python: 1,403,433; xml: 629,811; asm: 438,677; java: 186,421; sh: 67,287; makefile: 19,169; objc: 13,086; perl: 12,982; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (59 lines) | stat: -rw-r--r-- 2,626 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!doctype html>
<head>
  <meta charset="utf-8" />
  <meta name="timeout" content="long" />
  <meta
    name="help"
    href="https://github.com/WICG/CHIPS#chips-cookies-having-independent-partitioned-state"
  />
  <script src="/common/get-host-info.sub.js"></script>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/cookies/resources/testharness-helpers.js"></script>
  <script src="/resources/testdriver.js"></script>
  <script src="/resources/testdriver-vendor.js"></script>
  <title>Test SameSite attribute behavior for partitioned cookies</title>
</head>
<body>
  <script>
    document.body.onload = async () => {
      const iframe = document.createElement("iframe");
      iframe.src = new URL(
        "resources/partitioned-cookies-samesite-attributes-embed.html",
        get_host_info().HTTPS_NOTSAMESITE_ORIGIN + self.location.pathname,
      );
      document.body.appendChild(iframe);
      await new Promise(r => iframe.onload = r);
      await fetch_tests_from_window(iframe.contentWindow);
    };

    promise_test(async (t) => {
      t.add_cleanup(test_driver.delete_all_cookies);

      document.cookie = "testPartitioned=0; Secure; Partitioned;";
      document.cookie = "testUnpartitioned=1; Secure;";
      const partitionedCookie = await test_driver.get_named_cookie("testPartitioned");
      const unpartitionedCookie = await test_driver.get_named_cookie("testUnpartitioned");

      // Browsers have not aligned on a common SameSite attribute default yet.
      assert_any(assert_equals, partitionedCookie["sameSite"], ["Strict", "Lax", "None"]);
      assert_equals(partitionedCookie["sameSite"], unpartitionedCookie["sameSite"]);
    }, "In top-level contexts, partitioned cookies default to the same SameSite attribute as unpartitioned cookies.");

    promise_test(async (t) => {
      t.add_cleanup(test_driver.delete_all_cookies);

      document.cookie = "testStrict=0; Secure; Partitioned; SameSite=Strict;";
      let cookie = await test_driver.get_named_cookie("testStrict");
      assert_equals(cookie["sameSite"], "Strict");

      document.cookie = "testLax=0; Secure; Partitioned; SameSite=Lax;";
      cookie = await test_driver.get_named_cookie("testLax");
      assert_equals(cookie["sameSite"], "Lax");

      document.cookie = "testNone=0; Secure; Partitioned; SameSite=None;";
      cookie = await test_driver.get_named_cookie("testNone");
      assert_equals(cookie["sameSite"], "None");
    }, "In top-level contexts, partitioned cookies can be set with all SameSite attributes.");
  </script>
</body>