Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window object from nw.Window.open is null when an new_instance window is open #4691

Closed
ghostoy opened this issue Apr 7, 2016 · 3 comments
Closed
Assignees
Milestone

Comments

@ghostoy
Copy link
Member

ghostoy commented Apr 7, 2016

The issue can be reproduce with following steps:

  • Open the first window with new_instance set to true. The callback from nw.Window.open is null as expected.
  • Open another window without new_instance. The callback from nw.Window.open is also null, which is wrong.
  • Close all the two windows
  • Open the third window without new_instance. The callback from nw.Window.open now points to a right window object.

SAMPLE

package.json

{
  "name": "new-instance-open",
  "main": "index.html"
}

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>index</title>
</head>
<body>
  <h1>index.html</h1>
  <button onclick="openNewInstance()" type="button">new-instance</button>
  <button onclick="openSameInstance()" type="button">same-instance</button>
  <script>
    function openNewInstance() {
      nw.Window.open('new-instance.html', {'new_instance': true}, function(w) {
        alert('new instance window: ' + w);
      });
    }
    function openSameInstance() {
      nw.Window.open('same-instance.html', {}, function(w) {
        alert('same instance window: ' + w);
      });
    }  </script>
</body>
</html>

new-instance.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>new-instance</title>
</head>
<body>
  <h1>new-instance.html</h1>
</body>
</html>

same-instance.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>same-instance</title>
</head>
<body>
  <h1>same-instance.html</h1>
</body>
</html>
@ghostoy
Copy link
Member Author

ghostoy commented Apr 7, 2016

Interesting thing is that the window object same-instance.html seems to be held by the new-instance.html. If you run chrome.app.window.getAll() in the devtools of all three opened windows, you will find 1 object in index.html, and 2 objects in new-instance.html and 2 objects in same-instance.html. And later two are the same.

@rogerwang rogerwang self-assigned this Apr 8, 2016
@rogerwang rogerwang added this to the 0.13.x milestone Apr 8, 2016
@rogerwang
Copy link
Member

fixed in chromium git and will be available in the next nightly build.

ghostoy pushed a commit to ghostoy/nw.js that referenced this issue Aug 24, 2016
rogerwang added a commit that referenced this issue Aug 24, 2016
@gpetrov
Copy link

gpetrov commented Nov 10, 2016

@rogerwang just tried to use the new_instance on the latest 0.18.5 and it still fails as described above! It doesn't return the new window instance in the callback. I thought it was fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants