OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <style> | 2 <style> |
3 #target { | 3 #target { |
4 width: 100px; | 4 width: 100px; |
5 height: 100px; | 5 height: 100px; |
6 background: blue; | 6 background: blue; |
7 position: absolute; | 7 position: absolute; |
8 left: 0px; | 8 left: 0px; |
9 top: 0px; | 9 top: 0px; |
10 } | 10 } |
11 #drag{ | 11 #drag{ |
12 position: absolute; | 12 position: absolute; |
13 left: 0px; | 13 left: 0px; |
14 top: 100px; | 14 top: 100px; |
15 } | 15 } |
16 </style> | 16 </style> |
17 | |
18 <div id="target"></div> | 17 <div id="target"></div> |
19 <img id="drag" src="resources/greenbox30.png" draggable> | 18 <img id="drag" src="resources/greenbox30.png" draggable> |
19 | |
20 <script src="../../resources/js-test.js"></script> | 20 <script src="../../resources/js-test.js"></script> |
21 <script> | 21 <script> |
22 | 22 |
23 const L = 'leftButton'; | 23 const L = 'leftButton'; |
24 const R = 'rightButton'; | 24 const R = 'rightButton'; |
25 const M = 'middleButton'; | 25 const M = 'middleButton'; |
26 | 26 |
27 var targetDiv = document.getElementById('target'); | |
28 var dragImg = document.getElementById('drag'); | |
29 var seqNo = 0; | 27 var seqNo = 0; |
30 var testSet = [ | 28 var testSet = [ |
31 { initialButtons: [], action: doubleClickAction }, | 29 { initialButtons: [], action: doubleClickAction }, |
32 { initialButtons: [R], action: clickAction }, | 30 { initialButtons: [R], action: clickAction }, |
33 { initialButtons: [M, R], action: clickAction }, | 31 { initialButtons: [M, R], action: clickAction }, |
34 { initialButtons: [L, M, R], action: moveAction }, | 32 { initialButtons: [L, M, R], action: moveAction }, |
35 { initialButtons: [], action: rightClickAction, showContextMenuOnMouseU p: false }, | 33 { initialButtons: [], action: rightClickAction, showContextMenuOnMouseU p: false }, |
36 { initialButtons: [], action: rightClickAction, showContextMenuOnMouseU p: true }, | 34 { initialButtons: [], action: rightClickAction, showContextMenuOnMouseU p: true }, |
37 { initialButtons: [L, R], action: wheelAction }, | 35 { initialButtons: [L, R], action: wheelAction }, |
38 { initialButtons: [], action: doubleTapAction }, | 36 { initialButtons: [], action: doubleTapAction }, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 var showContextMenuOnMouseUp = ""; | 116 var showContextMenuOnMouseUp = ""; |
119 if (testItem.showContextMenuOnMouseUp != undefined) | 117 if (testItem.showContextMenuOnMouseUp != undefined) |
120 showContextMenuOnMouseUp = "and showContextMenuOnMouseUp=" + | 118 showContextMenuOnMouseUp = "and showContextMenuOnMouseUp=" + |
121 testItem.showContextMenuOnMouseUp + " "; | 119 testItem.showContextMenuOnMouseUp + " "; |
122 | 120 |
123 debug('===== ' + testItem.action.name + ' with initial state=[' + testItem.ini tialButtons + '] ' | 121 debug('===== ' + testItem.action.name + ' with initial state=[' + testItem.ini tialButtons + '] ' |
124 + showContextMenuOnMouseUp + '====='); | 122 + showContextMenuOnMouseUp + '====='); |
125 } | 123 } |
126 | 124 |
127 function init() { | 125 function init() { |
126 var targetDiv = document.getElementById('target'); | |
127 var dragImg = document.getElementById('drag'); | |
128 var eventList = ['dblclick', 'click', 'mousedown', 'mouseup', 'mousemove', 'mo useenter', 'mouseleave', 'mouseover', 'mouseout', 'mousewheel', 'dragstart', 'dr agend', 'dragenter', 'dragleave', 'dragover', 'drag', 'contextmenu']; | 128 var eventList = ['dblclick', 'click', 'mousedown', 'mouseup', 'mousemove', 'mo useenter', 'mouseleave', 'mouseover', 'mouseout', 'mousewheel', 'dragstart', 'dr agend', 'dragenter', 'dragleave', 'dragover', 'drag', 'contextmenu']; |
129 eventList.forEach(function(eventName) { | 129 eventList.forEach(function(eventName) { |
130 targetDiv.addEventListener(eventName, function(event) { | 130 targetDiv.addEventListener(eventName, function(event) { |
131 debug(++seqNo + ". targetDiv received " + event.type + " buttons: " + even t.buttons); | 131 debug(++seqNo + ". targetDiv received " + event.type + " buttons: " + even t.buttons); |
132 }); | 132 }); |
133 dragImg.addEventListener(eventName, function(event) { | 133 dragImg.addEventListener(eventName, function(event) { |
134 debug(++seqNo + ". dragImg received " + event.type + " buttons: " + event. buttons); | 134 debug(++seqNo + ". dragImg received " + event.type + " buttons: " + event. buttons); |
135 }); | 135 }); |
136 }); | 136 }); |
137 } | 137 } |
138 | 138 |
139 function runTests() { | 139 window.onload=function() { |
140 for (var i = 0; i < testSet.length; i++) { | 140 init(); |
141 printTestInfo(testSet[i]); | 141 if(window.eventSender) { |
142 for(var i=0; i<100; i++) { | |
143 » eventSender.mouseMoveTo(500+i, 500+i); | |
mustaq
2016/03/10 14:51:13
Why do you need this loop?
Nit: there's a tab cha
Navid Zolghadr
2016/03/10 15:55:26
Oops. This whole for loop was just a test thing th
| |
144 } | |
142 | 145 |
143 // Reset the state for the new test | 146 for (var i = 0; i < testSet.length; i++) { |
144 seqNo = 0; | 147 printTestInfo(testSet[i]); |
145 eventSender.setMouseButtonState(-1, testSet[i].initialButtons); | |
146 internals.settings.setShowContextMenuOnMouseUp(testSet[i].showContextMenuOnM ouseUp); | |
147 | 148 |
148 testSet[i].action(); | 149 // Reset the state for the new test |
150 seqNo = 0; | |
151 eventSender.setMouseButtonState(-1, testSet[i].initialButtons); | |
152 internals.settings.setShowContextMenuOnMouseUp(testSet[i].showContextMenuO nMouseUp); | |
149 | 153 |
150 // Reset the mouse position | 154 testSet[i].action(); |
151 eventSender.mouseMoveTo(-1, -1); | |
152 | 155 |
153 debug(''); | 156 // Reset the mouse position |
157 eventSender.mouseMoveTo(-1, -1); | |
158 | |
159 debug(''); | |
160 } | |
154 } | 161 } |
155 } | 162 } |
156 | 163 |
157 init(); | 164 if (!window.eventSender) { |
158 if (window.eventSender) | |
159 runTests(); | |
160 else | |
161 debug("This test requires eventSender"); | 165 debug("This test requires eventSender"); |
166 } | |
162 | 167 |
163 </script> | 168 </script> |
OLD | NEW |