Chromium Code Reviews| 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"; | |
|
tkent
2015/07/22 23:15:03
modifiers.push("shiftKey")
dtapuska
2015/07/23 01:28:10
Done.
| |
| 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) |
|
tkent
2015/07/22 23:15:03
We can simplify this block by
modifiers.push("
dtapuska
2015/07/23 01:28:10
Done.
| |
| 129 meta = true; | 130 modifiers[modifiers.length] = "metaKey"; |
|
tkent
2015/07/22 23:15:03
modifiers.push("metaKey")
dtapuska
2015/07/23 01:28:10
Done.
| |
| 130 else | 131 else |
| 131 ctrl = true; | 132 modifiers[modifiers.length] = "ctrlKey"; |
|
tkent
2015/07/22 23:15:03
modifiers.push("ctrlKey")
dtapuska
2015/07/23 01:28:10
Done.
| |
| 132 } | 133 } |
| 133 var sl = document.getElementById(selId); | 134 var sl = document.getElementById(selId); |
| 134 var event = document.createEvent("MouseEvent"); | 135 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); | 136 if (window.eventSender) { |
| 136 sl.options[index].dispatchEvent(event); | 137 eventSender.mouseMoveTo(rect.left + 1, rect.top + 1); |
| 138 eventSender.mouseDown(0, modifiers); | |
| 139 } else { | |
| 140 debug("FAIL: This test requires window.eventSender."); | |
|
tkent
2015/07/22 23:15:03
should be
testFaiiled("This test requires wind
dtapuska
2015/07/23 01:28:10
Done.
| |
| 141 } | |
| 137 } | 142 } |
| 138 | 143 |
| 139 function mouseUpOnSelect(selId, index, shift, metaOrCtrl) | 144 function mouseUpOnSelect(selId, index, shift, metaOrCtrl) |
| 140 { | 145 { |
| 141 var meta = false; | 146 modifiers = []; |
| 142 var ctrl = false; | 147 if (shift) |
| 148 modifiers[0] = "shiftKey"; | |
|
tkent
2015/07/22 23:15:03
modifiers.push("shiftKey")
dtapuska
2015/07/23 01:28:10
Done.
| |
| 143 if (metaOrCtrl) { | 149 if (metaOrCtrl) { |
| 144 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) | 150 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) |
|
tkent
2015/07/22 23:15:03
modifiers.push("addSelectionKey");
dtapuska
2015/07/23 01:28:10
Done.
| |
| 145 meta = true; | 151 modifiers[modifiers.length] = "metaKey"; |
| 146 else | 152 else |
| 147 ctrl = true; | 153 modifiers[modifiers.length] = "ctrlKey"; |
| 148 } | 154 } |
| 149 var sl = document.getElementById(selId); | 155 var sl = document.getElementById(selId); |
| 150 var event = document.createEvent("MouseEvent"); | 156 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); | 157 if (window.eventSender) { |
| 152 sl.options[index].dispatchEvent(event); | 158 eventSender.mouseMoveTo(rect.left + 1, rect.top + 1); |
| 159 eventSender.mouseUp(0, modifiers); | |
| 160 } else { | |
| 161 debug("FAIL: This test requires window.eventSender."); | |
|
tkent
2015/07/22 23:15:03
testFailed("This test ...");
dtapuska
2015/07/23 01:28:10
Done.
| |
| 162 } | |
| 153 } | 163 } |
| 154 | 164 |
| 155 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) | 165 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) |
| 156 { | 166 { |
| 157 modifiers = []; | 167 modifiers = []; |
| 158 if (shift) | 168 if (shift) |
| 159 modifiers[0] = "shiftKey"; | 169 modifiers[0] = "shiftKey"; |
| 160 if (metaOrCtrl) { | 170 if (metaOrCtrl) { |
| 161 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) | 171 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) |
|
tkent
2015/07/22 23:15:03
modifiers.push("addSelectionKey");
dtapuska
2015/07/23 01:28:10
Done.
| |
| 162 modifiers[modifiers.length] = "metaKey"; | 172 modifiers[modifiers.length] = "metaKey"; |
| 163 else | 173 else |
| 164 modifiers[modifiers.length] = "controlKey"; | 174 modifiers[modifiers.length] = "ctrlKey"; |
| 165 } | 175 } |
| 166 | 176 |
| 167 document.getElementById(selId).focus(); | 177 document.getElementById(selId).focus(); |
| 168 eventSender.keyDown(identifier, modifiers); | 178 eventSender.keyDown(identifier, modifiers); |
| 169 } | 179 } |
| 170 | 180 |
| 171 function getSelectedOptions(selId) | 181 function getSelectedOptions(selId) |
| 172 { | 182 { |
| 173 result = new Array; | 183 result = new Array; |
| 174 var sl = document.getElementById(selId); | 184 var sl = document.getElementById(selId); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 187 </head> | 197 </head> |
| 188 <body onload="test()"> | 198 <body onload="test()"> |
| 189 <select id="sl1" size=5 multiple onchange="log('onChange fired')"> | 199 <select id="sl1" size=5 multiple onchange="log('onChange fired')"> |
| 190 <option selected value="0">item 0</option> | 200 <option selected value="0">item 0</option> |
| 191 <option value="1">item 1 | 201 <option value="1">item 1 |
| 192 <option value="2">item 2 | 202 <option value="2">item 2 |
| 193 <option value="3">item 3 | 203 <option value="3">item 3 |
| 194 </select> | 204 </select> |
| 195 </body> | 205 </body> |
| 196 </html> | 206 </html> |
| OLD | NEW |