1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('<select> selection test for scrolling.');
12 var parent
= document
.createElement('div');
13 parent
.innerHTML
= '<select id="sl1" multiple size=5>'
14 + '<option>one</option>'
15 + '<option>two</option>'
16 + '<option>three</option>'
17 + '<option>four</option>'
18 + '<option>five</option>'
19 + '<option>six</option>'
20 + '<option>seven</option>'
21 + '<option>eight</option>'
22 + '<option>nine</option>'
23 + '<option>ten</option>'
24 + '<option>eleven</option>'
25 + '<option>twelve</option>'
26 + '<option>thirteen</option>'
27 + '<option>fourteen</option>'
28 + '<option>fifteen</option>'
29 + '<option>sixteen</option>'
30 + '<option>seventeen</option>'
32 + '<select id="sl2" multiple style="height: 135px; border: 10px solid; padding: 5px;">'
33 + '<option>one</option>'
34 + '<option>two</option>'
35 + '<option>three</option>'
37 document
.body
.appendChild(parent
);
39 // Determine the item height.
40 var sl1
= document
.getElementById('sl1');
41 var sl2
= document
.getElementById('sl2');
42 var itemHeight
= Math
.floor(sl1
.offsetHeight
/ sl1
.size
);
43 sl1
.removeAttribute('size');
44 var height
= itemHeight
* 9 + 9;
45 sl1
.setAttribute('style', 'height: ' + height
+ 'px; border: 10px solid; padding: 5px;');
47 function mouseDownOnSelect(selId
, index
)
49 var sl
= document
.getElementById(selId
);
50 var borderPaddingTop
= 15;
51 var borderPaddingLeft
= 15;
52 var y
= index
* itemHeight
+ itemHeight
/ 2 - window
.pageYOffset
+ borderPaddingTop
;
53 eventSender
.mouseMoveTo(sl
.offsetLeft
+ borderPaddingLeft
, sl
.offsetTop
+ y
);
54 eventSender
.mouseDown();
55 eventSender
.mouseUp();
58 function selectionPattern(selectId
)
60 var select
= document
.getElementById(selectId
);
62 for (var i
= 0; i
< select
.options
.length
; i
++)
63 result
+= select
.options
[i
].selected
? '1' : '0';
67 mouseDownOnSelect("sl1", 0);
68 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
70 mouseDownOnSelect("sl1", 1);
71 shouldBe('selectionPattern("sl1")', '"01000000000000000"');
73 mouseDownOnSelect("sl1", 6);
74 shouldBe('selectionPattern("sl1")', '"00000010000000000"');
76 mouseDownOnSelect("sl1", 7);
77 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
79 mouseDownOnSelect("sl1", 8);
80 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
82 mouseDownOnSelect("sl1", 0);
83 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
85 for (i
= 0; i
< 9; i
++)
86 mouseDownOnSelect("sl1", 7);
87 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
89 mouseDownOnSelect("sl2", 1);
90 shouldBe('selectionPattern("sl2")', '"010"');
92 mouseDownOnSelect("sl2", 3);
93 shouldBe('selectionPattern("sl2")', '"010"');
95 mouseDownOnSelect("sl2", 2);
96 shouldBe('selectionPattern("sl2")', '"001"');