В EDGE работает.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function createIframe(win) {
var frame = document.createElement('iframe');
frame.width = 300;
frame.height = 300;
frame.id = 'ifr';
frame.src = '';
document.body.appendChild(frame);
var script = document.createElement('script');
script.innerHTML = 'console.log(window.parent.foo);';
frame.contentWindow.document.head.appendChild(script)
}
window.foo = 'bar';
setTimeout(function() {
createIframe(window);
}, 3000);
</script>
</body>
</html>