OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script> | 3 <script> |
4 function setup() | 4 function setup() |
5 { | 5 { |
6 var results = document.createElement('div'); | 6 var results = document.createElement('div'); |
7 results.id = "res"; | 7 results.id = "res"; |
8 results.appendChild(document.createTextNode("Results:")); | 8 results.appendChild(document.createTextNode("Results:")); |
9 document.body.appendChild(results); | 9 document.body.appendChild(results); |
10 } | 10 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 log("18) Make sure onChange doesn't fire when leaving the select
"); | 115 log("18) Make sure onChange doesn't fire when leaving the select
"); |
116 document.getElementById("sl1").blur(); | 116 document.getElementById("sl1").blur(); |
117 checkSelection("4"); | 117 checkSelection("4"); |
118 | 118 |
119 if (window.testRunner) | 119 if (window.testRunner) |
120 testRunner.notifyDone(); | 120 testRunner.notifyDone(); |
121 } | 121 } |
122 | 122 |
123 function mouseDownOnSelect(selId, index, shift, metaOrCtrl) | 123 function mouseDownOnSelect(selId, index, shift, metaOrCtrl) |
124 { | 124 { |
125 var meta = false; | 125 modifiers = []; |
126 var ctrl = false; | 126 if (shift) |
| 127 modifiers[0] = "shiftKey"; |
127 if (metaOrCtrl) { | 128 if (metaOrCtrl) { |
128 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) | 129 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) |
129 meta = true; | 130 modifiers[modifiers.length] = "metaKey"; |
130 else | 131 else |
131 ctrl = true; | 132 modifiers[modifiers.length] = "ctrlKey"; |
132 } | 133 } |
| 134 |
133 var sl = document.getElementById(selId); | 135 var sl = document.getElementById(selId); |
134 var event = document.createEvent("MouseEvent"); | 136 var rect = sl.options[index].getBoundingClientRect(); |
135 event.initMouseEvent("mousedown", true, true, document.defaultVi
ew, 1, 0, 0, 0, 0, ctrl, false, shift, meta, 0, document); | 137 if (window.eventSender) { |
136 sl.options[index].dispatchEvent(event); | 138 eventSender.mouseMoveTo(rect.left + 1, rect.top + 1); |
| 139 eventSender.mouseDown(0, modifiers); |
| 140 } else { |
| 141 debug("FAIL: This test requires window.eventSender."); |
| 142 } |
137 } | 143 } |
138 | 144 |
139 function mouseUpOnSelect(selId, index, shift, metaOrCtrl) | 145 function mouseUpOnSelect(selId, index, shift, metaOrCtrl) |
140 { | 146 { |
141 var meta = false; | 147 modifiers = []; |
142 var ctrl = false; | 148 if (shift) |
| 149 modifiers[0] = "shiftKey"; |
143 if (metaOrCtrl) { | 150 if (metaOrCtrl) { |
144 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) | 151 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) |
145 meta = true; | 152 modifiers[modifiers.length] = "metaKey"; |
146 else | 153 else |
147 ctrl = true; | 154 modifiers[modifiers.length] = "ctrlKey"; |
148 } | 155 } |
| 156 |
149 var sl = document.getElementById(selId); | 157 var sl = document.getElementById(selId); |
150 var event = document.createEvent("MouseEvent"); | 158 var rect = sl.options[index].getBoundingClientRect(); |
151 event.initMouseEvent("mouseup", true, true, document.defaultView
, 1, 0, 0, 0, 0, ctrl, false, shift, meta, 0, document); | 159 if (window.eventSender) { |
152 sl.options[index].dispatchEvent(event); | 160 eventSender.mouseMoveTo(rect.left + 1, rect.top + 1); |
| 161 eventSender.mouseUp(0, modifiers); |
| 162 } else { |
| 163 debug("FAIL: This test requires window.eventSender."); |
| 164 } |
153 } | 165 } |
154 | 166 |
155 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) | 167 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) |
156 { | 168 { |
157 modifiers = []; | 169 modifiers = []; |
158 if (shift) | 170 if (shift) |
159 modifiers[0] = "shiftKey"; | 171 modifiers[0] = "shiftKey"; |
160 if (metaOrCtrl) { | 172 if (metaOrCtrl) { |
161 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) | 173 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) |
162 modifiers[modifiers.length] = "metaKey"; | 174 modifiers[modifiers.length] = "metaKey"; |
163 else | 175 else |
164 modifiers[modifiers.length] = "controlKey"; | 176 modifiers[modifiers.length] = "ctrlKey"; |
165 } | 177 } |
166 | 178 |
167 document.getElementById(selId).focus(); | 179 document.getElementById(selId).focus(); |
168 eventSender.keyDown(identifier, modifiers); | 180 eventSender.keyDown(identifier, modifiers); |
169 } | 181 } |
170 | 182 |
171 function getSelectedOptions(selId) | 183 function getSelectedOptions(selId) |
172 { | 184 { |
173 result = new Array; | 185 result = new Array; |
174 var sl = document.getElementById(selId); | 186 var sl = document.getElementById(selId); |
(...skipping 12 matching lines...) Expand all Loading... |
187 </head> | 199 </head> |
188 <body onload="test()"> | 200 <body onload="test()"> |
189 <select id="sl1" size=5 multiple onchange="log('onChange fired')"> | 201 <select id="sl1" size=5 multiple onchange="log('onChange fired')"> |
190 <option selected value="0">item 0</option> | 202 <option selected value="0">item 0</option> |
191 <option value="1">item 1 | 203 <option value="1">item 1 |
192 <option value="2">item 2 | 204 <option value="2">item 2 |
193 <option value="3">item 3 | 205 <option value="3">item 3 |
194 </select> | 206 </select> |
195 </body> | 207 </body> |
196 </html> | 208 </html> |
OLD | NEW |