summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup.html
blob: 7addc7943c0ee29dd92f6319d92501984f7f46fe (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" />
<meta name="timeout" content="long">
<title>Cross-site popup</title>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/cookies/resources/cookie-helper.sub.js"></script>
<script src="/cookies/third-party-cookies/resources/test-helpers.js"></script>

<body>
  <button id="button" onclick="userInteractionCallback()">Click for user interaction</button>

  <script>
    const origin = window.origin;
    const crossSiteOrigin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN + self.location.pathname;

    function userInteractionCallback() {
      // Third-party cookies are now allowed.
      const verify3pAllowedUrl = new URL(
        `./third-party-cookies-cross-site-popup-verify.html?desc=3P_fetch_with_heuristics&origin=${encodeURIComponent(origin)}`,
        crossSiteOrigin);
      const verify3pAllowedPopup = window.open(verify3pAllowedUrl);
      fetch_tests_from_window(verify3pAllowedPopup);
    };

    test_driver.set_test_context(window.opener.opener);
    test_driver.click(document.getElementById("button"));

  </script>
</body>