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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt_automation/pointerevents/pointerevent_common_input.js

Issue 2681923002: Pointerevent test cleanup (Closed)
Patch Set: Remove more double-quotes Created 3 years, 10 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
1 // This file contains the commonly used functions in pointerevent tests. 1 // This file contains the commonly used functions in pointerevent tests.
2 2
3 const scrollOffset = 30; 3 const scrollOffset = 20;
4 const boundaryOffset = 5; 4 const boundaryOffset = 2;
5 const touchSourceType = 1;
6 5
7 function delayPromise(delay) { 6 function delayPromise(delay) {
8 return new Promise(function(resolve, reject) { 7 return new Promise(function(resolve, reject) {
9 window.setTimeout(resolve, delay); 8 window.setTimeout(resolve, delay);
10 }); 9 });
11 } 10 }
12 11
13 function scrollPageIfNeeded(targetSelector, targetDocument) { 12 function scrollPageIfNeeded(targetSelector, targetDocument) {
14 var target = targetDocument.querySelector(targetSelector); 13 var target = targetDocument.querySelector(targetSelector);
15 var targetRect = target.getBoundingClientRect(); 14 var targetRect = target.getBoundingClientRect();
16 if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.in nerHeight || targetRect.right > window.innerWidth) 15 if (targetRect.top < 0 || targetRect.left < 0 || targetRect.bottom > window.in nerHeight || targetRect.right > window.innerWidth)
17 window.scrollTo(targetRect.left, targetRect.top); 16 window.scrollTo(targetRect.left, targetRect.top);
18 } 17 }
19 18
20 // Mouse inputs. 19 // Mouse inputs.
21 function mouseMoveToDocument() { 20 function mouseMoveToDocument() {
22 return new Promise(function(resolve, reject) { 21 return new Promise(function(resolve, reject) {
23 if (window.chrome && chrome.gpuBenchmarking) { 22 if (window.chrome && chrome.gpuBenchmarking) {
24 chrome.gpuBenchmarking.pointerActionSequence( 23 chrome.gpuBenchmarking.pointerActionSequence(
25 [{ 24 [{
26 'source': 'mouse', 25 source: 'mouse',
27 'actions': [{'name': 'pointerMove', 'x': 0, 'y': 0}] 26 actions: [{name: 'pointerMove', x: 0, y: 0}]
28 }], 27 }],
29 resolve); 28 resolve);
30 } else { 29 } else {
31 reject(); 30 reject();
32 } 31 }
33 }); 32 });
34 } 33 }
35 34
36 function mouseMoveIntoTarget(targetSelector, targetFrame) { 35 function mouseMoveIntoTarget(targetSelector, targetFrame) {
37 var targetDocument = document; 36 var targetDocument = document;
38 var frameLeft = 0; 37 var frameLeft = 0;
39 var frameTop = 0; 38 var frameTop = 0;
40 if (targetFrame !== undefined) { 39 if (targetFrame !== undefined) {
41 targetDocument = targetFrame.contentDocument; 40 targetDocument = targetFrame.contentDocument;
42 var frameRect = targetFrame.getBoundingClientRect(); 41 var frameRect = targetFrame.getBoundingClientRect();
43 frameLeft = frameRect.left; 42 frameLeft = frameRect.left;
44 frameTop = frameRect.top; 43 frameTop = frameRect.top;
45 } 44 }
46 return new Promise(function(resolve, reject) { 45 return new Promise(function(resolve, reject) {
47 if (window.chrome && chrome.gpuBenchmarking) { 46 if (window.chrome && chrome.gpuBenchmarking) {
48 scrollPageIfNeeded(targetSelector, targetDocument); 47 scrollPageIfNeeded(targetSelector, targetDocument);
49 var target = targetDocument.querySelector(targetSelector); 48 var target = targetDocument.querySelector(targetSelector);
50 var targetRect = target.getBoundingClientRect(); 49 var targetRect = target.getBoundingClientRect();
51 var xPosition = frameLeft + targetRect.left + boundaryOffset; 50 var xPosition = frameLeft + targetRect.left + boundaryOffset;
52 var yPosition = frameTop + targetRect.top + boundaryOffset; 51 var yPosition = frameTop + targetRect.top + boundaryOffset;
53 chrome.gpuBenchmarking.pointerActionSequence( 52 chrome.gpuBenchmarking.pointerActionSequence(
54 [{ 53 [{
55 'source': 'mouse', 54 source: 'mouse',
56 'actions': 55 actions:
57 [{'name': 'pointerMove', 'x': xPosition, 'y': yPosition}] 56 [{name: 'pointerMove', x: xPosition, y: yPosition}]
58 }], 57 }],
59 resolve); 58 resolve);
60 } else { 59 } else {
61 reject(); 60 reject();
62 } 61 }
63 }); 62 });
64 } 63 }
65 64
66 function mouseChordedButtonPress(targetSelector) { 65 function mouseChordedButtonPress(targetSelector) {
67 return new Promise(function(resolve, reject) { 66 return new Promise(function(resolve, reject) {
68 if (window.chrome && chrome.gpuBenchmarking) { 67 if (window.chrome && chrome.gpuBenchmarking) {
69 scrollPageIfNeeded(targetSelector, document); 68 scrollPageIfNeeded(targetSelector, document);
70 var target = document.querySelector(targetSelector); 69 var target = document.querySelector(targetSelector);
71 var targetRect = target.getBoundingClientRect(); 70 var targetRect = target.getBoundingClientRect();
72 var xPosition = targetRect.left + boundaryOffset; 71 var xPosition = targetRect.left + boundaryOffset;
73 var yPosition = targetRect.top + boundaryOffset; 72 var yPosition = targetRect.top + boundaryOffset;
74 chrome.gpuBenchmarking.pointerActionSequence( 73 chrome.gpuBenchmarking.pointerActionSequence(
75 [{ 74 [{
76 'source': 'mouse', 75 source: 'mouse',
77 'actions': [ 76 actions: [
78 { 77 {
79 'name': 'pointerDown', 78 name: 'pointerDown',
80 'x': xPosition, 79 x: xPosition,
81 'y': yPosition, 80 y: yPosition,
82 'button': 'left' 81 button: 'left'
83 }, 82 },
84 { 83 {
85 'name': 'pointerDown', 84 name: 'pointerDown',
86 'x': xPosition, 85 x: xPosition,
87 'y': yPosition, 86 y: yPosition,
88 'button': 'middle' 87 button: 'middle'
89 }, 88 },
90 {'name': 'pointerUp', 'button': 'middle'}, 89 {name: 'pointerUp', button: 'middle'},
91 {'name': 'pointerUp', 'button': 'left'} 90 {name: 'pointerUp', button: 'left'}
92 ] 91 ]
93 }], 92 }],
94 resolve); 93 resolve);
95 } else { 94 } else {
96 reject(); 95 reject();
97 } 96 }
98 }); 97 });
99 } 98 }
100 99
101 function mouseClickInTarget(targetSelector, targetFrame) { 100 function mouseClickInTarget(targetSelector, targetFrame) {
102 var targetDocument = document; 101 var targetDocument = document;
103 var frameLeft = 0; 102 var frameLeft = 0;
104 var frameTop = 0; 103 var frameTop = 0;
105 if (targetFrame !== undefined) { 104 if (targetFrame !== undefined) {
106 targetDocument = targetFrame.contentDocument; 105 targetDocument = targetFrame.contentDocument;
107 var frameRect = targetFrame.getBoundingClientRect(); 106 var frameRect = targetFrame.getBoundingClientRect();
108 frameLeft = frameRect.left; 107 frameLeft = frameRect.left;
109 frameTop = frameRect.top; 108 frameTop = frameRect.top;
110 } 109 }
111 return new Promise(function(resolve, reject) { 110 return new Promise(function(resolve, reject) {
112 if (window.chrome && chrome.gpuBenchmarking) { 111 if (window.chrome && chrome.gpuBenchmarking) {
113 scrollPageIfNeeded(targetSelector, targetDocument); 112 scrollPageIfNeeded(targetSelector, targetDocument);
114 var target = targetDocument.querySelector(targetSelector); 113 var target = targetDocument.querySelector(targetSelector);
115 var targetRect = target.getBoundingClientRect(); 114 var targetRect = target.getBoundingClientRect();
116 var xPosition = frameLeft + targetRect.left + boundaryOffset; 115 var xPosition = frameLeft + targetRect.left + boundaryOffset;
117 var yPosition = frameTop + targetRect.top + boundaryOffset; 116 var yPosition = frameTop + targetRect.top + boundaryOffset;
118 chrome.gpuBenchmarking.pointerActionSequence( 117 chrome.gpuBenchmarking.pointerActionSequence(
119 [{ 118 [{
120 'source': 'mouse', 119 source: 'mouse',
121 'actions': [ 120 actions: [
122 {'name': 'pointerMove', 'x': xPosition, 'y': yPosition}, 121 {name: 'pointerMove', x: xPosition, y: yPosition},
123 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition}, 122 {name: 'pointerDown', x: xPosition, y: yPosition},
124 {'name': 'pointerUp'} 123 {name: 'pointerUp'}
125 ] 124 ]
126 }], 125 }],
127 resolve); 126 resolve);
128 } else { 127 } else {
129 reject(); 128 reject();
130 } 129 }
131 }); 130 });
132 } 131 }
133 132
134 function mouseDragInTargets(targetSelectorList) { 133 function mouseDragInTargets(targetSelectorList) {
135 return new Promise(function(resolve, reject) { 134 return new Promise(function(resolve, reject) {
136 if (window.chrome && chrome.gpuBenchmarking) { 135 if (window.chrome && chrome.gpuBenchmarking) {
137 scrollPageIfNeeded(targetSelectorList[0], document); 136 scrollPageIfNeeded(targetSelectorList[0], document);
138 var target = document.querySelector(targetSelectorList[0]); 137 var target = document.querySelector(targetSelectorList[0]);
139 var targetRect = target.getBoundingClientRect(); 138 var targetRect = target.getBoundingClientRect();
140 var xPosition = targetRect.left + boundaryOffset; 139 var xPosition = targetRect.left + boundaryOffset;
141 var yPosition = targetRect.top + boundaryOffset; 140 var yPosition = targetRect.top + boundaryOffset;
142 var pointerActions = [{'source': 'mouse'}]; 141 var pointerActions = [{'source': 'mouse'}];
143 var pointerAction = pointerActions[0]; 142 var pointerAction = pointerActions[0];
144 pointerAction.actions = []; 143 pointerAction.actions = [];
145 pointerAction.actions.push( 144 pointerAction.actions.push(
146 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition}); 145 {name: 'pointerDown', x: xPosition, y: yPosition});
147 for (var i = 1; i < targetSelectorList.length; i++) { 146 for (var i = 1; i < targetSelectorList.length; i++) {
148 scrollPageIfNeeded(targetSelectorList[i], document); 147 scrollPageIfNeeded(targetSelectorList[i], document);
149 target = document.querySelector(targetSelectorList[i]); 148 target = document.querySelector(targetSelectorList[i]);
150 targetRect = target.getBoundingClientRect(); 149 targetRect = target.getBoundingClientRect();
151 xPosition = targetRect.left + boundaryOffset; 150 xPosition = targetRect.left + boundaryOffset;
152 yPosition = targetRect.top + boundaryOffset; 151 yPosition = targetRect.top + boundaryOffset;
153 pointerAction.actions.push( 152 pointerAction.actions.push(
154 {'name': 'pointerMove', 'x': xPosition, 'y': yPosition}); 153 {name: 'pointerMove', x: xPosition, y: yPosition});
155 } 154 }
156 pointerAction.actions.push({'name': 'pointerUp'}); 155 pointerAction.actions.push({name: 'pointerUp'});
157 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); 156 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
158 } else { 157 } else {
159 reject(); 158 reject();
160 } 159 }
161 }); 160 });
162 } 161 }
163 162
164 function mouseDragInTarget(targetSelector) { 163 function mouseDragInTarget(targetSelector) {
165 return mouseDragInTargets([targetSelector, targetSelector]); 164 return mouseDragInTargets([targetSelector, targetSelector]);
166 } 165 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 frameTop = frameRect.top; 199 frameTop = frameRect.top;
201 } 200 }
202 return new Promise(function(resolve, reject) { 201 return new Promise(function(resolve, reject) {
203 if (window.chrome && chrome.gpuBenchmarking) { 202 if (window.chrome && chrome.gpuBenchmarking) {
204 scrollPageIfNeeded(targetSelector, targetDocument); 203 scrollPageIfNeeded(targetSelector, targetDocument);
205 var target = targetDocument.querySelector(targetSelector); 204 var target = targetDocument.querySelector(targetSelector);
206 var targetRect = target.getBoundingClientRect(); 205 var targetRect = target.getBoundingClientRect();
207 var xPosition = frameLeft + targetRect.left + boundaryOffset; 206 var xPosition = frameLeft + targetRect.left + boundaryOffset;
208 var yPosition = frameTop + targetRect.top + boundaryOffset; 207 var yPosition = frameTop + targetRect.top + boundaryOffset;
209 chrome.gpuBenchmarking.pointerActionSequence( [ 208 chrome.gpuBenchmarking.pointerActionSequence( [
210 {"source": "touch", 209 {source: 'touch',
211 "actions": [ 210 actions: [
212 { "name": "pointerDown", "x": xPosition, "y": yPosition }, 211 { name: 'pointerDown', x: xPosition, y: yPosition },
213 { "name": "pointerUp" } 212 { name: 'pointerUp' }
214 ]}], resolve); 213 ]}], resolve);
215 } else { 214 } else {
216 reject(); 215 reject();
216 }
217 });
218 }
219
220 function twoPointerDragInTarget(pointerType, targetSelector, direction) {
221 return new Promise(function(resolve, reject) {
222 if (window.chrome && chrome.gpuBenchmarking) {
223 scrollPageIfNeeded(targetSelector, document);
224 var target = document.querySelector(targetSelector);
225 var targetRect = target.getBoundingClientRect();
226 var xPosition1 = targetRect.left + boundaryOffset + scrollOffset;
227 var yPosition1 = targetRect.top + boundaryOffset + scrollOffset;
228 var xPosition2 = xPosition1;
229 var yPosition2 = yPosition1;
230 var xPosition3 = xPosition1;
231 var yPosition3 = yPosition1;
232 if (direction == "down") {
233 yPosition1 -= scrollOffset;
234 yPosition3 += scrollOffset;
235 } else if (direction == "up") {
236 yPosition1 += scrollOffset;
237 yPosition3 -= scrollOffset;
238 } else if (direction == "right") {
239 xPosition1 -= scrollOffset;
240 xPosition3 += scrollOffset;
241 } else if (direction == "left") {
242 xPosition1 += scrollOffset;
243 xPosition3 -= scrollOffset;
244 } else {
245 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'");
246 }
247
248 chrome.gpuBenchmarking.pointerActionSequence( [
249 {source: pointerType,
250 actions: [
251 { name: 'pointerDown', x: xPosition1, y: yPosition1 },
252 { name: 'pointerMove', x: xPosition2, y: yPosition2 },
253 { name: 'pointerMove', x: xPosition3, y: yPosition3 },
254 { name: 'pause', duration: 0.1 },
255 { name: 'pointerUp' }
256 ]},
257 {source: pointerType,
258 actions: [
259 { name: 'pointerDown', x: xPosition1 + boundaryOffset, y: yPosition1 },
260 { name: 'pointerMove', x: xPosition2 + boundaryOffset, y: yPosition2 },
261 { name: 'pointerMove', x: xPosition3 + boundaryOffset, y: yPosition3 },
262 { name: 'pause', duration: 0.1 },
263 { name: 'pointerUp' }
264 ]}], resolve);
265 } else {
266 reject();
217 } 267 }
218 }); 268 });
219 } 269 }
220 270
221 function pointerDragInTarget(pointerType, targetSelector, direction) { 271 function pointerDragInTarget(pointerType, targetSelector, direction) {
222 return new Promise(function(resolve, reject) { 272 return new Promise(function(resolve, reject) {
223 if (window.chrome && chrome.gpuBenchmarking) { 273 if (window.chrome && chrome.gpuBenchmarking) {
224 scrollPageIfNeeded(targetSelector, document); 274 scrollPageIfNeeded(targetSelector, document);
225 var target = document.querySelector(targetSelector); 275 var target = document.querySelector(targetSelector);
226 var targetRect = target.getBoundingClientRect(); 276 var targetRect = target.getBoundingClientRect();
227 var xPosition = targetRect.left + boundaryOffset; 277 var xPosition1 = targetRect.left + boundaryOffset + scrollOffset;
228 var yPosition = targetRect.top + boundaryOffset; 278 var yPosition1 = targetRect.top + boundaryOffset + scrollOffset;
229 var newXPosition = xPosition; 279 var xPosition2 = xPosition1;
230 var newYPosition = yPosition; 280 var yPosition2 = yPosition1;
231 if (direction == "down") 281 var xPosition3 = xPosition1;
232 newYPosition += scrollOffset; 282 var yPosition3 = yPosition1;
233 else if (direction == "up") 283 if (direction == "down") {
234 newYPosition -= scrollOffset; 284 yPosition1 -= scrollOffset;
235 else if (direction == "right") 285 yPosition3 += scrollOffset;
236 newXPosition += scrollOffset; 286 } else if (direction == "up") {
237 else if (direction == "left") 287 yPosition1 += scrollOffset;
238 newXPosition -= scrollOffset; 288 yPosition3 -= scrollOffset;
239 else 289 } else if (direction == "right") {
290 xPosition1 -= scrollOffset;
291 xPosition3 += scrollOffset;
292 } else if (direction == "left") {
293 xPosition1 += scrollOffset;
294 xPosition3 -= scrollOffset;
295 } else {
240 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'"); 296 throw("drag direction '" + direction + "' is not expected, direction sho uld be 'down', 'up', 'left' or 'right'");
297 }
241 298
242 chrome.gpuBenchmarking.pointerActionSequence( [ 299 chrome.gpuBenchmarking.pointerActionSequence( [
243 {"source": pointerType, 300 {source: pointerType,
244 "actions": [ 301 actions: [
245 { "name": "pointerDown", "x": xPosition, "y": yPosition }, 302 { name: 'pointerDown', x: xPosition1, y: yPosition1 },
246 { "name": "pointerMove", "x": newXPosition, "y": newYPosition }, 303 { name: 'pointerMove', x: xPosition2, y: yPosition2 },
247 { "name": "pause", "duration": 0.1 }, 304 { name: 'pointerMove', x: xPosition3, y: yPosition3 },
248 { "name": "pointerUp" } 305 { name: 'pause', duration: 0.1 },
306 { name: 'pointerUp' }
249 ]}], resolve); 307 ]}], resolve);
250 } else { 308 } else {
251 reject(); 309 reject();
252 } 310 }
253 }); 311 });
254 } 312 }
255 313
256 function touchScrollInTarget(targetSelector, direction) { 314 function touchScrollInTarget(targetSelector, direction) {
257 if (direction == "down") 315 if (direction == "down")
258 direction = "up"; 316 direction = "up";
(...skipping 14 matching lines...) Expand all
273 var targetRect = target.getBoundingClientRect(); 331 var targetRect = target.getBoundingClientRect();
274 var xPosition = targetRect.left + (targetRect.width/2); 332 var xPosition = targetRect.left + (targetRect.width/2);
275 var yPosition1 = targetRect.top + (targetRect.height/2) - 10; 333 var yPosition1 = targetRect.top + (targetRect.height/2) - 10;
276 var yPosition2 = targetRect.top + (targetRect.height/2) + 10; 334 var yPosition2 = targetRect.top + (targetRect.height/2) + 10;
277 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}]; 335 var pointerActions = [{'source': 'touch'}, {'source': 'touch'}];
278 var pointerAction1 = pointerActions[0]; 336 var pointerAction1 = pointerActions[0];
279 var pointerAction2 = pointerActions[1]; 337 var pointerAction2 = pointerActions[1];
280 pointerAction1.actions = []; 338 pointerAction1.actions = [];
281 pointerAction2.actions = []; 339 pointerAction2.actions = [];
282 pointerAction1.actions.push( 340 pointerAction1.actions.push(
283 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition1}); 341 {name: 'pointerDown', x: xPosition, y: yPosition1});
284 pointerAction2.actions.push( 342 pointerAction2.actions.push(
285 {'name': 'pointerDown', 'x': xPosition, 'y': yPosition2}); 343 {name: 'pointerDown', x: xPosition, y: yPosition2});
286 for (var offset = 10; offset < 80; offset += 10) { 344 for (var offset = 10; offset < 80; offset += 10) {
287 pointerAction1.actions.push({ 345 pointerAction1.actions.push({
288 'name': 'pointerMove', 346 name: 'pointerMove',
289 'x': xPosition, 347 x: xPosition,
290 'y': (yPosition1 - offset) 348 y: (yPosition1 - offset)
291 }); 349 });
292 pointerAction2.actions.push({ 350 pointerAction2.actions.push({
293 'name': 'pointerMove', 351 name: 'pointerMove',
294 'x': xPosition, 352 x: xPosition,
295 'y': (yPosition2 + offset) 353 y: (yPosition2 + offset)
296 }); 354 });
297 } 355 }
298 pointerAction1.actions.push({'name': 'pointerUp'}); 356 pointerAction1.actions.push({name: 'pointerUp'});
299 pointerAction2.actions.push({'name': 'pointerUp'}); 357 pointerAction2.actions.push({name: 'pointerUp'});
300 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); 358 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
301 } else { 359 } else {
302 reject(); 360 reject();
303 } 361 }
304 }); 362 });
305 } 363 }
306 364
307 // Pen inputs. 365 // Pen inputs.
308 function penMoveToDocument() { 366 function penMoveToDocument() {
309 return new Promise(function(resolve, reject) { 367 return new Promise(function(resolve, reject) {
310 if (window.chrome && chrome.gpuBenchmarking) { 368 if (window.chrome && chrome.gpuBenchmarking) {
311 chrome.gpuBenchmarking.pointerActionSequence( [ 369 chrome.gpuBenchmarking.pointerActionSequence( [
312 {"source": "pen", 370 {source: 'pen',
313 "actions": [ 371 actions: [
314 { "name": "pointerMove", "x": 0, "y": 0 } 372 { name: 'pointerMove', x: 0, y: 0 }
315 ]}], resolve); 373 ]}], resolve);
316 } else { 374 } else {
317 reject(); 375 reject();
318 } 376 }
319 }); 377 });
320 } 378 }
321 379
322 function penMoveIntoTarget(targetSelector, targetFrame) { 380 function penMoveIntoTarget(targetSelector, targetFrame) {
323 var targetDocument = document; 381 var targetDocument = document;
324 var frameLeft = 0; 382 var frameLeft = 0;
325 var frameTop = 0; 383 var frameTop = 0;
326 if (targetFrame !== undefined) { 384 if (targetFrame !== undefined) {
327 targetDocument = targetFrame.contentDocument; 385 targetDocument = targetFrame.contentDocument;
328 var frameRect = targetFrame.getBoundingClientRect(); 386 var frameRect = targetFrame.getBoundingClientRect();
329 frameLeft = frameRect.left; 387 frameLeft = frameRect.left;
330 frameTop = frameRect.top; 388 frameTop = frameRect.top;
331 } 389 }
332 return new Promise(function(resolve, reject) { 390 return new Promise(function(resolve, reject) {
333 if (window.chrome && chrome.gpuBenchmarking) { 391 if (window.chrome && chrome.gpuBenchmarking) {
334 var target = targetDocument.querySelector(targetSelector); 392 var target = targetDocument.querySelector(targetSelector);
335 var targetRect = target.getBoundingClientRect(); 393 var targetRect = target.getBoundingClientRect();
336 var xPosition = frameLeft + targetRect.left + boundaryOffset; 394 var xPosition = frameLeft + targetRect.left + boundaryOffset;
337 var yPosition = frameTop + targetRect.top + boundaryOffset; 395 var yPosition = frameTop + targetRect.top + boundaryOffset;
338 chrome.gpuBenchmarking.pointerActionSequence( [ 396 chrome.gpuBenchmarking.pointerActionSequence( [
339 {"source": "pen", 397 {source: 'pen',
340 "actions": [ 398 actions: [
341 { "name": "pointerMove", "x": xPosition, "y": yPosition } 399 { name: 'pointerMove', x: xPosition, y: yPosition }
342 ]}], resolve); 400 ]}], resolve);
343 } else { 401 } else {
344 reject(); 402 reject();
345 } 403 }
346 }); 404 });
347 } 405 }
348 406
349 function penClickInTarget(targetSelector, targetFrame) { 407 function penClickInTarget(targetSelector, targetFrame) {
350 var targetDocument = document; 408 var targetDocument = document;
351 var frameLeft = 0; 409 var frameLeft = 0;
352 var frameTop = 0; 410 var frameTop = 0;
353 if (targetFrame !== undefined) { 411 if (targetFrame !== undefined) {
354 targetDocument = targetFrame.contentDocument; 412 targetDocument = targetFrame.contentDocument;
355 var frameRect = targetFrame.getBoundingClientRect(); 413 var frameRect = targetFrame.getBoundingClientRect();
356 frameLeft = frameRect.left; 414 frameLeft = frameRect.left;
357 frameTop = frameRect.top; 415 frameTop = frameRect.top;
358 } 416 }
359 return new Promise(function(resolve, reject) { 417 return new Promise(function(resolve, reject) {
360 if (window.chrome && chrome.gpuBenchmarking) { 418 if (window.chrome && chrome.gpuBenchmarking) {
361 scrollPageIfNeeded(targetSelector, targetDocument); 419 scrollPageIfNeeded(targetSelector, targetDocument);
362 var target = targetDocument.querySelector(targetSelector); 420 var target = targetDocument.querySelector(targetSelector);
363 var targetRect = target.getBoundingClientRect(); 421 var targetRect = target.getBoundingClientRect();
364 var xPosition = frameLeft + targetRect.left + boundaryOffset; 422 var xPosition = frameLeft + targetRect.left + boundaryOffset;
365 var yPosition = frameTop + targetRect.top + boundaryOffset; 423 var yPosition = frameTop + targetRect.top + boundaryOffset;
366 chrome.gpuBenchmarking.pointerActionSequence( [ 424 chrome.gpuBenchmarking.pointerActionSequence( [
367 {"source": "pen", 425 {source: 'pen',
368 "actions": [ 426 actions: [
369 { "name": "pointerMove", "x": xPosition, "y": yPosition }, 427 { name: 'pointerMove', x: xPosition, y: yPosition },
370 { "name": "pointerDown", "x": xPosition, "y": yPosition }, 428 { name: 'pointerDown', x: xPosition, y: yPosition },
371 { "name": "pointerUp" } 429 { name: 'pointerUp' }
372 ]}], resolve); 430 ]}], resolve);
373 } else { 431 } else {
374 reject(); 432 reject();
375 } 433 }
376 }); 434 });
377 } 435 }
378 436
379 // Keyboard inputs. 437 // Keyboard inputs.
380 function keyboardScroll(direction) { 438 function keyboardScroll(direction) {
381 return new Promise(function(resolve, reject) { 439 return new Promise(function(resolve, reject) {
(...skipping 12 matching lines...) Expand all
394 } 452 }
395 453
396 { 454 {
397 var pointerevent_automation = async_test("PointerEvent Automation"); 455 var pointerevent_automation = async_test("PointerEvent Automation");
398 // Defined in every test and should return a promise that gets resolved when i nput is finished. 456 // Defined in every test and should return a promise that gets resolved when i nput is finished.
399 inject_input().then(function() { 457 inject_input().then(function() {
400 pointerevent_automation.done(); 458 pointerevent_automation.done();
401 }); 459 });
402 } 460 }
403 461
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698