nw.js
nw.js copied to clipboard
frames in sites get wrong window object when accessing `window.top` when calling `onload`
Issue Type
- [x] Bug Report
- [x] Successfully reproduced against the latest version of NW.js?
Current/Missing Behavior
iframe in sites get wrong window object when accessing window.top when calling onload. Consider the following HTML loaded inside an iframe. The parent window name is TOP:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test window.top IFRAME</title>
<script type="application/javascript">
function test() {
console.log('name:', window.top.name);
setTimeout(() => {
console.log('name:', window.top.name);
}, 1000);
}
</script>
</head>
<body onload="test()">
</body>
</html>
In Chrome, console.log outputs:
name: 'TOP'
name: 'TOP'
In NW.js, console.log outputs:
name: ''
name: 'TOP'
Code used in main.js for NW.js
nw.Window.open('http://localhost:3000/test-window-top', {}, (win) => {
win.showDevTools();
});
Expected/Proposed Behavior
NW.js should match Chrome behaviour.
Additional Info
- Operating System: OSX
- NW.js Version: 0.67.1
Hello guys, any comments on this issue: it's a bit pressing for us and we can even discuss a bounty. Thanks.
It works for me with 0.71.0
I can confirm that it is no longer reproducible in 0.71.0. Thanks for checking!