Specify repeat property on repeated keypresses (#172)

This patch implements 'autoRepeat' functionality for `keyboard.down`.
With this patch, the subsequent calls to `keyboard.down` would generate
an event with 'autoRepeat` flag set to true.

Closes #157
This commit is contained in:
JoelEinbinder
2017-07-31 12:05:46 -07:00
committed by Andrey Lushnikov
parent 08799dd839
commit bfc40b2ee6
3 changed files with 19 additions and 3 deletions

View File

@@ -1098,6 +1098,15 @@ describe('Puppeteer', function() {
fail(modifiers[modifier] + ' should be false');
}
}));
it('should specify repeat property', SX(async function(){
await page.navigate(PREFIX + '/input/textarea.html');
await page.focus('textarea');
await page.$('textarea', textarea => textarea.addEventListener('keydown', e => window.lastEvent = e, true));
await page.keyboard.down('a', {text: 'a'});
expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(false);
await page.press('a');
expect(await page.evaluate(() => window.lastEvent.repeat)).toBe(true);
}));
function dimensions() {
let rect = document.querySelector('textarea').getBoundingClientRect();
return {