accessible/tests/mochitest/selectable/test_listbox.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/selectable/test_listbox.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.7 +                 type="text/css"?>
     1.8 +<?xml-stylesheet href="../treeview.css" type="text/css"?>
     1.9 +
    1.10 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.11 +        title="XUL tree selectable tests">
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    1.15 +
    1.16 +  <script type="application/javascript"
    1.17 +          src="../common.js" />
    1.18 +  <script type="application/javascript"
    1.19 +          src="../role.js" />
    1.20 +  <script type="application/javascript"
    1.21 +          src="../states.js" />
    1.22 +  <script type="application/javascript"
    1.23 +          src="../selectable.js" />
    1.24 +
    1.25 +  <script type="application/javascript">
    1.26 +  <![CDATA[
    1.27 +
    1.28 +    ////////////////////////////////////////////////////////////////////////////
    1.29 +    // Test
    1.30 +
    1.31 +    //gA11yEventDumpID = "debug";
    1.32 +
    1.33 +    var gQueue = null;
    1.34 +
    1.35 +    function doTest()
    1.36 +    {
    1.37 +      //////////////////////////////////////////////////////////////////////////
    1.38 +      // single selectable listbox
    1.39 +
    1.40 +      var id = "listbox";
    1.41 +      ok(isAccessible(id, [nsIAccessibleSelectable]),
    1.42 +         "No selectable accessible for list of " + id);
    1.43 +
    1.44 +      var select = getAccessible(id, [nsIAccessibleSelectable]);
    1.45 +      testSelectableSelection(select, [ ]);
    1.46 +
    1.47 +      select.addItemToSelection(1);
    1.48 +      testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): ");
    1.49 +
    1.50 +      select.removeItemFromSelection(1);
    1.51 +      testSelectableSelection(select, [ ],
    1.52 +                              "removeItemFromSelection(1): ");
    1.53 +
    1.54 +      todo(select.selectAll() == false,
    1.55 +           "No way to select all items in listbox '" + id + "'");
    1.56 +      testSelectableSelection(select, [ "lb1_item1" ], "selectAll: ");
    1.57 +
    1.58 +      select.addItemToSelection(1);
    1.59 +      select.unselectAll();
    1.60 +      testSelectableSelection(select, [ ], "unselectAll: ");
    1.61 +
    1.62 +      //////////////////////////////////////////////////////////////////////////
    1.63 +      // multiple selectable listbox
    1.64 +
    1.65 +      var id = "listbox2";
    1.66 +      ok(isAccessible(id, [nsIAccessibleSelectable]),
    1.67 +         "No selectable accessible for list of " + id);
    1.68 +
    1.69 +      var select = getAccessible(id, [nsIAccessibleSelectable]);
    1.70 +      testSelectableSelection(select, [ ]);
    1.71 +
    1.72 +      select.addItemToSelection(1);
    1.73 +      testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): ");
    1.74 +
    1.75 +      select.removeItemFromSelection(1);
    1.76 +      testSelectableSelection(select, [ ],
    1.77 +                              "removeItemFromSelection(1): ");
    1.78 +
    1.79 +      is(select.selectAll(), true,
    1.80 +         "All items should be selected in listbox '" + id + "'");
    1.81 +      testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ],
    1.82 +                              "selectAll: ");
    1.83 +
    1.84 +      select.unselectAll();
    1.85 +      testSelectableSelection(select, [ ], "unselectAll: ");
    1.86 +
    1.87 +      //////////////////////////////////////////////////////////////////////////
    1.88 +      // listbox with headers
    1.89 +
    1.90 +      // XXX: addItemToSelection/removeItemFromSelection don't work correctly
    1.91 +      // on listboxes with headers because header is inserted into hierarchy
    1.92 +      // and child indexes that are used in these methods are shifted (see bug
    1.93 +      // 591939).
    1.94 +      todo(false,
    1.95 +           "Fix addItemToSelection/removeItemFromSelection on listboxes with headers.");
    1.96 +
    1.97 +      SimpleTest.finish();
    1.98 +    }
    1.99 +
   1.100 +    SimpleTest.waitForExplicitFinish();
   1.101 +    addA11yLoadEvent(doTest);
   1.102 +  ]]>
   1.103 +  </script>
   1.104 +
   1.105 +  <hbox flex="1" style="overflow: auto;">
   1.106 +    <body xmlns="http://www.w3.org/1999/xhtml">
   1.107 +      <a target="_blank"
   1.108 +        href="https://bugzilla.mozilla.org/show_bug.cgi?id=590176"
   1.109 +        title="add pseudo SelectAccessible interface">
   1.110 +       Mozilla Bug 590176
   1.111 +      </a><br/>
   1.112 +      <p id="display"></p>
   1.113 +      <div id="content" style="display: none">
   1.114 +      </div>
   1.115 +      <pre id="test">
   1.116 +      </pre>
   1.117 +    </body>
   1.118 +
   1.119 +    <vbox flex="1">
   1.120 +      <listbox id="listbox">
   1.121 +        <listcols>
   1.122 +          <listcol flex="1"/>
   1.123 +          <listcol flex="1"/>
   1.124 +        </listcols>
   1.125 +        <listitem id="lb1_item1">
   1.126 +          <listcell label="cell0"/>
   1.127 +          <listcell label="cell1"/>
   1.128 +        </listitem>
   1.129 +        <listitem id="lb1_item2">
   1.130 +          <listcell label="cell3"/>
   1.131 +          <listcell label="cell4"/>
   1.132 +        </listitem>
   1.133 +      </listbox>
   1.134 +
   1.135 +      <listbox id="listbox2" seltype="multiple">
   1.136 +        <listcols>
   1.137 +          <listcol flex="1"/>
   1.138 +          <listcol flex="1"/>
   1.139 +        </listcols>
   1.140 +        <listitem id="lb2_item1">
   1.141 +          <listcell label="cell0"/>
   1.142 +          <listcell label="cell1"/>
   1.143 +        </listitem>
   1.144 +        <listitem id="lb2_item2">
   1.145 +          <listcell label="cell3"/>
   1.146 +          <listcell label="cell4"/>
   1.147 +        </listitem>
   1.148 +      </listbox>
   1.149 +
   1.150 +      <vbox id="debug"/>
   1.151 +    </vbox>
   1.152 +  </hbox>
   1.153 +
   1.154 +</window>
   1.155 +

mercurial