mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
test(mouse): add a test for pointerdown event with custom button (#10697)
This commit is contained in:
parent
105912e898
commit
8b5e146b90
@ -40,9 +40,9 @@ function toButtonsMask(buttons: Set<types.MouseButton>): number {
|
||||
let mask = 0;
|
||||
if (buttons.has('left'))
|
||||
mask |= 1;
|
||||
if (buttons.has('middle'))
|
||||
mask |= 2;
|
||||
if (buttons.has('right'))
|
||||
mask |= 2;
|
||||
if (buttons.has('middle'))
|
||||
mask |= 4;
|
||||
return mask;
|
||||
}
|
||||
|
@ -78,6 +78,38 @@ it('should dblclick the div', async ({ page, server }) => {
|
||||
expect(event.button).toBe(0);
|
||||
});
|
||||
|
||||
it('should pointerdown the div with a custom button', async ({ page, server, browserName }) => {
|
||||
await page.setContent(`<div style='width: 100px; height: 100px;'>Click me</div>`);
|
||||
await page.evaluate(() => {
|
||||
window['pointerdownPromise'] = new Promise(resolve => {
|
||||
document.querySelector('div').addEventListener('pointerdown', event => {
|
||||
resolve({
|
||||
type: event.type,
|
||||
detail: event.detail,
|
||||
clientX: event.clientX,
|
||||
clientY: event.clientY,
|
||||
isTrusted: event.isTrusted,
|
||||
button: event.button,
|
||||
buttons: event.buttons,
|
||||
pointerId: event.pointerId,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
await page.mouse.click(50, 60, {
|
||||
button: 'middle'
|
||||
});
|
||||
const event = await page.evaluate(() => window['pointerdownPromise']);
|
||||
expect(event.type).toBe('pointerdown');
|
||||
expect(event.detail).toBe(browserName === 'webkit' ? 1 : 0);
|
||||
expect(event.clientX).toBe(50);
|
||||
expect(event.clientY).toBe(60);
|
||||
expect(event.isTrusted).toBe(true);
|
||||
expect(event.button).toBe(1);
|
||||
expect(event.buttons).toBe(4);
|
||||
expect(event.pointerId).toBe(browserName === 'firefox' ? 0 : 1);
|
||||
});
|
||||
|
||||
it('should select the text with mouse', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
await page.focus('textarea');
|
||||
|
Loading…
Reference in New Issue
Block a user