summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/form-action/form-action-src-allowed-target-frame.sub.html
blob: 81921d395e312f2e0958c266a638aa4d5e1ce2f6 (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
33
34
<!DOCTYPE html>
<html>
<head>
  <title>form-action-src-allowed-target-frame</title>
  <meta http-equiv="Content-Security-Policy" content="form-action 'self'">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script>
    function OnDocumentLoaded() {
      let test = async_test("form submission targetting a frame allowed");
      window.addEventListener("message", function(event) {
        if (event.data == "DocumentNotBlocked") {
          test.done();
        }
      });

      let form = document.getElementById("form");
      form.action =
        "/content-security-policy/form-action/support/post-message-to-parent.sub.html";

      let submit = document.getElementById("submit");
      submit.click();
    }
  </script>
</head>
<body onload="OnDocumentLoaded();">
  <form id="form" method="GET" target="frame">
    <input type="hidden" name="message" value="DocumentNotBlocked">
    <input type="submit" id="submit">
  </form>
  <iframe name="frame"></iframe>
</body>
</html>