nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

frames in sites get wrong window object when accessing `window.top` when calling `onload`

Open nicolasgarfinkiel opened this issue 3 years ago • 1 comments

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

nicolasgarfinkiel avatar Aug 17 '22 15:08 nicolasgarfinkiel

Hello guys, any comments on this issue: it's a bit pressing for us and we can even discuss a bounty. Thanks.

nicolasgarfinkiel avatar Sep 12 '22 08:09 nicolasgarfinkiel

It works for me with 0.71.0

rogerwang avatar Dec 14 '22 17:12 rogerwang

I can confirm that it is no longer reproducible in 0.71.0. Thanks for checking!

nicolasgarfinkiel avatar Jan 11 '23 17:01 nicolasgarfinkiel