Add test for AltGr abort on blur

This commit is contained in:
Pierre Ossman 2024-08-05 16:31:59 +02:00
parent a020ef0f44
commit 06f14a5cd3
1 changed files with 16 additions and 0 deletions

View File

@ -478,6 +478,22 @@ describe('Key Event Handling', function () {
expect(kbd.onkeyevent).to.not.have.been.called; expect(kbd.onkeyevent).to.not.have.been.called;
}); });
it('should release ControlLeft on blur', function () {
const kbd = new Keyboard(document);
kbd.onkeyevent = sinon.spy();
kbd._handleKeyDown(keyevent('keydown', {code: 'ControlLeft', key: 'Control', location: 1}));
expect(kbd.onkeyevent).to.not.have.been.called;
kbd._allKeysUp();
expect(kbd.onkeyevent).to.have.been.calledTwice;
expect(kbd.onkeyevent.firstCall).to.have.been.calledWith(0xffe3, "ControlLeft", true);
expect(kbd.onkeyevent.secondCall).to.have.been.calledWith(0xffe3, "ControlLeft", false);
// Check that the timer is properly dead
kbd.onkeyevent.resetHistory();
this.clock.tick(100);
expect(kbd.onkeyevent).to.not.have.been.called;
});
it('should generate AltGraph for quick Ctrl+Alt sequence', function () { it('should generate AltGraph for quick Ctrl+Alt sequence', function () {
const kbd = new Keyboard(document); const kbd = new Keyboard(document);
kbd.onkeyevent = sinon.spy(); kbd.onkeyevent = sinon.spy();