electron/spec/fixtures/pages/window-opener-targetOrigin.html

19 lines
682 B
HTML
Raw Normal View History

<html>
<body>
<script type="text/javascript" charset="utf-8">
const url = require('url')
if (url.parse(window.location.href, true).query.opened != null) {
// Ensure origin are properly checked by removing a single character from the end
window.opener.postMessage('first message', window.location.origin.substring(0, window.location.origin.length - 1))
window.opener.postMessage('second message', window.location.origin)
} else {
const opened = window.open(`${window.location.href}?opened=true`)
window.addEventListener('message', function (event) {
window.opener.postMessage(event.data, '*')
opened.close()
})
}
</script>
</body>
</html>