Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/input/emulateTouchFromMouseEvent.html

Issue 2961493002: [DevTools] Migrate inspector-protocol/{input,network} tests to new harness (Closed)
Patch Set: minor fixes Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource s/inspector-protocol-test.js"></script>
4 <script>
5
6 window.addEventListener("touchstart", logEvent, {passive: false});
7 window.addEventListener("touchmove", logEvent, {passive: false});
8 window.addEventListener("touchend", logEvent);
9 window.addEventListener("touchcancel", logEvent);
10
11 function logEvent(event)
12 {
13 event.preventDefault();
14 log("-----Event-----");
15 log("type: " + event.type);
16 if (event.shiftKey)
17 log("shiftKey");
18 log("----Touches----");
19 for (var i = 0; i < event.touches.length; i++) {
20 var touch = event.touches[i];
21 log("id: " + i);
22 log("pageX: " + touch.pageX);
23 log("pageY: " + touch.pageY);
24 log("radiusX: " + touch.radiusX);
25 log("radiusY: " + touch.radiusY);
26 log("rotationAngle: " + touch.rotationAngle);
27 log("force: " + touch.force);
28 }
29 evaluateInFrontend("onEvent();");
30 }
31
32 function test()
33 {
34 var events = [
35 {
36 "type": "mousePressed",
37 "button": "left",
38 "clickCount": 1,
39 "x": 100,
40 "y": 200
41 },
42 {
43 "type": "mouseMoved",
44 "button": "left",
45 "clickCount": 1,
46 "x": 100,
47 "y": 250
48 },
49 {
50 "type": "mouseReleased",
51 "button": "left",
52 "clickCount": 1,
53 "x": 100,
54 "y": 250
55 },
56 {
57 "type": "mouseMoved",
58 "button": "none",
59 "modifiers": 8, // shift
60 "x": 50,
61 "y": 150
62 },
63 {
64 "type": "mousePressed",
65 "button": "left",
66 "clickCount": 1,
67 "x": 100,
68 "y": 200
69 },
70 {
71 "type": "mouseMoved",
72 "button": "left",
73 "clickCount": 1,
74 "x": 100,
75 "y": 250
76 },
77 {
78 "type": "mouseReleased",
79 "button": "left",
80 "clickCount": 1,
81 "x": 100,
82 "y": 250
83 }
84 ];
85
86 var time = Number(new Date()) / 1000;
87 var index = 0;
88
89 function sendNextEvent() {
90 if (index === events.length) {
91 maybeFinish();
92 return;
93 }
94 var event = events[index];
95 event.timestamp = time + index;
96 index++;
97 InspectorTest.sendCommand("Input.emulateTouchFromMouseEvent", event, che ckResponse);
98 }
99
100 function checkResponse(msg)
101 {
102 if (msg.error)
103 InspectorTest.log("Error: " + msg.error.message);
104 sendNextEvent();
105 }
106
107 const expectedEventCount = 6;
108 var eventCount = 0;
109 window.onEvent = function()
110 {
111 eventCount++;
112 maybeFinish();
113 };
114
115 function maybeFinish()
116 {
117 if (index === events.length && eventCount === expectedEventCount)
118 InspectorTest.completeTest();
119 }
120
121 InspectorTest.sendCommand("Page.enable", {}, function() {
122 InspectorTest.sendCommand("Page.setTouchEmulationEnabled", { enabled: tr ue }, sendNextEvent);
123 });
124 }
125
126 </script>
127 </head>
128 <body onload="runTest()">
129 </body>
130 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698