1 description('This tests that deselecting an option won't cause unnecessary scrolling.');
3 function mouseDownOnSelect(selId, index, modifier) {
4 var sl = document.getElementById(selId);
5 var itemHeight = Math.floor(sl.offsetHeight / sl.size);
7 var y = border + index * itemHeight - window.pageYOffset;
8 if (window.eventSender) {
9 eventSender.mouseMoveTo(sl.offsetLeft + border, sl.offsetTop + y);
10 eventSender.mouseDown(0, [modifier]);
11 eventSender.mouseUp(0, [modifier]);
15 function selectionPattern(select) {
17 for (var i = 0; i < select.options.length; i++)
18 result += select.options[i].selected ? '1' : '0';
22 var parent = document.createElement('div');
23 parent.innerHTML = '<select id="sl" multiple="multiple" size="5">'
24 + '<option value="Accessibility">Accessibility</option>'
25 + '<option value="CSS">CSS</option>'
26 + '<option value="Drosera">Drosera</option>'
27 + '<option value="Evangelism">Evangelism</option>'
28 + '<option value="Forms">Forms</option>'
29 + '<option value="Frames">Frames</option>'
30 + '<option value="History">History</option>'
31 + '<option value="HTML DOM">HTML DOM</option>'
32 + '<option value="HTML Editing">HTML Editing</option>'
33 + '<option value="Images">Images</option>'
34 + '<option>SCROLL UP</option>'
36 document.body.appendChild(parent);
38 var sl = document.getElementById('sl');
40 document.execCommand("SelectAll");
41 sl.scrollTop = Math.floor(sl.offsetHeight / sl.size) * 4 + 6;
42 var scrollBeforeClick = sl.scrollTop;
43 mouseDownOnSelect("sl", 3, "addSelectionKey");
44 shouldBe('sl.scrollTop', 'scrollBeforeClick');
45 shouldBe('selectionPattern(sl)', '"11111110111"');