fix: keyCode
s being incorrectly converted in webContents.sendInputEvent()
(#39776)
fix: sendInputEvent keyCodes being incorrectly converted
This commit is contained in:
parent
470a14d8d4
commit
ec9c8476fe
3 changed files with 32 additions and 4 deletions
|
@ -839,6 +839,20 @@ describe('webContents module', () => {
|
|||
expect(altKey).to.be.false();
|
||||
});
|
||||
|
||||
it('can correctly convert accelerators to key codes', async () => {
|
||||
const keyup = once(ipcMain, 'keyup');
|
||||
w.webContents.sendInputEvent({ keyCode: 'Plus', type: 'char' });
|
||||
w.webContents.sendInputEvent({ keyCode: 'Space', type: 'char' });
|
||||
w.webContents.sendInputEvent({ keyCode: 'Plus', type: 'char' });
|
||||
w.webContents.sendInputEvent({ keyCode: 'Space', type: 'char' });
|
||||
w.webContents.sendInputEvent({ keyCode: 'Plus', type: 'char' });
|
||||
w.webContents.sendInputEvent({ keyCode: 'Plus', type: 'keyUp' });
|
||||
|
||||
await keyup;
|
||||
const inputText = await w.webContents.executeJavaScript('document.getElementById("input").value');
|
||||
expect(inputText).to.equal('+ + +');
|
||||
});
|
||||
|
||||
it('can send char events with modifiers', async () => {
|
||||
const keypress = once(ipcMain, 'keypress');
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Z' });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue