summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-3.html
blob: ef3e59037f4f67a53bc87ce3fcf1999886974c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<script>
  if (opener) {
    // We're the popup.  Send back our state.  What we really want to send is
    // our origin, but that will come automatically.
    opener.postMessage(undefined, "*");
    self.close();
  } else {
    // We're the child.  Start listening for messages and open ourselves as the
    // popup.
    onmessage = function (e) {
      parent.postMessage({ data: e.data, origin: e.origin }, "*");
    };
    var popupWin = window.open();
    popupWin.location.href = location.href;
  }
</script>