fix(firefox): fix missing awaits in mouse.click (#4561)
This applies the same fix we used on the Chrome-side and adds a test. Fix #4536
This commit is contained in:
parent
e1432cc08a
commit
6a50888d34
@ -218,11 +218,20 @@ class Mouse {
|
|||||||
*/
|
*/
|
||||||
async click(x, y, options = {}) {
|
async click(x, y, options = {}) {
|
||||||
const {delay = null} = options;
|
const {delay = null} = options;
|
||||||
this.move(x, y);
|
if (delay !== null) {
|
||||||
this.down(options);
|
await Promise.all([
|
||||||
if (delay !== null)
|
this.move(x, y),
|
||||||
|
this.down(options),
|
||||||
|
]);
|
||||||
await new Promise(f => setTimeout(f, delay));
|
await new Promise(f => setTimeout(f, delay));
|
||||||
await this.up(options);
|
await this.up(options);
|
||||||
|
} else {
|
||||||
|
await Promise.all([
|
||||||
|
this.move(x, y),
|
||||||
|
this.down(options),
|
||||||
|
this.up(options),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,6 +55,13 @@ module.exports.addTests = function({testRunner, expect, puppeteer}) {
|
|||||||
await page.click('span');
|
await page.click('span');
|
||||||
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
|
expect(await page.evaluate(() => window.CLICKED)).toBe(42);
|
||||||
});
|
});
|
||||||
|
it('should not throw UnhandledPromiseRejection when page closes', async({page, server}) => {
|
||||||
|
const newPage = await page.browser().newPage();
|
||||||
|
await Promise.all([
|
||||||
|
newPage.close(),
|
||||||
|
newPage.mouse.click(1, 2),
|
||||||
|
]).catch(e => {});
|
||||||
|
});
|
||||||
it('should click the button after navigation ', async({page, server}) => {
|
it('should click the button after navigation ', async({page, server}) => {
|
||||||
await page.goto(server.PREFIX + '/input/button.html');
|
await page.goto(server.PREFIX + '/input/button.html');
|
||||||
await page.click('button');
|
await page.click('button');
|
||||||
|
Loading…
Reference in New Issue
Block a user