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

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

Issue 2840023002: Fix button event on mouse events. (Closed)
Patch Set: Fix button event on mouse events. Created 3 years, 7 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 = 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 {name: 'pointerUp'} 123 {name: 'pointerUp'}
124 ] 124 ]
125 }], 125 }],
126 resolve); 126 resolve);
127 } else { 127 } else {
128 reject(); 128 reject();
129 } 129 }
130 }); 130 });
131 } 131 }
132 132
133 function mouseDragInTargets(targetSelectorList) { 133 function mouseDragInTargets(targetSelectorList, button) {
134 return new Promise(function(resolve, reject) { 134 return new Promise(function(resolve, reject) {
135 if (window.chrome && chrome.gpuBenchmarking) { 135 if (window.chrome && chrome.gpuBenchmarking) {
136 if (button === undefined) {
137 button = 'left';
138 }
136 scrollPageIfNeeded(targetSelectorList[0], document); 139 scrollPageIfNeeded(targetSelectorList[0], document);
137 var target = document.querySelector(targetSelectorList[0]); 140 var target = document.querySelector(targetSelectorList[0]);
138 var targetRect = target.getBoundingClientRect(); 141 var targetRect = target.getBoundingClientRect();
139 var xPosition = targetRect.left + boundaryOffset; 142 var xPosition = targetRect.left + boundaryOffset;
140 var yPosition = targetRect.top + boundaryOffset; 143 var yPosition = targetRect.top + boundaryOffset;
141 var pointerActions = [{'source': 'mouse'}]; 144 var pointerActions = [{'source': 'mouse'}];
142 var pointerAction = pointerActions[0]; 145 var pointerAction = pointerActions[0];
143 pointerAction.actions = []; 146 pointerAction.actions = [];
144 pointerAction.actions.push( 147 pointerAction.actions.push(
145 {name: 'pointerDown', x: xPosition, y: yPosition}); 148 {name: 'pointerDown', x: xPosition, y: yPosition, button: button});
146 for (var i = 1; i < targetSelectorList.length; i++) { 149 for (var i = 1; i < targetSelectorList.length; i++) {
147 scrollPageIfNeeded(targetSelectorList[i], document); 150 scrollPageIfNeeded(targetSelectorList[i], document);
148 target = document.querySelector(targetSelectorList[i]); 151 target = document.querySelector(targetSelectorList[i]);
149 targetRect = target.getBoundingClientRect(); 152 targetRect = target.getBoundingClientRect();
150 xPosition = targetRect.left + boundaryOffset; 153 xPosition = targetRect.left + boundaryOffset;
151 yPosition = targetRect.top + boundaryOffset; 154 yPosition = targetRect.top + boundaryOffset;
152 pointerAction.actions.push( 155 pointerAction.actions.push(
153 {name: 'pointerMove', x: xPosition, y: yPosition}); 156 {name: 'pointerMove', x: xPosition, y: yPosition, button: button});
154 } 157 }
155 pointerAction.actions.push({name: 'pointerUp'}); 158 pointerAction.actions.push({name: 'pointerUp', button: button});
156 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve); 159 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
157 } else { 160 } else {
158 reject(); 161 reject();
159 } 162 }
160 }); 163 });
161 } 164 }
162 165
163 function mouseDragInTarget(targetSelector) { 166 function mouseDragInTarget(targetSelector) {
164 return mouseDragInTargets([targetSelector, targetSelector]); 167 return mouseDragInTargets([targetSelector, targetSelector]);
165 } 168 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698