| OLD | NEW |
| (Empty) | |
| 1 (async function(testRunner) { |
| 2 let {page, session, dp} = await testRunner.startBlank(``); |
| 3 |
| 4 await session.evaluate(` |
| 5 var logs = []; |
| 6 function log(text) { |
| 7 logs.push(text); |
| 8 } |
| 9 |
| 10 function logEvent(event) { |
| 11 log('-----Event-----'); |
| 12 log('type: ' + event.type); |
| 13 if (event.shiftKey) |
| 14 log('shiftKey'); |
| 15 log('----Touches----'); |
| 16 for (var i = 0; i < event.touches.length; i++) { |
| 17 var touch = event.touches[i]; |
| 18 log('id: ' + i); |
| 19 log('pageX: ' + touch.pageX); |
| 20 log('pageY: ' + touch.pageY); |
| 21 log('radiusX: ' + touch.radiusX); |
| 22 log('radiusY: ' + touch.radiusY); |
| 23 log('rotationAngle: ' + touch.rotationAngle); |
| 24 log('force: ' + touch.force); |
| 25 } |
| 26 } |
| 27 |
| 28 window.addEventListener('touchstart', logEvent); |
| 29 window.addEventListener('touchend', logEvent); |
| 30 window.addEventListener('touchmove', logEvent); |
| 31 `); |
| 32 |
| 33 function dumpError(message) { |
| 34 if (message.error) |
| 35 testRunner.log('Error: ' + message.error.message); |
| 36 } |
| 37 |
| 38 dumpError(await dp.Input.dispatchTouchEvent({ |
| 39 type: 'touchStart', |
| 40 touchPoints: [{ |
| 41 state: 'touchPressed', |
| 42 x: 100, |
| 43 y: 200 |
| 44 }] |
| 45 })); |
| 46 dumpError(await dp.Input.dispatchTouchEvent({ |
| 47 type: 'touchMove', |
| 48 touchPoints: [{ |
| 49 state: 'touchMoved', |
| 50 x: 100, |
| 51 y: 200 |
| 52 }] |
| 53 })); |
| 54 dumpError(await dp.Input.dispatchTouchEvent({ |
| 55 type: 'touchEnd', |
| 56 touchPoints: [{ |
| 57 state: 'touchReleased', |
| 58 x: 100, |
| 59 y: 200 |
| 60 }] |
| 61 })); |
| 62 dumpError(await dp.Input.dispatchTouchEvent({ |
| 63 type: 'touchStart', |
| 64 touchPoints: [{ |
| 65 state: 'touchPressed', |
| 66 x: 20, |
| 67 y: 30, |
| 68 id: 0 |
| 69 }, { |
| 70 state: 'touchPressed', |
| 71 x: 100, |
| 72 y: 200, |
| 73 radiusX: 5, |
| 74 radiusY: 6, |
| 75 rotationAngle: 1.0, |
| 76 force: 0.0, |
| 77 id: 1 |
| 78 }], |
| 79 modifiers: 8 // shift |
| 80 })); |
| 81 dumpError(await dp.Input.dispatchTouchEvent({ |
| 82 type: 'touchEnd', |
| 83 touchPoints: [{ |
| 84 state: 'touchReleased', |
| 85 x: 100, |
| 86 y: 100, |
| 87 id: 0 |
| 88 }, { |
| 89 state: 'touchReleased', |
| 90 x: 100, |
| 91 y: 200, |
| 92 id: 1 |
| 93 }] |
| 94 })); |
| 95 |
| 96 testRunner.log(await session.evaluate(`window.logs.join('\\n')`)); |
| 97 testRunner.completeTest(); |
| 98 }) |
| OLD | NEW |