diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html new file mode 100644 index 0000000000..ea28cf5375 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_helper-2.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<body> +<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 from our parent and open + // ourselves as the popup when we get the "start" message. + onmessage = function (e) { + if (e.data == "start") { + // Now listen for messages from the thing we plan to open. + onmessage = function(e) { + parent.postMessage({ data: e.data, origin: e.origin }, "*"); + } + + var a = document.createElement("a"); + a.href = location.href; + a.target = "_blank"; + a.rel = "opener"; + document.body.appendChild(a); + a.click(); + } + }; + } +</script> |