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

25 lines
1.1 KiB
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) {
2017-04-26 17:55:38 +00:00
// Ensure origins are properly checked by removing a single character from the end
2017-04-26 18:03:11 +00:00
window.opener.postMessage('do not deliver substring origin', window.location.origin.substring(0, window.location.origin.length - 1))
window.opener.postMessage('do not deliver file://', 'file://')
window.opener.postMessage('do not deliver http without port', 'http://127.0.0.1')
window.opener.postMessage('do not deliver atom', 'atom://')
window.opener.postMessage('do not deliver null', 'null')
window.opener.postMessage('do not deliver \\:/', '\\:/')
window.opener.postMessage('do not deliver empty', '')
window.opener.postMessage('deliver', window.location.origin)
} else {
2017-04-26 18:03:11 +00:00
const opened = window.open(`${window.location.href}?opened=true`, '', 'show=no')
window.addEventListener('message', function (event) {
window.opener.postMessage(event.data, '*')
opened.close()
})
}
</script>
</body>
</html>