https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 266ac8ec00a6f75e2dc971ee3ebde12ee804d093 authored by James Graham on 12 April 2018, 14:20:58 UTC
Fix computing reftest_nodes_by_url.
Tip revision: 266ac8e
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