Add webContents.focus() spec
This commit is contained in:
parent
be79417a03
commit
35908ac398
2 changed files with 36 additions and 0 deletions
|
@ -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'))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
24
spec/fixtures/pages/focus-web-contents.html
vendored
Normal file
24
spec/fixtures/pages/focus-web-contents.html
vendored
Normal file
|
@ -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>
|
Loading…
Reference in a new issue