Index: third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js |
diff --git a/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js b/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9cc17bcee5f877742c22741fc10250fda691310e |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/imported/wpt_automation/pointerevents/pointerevent_common_input.js |
@@ -0,0 +1,104 @@ |
+// Mouse actions |
Rick Byers
2016/06/21 15:43:46
nit: please add a comment at the top summarizing w
Navid Zolghadr
2016/06/30 17:32:51
Done.
|
+function mouseMoveToDocument() { |
+ if (window.eventSender) |
+ eventSender.mouseMoveTo(0, 0); |
+} |
+ |
+function mouseMoveIntoTarget(targetId) { |
+ if (window.eventSender) { |
+ var target = document.getElementById(targetId); |
+ var targetRect = target.getBoundingClientRect(); |
+ eventSender.mouseMoveTo(targetRect.left+5, targetRect.top+5); |
+ } |
+} |
+ |
+function mouseClickInTarget(targetId) { |
+ if (window.eventSender) { |
+ mouseMoveIntoTarget(targetId); |
+ eventSender.mouseDown(0); |
+ eventSender.mouseUp(0); |
+ } |
+} |
+ |
+function mouseDragInTargets(targetIdList) { |
+ if (window.eventSender) { |
+ var target = document.getElementById(targetIdList[0]); |
+ mouseMoveIntoTarget(targetIdList[0]); |
+ eventSender.mouseDown(0); |
+ for (var i=1; i<targetIdList.length; i++) |
+ mouseMoveIntoTarget(targetIdList[i]); |
+ eventSender.mouseUp(0); |
+ } |
+} |
+ |
+function mouseDragInTarget(targetId) { |
+ if (window.eventSender) { |
+ var target = document.getElementById(targetId); |
+ mouseMoveIntoTarget(targetId); |
+ eventSender.mouseDown(0); |
+ mouseMoveIntoTarget(targetId); |
Rick Byers
2016/06/21 15:43:46
Doesn't this just send a mousemove to the exact sa
Navid Zolghadr
2016/06/30 17:32:51
It does. But for the purpose of testing this cause
|
+ eventSender.mouseUp(0); |
+ } |
+} |
+ |
+function mouseScrollUp() { |
+ if (window.eventSender) |
+ eventSender.continuousMouseScrollBy(-50, 0); |
+ |
+} |
+ |
+function mouseScrollLeft() { |
+ if (window.eventSender) |
+ eventSender.continuousMouseScrollBy(0, -50); |
+} |
+ |
+// Touch actions |
+function tapInTarget(targetId) { |
+ if (window.chrome && chrome.gpuBenchmarking) { |
+ var target = document.getElementById(targetId); |
+ var targetRect = target.getBoundingClientRect(); |
+ chrome.gpuBenchmarking.tap(targetRect.left+5, targetRect.top+5); |
+ } |
+} |
+ |
+function scrollUpInTarget(targetId) { |
Rick Byers
2016/06/21 15:43:46
nit: I guess these should be named like "touchScro
mustaq
2016/06/28 17:49:19
Perhaps all touch-related actions should start wit
Navid Zolghadr
2016/06/30 17:32:51
Done.
mustaq
2016/06/30 19:13:10
Can't we rename tapInTarget too? May be touchInTar
|
+ if (window.chrome && chrome.gpuBenchmarking) { |
+ var target = document.getElementById(targetId); |
+ var targetRect = target.getBoundingClientRect(); |
+ chrome.gpuBenchmarking.smoothDrag(targetRect.left, targetRect.bottom-5, targetRect.left, targetRect.top+5); |
+ } |
+} |
+ |
+function scrollLeftInTarget(targetId) { |
+ if (window.chrome && chrome.gpuBenchmarking) { |
+ var target = document.getElementById(targetId); |
+ var targetRect = target.getBoundingClientRect(); |
+ chrome.gpuBenchmarking.smoothDrag(targetRect.right-5, targetRect.top+5, targetRect.left+5, targetRect.top+5); |
+ } |
+} |
+ |
+// Pen actions |
+function penMoveIntoTarget(target) { |
+ var targetRect = target.getBoundingClientRect(); |
+ eventSender.mouseMoveTo(targetRect.left+5, targetRect.top+5, [], "pen", 0); |
+} |
+ |
+function penClickIntoTarget(target) { |
+ penMoveIntoTarget(target); |
+ eventSender.mouseDown(0, [], "pen", 0); |
+ eventSender.mouseUp(0, [], "pen", 0); |
+} |
+ |
+// Keyboard actions |
+function keyboardScrollUp() { |
+ if (window.eventSender) |
+ eventSender.keyDown('downArrow'); |
+} |
+ |
+function keyboardScrollLeft() { |
+ if (window.eventSender) |
+ eventSender.keyDown('rightArrow'); |
+} |
+ |
+// Defined in every test |
+inject_input(); |