| <html> |
| <head> |
| <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
| <script> |
| |
| window.addEventListener("touchstart", logEvent, {passive: false}); |
| window.addEventListener("touchmove", logEvent, {passive: false}); |
| window.addEventListener("touchend", logEvent); |
| window.addEventListener("touchcancel", logEvent); |
| |
| function logEvent(event) |
| { |
| event.preventDefault(); |
| log("-----Event-----"); |
| log("type: " + event.type); |
| if (event.shiftKey) |
| log("shiftKey"); |
| log("----Touches----"); |
| for (var i = 0; i < event.touches.length; i++) { |
| var touch = event.touches[i]; |
| log("id: " + i); |
| log("pageX: " + touch.pageX); |
| log("pageY: " + touch.pageY); |
| log("radiusX: " + touch.radiusX); |
| log("radiusY: " + touch.radiusY); |
| log("rotationAngle: " + touch.rotationAngle); |
| log("force: " + touch.force); |
| } |
| evaluateInFrontend("onEvent();"); |
| } |
| |
| function test() |
| { |
| var events = [ |
| { |
| "type": "mousePressed", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 200 |
| }, |
| { |
| "type": "mouseMoved", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 250 |
| }, |
| { |
| "type": "mouseReleased", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 250 |
| }, |
| { |
| "type": "mouseMoved", |
| "button": "none", |
| "modifiers": 8, // shift |
| "x": 50, |
| "y": 150 |
| }, |
| { |
| "type": "mousePressed", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 200 |
| }, |
| { |
| "type": "mouseMoved", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 250 |
| }, |
| { |
| "type": "mouseReleased", |
| "button": "left", |
| "clickCount": 1, |
| "x": 100, |
| "y": 250 |
| } |
| ]; |
| |
| var time = Number(new Date()) / 1000; |
| var index = 0; |
| |
| function sendNextEvent() { |
| if (index === events.length) { |
| maybeFinish(); |
| return; |
| } |
| var event = events[index]; |
| event.timestamp = time + index; |
| index++; |
| InspectorTest.sendCommand("Input.emulateTouchFromMouseEvent", event, checkResponse); |
| } |
| |
| function checkResponse(msg) |
| { |
| if (msg.error) |
| InspectorTest.log("Error: " + msg.error.message); |
| sendNextEvent(); |
| } |
| |
| const expectedEventCount = 6; |
| var eventCount = 0; |
| window.onEvent = function() |
| { |
| eventCount++; |
| maybeFinish(); |
| }; |
| |
| function maybeFinish() |
| { |
| if (index === events.length && eventCount === expectedEventCount) |
| InspectorTest.completeTest(); |
| } |
| |
| InspectorTest.sendCommand("Page.enable", {}, function() { |
| InspectorTest.sendCommand("Page.setTouchEmulationEnabled", { enabled: true }, sendNextEvent); |
| }); |
| } |
| |
| </script> |
| </head> |
| <body onload="runTest()"> |
| </body> |
| </html> |