}
})
})
+
+ describe('focus()', function () {
+ it('focuses the parent window', function (done) {
+ ipcMain.once('answer', (event, visible, focused) => {
+ assert.equal(visible, true)
+ assert.equal(focused, true)
+ done()
+ })
+ w.show()
+ w.loadURL('file://' + path.join(__dirname, 'fixtures', 'pages', 'focus-web-contents.html'))
+ })
+ })
})
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ <script>
+ const {ipcRenderer, remote} = require('electron')
+
+ const child = new remote.BrowserWindow({show: false})
+
+ remote.getCurrentWindow().once('blur', () => {
+ ipcRenderer.send('answer', child.isVisible(), child.isFocused())
+ child.close()
+ })
+
+ child.webContents.focus()
+ child.show()
+ child.webContents.focus()
+ </script>
+ </head>
+ <body>
+
+ </body>
+</html>