Implement Same-Site cookies
[WebKit-https.git] / LayoutTests / http / tests / cookies / same-site / popup-cross-site.html
1 <!DOCTYPE html>
2 <script src="/js-test-resources/testharness.js"></script>
3 <script src="/js-test-resources/testharnessreport.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
5 <script>
6 if (window.location.hostname == "127.0.0.1") {
7     document.cookie = STRICT_DOM + "=1; SameSite=Strict; Max-Age=100; path=/";
8     document.cookie = IMPLICIT_STRICT_DOM + "=1; SameSite; Max-Age=100; path=/";
9     document.cookie = STRICT_BECAUSE_INVALID_SAMESITE_VALUE + "=1; SameSite=invalid; Max-Age=100; path=/";
10     document.cookie = LAX_DOM + "=1; SameSite=Lax; Max-Age=100; path=/";
11     document.cookie = NORMAL_DOM + "=1; Max-Age=100; path=/";
12     window.location.hostname = "localhost";
13 } else {
14     async_test(t => {
15         var i = window.open("http://127.0.0.1:8000/cookies/resources/post-cookies-to-opener.php");
16         window.addEventListener("message", t.step_func_done(e => {
17             assert_equals(e.data.http[STRICT_DOM], undefined, "strict");
18             assert_equals(e.data.http[IMPLICIT_STRICT_DOM], undefined, "implicit-strict");
19             assert_equals(e.data.http[STRICT_BECAUSE_INVALID_SAMESITE_VALUE], undefined, "strict-because-invalid-SameSite-value");
20             assert_equals(e.data.http[LAX_DOM], "1", "lax");
21             assert_equals(e.data.http[NORMAL_DOM], "1", "normal");
22             assert_equals(normalizeCookie(e.data.document), normalizeCookie(LAX_DOM + "=1; " + NORMAL_DOM + "=1"));
23         }));
24     }, "'127.0.0.1' is not same-site with 'localhost', so strict samesite cookies are not sent.");
25 }
26 </script>