| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 {name: 'pointerUp', button: 'left'} | 90 {name: 'pointerUp', button: 'left'} |
| 91 ] | 91 ] |
| 92 }], | 92 }], |
| 93 resolve); | 93 resolve); |
| 94 } else { | 94 } else { |
| 95 reject(); | 95 reject(); |
| 96 } | 96 } |
| 97 }); | 97 }); |
| 98 } | 98 } |
| 99 | 99 |
| 100 function mouseClickInTarget(targetSelector, targetFrame) { | 100 function mouseClickInTarget(targetSelector, targetFrame, button) { |
| 101 var targetDocument = document; | 101 var targetDocument = document; |
| 102 var frameLeft = 0; | 102 var frameLeft = 0; |
| 103 var frameTop = 0; | 103 var frameTop = 0; |
| 104 if (button === undefined) { |
| 105 button = 'left'; |
| 106 } |
| 104 if (targetFrame !== undefined) { | 107 if (targetFrame !== undefined) { |
| 105 targetDocument = targetFrame.contentDocument; | 108 targetDocument = targetFrame.contentDocument; |
| 106 var frameRect = targetFrame.getBoundingClientRect(); | 109 var frameRect = targetFrame.getBoundingClientRect(); |
| 107 frameLeft = frameRect.left; | 110 frameLeft = frameRect.left; |
| 108 frameTop = frameRect.top; | 111 frameTop = frameRect.top; |
| 109 } | 112 } |
| 110 return new Promise(function(resolve, reject) { | 113 return new Promise(function(resolve, reject) { |
| 111 if (window.chrome && chrome.gpuBenchmarking) { | 114 if (window.chrome && chrome.gpuBenchmarking) { |
| 112 scrollPageIfNeeded(targetSelector, targetDocument); | 115 scrollPageIfNeeded(targetSelector, targetDocument); |
| 113 var target = targetDocument.querySelector(targetSelector); | 116 var target = targetDocument.querySelector(targetSelector); |
| 114 var targetRect = target.getBoundingClientRect(); | 117 var targetRect = target.getBoundingClientRect(); |
| 115 var xPosition = frameLeft + targetRect.left + boundaryOffset; | 118 var xPosition = frameLeft + targetRect.left + boundaryOffset; |
| 116 var yPosition = frameTop + targetRect.top + boundaryOffset; | 119 var yPosition = frameTop + targetRect.top + boundaryOffset; |
| 117 chrome.gpuBenchmarking.pointerActionSequence( | 120 chrome.gpuBenchmarking.pointerActionSequence( |
| 118 [{ | 121 [{ |
| 119 source: 'mouse', | 122 source: 'mouse', |
| 120 actions: [ | 123 actions: [ |
| 121 {name: 'pointerMove', x: xPosition, y: yPosition}, | 124 {name: 'pointerMove', x: xPosition, y: yPosition}, |
| 122 {name: 'pointerDown', x: xPosition, y: yPosition}, | 125 {name: 'pointerDown', x: xPosition, y: yPosition, button: button}, |
| 123 {name: 'pointerUp'} | 126 {name: 'pointerUp', button: button} |
| 124 ] | 127 ] |
| 125 }], | 128 }], |
| 126 resolve); | 129 resolve); |
| 127 } else { | 130 } else { |
| 128 reject(); | 131 reject(); |
| 129 } | 132 } |
| 130 }); | 133 }); |
| 131 } | 134 } |
| 132 | 135 |
| 133 function mouseDragInTargets(targetSelectorList) { | 136 function mouseDragInTargets(targetSelectorList) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 }); | 478 }); |
| 476 } | 479 } |
| 477 | 480 |
| 478 { | 481 { |
| 479 var pointerevent_automation = async_test("PointerEvent Automation"); | 482 var pointerevent_automation = async_test("PointerEvent Automation"); |
| 480 // Defined in every test and should return a promise that gets resolved when i
nput is finished. | 483 // Defined in every test and should return a promise that gets resolved when i
nput is finished. |
| 481 inject_input().then(function() { | 484 inject_input().then(function() { |
| 482 pointerevent_automation.done(); | 485 pointerevent_automation.done(); |
| 483 }); | 486 }); |
| 484 } | 487 } |
| OLD | NEW |