https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 21f1c08f6e5d4ead08f51968aa6246b2c54b7f15 authored by Geoffrey Sneddon on 10 April 2018, 07:46:22 UTC
Fix #10388: Make resources/test use the upstream config
Tip revision: 21f1c08
form-action-src-redirect-allowed-target-blank.sub.html
<!DOCTYPE html>
<html>
<head>
  <title>form-action-src-redirect-allowed-target-blank</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 _blank allowed after a redirect");
      window.addEventListener("message", function(event) {
        if (event.data == "DocumentNotBlocked") {
          event.source.close();
          test.done();
        }
      });

      let form = document.getElementById("form");
      let final_url = "/content-security-policy/form-action/support/post-message-to-opener.sub.html?message=DocumentNotBlocked";
      let redirect_url = "/common/redirect.py?location=";
      form.action = redirect_url + encodeURIComponent(final_url);

      let submit = document.getElementById("submit");
      submit.click();
    }
  </script>
</head>
<body onload="OnDocumentLoaded();">
  <form id="form" method="POST" target="_blank">
    <input type="submit" id="submit">
  </form>
</body>
</html>

back to top