https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 03598e505d3e3cd46ce992b3d6f358791125b04f authored by Ben Wells on 27 March 2018, 05:42:26 UTC
Revert "Don't adjust the NavigationTimings on redirects"
Tip revision: 03598e5
nested.py
def main(request, response):
    origin = request.GET.first("origin");
    value = request.GET.first("value");
    return ([("Content-Type", "text/html")],
            """<!DOCTYPE html>
<title>XFO.</title>
<body>
<script>
  var gotMessage = false;
  window.addEventListener("message", e => {
    gotMessage = true;
    window.parent.postMessage(e.data, "*");
  });

  var i = document.createElement("iframe");
  i.src = "%s/x-frame-options/support/xfo.py?value=%s";
  i.onload = _ => {
    // Why two rAFs? Because that seems to be enough to stop the
    // load event from racing with the onmessage event.
    requestAnimationFrame(_ => {
      requestAnimationFrame(_ => {
        if (!gotMessage) {
          window.parent.postMessage("Failed", "*");
        }
      });
    });
  };
  document.body.appendChild(i);
</script>
            """ % (origin, value))

back to top