Update blur parent window spec
This commit is contained in:
parent
35908ac398
commit
86007fe61d
2 changed files with 17 additions and 15 deletions
|
@ -310,14 +310,16 @@ describe('webContents module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('focus()', function () {
|
describe('focus()', function () {
|
||||||
it('focuses the parent window', function (done) {
|
describe('when the web contents is hidden', function () {
|
||||||
ipcMain.once('answer', (event, visible, focused) => {
|
it('does not blur the focused window', function (done) {
|
||||||
assert.equal(visible, true)
|
ipcMain.once('answer', (event, parentFocused, childFocused) => {
|
||||||
assert.equal(focused, true)
|
assert.equal(parentFocused, true)
|
||||||
done()
|
assert.equal(childFocused, false)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
w.show()
|
||||||
|
w.loadURL('file://' + path.join(__dirname, 'fixtures', 'pages', 'focus-web-contents.html'))
|
||||||
})
|
})
|
||||||
w.show()
|
|
||||||
w.loadURL('file://' + path.join(__dirname, 'fixtures', 'pages', 'focus-web-contents.html'))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
16
spec/fixtures/pages/focus-web-contents.html
vendored
16
spec/fixtures/pages/focus-web-contents.html
vendored
|
@ -6,16 +6,16 @@
|
||||||
<script>
|
<script>
|
||||||
const {ipcRenderer, remote} = require('electron')
|
const {ipcRenderer, remote} = require('electron')
|
||||||
|
|
||||||
|
remote.getCurrentWindow().focus()
|
||||||
|
|
||||||
const child = new remote.BrowserWindow({show: false})
|
const child = new remote.BrowserWindow({show: false})
|
||||||
|
child.loadURL('about:blank')
|
||||||
remote.getCurrentWindow().once('blur', () => {
|
|
||||||
ipcRenderer.send('answer', child.isVisible(), child.isFocused())
|
|
||||||
child.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
child.webContents.focus()
|
|
||||||
child.show()
|
|
||||||
child.webContents.focus()
|
child.webContents.focus()
|
||||||
|
|
||||||
|
const currentFocused = remote.getCurrentWindow().isFocused()
|
||||||
|
const childFocused = child.isFocused()
|
||||||
|
child.close()
|
||||||
|
ipcRenderer.send('answer', currentFocused, childFocused)
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Reference in a new issue