OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <p id="description"></p> | |
8 <div id="console"></div> | |
9 <script> | |
10 description('This tests that deselecting an option won't cause unnecessary
scrolling.'); | |
11 | |
12 function mouseDownOnSelect(selId, index, modifier) { | |
13 var sl = document.getElementById(selId); | |
14 var itemHeight = Math.floor(sl.offsetHeight / sl.size); | |
15 var border = 1; | |
16 var y = border + index * itemHeight - window.pageYOffset; | |
17 if (window.eventSender) { | |
18 eventSender.mouseMoveTo(sl.offsetLeft + border, sl.offsetTop + y); | |
19 eventSender.mouseDown(0, [modifier]); | |
20 eventSender.mouseUp(0, [modifier]); | |
21 } | |
22 } | |
23 | |
24 function selectionPattern(select) { | |
25 var result = ''; | |
26 for (var i = 0; i < select.options.length; i++) | |
27 result += select.options[i].selected ? '1' : '0'; | |
28 return result; | |
29 } | |
30 | |
31 var parent = document.createElement('div'); | |
32 parent.innerHTML = '<select id="sl" multiple="multiple" size="5">' | |
33 + '<option value="Accessibility">Accessibility</option>' | |
34 + '<option value="CSS">CSS</option>' | |
35 + '<option value="Drosera">Drosera</option>' | |
36 + '<option value="Evangelism">Evangelism</option>' | |
37 + '<option value="Forms">Forms</option>' | |
38 + '<option value="Frames">Frames</option>' | |
39 + '<option value="History">History</option>' | |
40 + '<option value="HTML DOM">HTML DOM</option>' | |
41 + '<option value="HTML Editing">HTML Editing</option>' | |
42 + '<option value="Images">Images</option>' | |
43 + '<option>SCROLL UP</option>' | |
44 + '</select>'; | |
45 document.body.appendChild(parent); | |
46 | |
47 var sl = document.getElementById('sl'); | |
48 sl.focus(); | |
49 document.execCommand("SelectAll"); | |
50 sl.scrollTop = Math.floor(sl.offsetHeight / sl.size) * 4 + 6; | |
51 var scrollBeforeClick = sl.scrollTop; | |
52 mouseDownOnSelect("sl", 3, "addSelectionKey"); | |
53 shouldBe('sl.scrollTop', 'scrollBeforeClick'); | |
54 shouldBe('selectionPattern(sl)', '"11111110111"'); | |
55 </script> | |
56 </body> | |
57 </html> | |
OLD | NEW |