diff --git a/lib/Input.js b/lib/Input.js index 02ce5d8b..c49ae3dd 100644 --- a/lib/Input.js +++ b/lib/Input.js @@ -115,6 +115,7 @@ class Mouse { x, y, modifiers: this._keyboard._modifiers }); + await this._doubleRaf(); } /** @@ -123,12 +124,15 @@ class Mouse { * @param {!Object=} options */ async click(x, y, options) { - await this.move(x, y); - await this.down(options); + this.move(x, y); + this.down(options); await this.up(options); + } + + async _doubleRaf() { // This is a hack for now, to make clicking less race-prone. See crbug.com/747647 await this._client.send('Runtime.evaluate', { - expression: 'new Promise(f => requestAnimationFrame(f))', + expression: 'new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))', awaitPromise: true, returnByValue: true }); @@ -149,6 +153,7 @@ class Mouse { modifiers: this._keyboard._modifiers, clickCount: (options.clickCount || 1) }); + await this._doubleRaf(); } /** @@ -166,6 +171,7 @@ class Mouse { modifiers: this._keyboard._modifiers, clickCount: (options.clickCount || 1) }); + await this._doubleRaf(); } }