<!DOCTYPE html>
<head>
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/cookies/resources/cookie-helper.sub.js"></script>
</head>
<body>
  <script>
    //
    //  Set-Cookie: a=b; Path=/; Domain=.{{host}}
    //  Set-Cookie: a=c; Path=/; Domain={{host}}
    //
    test(t => {
      assert_dom_cookie("a", "c", true);
    }, "Domain=.{{host}} => Second value available via `document.cookie`");

    async_test(t => {
      fetch("/cookies/resources/list.py", { credentials: "include" })
        .then(t.step_func(r => r.json()))
        .then(t.step_func_done(r => {
          assert_equals(r["a"], "c");
        }))
        .catch(_ => assert_unreached);
    }, "Domain=.{{host}} => Second value sent with same-origin requests.");

    async_test(t => {
      fetch(`${SECURE_SUBDOMAIN_ORIGIN}/cookies/resources/list.py`, { credentials: "include" })
        .then(t.step_func(r => r.json()))
        .then(t.step_func_done(r => {
          assert_equals(r["a"], "c");
        }))
        .catch(_ => assert_unreached);
    }, "Domain=.{{host}} => Second value sent with subdomain requests.");
  </script>
</body>
