mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(page): fix missing awaits in mouse.click (#4541)
Lack of await causes dangling promises, which lead to unhandled rejections that cannot be caught if these calls fail (e.g. if the page is closed). References #4536
This commit is contained in:
parent
7faf1c9030
commit
dd6fcfe77b
15
lib/Input.js
15
lib/Input.js
@ -224,11 +224,20 @@ class Mouse {
|
||||
*/
|
||||
async click(x, y, options = {}) {
|
||||
const {delay = null} = options;
|
||||
this.move(x, y);
|
||||
this.down(options);
|
||||
if (delay !== null)
|
||||
if (delay !== null) {
|
||||
await Promise.all([
|
||||
this.move(x, y),
|
||||
this.down(options),
|
||||
]);
|
||||
await new Promise(f => setTimeout(f, delay));
|
||||
await this.up(options);
|
||||
} else {
|
||||
await Promise.all([
|
||||
this.move(x, y),
|
||||
this.down(options),
|
||||
this.up(options),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user