summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/cookies/samesite/resources/puppet.html
blob: 6d36132d3a89abea2f707e520e83a41590dac67a (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>
<script src="/cookies/resources/cookie-helper.sub.js"></script>
<script>
  // Helper to either set or clear some cookies on its own origin, or
  // (potentially) cross-site on SECURE_ORIGIN.
  window.onmessage = e => {
    var originToUse = SECURE_ORIGIN;
    if (e.data.useOwnOrigin)
      originToUse = self.origin;

    if (e.data.type === "set") {
      credFetch(originToUse + "/cookies/resources/setSameSite.py?" + e.data.value)
        .then(_ => {
          e.source.postMessage({
            type: "set-complete",
            value: e.data.value
          }, "*");
        });
    }

    if (e.data.type === "drop") {
      credFetch(originToUse + "/cookies/resources/dropSameSite.py")
        .then(_ => {
          e.source.postMessage({type: "drop-complete"}, "*");
        });
    }
  };

  window.opener.postMessage({
    type: "READY"
  }, "*");
</script>