2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
3 <?xml-stylesheet href=
"/tests/SimpleTest/test.css" type=
"text/css"?>
5 https://bugzilla.mozilla.org/show_bug.cgi?id=317422
7 <window title=
"Mozilla Bug 317422"
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type=
"application/javascript" src=
"/MochiKit/packed.js" />
10 <script type=
"application/javascript" src=
"/tests/SimpleTest/SimpleTest.js"/>
11 <script type=
"application/javascript" src=
"/tests/SimpleTest/EventUtils.js"/>
13 <!-- test results are displayed in the html:body -->
14 <body xmlns=
"http://www.w3.org/1999/xhtml">
15 <a href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=317422"
16 target=
"_blank">Mozilla Bug
317422</a>
19 <richlistbox id=
"richlistbox" seltype=
"multiple">
20 <richlistitem id=
"richlistbox_item1"><label value=
"Item 1"/></richlistitem>
21 <richlistitem id=
"richlistbox_item2"><label value=
"Item 2"/></richlistitem>
22 <richlistitem id=
"richlistbox_item3" hidden=
"true"><label value=
"Item 3"/></richlistitem>
23 <richlistitem id=
"richlistbox_item4"><label value=
"Item 4"/></richlistitem>
24 <richlistitem id=
"richlistbox_item5" collapsed=
"true"><label value=
"Item 5"/></richlistitem>
25 <richlistitem id=
"richlistbox_item6"><label value=
"Item 6"/></richlistitem>
26 <richlistitem id=
"richlistbox_item7" hidden=
"true"><label value=
"Item 7"/></richlistitem>
29 <listbox id=
"listbox" seltype=
"multiple">
30 <listitem id=
"listbox_item1" label=
"Item 1"/>
31 <listitem id=
"listbox_item2" label=
"Item 2"/>
32 <listitem id=
"listbox_item3" label=
"Item 3" hidden=
"true"/>
33 <listitem id=
"listbox_item4" label=
"Item 4"/>
34 <listitem id=
"listbox_item5" label=
"Item 5" collapsed=
"true"/>
35 <listitem id=
"listbox_item6" label=
"Item 6"/>
36 <listitem id=
"listbox_item7" label=
"Item 7" hidden=
"true"/>
39 <!-- test code goes here -->
40 <script type=
"application/javascript"><![CDATA[
42 /** Test for Bug
317422 **/
43 SimpleTest.waitForExplicitFinish();
45 function testListbox(id)
47 var listbox = document.getElementById(id);
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");
53 is(listbox.selectedItem.id, id +
"_item2", id +
": Down didn't move to second item");
55 is(listbox.selectedItem.id, id +
"_item4", id +
": Down didn't skip hidden item");
57 is(listbox.selectedItem.id, id +
"_item6", id +
": Down didn't skip collapsed item");
59 is(listbox.selectedItem.id, id +
"_item4", id +
": Up didn't skip collapsed item");
61 is(listbox.selectedItem.id, id +
"_item2", id +
": Up didn't skip hidden item");
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;
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", id);
78 is(listbox.selectedItem.id, id +
"_item6", id +
": Page down should go to the last visible item");
79 sendKey(
"PAGE_UP", id);
80 is(listbox.selectedItem.id, id +
"_item1", id +
": Page up should go to the first visible item");
83 window.onload = function runTests() {
84 testListbox(
"richlistbox");
85 testListbox(
"listbox");