|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
|
4 <!-- |
|
5 https://bugzilla.mozilla.org/show_bug.cgi?id=317422 |
|
6 --> |
|
7 <window title="Mozilla Bug 317422" |
|
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
|
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
11 |
|
12 <!-- test results are displayed in the html:body --> |
|
13 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
14 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=317422" |
|
15 target="_blank">Mozilla Bug 317422</a> |
|
16 </body> |
|
17 |
|
18 <richlistbox id="richlistbox" seltype="multiple"> |
|
19 <richlistitem id="richlistbox_item1"><label value="Item 1"/></richlistitem> |
|
20 <richlistitem id="richlistbox_item2"><label value="Item 2"/></richlistitem> |
|
21 <richlistitem id="richlistbox_item3" hidden="true"><label value="Item 3"/></richlistitem> |
|
22 <richlistitem id="richlistbox_item4"><label value="Item 4"/></richlistitem> |
|
23 <richlistitem id="richlistbox_item5" collapsed="true"><label value="Item 5"/></richlistitem> |
|
24 <richlistitem id="richlistbox_item6"><label value="Item 6"/></richlistitem> |
|
25 <richlistitem id="richlistbox_item7" hidden="true"><label value="Item 7"/></richlistitem> |
|
26 </richlistbox> |
|
27 |
|
28 <listbox id="listbox" seltype="multiple"> |
|
29 <listitem id="listbox_item1" label="Item 1"/> |
|
30 <listitem id="listbox_item2" label="Item 2"/> |
|
31 <listitem id="listbox_item3" label="Item 3" hidden="true"/> |
|
32 <listitem id="listbox_item4" label="Item 4"/> |
|
33 <listitem id="listbox_item5" label="Item 5" collapsed="true"/> |
|
34 <listitem id="listbox_item6" label="Item 6"/> |
|
35 <listitem id="listbox_item7" label="Item 7" hidden="true"/> |
|
36 </listbox> |
|
37 |
|
38 <!-- test code goes here --> |
|
39 <script type="application/javascript"><![CDATA[ |
|
40 |
|
41 /** Test for Bug 317422 **/ |
|
42 SimpleTest.waitForExplicitFinish(); |
|
43 |
|
44 function testListbox(id) |
|
45 { |
|
46 var listbox = document.getElementById(id); |
|
47 listbox.focus(); |
|
48 is(listbox.getRowCount(), 7, id + ": Returned the wrong number of rows"); |
|
49 is(listbox.getItemAtIndex(2).id, id + "_item3", id + ": Should still return hidden items"); |
|
50 listbox.selectedIndex = 0; |
|
51 is(listbox.selectedItem.id, id + "_item1", id + ": First item was not selected"); |
|
52 sendKey("DOWN"); |
|
53 is(listbox.selectedItem.id, id + "_item2", id + ": Down didn't move to second item"); |
|
54 sendKey("DOWN"); |
|
55 is(listbox.selectedItem.id, id + "_item4", id + ": Down didn't skip hidden item"); |
|
56 sendKey("DOWN"); |
|
57 is(listbox.selectedItem.id, id + "_item6", id + ": Down didn't skip collapsed item"); |
|
58 sendKey("UP"); |
|
59 is(listbox.selectedItem.id, id + "_item4", id + ": Up didn't skip collapsed item"); |
|
60 sendKey("UP"); |
|
61 is(listbox.selectedItem.id, id + "_item2", id + ": Up didn't skip hidden item"); |
|
62 listbox.selectAll(); |
|
63 is(listbox.selectedItems.length, 7, id + ": Should have still selected all items"); |
|
64 listbox.invertSelection(); |
|
65 is(listbox.selectedItems.length, 0, id + ": Should have unselected all items"); |
|
66 listbox.selectedIndex = 2; |
|
67 ok(listbox.selectedItem == listbox.getItemAtIndex(2), id + ": Should have selected the hidden item"); |
|
68 listbox.selectedIndex = 0; |
|
69 sendKey("END"); |
|
70 is(listbox.selectedItem.id, id + "_item6", id + ": Should have moved to the last unhidden item"); |
|
71 sendMouseEvent({type: 'click'}, id + "_item1"); |
|
72 ok(listbox.selectedItem == listbox.getItemAtIndex(0), id + ": Should have selected the first item"); |
|
73 is(listbox.selectedItems.length, 1, id + ": Should only be one selected item"); |
|
74 sendMouseEvent({type: 'click', shiftKey: true}, id + "_item6"); |
|
75 is(listbox.selectedItems.length, 4, id + ": Should have selected all visible items"); |
|
76 listbox.selectedIndex = 0; |
|
77 sendKey("PAGE_DOWN"); |
|
78 is(listbox.selectedItem.id, id + "_item6", id + ": Page down should go to the last visible item"); |
|
79 sendKey("PAGE_UP"); |
|
80 is(listbox.selectedItem.id, id + "_item1", id + ": Page up should go to the first visible item"); |
|
81 } |
|
82 |
|
83 window.onload = function runTests() { |
|
84 testListbox("richlistbox"); |
|
85 testListbox("listbox"); |
|
86 SimpleTest.finish(); |
|
87 }; |
|
88 ]]></script> |
|
89 </window> |