fix(touch): requestAnimationFrame before sending tap (#1142)

This patch adds a work-around for the upstream bug, issuing double-raf before emulating touch event.

References #673
This commit is contained in:
JoelEinbinder 2017-10-26 14:53:50 -07:00 committed by Andrey Lushnikov
parent d1f044e18f
commit 655b94db47

View File

@ -281,6 +281,14 @@ class Touchscreen {
* @param {number} y
*/
async tap(x, y) {
// Touches appear to be lost during the first frame after navigation.
// This waits a frame before sending the tap.
// @see https://crbug.com/613219
await this._client.send('Runtime.evaluate', {
expression: 'new Promise(x => requestAnimationFrame(() => requestAnimationFrame(x)))',
awaitPromise: true
});
const touchPoints = [{x: Math.round(x), y: Math.round(y)}];
await this._client.send('Input.dispatchTouchEvent', {
type: 'touchStart',