summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/form-action/form-action-self-allowed-target-blank.html
blob: bc81a63b621deb225bbce53d4cfd957ea2deef98 (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
35
36
37
38
39
40
<!DOCTYPE html>
<html>

<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta http-equiv="Content-Security-Policy" content="form-action 'self'">
</head>

<body>
  <form action='/content-security-policy/support/postmessage-pass-to-opener.html'
        id='form_id'
        target="_blank"
        rel="opener">
  </form>

  <p>
    Test that "form-action 'self'" works correctly when the form uses
    target="_blank". If this test passes, a new window must open after pressing
    "submit".
  </p>
</body>

<script>
  async_test(t => {
    document.addEventListener('securitypolicyviolation', function(e) {
      t.unreached_func("Form submission was blocked.");
    });

    window.addEventListener('message', function(event) {
      t.done();
    })

    window.addEventListener("load", function() {
      document.getElementById("form_id").submit();
    });
  }, "The form submission should not be blocked by the iframe's CSP.");
</script>

</html>