tor-browser

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

domain-attribute-missing.sub.html (1401B)


      1 <!DOCTYPE html>
      2 <head>
      3  <script src="/resources/testharness.js"></script>
      4  <script src="/resources/testharnessreport.js"></script>
      5  <script src="/cookies/resources/cookie-helper.sub.js"></script>
      6 </head>
      7 <body>
      8  <script>
      9    //
     10    //  Set-Cookie: domain-attribute-missing=b; Path=/
     11    //
     12    const cookieName = "domain-attribute-missing";
     13    // Clean up cookie at the end to avoid interfering with subsequent tests.
     14    add_completion_callback(tests => document.cookie =
     15      `${cookieName}=0; Path=/; expires=01-jan-1970 00:00:00 GMT`);
     16 
     17    test(t => {
     18      assert_dom_cookie(cookieName, "b", true);
     19    }, "No domain attribute => available via `document.cookie`");
     20 
     21    async_test(t => {
     22      fetch("/cookies/resources/list.py", { credentials: "include" })
     23        .then(t.step_func(r => r.json()))
     24        .then(t.step_func_done(r => {
     25          assert_equals(r[cookieName], "b");
     26        }))
     27        .catch(_ => assert_unreached);
     28    }, "No domain attribute => sent with same-origin requests.");
     29 
     30    async_test(t => {
     31      fetch(`${SECURE_SUBDOMAIN_ORIGIN}/cookies/resources/list.py`, { credentials: "include" })
     32        .then(t.step_func(r => r.json()))
     33        .then(t.step_func_done(r => {
     34          assert_equals(r[cookieName], undefined);
     35        }))
     36        .catch(_ => assert_unreached);
     37    }, "No domain attribute => not sent with subdomain requests.");
     38  </script>
     39 </body>