<!DOCTYPE html>
<meta charset="utf-8">
<title>WebSocket Opener</title>
<script>
  window.addEventListener("message", function (event) {
    const socket = new WebSocket(event.data);

    socket.onopen = () => {
      parent.postMessage("open", "*");
    };
    socket.onclose = (evt) => {
      parent.postMessage(`close: code ${evt.code}`, "*");
    };
  });
</script>
