summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/samesite/setcookie-lax.https.html
blob: f2094af693d64919dffdc31c532a3d04d0b7d5db (plain)
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
<!DOCTYPE html>
<meta charset="utf-8"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/cookies/resources/cookie-helper.sub.js"></script>
<script>
  promise_test(async function(t) {
    let w = window.open(SECURE_ORIGIN + "/cookies/samesite/resources/puppet.html");
    await wait_for_message("READY", SECURE_ORIGIN);
    let random = "" + Math.random();
    w.postMessage({type: "set", value: random}, "*");
    let e = await wait_for_message("set-complete", SECURE_ORIGIN)
    assert_dom_cookie("samesite_strict", e.data.value, true);
    assert_dom_cookie("samesite_lax", e.data.value, true);
    assert_dom_cookie("samesite_none", e.data.value, true);
    assert_dom_cookie("samesite_unspecified", e.data.value, true);
    w.close();
  }, "Same-site window should be able to set `SameSite=Lax` or `SameSite=Strict` cookies.");

  promise_test(async function(t) {
    let w = window.open(SECURE_CROSS_SITE_ORIGIN + "/cookies/samesite/resources/puppet.html");
    await wait_for_message("READY", SECURE_CROSS_SITE_ORIGIN);
    let random = "" + Math.random();
    w.postMessage({type: "set", value: random}, "*");
    let e = await wait_for_message("set-complete", SECURE_CROSS_SITE_ORIGIN);
    assert_dom_cookie("samesite_strict", e.data.value, false);
    assert_dom_cookie("samesite_lax", e.data.value, false);
    assert_dom_cookie("samesite_none", e.data.value, true);
    assert_dom_cookie("samesite_unspecified", e.data.value, false);
    w.close();
  }, "Cross-site window shouldn't be able to set `SameSite=Lax` or `SameSite=Strict` cookies.");
</script>