зеркало из https://github.com/electron/electron.git
Add webContents.focus() spec
This commit is contained in:
Родитель
be79417a03
Коммит
35908ac398
|
@ -308,4 +308,16 @@ describe('webContents module', function () {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
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'))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<!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>
|
Загрузка…
Ссылка в новой задаче