| OLD | NEW |
| 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 = 20; | 3 const scrollOffset = 20; |
| 4 const boundaryOffset = 2; | 4 const boundaryOffset = 2; |
| 5 | 5 |
| 6 function delayPromise(delay) { | 6 function delayPromise(delay) { |
| 7 return new Promise(function(resolve, reject) { | 7 return new Promise(function(resolve, reject) { |
| 8 window.setTimeout(resolve, delay); | 8 window.setTimeout(resolve, delay); |
| 9 }); | 9 }); |
| 10 } | 10 } |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 { name: 'pointerMove', x: xPosition, y: yPosition }, | 433 { name: 'pointerMove', x: xPosition, y: yPosition }, |
| 434 { name: 'pointerDown', x: xPosition, y: yPosition }, | 434 { name: 'pointerDown', x: xPosition, y: yPosition }, |
| 435 { name: 'pointerUp' } | 435 { name: 'pointerUp' } |
| 436 ]}], resolve); | 436 ]}], resolve); |
| 437 } else { | 437 } else { |
| 438 reject(); | 438 reject(); |
| 439 } | 439 } |
| 440 }); | 440 }); |
| 441 } | 441 } |
| 442 | 442 |
| 443 // Drag and drop actions |
| 444 function mouseDragAndDropInTargets(targetSelectorList) { |
| 445 return new Promise(function(resolve, reject) { |
| 446 if (window.eventSender) { |
| 447 scrollPageIfNeeded(targetSelectorList[0], document); |
| 448 var target = document.querySelector(targetSelectorList[0]); |
| 449 var targetRect = target.getBoundingClientRect(); |
| 450 var xPosition = targetRect.left + boundaryOffset; |
| 451 var yPosition = targetRect.top + boundaryOffset; |
| 452 eventSender.mouseMoveTo(xPosition, yPosition); |
| 453 eventSender.mouseDown(); |
| 454 eventSender.leapForward(100); |
| 455 for (var i = 1; i < targetSelectorList.length; i++) { |
| 456 scrollPageIfNeeded(targetSelectorList[i], document); |
| 457 target = document.querySelector(targetSelectorList[i]); |
| 458 targetRect = target.getBoundingClientRect(); |
| 459 xPosition = targetRect.left + boundaryOffset; |
| 460 yPosition = targetRect.top + boundaryOffset; |
| 461 eventSender.mouseMoveTo(xPosition, yPosition); |
| 462 } |
| 463 eventSender.mouseUp(); |
| 464 resolve(); |
| 465 } else { |
| 466 reject(); |
| 467 } |
| 468 }); |
| 469 } |
| 470 |
| 443 // Keyboard inputs. | 471 // Keyboard inputs. |
| 444 function keyboardScroll(direction) { | 472 function keyboardScroll(direction) { |
| 445 return new Promise(function(resolve, reject) { | 473 return new Promise(function(resolve, reject) { |
| 446 if (window.eventSender) { | 474 if (window.eventSender) { |
| 447 if (direction == 'down') | 475 if (direction == 'down') |
| 448 eventSender.keyDown('ArrowDown'); | 476 eventSender.keyDown('ArrowDown'); |
| 449 else if (direction == 'right') | 477 else if (direction == 'right') |
| 450 eventSender.keyDown('ArrowRight'); | 478 eventSender.keyDown('ArrowRight'); |
| 451 else | 479 else |
| 452 reject(); | 480 reject(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 481 }); | 509 }); |
| 482 } | 510 } |
| 483 | 511 |
| 484 { | 512 { |
| 485 var pointerevent_automation = async_test("PointerEvent Automation"); | 513 var pointerevent_automation = async_test("PointerEvent Automation"); |
| 486 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 514 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
| 487 inject_input().then(function() { | 515 inject_input().then(function() { |
| 488 pointerevent_automation.done(); | 516 pointerevent_automation.done(); |
| 489 }); | 517 }); |
| 490 } | 518 } |
| OLD | NEW |