test: make before-input-event test more robust
This commit is contained in:
parent
41d806ee45
commit
b11b4f2235
2 changed files with 7 additions and 7 deletions
|
@ -159,17 +159,16 @@ describe('webContents module', () => {
|
|||
|
||||
describe('before-input-event event', () => {
|
||||
it('can prevent document keyboard events', (done) => {
|
||||
w.loadFile(path.join(fixtures, 'pages', 'key-events.html'))
|
||||
w.webContents.once('did-finish-load', () => {
|
||||
ipcMain.once('keydown', (event, key) => {
|
||||
assert.strictEqual(key, 'b')
|
||||
done()
|
||||
})
|
||||
|
||||
ipcRenderer.send('prevent-next-input-event', 'a', w.webContents.id)
|
||||
w.webContents.once('did-finish-load', () => {
|
||||
ipcRenderer.sendSync('prevent-next-input-event', 'a', w.webContents.id)
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'a' })
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'b' })
|
||||
})
|
||||
w.loadFile(path.join(fixtures, 'pages', 'key-events.html'))
|
||||
})
|
||||
|
||||
it('has the correct properties', (done) => {
|
||||
|
|
|
@ -212,6 +212,7 @@ app.on('ready', function () {
|
|||
webContents.fromId(id).once('before-input-event', (event, input) => {
|
||||
if (key === input.key) event.preventDefault()
|
||||
})
|
||||
event.returnValue = null
|
||||
})
|
||||
|
||||
ipcMain.on('executeJavaScript', function (event, code, hasCallback) {
|
||||
|
|
Loading…
Reference in a new issue