title: Electron Doesn't Return Proper Value From window.open()
body: <p>I have an Electron app  which renders an HTML file with contents along the lines of:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script&gt;
        var myfunc = function() {
          var data = "Some stuff to display in another window.";
          var secondWindow = window.open();
          secondWindow.document.write(data);
        };
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;button onclick="myfunc();"&gt;Open Second Window&lt;/button&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now this works in my normal browser (Firefox) but in the Electron app when I <code>JSON.stringify(secondWindow);</code> I get <code>{'closed': false}</code> and not an actual window handle (though an empty window does open). </p>
  
  <p>Can anyone shed extra light on this behavior and perhaps a way to achieve the desired result with Electron?</p>
  
  <p>Electron app:</p>
  
  <pre><code>const {app, BrowserWindow} = require("electron");
  const path = require("path");
  const url = require("url");
  
  let win
  
  function createWindow () {
    win = new BrowserWindow({width: 800, height: 600})
    win.loadURL(url.format({
      pathname: path.join(__dirname, 'index.html'),
      protocol: 'file:',
      slashes: true
    }))
    win.webContents.openDevTools({"detach": true})
    win.on('closed', () =&gt; {
      win = null
    })
  }
  
  app.on('ready', createWindow)
  
  app.on('window-all-closed', () =&gt; {
    if (process.platform !== 'darwin') {
      app.quit()
    }
  })
  
  app.on('activate', () =&gt; {
    if (win === null) {
      createWindow()
    }
  })
  </code></pre>